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

Appearance settings

Commit c35a3fb

Browse filesBrowse files
committed
Allow table AM tuple_insert() method to return the different slot
This allows table AM to return a native tuple slot even if VirtualTupleTableSlot is given as an input. Native tuple slots have knowledge about 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.com Reviewed-by: Matthias van de Meent, Mark Dilger, Pavel Borisov Reviewed-by: Nikita Malakhov, Japin Li
1 parent 02eb07e commit c35a3fb
Copy full SHA for c35a3fb

File tree

Expand file treeCollapse file tree

3 files changed

+18
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-13
lines changed

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

Copy file name to clipboardExpand all lines: src/backend/access/heap/heapam_handler.c
+3-1Lines 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-
static void
240+
static TupleTableSlot *
241241
heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
242242
int options, BulkInsertState bistate)
243243
{
@@ -254,6 +254,8 @@ heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
254254

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

259261
static void

‎src/backend/executor/nodeModifyTable.c

Copy file name to clipboardExpand all lines: src/backend/executor/nodeModifyTable.c
+3-3Lines 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

Copy file name to clipboardExpand all lines: src/include/access/tableam.h
+12-9Lines 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) (Relation rel, TupleTableSlot *slot,
504-
CommandId cid, int options,
505-
struct BulkInsertStateData *bistate);
503+
TupleTableSlot *(*tuple_insert) (Relation rel, TupleTableSlot *slot,
504+
CommandId cid, int options,
505+
struct BulkInsertStateData *bistate);
506506

507507
/* see table_tuple_insert_speculative() for reference about parameters */
508508
void (*tuple_insert_speculative) (Relation rel,
@@ -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-
static inline void
1402+
static inline TupleTableSlot *
14001403
table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid,
14011404
int options, struct BulkInsertStateData *bistate)
14021405
{
1403-
rel->rd_tableam->tuple_insert(rel, slot, cid, options,
1404-
bistate);
1406+
return rel->rd_tableam->tuple_insert(rel, slot, cid, options,
1407+
bistate);
14051408
}
14061409

14071410
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.