This check is odd (tablecmds.c ATExecAttachPartition line 13861): /* Temp parent cannot have a partition that is itself not a temp */ if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP && attachrel->rd_rel->relpersistence != RELPERSISTENCE_TEMP) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot attach a permanent relation as partition of temporary relation \"%s\"", RelationGetRelationName(rel))));
This seems to work (i.e. it's allowed to create a temp partition on a permanent parent and not vice-versa, which you'd think makes sense) but it's illusory, because if two sessions try to create temp partitions for overlapping values, the second session fails with a silly error message. To be more precise, do this in one session: CREATE TABLE p (a int, b int) PARTITION BY RANGE (a); CREATE TEMP TABLE p1 PARTITION OF p FOR VALUES FROM (0) TO (10); then without closing that one, in another session repeat the second command: alvherre=# CREATE TEMP TABLE p1 PARTITION OF p FOR VALUES FROM (0) TO (10); ERROR: partition "p1" would overlap partition "p1" which is not what I would have expected. Maybe there are combinations of different persistence values that can be allowed to differ (an unlogged partition is probably OK with a permanent parent), but I don't think the current check is good enough. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers