diff options
Diffstat (limited to 'src/include/access/tableam.h')
-rw-r--r-- | src/include/access/tableam.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 42e2ba68bf9..90c329a88d3 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -350,6 +350,10 @@ typedef struct TableAmRoutine uint32 specToken, bool succeeded); + /* see table_multi_insert() for reference about parameters */ + void (*multi_insert) (Relation rel, TupleTableSlot **slots, int nslots, + CommandId cid, int options, struct BulkInsertStateData *bistate); + /* see table_delete() for reference about parameters */ TM_Result (*tuple_delete) (Relation rel, ItemPointer tid, @@ -1078,6 +1082,28 @@ table_complete_speculative(Relation rel, TupleTableSlot *slot, } /* + * Insert multiple tuple into a table. + * + * This is like table_insert(), but inserts multiple tuples in one + * operation. That's often faster than calling table_insert() in a loop, + * because e.g. the AM can reduce WAL logging and page locking overhead. + * + * Except for taking `nslots` tuples as input, as an array of TupleTableSlots + * in `slots`, the parameters for table_multi_insert() are the same as for + * table_insert(). + * + * Note: this leaks memory into the current memory context. You can create a + * temporary context before calling this, if that's a problem. + */ +static inline void +table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots, + CommandId cid, int options, struct BulkInsertStateData *bistate) +{ + rel->rd_tableam->multi_insert(rel, slots, nslots, + cid, options, bistate); +} + +/* * Delete a tuple. * * NB: do not call this directly unless prepared to deal with |