tableam: Rename wrapper functions to match callback names.
authorAndres Freund <andres@anarazel.de>
Thu, 23 May 2019 23:25:48 +0000 (16:25 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 23 May 2019 23:32:36 +0000 (16:32 -0700)
Some of the wrapper functions didn't match the callback names. Many of
them due to staying "consistent" with historic naming of the wrapped
functionality. We decided that for most cases it's more important to
be for tableam to be consistent going forward, than with the past.

The one exception is beginscan/endscan/...  because it'd have looked
odd to have systable_beginscan/endscan/... with a different naming
scheme, and changing the systable_* APIs would have caused way too
much churn (including breaking a lot of external users).

Author: Ashwin Agrawal, with some small additions by Andres Freund
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/CALfoeiugyrXZfX7n0ORCa4L-m834dzmaE8eFdbNR6PMpetU4Ww@mail.gmail.com

14 files changed:
src/backend/access/heap/heapam.c
src/backend/access/table/tableam.c
src/backend/commands/copy.c
src/backend/commands/createas.c
src/backend/commands/matview.c
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/executor/execMain.c
src/backend/executor/execReplication.c
src/backend/executor/nodeLockRows.c
src/backend/executor/nodeModifyTable.c
src/backend/executor/nodeTidscan.c
src/backend/utils/adt/tid.c
src/include/access/tableam.h

index 6c342635e84085eb62de56f232dfc71e62c6d9d9..419da8784ac80727e334df5e8cb9c919f57811f6 100644 (file)
@@ -1866,12 +1866,12 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
  * The new tuple is stamped with current transaction ID and the specified
  * command ID.
  *
- * See table_insert for comments about most of the input flags, except that
- * this routine directly takes a tuple rather than a slot.
+ * See table_tuple_insert for comments about most of the input flags, except
+ * that this routine directly takes a tuple rather than a slot.
  *
  * There's corresponding HEAP_INSERT_ options to all the TABLE_INSERT_
  * options, and there additionally is HEAP_INSERT_SPECULATIVE which is used to
- * implement table_insert_speculative().
+ * implement table_tuple_insert_speculative().
  *
  * On return the header fields of *tup are updated to match the stored tuple;
  * in particular tup->t_self receives the actual TID where the tuple was
@@ -2444,8 +2444,8 @@ xmax_infomask_changed(uint16 new_infomask, uint16 old_infomask)
 /*
  *     heap_delete - delete a tuple
  *
- * See table_delete() for an explanation of the parameters, except that this
- * routine directly takes a tuple rather than a slot.
+ * See table_tuple_delete() for an explanation of the parameters, except that
+ * this routine directly takes a tuple rather than a slot.
  *
  * In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
  * t_xmax (resolving a possible MultiXact, if necessary), and t_cmax (the last
@@ -2890,8 +2890,8 @@ simple_heap_delete(Relation relation, ItemPointer tid)
 /*
  *     heap_update - replace a tuple
  *
- * See table_update() for an explanation of the parameters, except that this
- * routine directly takes a tuple rather than a slot.
+ * See table_tuple_update() for an explanation of the parameters, except that
+ * this routine directly takes a tuple rather than a slot.
  *
  * In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
  * t_xmax (resolving a possible MultiXact, if necessary), and t_cmax (the last
@@ -3961,7 +3961,7 @@ get_mxact_status_for_lock(LockTupleMode mode, bool is_update)
  *     *buffer: set to buffer holding tuple (pinned but not locked at exit)
  *     *tmfd: filled in failure cases (see below)
  *
- * Function results are the same as the ones for table_lock_tuple().
+ * Function results are the same as the ones for table_tuple_lock().
  *
  * In the failure cases other than TM_Invisible, the routine fills
  * *tmfd with the tuple's t_ctid, t_xmax (resolving a possible MultiXact,
index 12adf590853103b9af816ea424faf09b02fab1d9..7d9fc6bb137a9ac5c8b32fd401d0d5be5c9265d1 100644 (file)
@@ -221,7 +221,7 @@ table_index_fetch_tuple_check(Relation rel,
  */
 
 void
-table_get_latest_tid(TableScanDesc scan, ItemPointer tid)
+table_tuple_get_latest_tid(TableScanDesc scan, ItemPointer tid)
 {
        Relation        rel = scan->rs_rd;
        const TableAmRoutine *tableam = rel->rd_tableam;
@@ -248,19 +248,19 @@ table_get_latest_tid(TableScanDesc scan, ItemPointer tid)
  */
 
 /*
- * simple_table_insert - insert a tuple
+ * simple_table_tuple_insert - insert a tuple
  *
- * Currently, this routine differs from table_insert only in supplying a
+ * Currently, this routine differs from table_tuple_insert only in supplying a
  * default command ID and not allowing access to the speedup options.
  */
 void
-simple_table_insert(Relation rel, TupleTableSlot *slot)
+simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
 {
-       table_insert(rel, slot, GetCurrentCommandId(true), 0, NULL);
+       table_tuple_insert(rel, slot, GetCurrentCommandId(true), 0, NULL);
 }
 
 /*
- * simple_table_delete - delete a tuple
+ * simple_table_tuple_delete - delete a tuple
  *
  * This routine may be used to delete a tuple when concurrent updates of
  * the target tuple are not expected (for example, because we have a lock
@@ -268,16 +268,16 @@ simple_table_insert(Relation rel, TupleTableSlot *slot)
  * via ereport().
  */
 void
-simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
+simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
 {
        TM_Result       result;
        TM_FailureData tmfd;
 
-       result = table_delete(rel, tid,
-                                                 GetCurrentCommandId(true),
-                                                 snapshot, InvalidSnapshot,
-                                                 true /* wait for commit */ ,
-                                                 &tmfd, false /* changingPart */ );
+       result = table_tuple_delete(rel, tid,
+                                                               GetCurrentCommandId(true),
+                                                               snapshot, InvalidSnapshot,
+                                                               true /* wait for commit */ ,
+                                                               &tmfd, false /* changingPart */ );
 
        switch (result)
        {
@@ -299,13 +299,13 @@ simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
                        break;
 
                default:
-                       elog(ERROR, "unrecognized table_delete status: %u", result);
+                       elog(ERROR, "unrecognized table_tuple_delete status: %u", result);
                        break;
        }
 }
 
 /*
- * simple_table_update - replace a tuple
+ * simple_table_tuple_update - replace a tuple
  *
  * This routine may be used to update a tuple when concurrent updates of
  * the target tuple are not expected (for example, because we have a lock
@@ -313,20 +313,20 @@ simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
  * via ereport().
  */
 void
-simple_table_update(Relation rel, ItemPointer otid,
-                                       TupleTableSlot *slot,
-                                       Snapshot snapshot,
-                                       bool *update_indexes)
+simple_table_tuple_update(Relation rel, ItemPointer otid,
+                                                 TupleTableSlot *slot,
+                                                 Snapshot snapshot,
+                                                 bool *update_indexes)
 {
        TM_Result       result;
        TM_FailureData tmfd;
        LockTupleMode lockmode;
 
-       result = table_update(rel, otid, slot,
-                                                 GetCurrentCommandId(true),
-                                                 snapshot, InvalidSnapshot,
-                                                 true /* wait for commit */ ,
-                                                 &tmfd, &lockmode, update_indexes);
+       result = table_tuple_update(rel, otid, slot,
+                                                               GetCurrentCommandId(true),
+                                                               snapshot, InvalidSnapshot,
+                                                               true /* wait for commit */ ,
+                                                               &tmfd, &lockmode, update_indexes);
 
        switch (result)
        {
@@ -348,7 +348,7 @@ simple_table_update(Relation rel, ItemPointer otid,
                        break;
 
                default:
-                       elog(ERROR, "unrecognized table_update status: %u", result);
+                       elog(ERROR, "unrecognized table_tuple_update status: %u", result);
                        break;
        }
 
index b00891ffd2b8db70fec1975f4841f6573310efba..a8ff30490947df8b28cdc52d2f8ac87d9c03651c 100644 (file)
@@ -90,7 +90,7 @@ typedef enum EolType
  */
 typedef enum CopyInsertMethod
 {
-       CIM_SINGLE,                                     /* use table_insert or fdw routine */
+       CIM_SINGLE,                                     /* use table_tuple_insert or fdw routine */
        CIM_MULTI,                                      /* always use table_multi_insert */
        CIM_MULTI_CONDITIONAL           /* use table_multi_insert only if valid */
 } CopyInsertMethod;
@@ -2664,7 +2664,7 @@ CopyFrom(CopyState cstate)
        PartitionTupleRouting *proute = NULL;
        ErrorContextCallback errcallback;
        CommandId       mycid = GetCurrentCommandId(true);
-       int                     ti_options = 0; /* start with default table_insert options */
+       int                     ti_options = 0; /* start with default options for insert */
        BulkInsertState bistate = NULL;
        CopyInsertMethod insertMethod;
        CopyMultiInsertInfo multiInsertInfo = {0};      /* pacify compiler */
@@ -2737,11 +2737,11 @@ CopyFrom(CopyState cstate)
         * FSM for free space is a waste of time, even if we must use WAL because
         * of archiving.  This could possibly be wrong, but it's unlikely.
         *
-        * The comments for table_insert and RelationGetBufferForTuple specify that
-        * skipping WAL logging is only safe if we ensure that our tuples do not
-        * go into pages containing tuples from any other transactions --- but this
-        * must be the case if we have a new table or new relfilenode, so we need
-        * no additional work to enforce that.
+        * The comments for table_tuple_insert and RelationGetBufferForTuple
+        * specify that skipping WAL logging is only safe if we ensure that our
+        * tuples do not go into pages containing tuples from any other
+        * transactions --- but this must be the case if we have a new table or
+        * new relfilenode, so we need no additional work to enforce that.
         *
         * We currently don't support this optimization if the COPY target is a
         * partitioned table as we currently only lazily initialize partition
@@ -2888,9 +2888,9 @@ CopyFrom(CopyState cstate)
        /*
         * It's generally more efficient to prepare a bunch of tuples for
         * insertion, and insert them in one table_multi_insert() call, than call
-        * table_insert() separately for every tuple. However, there are a number
-        * of reasons why we might not be able to do this.  These are explained
-        * below.
+        * table_tuple_insert() separately for every tuple. However, there are a
+        * number of reasons why we might not be able to do this.  These are
+        * explained below.
         */
        if (resultRelInfo->ri_TrigDesc != NULL &&
                (resultRelInfo->ri_TrigDesc->trig_insert_before_row ||
@@ -3286,8 +3286,8 @@ CopyFrom(CopyState cstate)
                                        else
                                        {
                                                /* OK, store the tuple and create index entries for it */
-                                               table_insert(resultRelInfo->ri_RelationDesc, myslot,
-                                                                        mycid, ti_options, bistate);
+                                               table_tuple_insert(resultRelInfo->ri_RelationDesc,
+                                                                                  myslot, mycid, ti_options, bistate);
 
                                                if (resultRelInfo->ri_NumIndices > 0)
                                                        recheckIndexes = ExecInsertIndexTuples(myslot,
index 43c2fa91242eea6a2e61f790a6f2de5f3d131a83..4c1d909d380ce0b794f1605b6a17550fac038f70 100644 (file)
@@ -60,7 +60,7 @@ typedef struct
        Relation        rel;                    /* relation to write to */
        ObjectAddress reladdr;          /* address of rel, for ExecCreateTableAs */
        CommandId       output_cid;             /* cmin to insert in output tuples */
-       int                     ti_options;             /* table_insert performance options */
+       int                     ti_options;             /* table_tuple_insert performance options */
        BulkInsertState bistate;        /* bulk insert state */
 } DR_intorel;
 
@@ -576,18 +576,18 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
 
        /*
         * Note that the input slot might not be of the type of the target
-        * relation. That's supported by table_insert(), but slightly less
+        * relation. That's supported by table_tuple_insert(), but slightly less
         * efficient than inserting with the right slot - but the alternative
         * would be to copy into a slot of the right type, which would not be
         * cheap either. This also doesn't allow accessing per-AM data (say a
         * tuple's xmin), but since we don't do that here...
         */
 
-       table_insert(myState->rel,
-                                slot,
-                                myState->output_cid,
-                                myState->ti_options,
-                                myState->bistate);
+       table_tuple_insert(myState->rel,
+                                          slot,
+                                          myState->output_cid,
+                                          myState->ti_options,
+                                          myState->bistate);
 
        /* We know this is a newly created relation, so there are no indexes */
 
index dc2940cd4eb92f47c8963c4a86352a9fdb7cf7bf..537d0e8ceff656e89863961ce2bd439fb96d38da 100644 (file)
@@ -54,7 +54,7 @@ typedef struct
        /* These fields are filled by transientrel_startup: */
        Relation        transientrel;   /* relation to write to */
        CommandId       output_cid;             /* cmin to insert in output tuples */
-       int                     ti_options;             /* table_insert performance options */
+       int                     ti_options;             /* table_tuple_insert performance options */
        BulkInsertState bistate;        /* bulk insert state */
 } DR_transientrel;
 
@@ -481,18 +481,18 @@ transientrel_receive(TupleTableSlot *slot, DestReceiver *self)
 
        /*
         * Note that the input slot might not be of the type of the target
-        * relation. That's supported by table_insert(), but slightly less
+        * relation. That's supported by table_tuple_insert(), but slightly less
         * efficient than inserting with the right slot - but the alternative
         * would be to copy into a slot of the right type, which would not be
         * cheap either. This also doesn't allow accessing per-AM data (say a
         * tuple's xmin), but since we don't do that here...
         */
 
-       table_insert(myState->transientrel,
-                                slot,
-                                myState->output_cid,
-                                myState->ti_options,
-                                myState->bistate);
+       table_tuple_insert(myState->transientrel,
+                                          slot,
+                                          myState->output_cid,
+                                          myState->ti_options,
+                                          myState->bistate);
 
        /* We know this is a newly created relation, so there are no indexes */
 
index 602a8dbd1c3aa0534dd08c9919bb7326578e3853..c9b8857d3064b23ab46d8b8075d1ee5512d79047 100644 (file)
@@ -4732,9 +4732,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
                newrel = NULL;
 
        /*
-        * Prepare a BulkInsertState and options for table_insert. Because we're
-        * building a new heap, we can skip WAL-logging and fsync it to disk at
-        * the end instead (unless WAL-logging is required for archiving or
+        * Prepare a BulkInsertState and options for table_tuple_insert. Because
+        * we're building a new heap, we can skip WAL-logging and fsync it to disk
+        * at the end instead (unless WAL-logging is required for archiving or
         * streaming replication). The FSM is empty too, so don't bother using it.
         */
        if (newrel)
@@ -5005,7 +5005,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
 
                        /* Write the tuple out to the new relation */
                        if (newrel)
-                               table_insert(newrel, insertslot, mycid, ti_options, bistate);
+                               table_tuple_insert(newrel, insertslot, mycid,
+                                                                  ti_options, bistate);
 
                        ResetExprContext(econtext);
 
index 3132a13785be4d4605c46357346818731865413d..316692b7c276dd020d799b344e584b9e6a4d24eb 100644 (file)
@@ -3332,7 +3332,7 @@ GetTupleForTrigger(EState *estate,
                 */
                if (!IsolationUsesXactSnapshot())
                        lockflags |= TUPLE_LOCK_FLAG_FIND_LAST_VERSION;
-               test = table_lock_tuple(relation, tid, estate->es_snapshot, oldslot,
+               test = table_tuple_lock(relation, tid, estate->es_snapshot, oldslot,
                                                                estate->es_output_cid,
                                                                lockmode, LockWaitBlock,
                                                                lockflags,
@@ -3386,7 +3386,7 @@ GetTupleForTrigger(EState *estate,
                               &n