Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5db6df0

Browse files
committed
tableam: Add tuple_{insert, delete, update, lock} and use.
This adds new, required, table AM callbacks for insert/delete/updateand lock_tuple. To be able to reasonably use those, the EvalPlanQualmechanism had to be adapted, moving more logic into the AM.Previously both delete/update/lock call-sites and the EPQ mechanism hadto have awareness of the specific tuple format to be able to fetch thelatest version of a tuple. Obviously that needs to be abstractedaway. To do so, move the logic that find the latest row version intothe AM. lock_tuple has a new flag argument,TUPLE_LOCK_FLAG_FIND_LAST_VERSION, that forces it to lock the lastversion, rather than the current one. It'd have been possible to doso via a separate callback as well, but finding the last versionusually also necessitates locking the newest version, making itsensible to combine the two. This replaces the previous use ofEvalPlanQualFetch(). Additionally HeapTupleUpdated, which previouslysignaled either a concurrent update or delete, is now split into two,to avoid callers needing AM specific knowledge to differentiate.The move of finding the latest row version into tuple_lock means thatencountering a row concurrently moved into another partition will nowraise an error about "tuple to be locked" rather than "tuple to beupdated/deleted" - which is accurate, as that always happens whenlocking rows. While possible slightly less helpful for users, it seemslike an acceptable trade-off.As part of this commit HTSU_Result has been renamed to TM_Result, andits members been expanded to differentiated between updating anddeleting. HeapUpdateFailureData has been renamed to TM_FailureData.The interface to speculative insertion is changed so nodeModifyTable.cdoes not have to set the speculative token itself anymore. Insteadthere's a version of tuple_insert, tuple_insert_speculative, thatperforms the speculative insertion (without requiring a flag to signalthat fact), and the speculative insertion is either made permanentwith table_complete_speculative(succeeded = true) or aborted withsucceeded = false).Note that multi_insert is not yet routed through tableam, nor isCOPY. Changing multi_insert requires changes to copy.c that are largeenough to better be done separately.Similarly, although simpler, CREATE TABLE AS and CREATE MATERIALIZEDVIEW are also only going to be adjusted in a later commit.Author: Andres Freund and Haribabu KommiDiscussion:https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.dehttps://postgr.es/m/20190313003903.nwvrxi7rw3ywhdel@alap3.anarazel.dehttps://postgr.es/m/20160812231527.GA690404@alvherre.pgsql
1 parentf778e53 commit5db6df0

File tree

21 files changed

+1527
-1063
lines changed

21 files changed

+1527
-1063
lines changed

‎contrib/pgrowlocks/pgrowlocks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
146146
/* scan the relation */
147147
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
148148
{
149-
HTSU_Resulthtsu;
149+
TM_Resulthtsu;
150150
TransactionIdxmax;
151151
uint16infomask;
152152

@@ -160,9 +160,9 @@ pgrowlocks(PG_FUNCTION_ARGS)
160160
infomask=tuple->t_data->t_infomask;
161161

162162
/*
163-
* A tuple is locked if HTSU returnsBeingUpdated.
163+
* A tuple is locked if HTSU returnsBeingModified.
164164
*/
165-
if (htsu==HeapTupleBeingUpdated)
165+
if (htsu==TM_BeingModified)
166166
{
167167
char**values;
168168

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp