forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADBDEV-3951: Backport of "Implemented InPlaceUpdate to be used for updates made on non-distribution columns" #609
Open
KnightMurloc
wants to merge
2
commits into
adb-6.x-dev
Choose a base branch
from
ADBDEV-3951
base: adb-6.x-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,18 +59,17 @@ ExecDML(DMLState *node) | |
} | ||
|
||
bool isnull = false; | ||
int action = DatumGetUInt32(slot_getattr(slot, plannode->actionColIdx, &isnull)); | ||
Assert(!isnull); | ||
|
||
bool isUpdate = false; | ||
if (node->ps.state->es_plannedstmt->commandType == CMD_UPDATE) | ||
int action = -1; | ||
bool isUpdate = node->ps.state->es_plannedstmt->commandType == CMD_UPDATE; | ||
// if it's not in place update | ||
if (AttributeNumberIsValid(plannode->actionColIdx)) | ||
{ | ||
isUpdate = true; | ||
action = DatumGetUInt32( | ||
slot_getattr(slot, plannode->actionColIdx, &isnull)); | ||
Assert(!isnull); | ||
Assert(action == DML_INSERT || action == DML_DELETE); | ||
} | ||
|
||
Assert(action == DML_INSERT || action == DML_DELETE); | ||
|
||
|
||
/* | ||
* Reset per-tuple memory context to free any expression evaluation | ||
* storage allocated in the previous tuple cycle. | ||
|
@@ -116,6 +115,13 @@ ExecDML(DMLState *node) | |
* es_result_relations will contain the only relation. | ||
*/ | ||
node->ps.state->es_result_relation_info = relInfo; | ||
|
||
/* | ||
* Perform partition selection for in place update | ||
*/ | ||
if (isUpdate && !AttributeNumberIsValid(plannode->actionColIdx)) | ||
node->ps.state->es_result_relation_info = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the tests check this code branch? |
||
slot_get_partition(node->cleanedUpSlot, node->ps.state); | ||
} | ||
/* GPDB_91_MERGE_FIXME: | ||
* This kind of node is used by ORCA only. If in the future ORCA still uses | ||
|
@@ -155,7 +161,7 @@ ExecDML(DMLState *node) | |
isUpdate, | ||
InvalidOid); | ||
} | ||
else /* DML_DELETE */ | ||
else | ||
{ | ||
int32 segid = GpIdentity.segindex; | ||
Datum ctid = slot_getattr(slot, plannode->ctidColIdx, &isnull); | ||
|
@@ -172,16 +178,31 @@ ExecDML(DMLState *node) | |
Assert(!isnull); | ||
} | ||
|
||
/* Correct tuple count by ignoring deletes when splitting tuples. */ | ||
ExecDelete(tupleid, | ||
segid, | ||
NULL, /* GPDB_91_MERGE_FIXME: oldTuple? */ | ||
node->cleanedUpSlot, | ||
NULL /* DestReceiver */, | ||
node->ps.state, | ||
!isUpdate, /* GPDB_91_MERGE_FIXME: where to get canSetTag? */ | ||
PLANGEN_OPTIMIZER /* Plan origin */, | ||
isUpdate); | ||
if (DML_DELETE == action) | ||
{ | ||
/* Correct tuple count by ignoring deletes when splitting tuples. */ | ||
RekGRpth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ExecDelete(tupleid, | ||
segid, | ||
NULL, /* GPDB_91_MERGE_FIXME: oldTuple? */ | ||
node->cleanedUpSlot, | ||
NULL /* DestReceiver */, | ||
node->ps.state, | ||
!isUpdate, /* GPDB_91_MERGE_FIXME: where to get canSetTag? */ | ||
PLANGEN_OPTIMIZER /* Plan origin */, | ||
isUpdate); | ||
} | ||
else | ||
{ | ||
ExecUpdate(tupleid, | ||
segid, | ||
NULL, //oldtuple | ||
node->cleanedUpSlot, | ||
NULL, //planSlot | ||
NULL /* DestReceiver */, | ||
node->ps.state, | ||
true, | ||
PLANGEN_OPTIMIZER); | ||
} | ||
} | ||
|
||
return slot; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1301,7 +1301,8 @@ ExecUpdate(ItemPointer tupleid, | |
TupleTableSlot *planSlot, | ||
EPQState *epqstate, | ||
EState *estate, | ||
bool canSetTag) | ||
bool canSetTag, | ||
PlanGenerator planGen) | ||
{ | ||
ResultRelInfo *resultRelInfo; | ||
Relation resultRelationDesc; | ||
|
@@ -1370,8 +1371,12 @@ ExecUpdate(ItemPointer tupleid, | |
|
||
/* see if this update would move the tuple to a different partition */ | ||
if (estate->es_result_partitions) | ||
{ | ||
checkPartitionUpdate(estate, slot, resultRelInfo); | ||
|
||
if (planGen == PLANGEN_OPTIMIZER) | ||
slot = reconstructMatchingTupleSlot(slot, resultRelInfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the tests check this code branch? |
||
} | ||
/* BEFORE ROW UPDATE Triggers */ | ||
if (resultRelInfo->ri_TrigDesc && | ||
resultRelInfo->ri_TrigDesc->trig_update_before_row) | ||
|
@@ -1571,6 +1576,17 @@ lreplace:; | |
{ | ||
TupleTableSlot *epqslot; | ||
|
||
/* | ||
* TODO: DML node doesn't initialize `epqstate` parameter so | ||
* we exclude EPQ routine for this type of modification and | ||
* act as in RR and upper isolation levels. | ||
*/ | ||
if (!epqstate) | ||
ereport(ERROR, | ||
RekGRpth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), | ||
errmsg("could not serialize access due to concurrent update"), | ||
errhint("Use PostgreSQL Planner instead of Optimizer for this query via optimizer=off GUC setting"))); | ||
|
||
epqslot = EvalPlanQual(estate, | ||
epqstate, | ||
resultRelationDesc, | ||
|
@@ -1942,7 +1958,7 @@ ExecModifyTable(ModifyTableState *node) | |
slot = ExecUpdate(tupleid, segid, | ||
oldtuple, slot, planSlot, | ||
&node->mt_epqstate, estate, | ||
node->canSetTag); | ||
node->canSetTag, PLANGEN_PLANNER); | ||
break; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to perform partition selection in case of updating leaf partition. Do we?