Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc35a3fb

Browse files
committed
Allow table AM tuple_insert() method to return the different slot
This allows table AM to return a native tuple slot even ifVirtualTupleTableSlot is given as an input. Native tuple slots have knowledgeabout system attributes, which could be accessed in the future.table_multi_insert() method already can modify the input 'slots' array.Discussion:https://postgr.es/m/CAPpHfdurb9ycV8udYqM%3Do0sPS66PJ4RCBM1g-bBpvzUfogY0EA%40mail.gmail.comReviewed-by: Matthias van de Meent, Mark Dilger, Pavel BorisovReviewed-by: Nikita Malakhov, Japin Li
1 parent02eb07e commitc35a3fb

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ heapam_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
237237
* ----------------------------------------------------------------------------
238238
*/
239239

240-
staticvoid
240+
staticTupleTableSlot*
241241
heapam_tuple_insert(Relationrelation,TupleTableSlot*slot,CommandIdcid,
242242
intoptions,BulkInsertStatebistate)
243243
{
@@ -254,6 +254,8 @@ heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
254254

255255
if (shouldFree)
256256
pfree(tuple);
257+
258+
returnslot;
257259
}
258260

259261
staticvoid

‎src/backend/executor/nodeModifyTable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,9 +1125,9 @@ ExecInsert(ModifyTableContext *context,
11251125
else
11261126
{
11271127
/* insert the tuple normally */
1128-
table_tuple_insert(resultRelationDesc,slot,
1129-
estate->es_output_cid,
1130-
0,NULL);
1128+
slot=table_tuple_insert(resultRelationDesc,slot,
1129+
estate->es_output_cid,
1130+
0,NULL);
11311131

11321132
/* insert index entries for tuple */
11331133
if (resultRelInfo->ri_NumIndices>0)

‎src/include/access/tableam.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,9 @@ typedef struct TableAmRoutine
500500
*/
501501

502502
/* see table_tuple_insert() for reference about parameters */
503-
void(*tuple_insert) (Relationrel,TupleTableSlot*slot,
504-
CommandIdcid,intoptions,
505-
structBulkInsertStateData*bistate);
503+
TupleTableSlot*(*tuple_insert) (Relationrel,TupleTableSlot*slot,
504+
CommandIdcid,intoptions,
505+
structBulkInsertStateData*bistate);
506506

507507
/* see table_tuple_insert_speculative() for reference about parameters */
508508
void(*tuple_insert_speculative) (Relationrel,
@@ -1392,16 +1392,19 @@ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
13921392
* behavior) is also just passed through to RelationGetBufferForTuple. If
13931393
* `bistate` is provided, table_finish_bulk_insert() needs to be called.
13941394
*
1395-
* On return the slot's tts_tid and tts_tableOid are updated to reflect the
1396-
* insertion. But note that any toasting of fields within the slot is NOT
1397-
* reflected in the slots contents.
1395+
* Returns the slot containing the inserted tuple, which may differ from the
1396+
* given slot. For instance, the source slot may be VirtualTupleTableSlot, but
1397+
* the result slot may correspond to the table AM. On return the slot's
1398+
* tts_tid and tts_tableOid are updated to reflect the insertion. But note
1399+
* that any toasting of fields within the slot is NOT reflected in the slots
1400+
* contents.
13981401
*/
1399-
staticinlinevoid
1402+
staticinlineTupleTableSlot*
14001403
table_tuple_insert(Relationrel,TupleTableSlot*slot,CommandIdcid,
14011404
intoptions,structBulkInsertStateData*bistate)
14021405
{
1403-
rel->rd_tableam->tuple_insert(rel,slot,cid,options,
1404-
bistate);
1406+
returnrel->rd_tableam->tuple_insert(rel,slot,cid,options,
1407+
bistate);
14051408
}
14061409

14071410
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp