Commit 73b8c3bd authored by Andres Freund's avatar Andres Freund

tableam: Rename wrapper functions to match callback names.

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
parent 54487d15
...@@ -1866,12 +1866,12 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate) ...@@ -1866,12 +1866,12 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
* The new tuple is stamped with current transaction ID and the specified * The new tuple is stamped with current transaction ID and the specified
* command ID. * command ID.
* *
* See table_insert for comments about most of the input flags, except that * See table_tuple_insert for comments about most of the input flags, except
* this routine directly takes a tuple rather than a slot. * that this routine directly takes a tuple rather than a slot.
* *
* There's corresponding HEAP_INSERT_ options to all the TABLE_INSERT_ * There's corresponding HEAP_INSERT_ options to all the TABLE_INSERT_
* options, and there additionally is HEAP_INSERT_SPECULATIVE which is used to * 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; * 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 * 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) ...@@ -2444,8 +2444,8 @@ xmax_infomask_changed(uint16 new_infomask, uint16 old_infomask)
/* /*
* heap_delete - delete a tuple * heap_delete - delete a tuple
* *
* See table_delete() for an explanation of the parameters, except that this * See table_tuple_delete() for an explanation of the parameters, except that
* routine directly takes a tuple rather than a slot. * this routine directly takes a tuple rather than a slot.
* *
* In the failure cases, the routine fills *tmfd with the tuple's t_ctid, * 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 * t_xmax (resolving a possible MultiXact, if necessary), and t_cmax (the last
...@@ -2890,8 +2890,8 @@ simple_heap_delete(Relation relation, ItemPointer tid) ...@@ -2890,8 +2890,8 @@ simple_heap_delete(Relation relation, ItemPointer tid)
/* /*
* heap_update - replace a tuple * heap_update - replace a tuple
* *
* See table_update() for an explanation of the parameters, except that this * See table_tuple_update() for an explanation of the parameters, except that
* routine directly takes a tuple rather than a slot. * this routine directly takes a tuple rather than a slot.
* *
* In the failure cases, the routine fills *tmfd with the tuple's t_ctid, * 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 * 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) ...@@ -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) * *buffer: set to buffer holding tuple (pinned but not locked at exit)
* *tmfd: filled in failure cases (see below) * *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 * In the failure cases other than TM_Invisible, the routine fills
* *tmfd with the tuple's t_ctid, t_xmax (resolving a possible MultiXact, * *tmfd with the tuple's t_ctid, t_xmax (resolving a possible MultiXact,
......
...@@ -221,7 +221,7 @@ table_index_fetch_tuple_check(Relation rel, ...@@ -221,7 +221,7 @@ table_index_fetch_tuple_check(Relation rel,
*/ */
void void
table_get_latest_tid(TableScanDesc scan, ItemPointer tid) table_tuple_get_latest_tid(TableScanDesc scan, ItemPointer tid)
{ {
Relation rel = scan->rs_rd; Relation rel = scan->rs_rd;
const TableAmRoutine *tableam = rel->rd_tableam; const TableAmRoutine *tableam = rel->rd_tableam;
...@@ -248,19 +248,19 @@ table_get_latest_tid(TableScanDesc scan, ItemPointer tid) ...@@ -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. * default command ID and not allowing access to the speedup options.
*/ */
void 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 * 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 * the target tuple are not expected (for example, because we have a lock
...@@ -268,16 +268,16 @@ simple_table_insert(Relation rel, TupleTableSlot *slot) ...@@ -268,16 +268,16 @@ simple_table_insert(Relation rel, TupleTableSlot *slot)
* via ereport(). * via ereport().
*/ */
void void
simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot) simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
{ {
TM_Result result; TM_Result result;
TM_FailureData tmfd; TM_FailureData tmfd;
result = table_delete(rel, tid, result = table_tuple_delete(rel, tid,
GetCurrentCommandId(true), GetCurrentCommandId(true),
snapshot, InvalidSnapshot, snapshot, InvalidSnapshot,
true /* wait for commit */ , true /* wait for commit */ ,
&tmfd, false /* changingPart */ ); &tmfd, false /* changingPart */ );
switch (result) switch (result)
{ {
...@@ -299,13 +299,13 @@ simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot) ...@@ -299,13 +299,13 @@ simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
break; break;
default: default:
elog(ERROR, "unrecognized table_delete status: %u", result); elog(ERROR, "unrecognized table_tuple_delete status: %u", result);
break; 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 * 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 * 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) ...@@ -313,20 +313,20 @@ simple_table_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
* via ereport(). * via ereport().
*/ */
void void
simple_table_update(Relation rel, ItemPointer otid, simple_table_tuple_update(Relation rel, ItemPointer otid,
TupleTableSlot *slot, TupleTableSlot *slot,
Snapshot snapshot, Snapshot snapshot,
bool *update_indexes) bool *update_indexes)
{ {
TM_Result result; TM_Result result;
TM_FailureData tmfd; TM_FailureData tmfd;
LockTupleMode lockmode; LockTupleMode lockmode;
result = table_update(rel, otid, slot, result = table_tuple_update(rel, otid, slot,
GetCurrentCommandId(true), GetCurrentCommandId(true),
snapshot, InvalidSnapshot, snapshot, InvalidSnapshot,
true /* wait for commit */ , true /* wait for commit */ ,
&tmfd, &lockmode, update_indexes); &tmfd, &lockmode, update_indexes);
switch (result) switch (result)
{ {
...@@ -348,7 +348,7 @@ simple_table_update(Relation rel, ItemPointer otid, ...@@ -348,7 +348,7 @@ simple_table_update(Relation rel, ItemPointer otid,
break; break;
default: default:
elog(ERROR, "unrecognized table_update status: %u", result); elog(ERROR, "unrecognized table_tuple_update status: %u", result);
break; break;
} }
......
...@@ -90,7 +90,7 @@ typedef enum EolType ...@@ -90,7 +90,7 @@ typedef enum EolType
*/ */
typedef enum CopyInsertMethod 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, /* always use table_multi_insert */
CIM_MULTI_CONDITIONAL /* use table_multi_insert only if valid */ CIM_MULTI_CONDITIONAL /* use table_multi_insert only if valid */
} CopyInsertMethod; } CopyInsertMethod;
...@@ -2664,7 +2664,7 @@ CopyFrom(CopyState cstate) ...@@ -2664,7 +2664,7 @@ CopyFrom(CopyState cstate)
PartitionTupleRouting *proute = NULL; PartitionTupleRouting *proute = NULL;
ErrorContextCallback errcallback; ErrorContextCallback errcallback;
CommandId mycid = GetCurrentCommandId(true); 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; BulkInsertState bistate = NULL;
CopyInsertMethod insertMethod; CopyInsertMethod insertMethod;
CopyMultiInsertInfo multiInsertInfo = {0}; /* pacify compiler */ CopyMultiInsertInfo multiInsertInfo = {0}; /* pacify compiler */
...@@ -2737,11 +2737,11 @@ CopyFrom(CopyState cstate) ...@@ -2737,11 +2737,11 @@ CopyFrom(CopyState cstate)
* FSM for free space is a waste of time, even if we must use WAL because * 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. * of archiving. This could possibly be wrong, but it's unlikely.
* *
* The comments for table_insert and RelationGetBufferForTuple specify that * The comments for table_tuple_insert and RelationGetBufferForTuple
* skipping WAL logging is only safe if we ensure that our tuples do not * specify that skipping WAL logging is only safe if we ensure that our
* go into pages containing tuples from any other transactions --- but this * tuples do not go into pages containing tuples from any other
* must be the case if we have a new table or new relfilenode, so we need * transactions --- but this must be the case if we have a new table or
* no additional work to enforce that. * new relfilenode, so we need no additional work to enforce that.
* *
* We currently don't support this optimization if the COPY target is a * We currently don't support this optimization if the COPY target is a
* partitioned table as we currently only lazily initialize partition * partitioned table as we currently only lazily initialize partition
...@@ -2888,9 +2888,9 @@ CopyFrom(CopyState cstate) ...@@ -2888,9 +2888,9 @@ CopyFrom(CopyState cstate)
/* /*
* It's generally more efficient to prepare a bunch of tuples for * It's generally more efficient to prepare a bunch of tuples for
* insertion, and insert them in one table_multi_insert() call, than call * insertion, and insert them in one table_multi_insert() call, than call
* table_insert() separately for every tuple. However, there are a number * table_tuple_insert() separately for every tuple. However, there are a
* of reasons why we might not be able to do this. These are explained * number of reasons why we might not be able to do this. These are
* below. * explained below.
*/ */
if (resultRelInfo->ri_TrigDesc != NULL && if (resultRelInfo->ri_TrigDesc != NULL &&
(resultRelInfo->ri_TrigDesc->trig_insert_before_row || (resultRelInfo->ri_TrigDesc->trig_insert_before_row ||
...@@ -3286,8 +3286,8 @@ CopyFrom(CopyState cstate) ...@@ -3286,8 +3286,8 @@ CopyFrom(CopyState cstate)
else else
{ {
/* OK, store the tuple and create index entries for it */ /* OK, store the tuple and create index entries for it */
table_insert(resultRelInfo->ri_RelationDesc, myslot, table_tuple_insert(resultRelInfo->ri_RelationDesc,
mycid, ti_options, bistate); myslot, mycid, ti_options, bistate);
if (resultRelInfo->ri_NumIndices > 0) if (resultRelInfo->ri_NumIndices > 0)
recheckIndexes = ExecInsertIndexTuples(myslot, recheckIndexes = ExecInsertIndexTuples(myslot,
......
...@@ -60,7 +60,7 @@ typedef struct ...@@ -60,7 +60,7 @@ typedef struct
Relation rel; /* relation to write to */ Relation rel; /* relation to write to */
ObjectAddress reladdr; /* address of rel, for ExecCreateTableAs */ ObjectAddress reladdr; /* address of rel, for ExecCreateTableAs */
CommandId output_cid; /* cmin to insert in output tuples */ 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 */ BulkInsertState bistate; /* bulk insert state */
} DR_intorel; } DR_intorel;
...@@ -576,18 +576,18 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self) ...@@ -576,18 +576,18 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
/* /*
* Note that the input slot might not be of the type of the target * 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 * 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 * 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 * cheap either. This also doesn't allow accessing per-AM data (say a
* tuple's xmin), but since we don't do that here... * tuple's xmin), but since we don't do that here...
*/ */
table_insert(myState->rel, table_tuple_insert(myState->rel,
slot, slot,
myState->output_cid, myState->output_cid,
myState->ti_options, myState->ti_options,
myState->bistate); myState->bistate);
/* We know this is a newly created relation, so there are no indexes */ /* We know this is a newly created relation, so there are no indexes */
......
...@@ -54,7 +54,7 @@ typedef struct ...@@ -54,7 +54,7 @@ typedef struct
/* These fields are filled by transientrel_startup: */ /* These fields are filled by transientrel_startup: */
Relation transientrel; /* relation to write to */ Relation transientrel; /* relation to write to */
CommandId output_cid; /* cmin to insert in output tuples */ 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 */ BulkInsertState bistate; /* bulk insert state */
} DR_transientrel; } DR_transientrel;
...@@ -481,18 +481,18 @@ transientrel_receive(TupleTableSlot *slot, DestReceiver *self) ...@@ -481,18 +481,18 @@ transientrel_receive(TupleTableSlot *slot, DestReceiver *self)
/* /*
* Note that the input slot might not be of the type of the target * 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 * 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 * 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 * cheap either. This also doesn't allow accessing per-AM data (say a
* tuple's xmin), but since we don't do that here... * tuple's xmin), but since we don't do that here...
*/ */
table_insert(myState->transientrel, table_tuple_insert(myState->transientrel,
slot, slot,
myState->output_cid, myState->output_cid,
myState->ti_options, myState->ti_options,
myState->bistate); myState->bistate);
/* We know this is a newly created relation, so there are no indexes */ /* We know this is a newly created relation, so there are no indexes */
......
...@@ -4732,9 +4732,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) ...@@ -4732,9 +4732,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
newrel = NULL; newrel = NULL;
/* /*
* Prepare a BulkInsertState and options for table_insert. Because we're * Prepare a BulkInsertState and options for table_tuple_insert. Because
* building a new heap, we can skip WAL-logging and fsync it to disk at * we're building a new heap, we can skip WAL-logging and fsync it to disk
* the end instead (unless WAL-logging is required for archiving or * 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. * streaming replication). The FSM is empty too, so don't bother using it.
*/ */
if (newrel) if (newrel)
...@@ -5005,7 +5005,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) ...@@ -5005,7 +5005,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
/* Write the tuple out to the new relation */ /* Write the tuple out to the new relation */
if (newrel) if (newrel)
table_insert(newrel, insertslot, mycid, ti_options, bistate); table_tuple_insert(newrel, insertslot, mycid,
ti_options, bistate);
ResetExprContext(econtext); ResetExprContext(econtext);
......
...@@ -3332,7 +3332,7 @@ GetTupleForTrigger(EState *estate, ...@@ -3332,7 +3332,7 @@ GetTupleForTrigger(EState *estate,
*/ */
if (!IsolationUsesXactSnapshot()) if (!IsolationUsesXactSnapshot())
lockflags |= TUPLE_LOCK_FLAG_FIND_LAST_VERSION; 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, estate->es_output_cid,
lockmode, LockWaitBlock, lockmode, LockWaitBlock,
lockflags, lockflags,
...@@ -3386,7 +3386,7 @@ GetTupleForTrigger(EState *estate, ...@@ -3386,7 +3386,7 @@ GetTupleForTrigger(EState *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
errmsg("could not serialize access due to concurrent update"))); errmsg("could not serialize access due to concurrent update")));
elog(ERROR, "unexpected table_lock_tuple status: %u", test); elog(ERROR, "unexpected table_tuple_lock status: %u", test);
break; break;
case TM_Deleted: case TM_Deleted:
...@@ -3402,7 +3402,7 @@ GetTupleForTrigger(EState *estate, ...@@ -3402,7 +3402,7 @@ GetTupleForTrigger(EState *estate,
break; break;
default: default:
elog(ERROR, "unrecognized table_lock_tuple status: %u", test); elog(ERROR, "unrecognized table_tuple_lock status: %u", test);
return false; /* keep compiler quiet */ return false; /* keep compiler quiet */
} }
} }
...@@ -3412,7 +3412,8 @@ GetTupleForTrigger(EState *estate, ...@@ -3412,7 +3412,8 @@ GetTupleForTrigger(EState *estate,
* We expect the tuple to be present, thus very simple error handling * We expect the tuple to be present, thus very simple error handling
* suffices. * suffices.
*/ */
if (!table_fetch_row_version(relation, tid, SnapshotAny, oldslot)) if (!table_tuple_fetch_row_version(relation, tid, SnapshotAny,
oldslot))
elog(ERROR, "failed to fetch tuple for trigger"); elog(ERROR, "failed to fetch tuple for trigger");
} }
...@@ -4270,7 +4271,9 @@ AfterTriggerExecute(EState *estate, ...@@ -4270,7 +4271,9 @@ AfterTriggerExecute(EState *estate,
{ {
LocTriggerData.tg_trigslot = ExecGetTriggerOldSlot(estate, relInfo); LocTriggerData.tg_trigslot = ExecGetTriggerOldSlot(estate, relInfo);
if (!table_fetch_row_version(rel, &(event->ate_ctid1), SnapshotAny, LocTriggerData.tg_trigslot)) if (!table_tuple_fetch_row_version(rel, &(event->ate_ctid1),
SnapshotAny,
LocTriggerData.tg_trigslot))
elog(ERROR, "failed to fetch tuple1 for AFTER trigger"); elog(ERROR, "failed to fetch tuple1 for AFTER trigger");
LocTriggerData.tg_trigtuple = LocTriggerData.tg_trigtuple =
ExecFetchSlotHeapTuple(LocTriggerData.tg_trigslot, false, &should_free_trig); ExecFetchSlotHeapTuple(LocTriggerData.tg_trigslot, false, &should_free_trig);
...@@ -4287,7 +4290,9 @@ AfterTriggerExecute(EState *estate, ...@@ -4287,7 +4290,9 @@ AfterTriggerExecute(EState *estate,
{ {
LocTriggerData.tg_newslot = ExecGetTriggerNewSlot(estate, relInfo); LocTriggerData.tg_newslot = ExecGetTriggerNewSlot(estate, relInfo);
if (!table_fetch_row_version(rel, &(event->ate_ctid2), SnapshotAny, LocTriggerData.tg_newslot)) if (!table_tuple_fetch_row_version(rel, &(event->ate_ctid2),
SnapshotAny,
LocTriggerData.tg_newslot))
elog(ERROR, "failed to fetch tuple2 for AFTER trigger"); elog(ERROR, "failed to fetch tuple2 for AFTER trigger");
LocTriggerData.tg_newtuple = LocTriggerData.tg_newtuple =
ExecFetchSlotHeapTuple(LocTriggerData.tg_newslot, false, &should_free_new); ExecFetchSlotHeapTuple(LocTriggerData.tg_newslot, false, &should_free_new);
......
...@@ -2436,7 +2436,7 @@ ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist) ...@@ -2436,7 +2436,7 @@ ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
* quals. For that result to be useful, typically the input tuple has to be * quals. For that result to be useful, typically the input tuple has to be
* last row version (otherwise the result isn't particularly useful) and * last row version (otherwise the result isn't particularly useful) and
* locked (otherwise the result might be out of date). That's typically * locked (otherwise the result might be out of date). That's typically
* achieved by using table_lock_tuple() with the * achieved by using table_tuple_lock() with the
* TUPLE_LOCK_FLAG_FIND_LAST_VERSION flag. * TUPLE_LOCK_FLAG_FIND_LAST_VERSION flag.
* *
* Returns a slot containing the new candidate update/delete tuple, or * Returns a slot containing the new candidate update/delete tuple, or
...@@ -2654,9 +2654,9 @@ EvalPlanQualFetchRowMarks(EPQState *epqstate) ...@@ -2654,9 +2654,9 @@ EvalPlanQualFetchRowMarks(EPQState *epqstate)
else else
{ {
/* ordinary table, fetch the tuple */ /* ordinary table, fetch the tuple */
if (!table_fetch_row_version(erm->relation, if (!table_tuple_fetch_row_version(erm->relation,
(ItemPointer) DatumGetPointer(datum), (ItemPointer) DatumGetPointer(datum),
SnapshotAny, slot)) SnapshotAny, slot))
elog(ERROR, "failed to fetch tuple for EvalPlanQual recheck"); elog(ERROR, "failed to fetch tuple for EvalPlanQual recheck");
} }
} }
......
...@@ -173,7 +173,7 @@ retry: ...@@ -173,7 +173,7 @@ retry:
PushActiveSnapshot(GetLatestSnapshot()); PushActiveSnapshot(GetLatestSnapshot());
res = table_lock_tuple(rel, &(outslot->tts_tid), GetLatestSnapshot(), res = table_tuple_lock(rel, &(outslot->tts_tid), GetLatestSnapshot(),
outslot, outslot,
GetCurrentCommandId(false), GetCurrentCommandId(false),
lockmode, lockmode,
...@@ -208,7 +208,7 @@ retry: ...@@ -208,7 +208,7 @@ retry:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break; break;
default: default:
elog(ERROR, "unexpected table_lock_tuple status: %u", res); elog(ERROR, "unexpected table_tuple_lock status: %u", res);
break; break;
} }
} }
...@@ -337,7 +337,7 @@ retry: ...@@ -337,7 +337,7 @@ retry:
PushActiveSnapshot(GetLatestSnapshot()); PushActiveSnapshot(GetLatestSnapshot());
res = table_lock_tuple(rel, &(outslot->tts_tid), GetLatestSnapshot(), res = table_tuple_lock(rel, &(outslot->tts_tid), GetLatestSnapshot(),
outslot, outslot,
GetCurrentCommandId(false), GetCurrentCommandId(false),
lockmode, lockmode,
...@@ -372,7 +372,7 @@ retry: ...@@ -372,7 +372,7 @@ retry:
elog(ERROR, "attempted to lock invisible tuple"); elog(ERROR, "attempted to lock invisible tuple");
break; break;
default: default:
elog(ERROR, "unexpected table_lock_tuple status: %u", res); elog(ERROR, "unexpected table_tuple_lock status: %u", res);
break; break;
} }
} }
...@@ -425,7 +425,7 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot) ...@@ -425,7 +425,7 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
ExecPartitionCheck(resultRelInfo, slot, estate, true); ExecPartitionCheck(resultRelInfo, slot, estate, true);
/* OK, store the tuple and create index entries for it */ /* OK, store the tuple and create index entries for it */
simple_table_insert(resultRelInfo->ri_RelationDesc, slot); simple_table_tuple_insert(resultRelInfo->ri_RelationDesc, slot);
if (resultRelInfo->ri_NumIndices > 0) if (resultRelInfo->ri_NumIndices > 0)
recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL, recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL,
...@@ -490,8 +490,8 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate, ...@@ -490,8 +490,8 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
if (resultRelInfo->ri_PartitionCheck) if (resultRelInfo->ri_PartitionCheck)
ExecPartitionCheck(resultRelInfo, slot, estate, true); ExecPartitionCheck(resultRelInfo, slot, estate, true);
simple_table_update(rel, tid, slot, estate->es_snapshot, simple_table_tuple_update(rel, tid, slot, estate->es_snapshot,
&update_indexes); &update_indexes);
if (resultRelInfo->ri_NumIndices > 0 && update_indexes) if (resultRelInfo->ri_NumIndices > 0 && update_indexes)
recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL, recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL,
...@@ -535,7 +535,7 @@ ExecSimpleRelationDelete(EState *estate, EPQState *epqstate, ...@@ -535,7 +535,7 @@ ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
if (!skip_tuple) if (!skip_tuple)
{ {
/* OK, delete the tuple */ /* OK, delete the tuple */
simple_table_delete(rel, tid, estate->es_snapshot); simple_table_tuple_delete(rel, tid, estate->es_snapshot);
/* AFTER ROW DELETE Triggers */ /* AFTER ROW DELETE Triggers */
ExecARDeleteTriggers(estate, resultRelInfo, ExecARDeleteTriggers(estate, resultRelInfo,
......
...@@ -185,7 +185,7 @@ lnext: ...@@ -185,7 +185,7 @@ lnext:
if (!IsolationUsesXactSnapshot()) if (!IsolationUsesXactSnapshot())
lockflags |= TUPLE_LOCK_FLAG_FIND_LAST_VERSION; lockflags |= TUPLE_LOCK_FLAG_FIND_LAST_VERSION;
test = table_lock_tuple(erm->relation, &tid, estate->es_snapshot, test = table_tuple_lock(erm->relation, &tid, estate->es_snapshot,
markSlot, estate->es_output_cid, markSlot, estate->es_output_cid,
lockmode, erm->waitPolicy, lockmode, erm->waitPolicy,
lockflags, lockflags,
...@@ -208,7 +208,7 @@ lnext: ...@@ -208,7 +208,7 @@ lnext:
* to fetch the updated tuple instead, but doing so would * to fetch the updated tuple instead, but doing so would
* require changing heap_update and heap_delete to not * require changing heap_update and heap_delete to not
* complain about updating "invisible" tuples, which seems * complain about updating "invisible" tuples, which seems
* pretty scary (table_lock_tuple will not complain, but few * pretty scary (table_tuple_lock will not complain, but few
* callers expect TM_Invisible, and we're not one of them). So * callers expect TM_Invisible, and we're not one of them). So
* for now, treat the tuple as deleted and do not process. * for now, treat the tuple as deleted and do not process.
*/ */
...@@ -229,7 +229,7 @@ lnext: ...@@ -229,7 +229,7 @@ lnext:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
errmsg("could not serialize access due to concurrent update"))); errmsg("could not serialize access due to concurrent update")));
elog(ERROR, "unexpected table_lock_tuple status: %u", elog(ERROR, "unexpected table_tuple_lock status: %u",
test); test);
break; break;
...@@ -246,7 +246,7 @@ lnext: ...@@ -246,7 +246,7 @@ lnext:
break; break;
default: default:
elog(ERROR, "unrecognized table_lock_tuple status: %u", elog(ERROR, "unrecognized table_tuple_lock status: %u",
test); test);
} }
......
...@@ -236,7 +236,7 @@ ExecCheckTIDVisible(EState *estate, ...@@ -236,7 +236,7 @@ ExecCheckTIDVisible(EState *estate,
if (!IsolationUsesXactSnapshot()) if (!IsolationUsesXactSnapshot())
return; return;
if (!table_fetch_row_version(rel, tid, SnapshotAny, tempSlot)) if (!table_tuple_fetch_row_version(rel, tid, SnapshotAny, tempSlot))
elog(ERROR, "failed to fetch conflicting tuple for ON CONFLICT"); elog(ERROR, "failed to fetch conflicting tuple for ON CONFLICT");
ExecCheckTupleVisible(estate, rel, tempSlot); ExecCheckTupleVisible(estate, rel, tempSlot);
ExecClearTuple(tempSlot); ExecClearTuple(tempSlot);
...@@ -544,11 +544,11 @@ ExecInsert(ModifyTableState *mtstate, ...@@ -544,11 +544,11 @@ ExecInsert(ModifyTableState *mtstate,
specToken = SpeculativeInsertionLockAcquire(GetCurrentTransactionId()); specToken = SpeculativeInsertionLockAcquire(GetCurrentTransactionId());
/* insert the tuple, with the speculative token */ /* insert the tuple, with the speculative token */
table_insert_speculative(resultRelationDesc, slot, table_tuple_insert_speculative(resultRelationDesc, slot,
estate->es_output_cid, estate->es_output_cid,
0, 0,
NULL, NULL,
specToken); specToken);
/* insert index entries for tuple */ /* insert index entries for tuple */
recheckIndexes = ExecInsertIndexTuples(slot, estate, true, recheckIndexes = ExecInsertIndexTuples(slot, estate, true,
...@@ -556,8 +556,8 @@ ExecInsert(ModifyTableState *mtstate, ...@@ -556,8 +556,8 @@ ExecInsert(ModifyTableState *mtstate,
arbiterIndexes); arbiterIndexes);
/* adjust the tuple's state accordingly */ /* adjust the tuple's state accordingly */
table_complete_speculative(resultRelationDesc, slot, table_tuple_complete_speculative(resultRelationDesc, slot,
specToken, !specConflict); specToken, !specConflict);
/* /*
* Wake up anyone waiting for our decision. They will re-check * Wake up anyone waiting for our decision. They will re-check
...@@ -584,9 +584,9 @@ ExecInsert(ModifyTableState *mtstate, ...@@ -584,9 +584,9 @@ ExecInsert(ModifyTableState *mtstate,
else else
{ {
/* insert the tuple normally */ /* insert the tuple normally */
table_insert(resultRelationDesc, slot, table_tuple_insert(resultRelationDesc, slot,
estate->es_output_cid, estate->es_output_cid,
0, NULL); 0, NULL);
/* insert index entries for tuple */ /* insert index entries for tuple */
if (resultRelInfo->ri_NumIndices > 0) if (resultRelInfo->ri_NumIndices > 0)
...@@ -766,13 +766,13 @@ ExecDelete(ModifyTableState *mtstate, ...@@ -766,13 +766,13 @@ ExecDelete(ModifyTableState *mtstate,
* mode transactions. * mode transactions.
*/ */
ldelete:; ldelete:;
result = table_delete(resultRelationDesc, tupleid, result = table_tuple_delete(resultRelationDesc, tupleid,
estate->es_output_cid, estate->es_output_cid,
estate->es_snapshot, estate->es_snapshot,
estate->es_crosscheck_snapshot, estate->es_crosscheck_snapshot,
true /* wait for commit */ , true /* wait for commit */ ,
&tmfd, &tmfd,
changingPart); changingPart);
switch (result) switch (result)
{ {
...@@ -832,7 +832,7 @@ ldelete:; ...@@ -832,7 +832,7 @@ ldelete:;
inputslot = EvalPlanQualSlot(epqstate, resultRelationDesc, inputslot = EvalPlanQualSlot(epqstate, resultRelationDesc,
resultRelInfo->ri_RangeTableIndex); resultRelInfo->ri_RangeTableIndex);
result = table_lock_tuple(resultRelationDesc, tupleid, result = table_tuple_lock(resultRelationDesc, tupleid,
estate->es_snapshot, estate->es_snapshot,
inputslot, estate->es_output_cid, inputslot, estate->es_output_cid,
LockTupleExclusive, LockWaitBlock, LockTupleExclusive, LockWaitBlock,
...@@ -875,7 +875,7 @@ ldelete:; ...@@ -875,7 +875,7 @@ ldelete:;
* out. * out.
* *
* See also TM_SelfModified response to * See also TM_SelfModified response to
* table_delete() above. * table_tuple_delete() above.
*/ */
if (tmfd.cmax != estate->es_output_cid) if (tmfd.cmax != estate->es_output_cid)
ereport(ERROR, ereport(ERROR,
...@@ -900,7 +900,7 @@ ldelete:; ...@@ -900,7 +900,7 @@ ldelete:;
* locking the latest version via * locking the latest version via
* TUPLE_LOCK_FLAG_FIND_LAST_VERSION. * TUPLE_LOCK_FLAG_FIND_LAST_VERSION.
*/ */
elog(ERROR, "unexpected table_lock_tuple status: %u", elog(ERROR, "unexpected table_tuple_lock status: %u",
result); result);
return NULL; return NULL;
} }
...@@ -918,7 +918,8 @@ ldelete:; ...@@ -918,7 +918,8 @@ ldelete:;
return NULL; return NULL;
default: default:
elog(ERROR, "unrecognized table_delete status: %u", result); elog(ERROR, "unrecognized table_tuple_delete status: %u",
result);
return NULL; return NULL;
} }
...@@ -990,8 +991,8 @@ ldelete:; ...@@ -990,8 +991,8 @@ ldelete:;
} }
else else
{ {
if (!table_fetch_row_version(resultRelationDesc, tupleid, if (!table_tuple_fetch_row_version(resultRelationDesc, tupleid,
SnapshotAny, slot)) SnapshotAny, slot))
elog(ERROR, "failed to fetch deleted tuple for DELETE RETURNING"); elog(ERROR, "failed to fetch deleted tuple for DELETE RETURNING");
} }
} }
...@@ -1134,7 +1135,7 @@ ExecUpdate(ModifyTableState *mtstate, ...@@ -1134,7 +1135,7 @@ ExecUpdate(ModifyTableState *mtstate,
* If we generate a new candidate tuple after EvalPlanQual testing, we * If we generate a new candidate tuple after EvalPlanQual testing, we
* must loop back here and recheck any RLS policies and constraints. * must loop back here and recheck any RLS policies and constraints.
* (We don't need to redo triggers, however. If there are any BEFORE * (We don't need to redo triggers, however. If there are any BEFORE
* triggers then trigger.c will have done table_lock_tuple to lock the * triggers then trigger.c will have done table_tuple_lock to lock the
* correct tuple, so there's no need to do them again.) * correct tuple, so there's no need to do them again.)
*/ */
lreplace:; lreplace:;
...@@ -1309,12 +1310,12 @@ lreplace:; ...@@ -1309,12 +1310,12 @@ lreplace:;
* needed for referential integrity updates in transaction-snapshot * needed for referential integrity updates in transaction-snapshot
* mode transactions. * mode transactions.
*/ */
result = table_update(resultRelationDesc, tupleid, slot, result = table_tuple_update(resultRelationDesc, tupleid, slot,
estate->es_output_cid, estate->es_output_cid,
estate->es_snapshot, estate->es_snapshot,
estate->es_crosscheck_snapshot, estate->es_crosscheck_snapshot,
true /* wait for commit */ , true /* wait for commit */ ,
&tmfd, &lockmode, &update_indexes); &tmfd, &lockmode, &update_indexes);
switch (result) switch (result)
{ {
...@@ -1373,7 +1374,7 @@ lreplace:; ...@@ -1373,7 +1374,7 @@ lreplace:;
inputslot = EvalPlanQualSlot(epqstate, resultRelationDesc, inputslot = EvalPlanQualSlot(epqstate, resultRelationDesc,
resultRelInfo->ri_RangeTableIndex); resultRelInfo->ri_RangeTableIndex);
result = table_lock_tuple(resultRelationDesc, tupleid, result = table_tuple_lock(resultRelationDesc, tupleid,
estate->es_snapshot, estate->es_snapshot,
inputslot, estate->es_output_cid, inputslot, estate->es_output_cid,
lockmode, LockWaitBlock, lockmode, LockWaitBlock,
...@@ -1412,7 +1413,7 @@ lreplace:; ...@@ -1412,7 +1413,7 @@ lreplace:;
* otherwise error out. * otherwise error out.
* *
* See also TM_SelfModified response to * See also TM_SelfModified response to
* table_update() above. * table_tuple_update() above.
*/ */
if (tmfd.cmax != estate->es_output_cid) if (tmfd.cmax != estate->es_output_cid)
ereport(ERROR, ereport(ERROR,
...@@ -1422,8 +1423,8 @@ lreplace:; ...@@ -1422,8 +1423,8 @@ lreplace:;
return NULL; return NULL;
default: default:
/* see table_lock_tuple call in ExecDelete() */ /* see table_tuple_lock call in ExecDelete() */
elog(ERROR, "unexpected table_lock_tuple status: %u", elog(ERROR, "unexpected table_tuple_lock status: %u",
result); result);
return NULL; return NULL;
} }
...@@ -1440,7 +1441,8 @@ lreplace:; ...@@ -1440,7 +1441,8 @@ lreplace:;
return NULL; return NULL;
default: default:
elog(ERROR, "unrecognized table_update status: %u", result); elog(ERROR, "unrecognized table_tuple_update status: %u",
result);
return NULL; return NULL;
} }
...@@ -1521,7 +1523,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, ...@@ -1521,7 +1523,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
* previous conclusion that the tuple is conclusively committed is not * previous conclusion that the tuple is conclusively committed is not
* true anymore. * true anymore.
*/ */
test = table_lock_tuple(relation, conflictTid, test = table_tuple_lock(relation, conflictTid,
estate->es_snapshot, estate->es_snapshot,
existing, estate->es_output_cid, existing, estate->es_output_cid,
lockmode, LockWaitBlock, 0, lockmode, LockWaitBlock, 0,
...@@ -1612,7 +1614,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, ...@@ -1612,7 +1614,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
return false; return false;
default: default:
elog(ERROR, "unrecognized table_lock_tuple status: %u", test); elog(ERROR, "unrecognized table_tuple_lock status: %u", test);
} }
/* Success, the tuple is locked. */ /* Success, the tuple is locked. */
...@@ -1677,7 +1679,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, ...@@ -1677,7 +1679,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
/* /*
* Note that it is possible that the target tuple has been modified in * Note that it is possible that the target tuple has been modified in
* this session, after the above table_lock_tuple. We choose to not error * this session, after the above table_tuple_lock. We choose to not error
* out in that case, in line with ExecUpdate's treatment of similar cases. * out in that case, in line with ExecUpdate's treatment of similar cases.
* This can happen if an UPDATE is triggered from within ExecQual(), * This can happen if an UPDATE is triggered from within ExecQual(),
* ExecWithCheckOptions() or ExecProject() above, e.g. by selecting from a * ExecWithCheckOptions() or ExecProject() above, e.g. by selecting from a
......
...@@ -381,9 +381,9 @@ TidNext(TidScanState *node) ...@@ -381,9 +381,9 @@ TidNext(TidScanState *node)
* current according to our snapshot. * current according to our snapshot.
*/ */
if (node->tss_isCurrentOf) if (node->tss_isCurrentOf)
table_get_latest_tid(scan, &tid); table_tuple_get_latest_tid(scan, &tid);
if (table_fetch_row_version(heapRelation, &tid, snapshot, slot)) if (table_tuple_fetch_row_version(heapRelation, &tid, snapshot, slot))
return slot; return slot;
/* Bad TID or failed snapshot qual; try next */ /* Bad TID or failed snapshot qual; try next */
......
...@@ -382,7 +382,7 @@ currtid_byreloid(PG_FUNCTION_ARGS) ...@@ -382,7 +382,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
snapshot = RegisterSnapshot(GetLatestSnapshot()); snapshot = RegisterSnapshot(GetLatestSnapshot());
scan = table_beginscan(rel, snapshot, 0, NULL); scan = table_beginscan(rel, snapshot, 0, NULL);
table_get_latest_tid(scan, result); table_tuple_get_latest_tid(scan, result);
table_endscan(scan); table_endscan(scan);
UnregisterSnapshot(snapshot); UnregisterSnapshot(snapshot);
...@@ -420,7 +420,7 @@ currtid_byrelname(PG_FUNCTION_ARGS) ...@@ -420,7 +420,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
snapshot = RegisterSnapshot(GetLatestSnapshot()); snapshot = RegisterSnapshot(GetLatestSnapshot());
scan = table_beginscan(rel, snapshot, 0, NULL); scan = table_beginscan(rel, snapshot, 0, NULL);
table_get_latest_tid(scan, result); table_tuple_get_latest_tid(scan, result);
table_endscan(scan); table_endscan(scan);
UnregisterSnapshot(snapshot); UnregisterSnapshot(snapshot);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment