解决dolphin插件中当采用div作为分区键时,会导致crash的问题
This commit is contained in:
@ -1015,7 +1015,7 @@ static Oid ExecUpsert(ModifyTableState* state, TupleTableSlot* slot, TupleTableS
|
||||
return newid;
|
||||
}
|
||||
|
||||
extern Tuple ComputePartKeyExprTuple(Relation rel, EState *estate, TupleTableSlot *slot, Tuple oldtuple, Relation partRel);
|
||||
extern Datum ComputePartKeyExprTuple(Relation rel, EState *estate, TupleTableSlot *slot, Relation partRel);
|
||||
/* ----------------------------------------------------------------
|
||||
* ExecInsert
|
||||
*
|
||||
@ -1343,9 +1343,9 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
||||
|
||||
case PARTTYPE_PARTITIONED_RELATION: {
|
||||
/* get partititon oid for insert the record */
|
||||
Tuple newtuple = ComputePartKeyExprTuple(result_relation_desc, estate, slot, tuple, NULL);
|
||||
if (newtuple)
|
||||
partition_id = heapTupleGetPartitionId(result_relation_desc, newtuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
Datum newval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, NULL);
|
||||
if (newval)
|
||||
partition_id = heapTupleGetPartitionId(result_relation_desc, (void*)newval, false, estate->es_plannedstmt->hasIgnore);
|
||||
else
|
||||
partition_id = heapTupleGetPartitionId(result_relation_desc, tuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
/* if cannot find valid partition oid and sql has keyword ignore, return and don't insert */
|
||||
@ -1404,9 +1404,9 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
||||
Partition subPart = NULL;
|
||||
|
||||
/* get partititon oid for insert the record */
|
||||
Tuple newtuple = ComputePartKeyExprTuple(result_relation_desc, estate, slot, tuple, NULL);
|
||||
if (newtuple)
|
||||
partitionId = heapTupleGetPartitionId(result_relation_desc, newtuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
Datum newval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, NULL);
|
||||
if (newval)
|
||||
partitionId = heapTupleGetPartitionId(result_relation_desc, (void*)newval, false, estate->es_plannedstmt->hasIgnore);
|
||||
else
|
||||
partitionId = heapTupleGetPartitionId(result_relation_desc, tuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
if (estate->es_plannedstmt->hasIgnore && partitionId == InvalidOid) {
|
||||
@ -1425,9 +1425,9 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
||||
}
|
||||
|
||||
/* get subpartititon oid for insert the record */
|
||||
Tuple newsubtuple = ComputePartKeyExprTuple(result_relation_desc, estate, slot, tuple, partRel);
|
||||
if (newsubtuple)
|
||||
subPartitionId = heapTupleGetPartitionId(partRel, newsubtuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
Datum newsubval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, partRel);
|
||||
if (newsubval)
|
||||
subPartitionId = heapTupleGetPartitionId(partRel, (void*)newsubval, false, estate->es_plannedstmt->hasIgnore);
|
||||
else
|
||||
subPartitionId = heapTupleGetPartitionId(partRel, tuple, false, estate->es_plannedstmt->hasIgnore);
|
||||
if (estate->es_plannedstmt->hasIgnore && subPartitionId == InvalidOid) {
|
||||
@ -2422,9 +2422,9 @@ lreplace:
|
||||
row_movement = false;
|
||||
new_partId = oldPartitionOid;
|
||||
} else {
|
||||
Tuple newtuple = ComputePartKeyExprTuple(result_relation_desc, estate, slot, tuple, NULL);
|
||||
if (newtuple) {
|
||||
partitionRoutingForTuple(result_relation_desc, newtuple, u_sess->exec_cxt.route, can_ignore);
|
||||
Datum newval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, NULL);
|
||||
if (newval) {
|
||||
partitionRoutingForTuple(result_relation_desc, (void*)newval, u_sess->exec_cxt.route, can_ignore);
|
||||
} else {
|
||||
partitionRoutingForTuple(result_relation_desc, tuple, u_sess->exec_cxt.route, can_ignore);
|
||||
}
|
||||
@ -2434,9 +2434,9 @@ lreplace:
|
||||
if (RelationIsSubPartitioned(result_relation_desc)) {
|
||||
Partition part = partitionOpen(result_relation_desc, new_partId, RowExclusiveLock);
|
||||
Relation partRel = partitionGetRelation(result_relation_desc, part);
|
||||
Tuple newsubtuple = ComputePartKeyExprTuple(result_relation_desc, estate, slot, tuple, partRel);
|
||||
if (newsubtuple) {
|
||||
partitionRoutingForTuple(partRel, newsubtuple, u_sess->exec_cxt.route, can_ignore);
|
||||
Datum newsubval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, partRel);
|
||||
if (newsubval) {
|
||||
partitionRoutingForTuple(partRel, (void*)newsubval, u_sess->exec_cxt.route, can_ignore);
|
||||
} else {
|
||||
partitionRoutingForTuple(partRel, tuple, u_sess->exec_cxt.route, can_ignore);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user