-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,7 +265,7 @@ static void YBCExecWriteStmt(YBCPgStatement ybc_stmt, | |
} | ||
|
||
static Oid YBCApplyInsertRow( | ||
YBCPgStatement insert_stmt, Relation rel, TupleDesc tupleDesc, | ||
YBCPgStatement insert_stmt, Relation rel, TupleTableSlot *slot, TupleDesc tupleDesc, | ||
This comment has been minimized.
Sorry, something went wrong.
andrei-mart
Contributor
|
||
HeapTuple tuple, OnConflictAction onConflictAction, Datum *ybctid, | ||
YBCPgTransactionSetting transaction_setting) { | ||
Oid relfileNodeId = YbGetRelfileNodeId(rel); | ||
|
@@ -323,13 +323,12 @@ static Oid YBCApplyInsertRow( | |
*/ | ||
Oid collation_id = YBEncodingCollation(insert_stmt, attnum, | ||
ybc_get_attcollation(RelationGetDescr(rel), attnum)); | ||
column->datum = heap_getattr(tuple, attnum, tupleDesc, &column->is_null); | ||
column->datum = slot_getattr(slot, attnum, &column->is_null); | ||
YBGetCollationInfo(collation_id, column->type_entity, column->datum, column->is_null, &column->collation_info); | ||
|
||
/* Add the column value to the insert request */ | ||
++column; | ||
} | ||
|
||
HandleYBStatus(YBCPgDmlBindRow(insert_stmt, tuple->t_ybctid, columns, column - columns)); | ||
|
||
/* | ||
|
@@ -362,6 +361,7 @@ static Oid YBCApplyInsertRow( | |
*/ | ||
static Oid YBCExecuteInsertInternal(Oid dboid, | ||
Relation rel, | ||
TupleTableSlot *slot, | ||
TupleDesc tupleDesc, | ||
HeapTuple tuple, | ||
OnConflictAction onConflictAction, | ||
|
@@ -379,7 +379,7 @@ static Oid YBCExecuteInsertInternal(Oid dboid, | |
transaction_setting)); | ||
|
||
Oid result = YBCApplyInsertRow( | ||
insert_stmt, rel, tupleDesc, tuple, onConflictAction, ybctid, | ||
insert_stmt, rel, slot, tupleDesc, tuple, onConflictAction, ybctid, | ||
transaction_setting); | ||
|
||
/* Execute the insert */ | ||
|
@@ -389,12 +389,14 @@ static Oid YBCExecuteInsertInternal(Oid dboid, | |
} | ||
|
||
Oid YBCExecuteInsert(Relation rel, | ||
TupleTableSlot *slot, | ||
TupleDesc tupleDesc, | ||
HeapTuple tuple, | ||
OnConflictAction onConflictAction) | ||
{ | ||
return YBCExecuteInsertForDb(YBCGetDatabaseOid(rel), | ||
rel, | ||
slot, | ||
tupleDesc, | ||
tuple, | ||
onConflictAction, | ||
|
@@ -422,6 +424,7 @@ static YBCPgTransactionSetting YBCFixTransactionSetting( | |
|
||
Oid YBCExecuteInsertForDb(Oid dboid, | ||
Relation rel, | ||
TupleTableSlot *slot, | ||
TupleDesc tupleDesc, | ||
HeapTuple tuple, | ||
OnConflictAction onConflictAction, | ||
|
@@ -430,6 +433,7 @@ Oid YBCExecuteInsertForDb(Oid dboid, | |
{ | ||
return YBCExecuteInsertInternal(dboid, | ||
rel, | ||
slot, | ||
tupleDesc, | ||
tuple, | ||
onConflictAction, | ||
|
@@ -438,12 +442,14 @@ Oid YBCExecuteInsertForDb(Oid dboid, | |
} | ||
|
||
Oid YBCExecuteNonTxnInsert(Relation rel, | ||
TupleTableSlot *slot, | ||
TupleDesc tupleDesc, | ||
HeapTuple tuple, | ||
OnConflictAction onConflictAction) | ||
{ | ||
return YBCExecuteNonTxnInsertForDb(YBCGetDatabaseOid(rel), | ||
rel, | ||
slot, | ||
tupleDesc, | ||
tuple, | ||
onConflictAction, | ||
|
@@ -452,13 +458,15 @@ Oid YBCExecuteNonTxnInsert(Relation rel, | |
|
||
Oid YBCExecuteNonTxnInsertForDb(Oid dboid, | ||
Relation rel, | ||
TupleTableSlot *slot, | ||
TupleDesc tupleDesc, | ||
HeapTuple tuple, | ||
OnConflictAction onConflictAction, | ||
Datum *ybctid) | ||
{ | ||
return YBCExecuteInsertInternal(dboid, | ||
rel, | ||
slot, | ||
tupleDesc, | ||
tuple, | ||
onConflictAction, | ||
|
@@ -481,7 +489,7 @@ Oid YBCHeapInsert(TupleTableSlot *slot, | |
|
||
if (blockInsertStmt) { | ||
return YBCApplyInsertRow( | ||
blockInsertStmt, resultRelationDesc, slot->tts_tupleDescriptor, | ||
blockInsertStmt, resultRelationDesc, slot, slot->tts_tupleDescriptor, | ||
tuple, ONCONFLICT_NONE, NULL /* ybctid */, | ||
YBCFixTransactionSetting(resultRelationDesc, transaction_setting)); | ||
} | ||
|
@@ -496,7 +504,7 @@ Oid YBCHeapInsert(TupleTableSlot *slot, | |
* there are no indices or triggers on the target table. | ||
*/ | ||
return YBCExecuteInsertForDb( | ||
dboid, resultRelationDesc, slot->tts_tupleDescriptor, tuple, ONCONFLICT_NONE, NULL /* ybctid */, | ||
dboid, resultRelationDesc, slot, slot->tts_tupleDescriptor, tuple, ONCONFLICT_NONE, NULL /* ybctid */, | ||
transaction_setting); | ||
} | ||
|
||
|
@@ -1174,6 +1182,7 @@ Oid YBCExecuteUpdateReplace(Relation rel, | |
estate); | ||
|
||
return YBCExecuteInsert(rel, | ||
slot, | ||
RelationGetDescr(rel), | ||
tuple, | ||
ONCONFLICT_NONE); | ||
|
The slot is only needed for YBCExecuteInsert, so it makes sense to create and destroy it inside of the
if (IsYugaByteEnabled())
block.