]> granicus.if.org Git - postgresql/commit
Fix state reversal after partition tuple routing
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 19 Mar 2018 20:43:55 +0000 (17:43 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 19 Mar 2018 20:43:55 +0000 (17:43 -0300)
commite3faddf537903144553abd989b156168cb7984df
treec94e0917378325937100ff5239fa7948b165cbeb
parentff301166a9a6f23527277b89495ce56973a409f3
Fix state reversal after partition tuple routing

We make some changes to ModifyTableState and the EState it uses whenever
we route tuples to partitions; but we weren't restoring properly in all
cases, possibly causing crashes when partitions with different tuple
descriptors are targeted by tuples inserted in the same command.
Refactor some code, creating ExecPrepareTupleRouting, to encapsulate the
needed state changing logic, and have it invoked one level above its
current place (ie. put it in ExecModifyTable instead of ExecInsert);
this makes it all more readable.

Add a test case to exercise this.

We don't support having views as partitions; and since only views can
have INSTEAD OF triggers, there is no point in testing for INSTEAD OF
when processing insertions into a partitioned table.  Remove code that
appears to support this (but which is actually never relevant.)

In passing, fix location of some very confusing comments in
ModifyTableState.

Reported-by: Amit Langote
Author: Etsuro Fujita, Amit Langote
Discussion: https://postgr/es/m/0473bf5c-57b1-f1f7-3d58-455c2230bc5f@lab.ntt.co.jp
src/backend/commands/copy.c
src/backend/executor/nodeModifyTable.c
src/include/nodes/execnodes.h
src/test/regress/expected/insert.out
src/test/regress/sql/insert.sql