HAWQ-870. Allocate target's tuple table slot in PortalHeapMemory during split partition
merge GPDB split-partiton optimization Origin GPDB PR: greenplum-db/gpdb#866 Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/b32e56c5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/b32e56c5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/b32e56c5 Branch: refs/heads/master Commit: b32e56c501a1db2b91481c88192e65bdb8fbdfd2 Parents: 111655e Author: interma <[email protected]> Authored: Fri Dec 16 15:16:07 2016 +0800 Committer: Paul Guo <[email protected]> Committed: Mon Dec 19 10:21:29 2016 +0800 ---------------------------------------------------------------------- src/backend/commands/tablecmds.c | 29 +- src/test/regress/expected/partition.out | 2669 ++++++------------ .../regress/expected/partition_optimizer.out | 2666 ++++++----------- src/test/regress/sql/partition.sql | 18 + 4 files changed, 1697 insertions(+), 3685 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b32e56c5/src/backend/commands/tablecmds.c ---------------------------------------------------------------------- diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 975e121..fc35124 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -15304,6 +15304,10 @@ split_rows(Relation intoa, Relation intob, Relation temprel, List *splits, int s rrib->ri_partSlot = MakeSingleTupleTableSlot(RelationGetDescr(intob)); map_part_attrs(temprel, intoa, &rria->ri_partInsertMap, true); map_part_attrs(temprel, intob, &rrib->ri_partInsertMap, true); + Assert(NULL != rria->ri_RelationDesc); + rria->ri_resultSlot = MakeSingleTupleTableSlot(rria->ri_RelationDesc->rd_att); + Assert(NULL != rrib->ri_RelationDesc); + rrib->ri_resultSlot = MakeSingleTupleTableSlot(rrib->ri_RelationDesc->rd_att); /* constr might not be defined if this is a default partition */ if (intoa->rd_att->constr && intoa->rd_att->constr->num_check) @@ -15575,21 +15579,18 @@ split_rows(Relation intoa, Relation intob, Relation temprel, List *splits, int s ExecDropSingleTupleTableSlot(rrib->ri_partSlot); /* - * We may have created "cached" version of our target result tuple table slot - * inside reconstructMatchingTupleSlot. Drop any such slots. + * We created our target result tuple table slots upfront. + * We can drop them now. */ - if (NULL != rria->ri_resultSlot) - { - Assert(NULL != rria->ri_resultSlot->tts_tupleDescriptor); - ExecDropSingleTupleTableSlot(rria->ri_resultSlot); - rria->ri_resultSlot = NULL; - } - if (NULL != rrib->ri_resultSlot) - { - Assert(NULL != rrib->ri_resultSlot->tts_tupleDescriptor); - ExecDropSingleTupleTableSlot(rrib->ri_resultSlot); - rrib->ri_resultSlot = NULL; - } + Assert(NULL != rria->ri_resultSlot); + Assert(NULL != rria->ri_resultSlot->tts_tupleDescriptor); + ExecDropSingleTupleTableSlot(rria->ri_resultSlot); + rria->ri_resultSlot = NULL; + + Assert(NULL != rrib->ri_resultSlot); + Assert(NULL != rrib->ri_resultSlot->tts_tupleDescriptor); + ExecDropSingleTupleTableSlot(rrib->ri_resultSlot); + rrib->ri_resultSlot = NULL; if (rria->ri_partInsertMap) pfree(rria->ri_partInsertMap);
