Re: Partitioning with temp tables is broken
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>,
Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Michael Paquier <michael@paquier.xyz>, amul sul <sulamul@gmail.com>,
David Rowley <david.rowley@2ndquadrant.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Robert Haas <robertmhaas@gmail.com>
Date: 2018-06-15T01:05:04Z
Lists: pgsql-hackers
On 2018/06/14 23:42, Tom Lane wrote: > Ashutosh Bapat <ashutosh.bapat@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
Commits
-
Clarify use of temporary tables within partition trees
- 5862174ec78a 10.5 landed
- 1c7c317cd9d1 11.0 landed