Hi, It seems temp tables with partitioned tables is not working correctly. 9140cf8269b0c has not considered that in build_simple_rel() an AppendRelInfo could be missing due to it having been skipped in expand_partitioned_rtentry()
Assert(cnt_parts == nparts); fails in build_simple_rel, and without an assert enabled build it just crashes later when trying to dereference the in prune_append_rel_partitions() or apply_scanjoin_target_to_paths(), depending if partition pruning is used and does not prune the relation. There's also something pretty weird around the removal of the temp relation from the partition bound. I've had cases where the session that attached the temp table is long gone, but \d+ shows the table is still there and I can't attach another partition due to an overlap, and can't drop the temp table due to the session not existing anymore. I've not got a test case for that one yet, but the test case for the crash is: -- Session 1: create table listp (a int) partition by list(a); create table listp1 partition of listp for values in(1); create temp table listp2 partition of listp for values in (2); -- Session 2: select * from listp; We might want to create the RelOptInfo and somehow set it as a dummy rel, or consider setting it to NULL and skipping the NULLs. I'd rather see the latter for the future, but for PG11 we might prefer the former. I've not looked into how this would be done or if it can be done sanely. I'll add this to the open items list. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services