On 2018/06/14 23:42, Tom Lane wrote: > Ashutosh Bapat <ashutosh.ba...@enterprisedb.com> writes: >> If I am reading Tom's reply upthread correctly, we should not allow >> creating a temporary partitioned table as well as temporary partitions >> altogether. > > I think that if possible, we should still allow a partitioned table > in which all the rels are temp tables of the current session. What we > have to disallow is (a) temp/permanent mixes and (b) temp tables from > different sessions.
The patch I posted upthread does exactly that I think. It allows for a partition tree where all tables are temporary relations of the same session, whereas it disallows: 1. Temporary-permanent mix create table perm_p (a int) partition by list (a); create temp table temp_p partition of perm_p for values in (1); ERROR: cannot create a temporary relation as partition of permanent relation "perm_p" create temp table temp_p1 (a int); alter table perm_p attach partition temp_p1 for values in (1); ERROR: cannot attach a temporary relation as partition of permanent relation "perm_p" create temp table temp_p (a int) partition by list (a); create table perm_p1 partition of temp_p for values in (1); ERROR: cannot create a permanent relation as partition of temporary relation "temp_p" create table perm_p1 (a int); alter table temp_p attach partition perm_p1 for values in (1); ERROR: cannot attach a permanent relation as partition of temporary relation "temp_p" 2. Mixing of temp table from different sessions create temp table temp_other_p2 partition of temp_p for values in (2); ERROR: relation "temp_p" does not exist create temp table temp_other_p2 partition of pg_temp_2.temp_p for values in (2); ERROR: cannot create as partition of temporary relation of another session create temp table temp_other_p2 (a int); alter table temp_p attach partition temp_other_p2 for values in (2); ERROR: relation "temp_other_p2" does not exist alter table temp_p attach partition pg_temp_3.temp_other_p2 for values in (2); ERROR: cannot attach temporary relation of another session as partition Thanks, Amit