return result;
}
+static void
+heapam_finish_bulk_insert(Relation relation, int options)
+{
+ /*
+ * If we skipped writing WAL, then we need to sync the heap (but not
+ * indexes since those use WAL anyway)
+ */
+ if (options & HEAP_INSERT_SKIP_WAL)
+ heap_sync(relation);
+}
+
+
static bool
heapam_fetch_row_version(Relation relation,
ItemPointer tid,
.tuple_update = heapam_heap_update,
.multi_insert = heap_multi_insert,
.tuple_lock = heapam_lock_tuple,
+ .finish_bulk_insert = heapam_finish_bulk_insert,
.tuple_fetch_row_version = heapam_fetch_row_version,
.tuple_get_latest_tid = heap_get_latest_tid,
FreeExecutorState(estate);
- /*
- * If we skipped writing WAL, then we need to sync the heap (but not
- * indexes since those use WAL anyway)
- */
- if (hi_options & HEAP_INSERT_SKIP_WAL)
- heap_sync(cstate->rel);
+ table_finish_bulk_insert(cstate->rel, hi_options);
return processed;
}
#include "access/reloptions.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
+#include "access/tableam.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "catalog/namespace.h"
FreeBulkInsertState(myState->bistate);
- /* If we skipped using WAL, must heap_sync before commit */
- if (myState->hi_options & HEAP_INSERT_SKIP_WAL)
- heap_sync(myState->rel);
+ table_finish_bulk_insert(myState->rel, myState->hi_options);
/* close rel, but keep lock until commit */
table_close(myState->rel, NoLock);
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
+#include "access/tableam.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
FreeBulkInsertState(myState->bistate);
- /* If we skipped using WAL, must heap_sync before commit */
- if (myState->hi_options & HEAP_INSERT_SKIP_WAL)
- heap_sync(myState->transientrel);
+ table_finish_bulk_insert(myState->transientrel, myState->hi_options);
/* close transientrel, but keep lock until commit */
table_close(myState->transientrel, NoLock);
{
FreeBulkInsertState(bistate);
- /* If we skipped writing WAL, then we need to sync the heap. */
- if (hi_options & HEAP_INSERT_SKIP_WAL)
- heap_sync(newrel);
+ table_finish_bulk_insert(newrel, hi_options);
table_close(newrel, NoLock);
}
LockWaitPolicy wait_policy,
uint8 flags,
HeapUpdateFailureData *hufd);
+
+ /*
+ * 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 skipping
+ * WAL.
+ *
+ * May be NULL.
+ */
+ void (*finish_bulk_insert) (Relation rel, int options);
+
+
/* ------------------------------------------------------------------------
* Non-modifying operations on individual tuples.
* ------------------------------------------------------------------------
cid, mode, wait_policy,
flags, hufd);
}
+
+static inline void
+table_finish_bulk_insert(Relation rel, int options)
+{
+ /* optional */
+ if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
+ rel->rd_tableam->finish_bulk_insert(rel, options);
+}
+
+
/* ----------------------------------------------------------------------------
* Non-modifying operations on individual tuples.
* ----------------------------------------------------------------------------