mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
tableam: Add table_finish_bulk_insert().
This replaces the previous calls of heap_sync() in places using bulk-insert. By passing in the flags used for bulk-insert the AM can decide (first at insert time and then during the finish call) which of the optimizations apply to it, and what operations are necessary to finish a bulk insert operation. Also change HEAP_INSERT_* flags to TABLE_INSERT, and rename hi_options to ti_options. These changes are made even in copy.c, which hasn't yet been converted to tableam. There's no harm in doing so. Author: Andres Freund Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
This commit is contained in:
@@ -380,6 +380,21 @@ typedef struct TableAmRoutine
|
||||
uint8 flags,
|
||||
TM_FailureData *tmfd);
|
||||
|
||||
/*
|
||||
* Perform operations necessary to complete insertions made via
|
||||
* tuple_insert and multi_insert with a BulkInsertState specified. This
|
||||
* e.g. may e.g. used to flush the relation when inserting with
|
||||
* TABLE_INSERT_SKIP_WAL specified.
|
||||
*
|
||||
* Typically callers of tuple_insert and multi_insert will just pass all
|
||||
* the flags the apply to them, and each AM has to decide which of them
|
||||
* make sense for it, and then only take actions in finish_bulk_insert
|
||||
* that make sense for a specific AM.
|
||||
*
|
||||
* Optional callback.
|
||||
*/
|
||||
void (*finish_bulk_insert) (Relation rel, int options);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* DDL related functionality.
|
||||
@@ -1011,7 +1026,8 @@ table_compute_xid_horizon_for_tuples(Relation rel,
|
||||
*
|
||||
*
|
||||
* The BulkInsertState object (if any; bistate can be NULL for default
|
||||
* behavior) is also just passed through to RelationGetBufferForTuple.
|
||||
* behavior) is also just passed through to RelationGetBufferForTuple. If
|
||||
* `bistate` is provided, table_finish_bulk_insert() needs to be called.
|
||||
*
|
||||
* On return the slot's tts_tid and tts_tableOid are updated to reflect the
|
||||
* insertion. But note that any toasting of fields within the slot is NOT
|
||||
@@ -1185,6 +1201,20 @@ table_lock_tuple(Relation rel, ItemPointer tid, Snapshot snapshot,
|
||||
flags, tmfd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform operations necessary to complete insertions made via
|
||||
* tuple_insert and multi_insert with a BulkInsertState specified. This
|
||||
* e.g. may e.g. used to flush the relation when inserting with
|
||||
* TABLE_INSERT_SKIP_WAL specified.
|
||||
*/
|
||||
static inline void
|
||||
table_finish_bulk_insert(Relation rel, int options)
|
||||
{
|
||||
/* optional callback */
|
||||
if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
|
||||
rel->rd_tableam->finish_bulk_insert(rel, options);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* DDL related functionality.
|
||||
|
Reference in New Issue
Block a user