8000 Move ModifyTableContext->lockmode to UpdateContext · postgres/postgres@a87e759 · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"commit":{"oid":"a87e75956926f966d90bdd1a6bd495cf59cdc3ad","url":"/postgres/postgres/commit/a87e75956926f966d90bdd1a6bd495cf59cdc3ad","authoredDate":"2022-04-20T11:18:04.000+02:00","committedDate":"2022-04-20T11:18:04.000+02:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eMove ModifyTableContext-\u0026gt;lockmode to UpdateContext\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"Should have been done this way to start with, but I failed to notice\nThis way we avoid some pointless initialization, and better contains the\nvariable to exist in the scope where it is really used.\n\nReviewed-by: Michaël Paquier \u0026lt;michael@paquier.xyz\u0026gt;\nDiscussion: \u003ca href=\"https://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql\" rel=\"nofollow\"\u003ehttps://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql\u003c/a\u003e","authors":[{"login":"alvherre","displayName":"Alvaro Herrera","avatarUrl":"https://avatars.githubusercontent.com/u/340005?v=4","path":"/alvherre","isGitHub":false}],"committerAttribution":false,"committer":{"login":"alvherre","displayName":"Alvaro Herrera","avatarUrl":"https://avatars.githubusercontent.com/u/340005?v=4","path":"/alvherre","isGitHub":false},"parents":["3dcc6bf4068a29be2bebee80bb919f8057af0fd9"],"globalRelayId":"C_kwDOAA4m0toAKGE4N2U3NTk1NjkyNmY5NjZkOTBiZGQxYTZiZDQ5NWNmNTljZGMzYWQ","sha1":"3dcc6bf4068a29be2bebee80bb919f8057af0fd9","sha2":"a87e75956926f966d90bdd1a6bd495cf59cdc3ad"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":115,"text":"@@ -116,12 +116,6 @@ typedef struct ModifyTableContext","html":"@@ -116,12 +116,6 @@ typedef struct ModifyTableContext","displayNoNewLineWarning":false,"position":0,"left":115,"right":115},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":116,"text":" \t * cross-partition UPDATE","html":" \u003cspan class=pl-c\u003e\t * cross-partition UPDATE\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":116,"right":116},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":117,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":2,"left":117,"right":117},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":118,"text":" \tTupleTableSlot *cpUpdateReturningSlot;","html":" \t\u003cspan class=pl-smi\u003eTupleTableSlot\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-c1\u003ecpUpdateReturningSlot\u003c/span\u003e;","displayNoNewLineWarning":false,"position":3,"left":118,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":119,"text":"-","html":"-","displayNoNewLineWarning":false,"position":4,"left":119,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":120,"text":"-\t/*","html":"-\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":120,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":121,"text":"-\t * Lock mode to acquire on the latest tuple version before performing","html":"-\u003cspan class=pl-c\u003e\t * Lock mode to acquire on the latest tuple version before performing\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":121,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":122,"text":"-\t * EvalPlanQual on it","html":"-\u003cspan class=pl-c\u003e\t * EvalPlanQual on it\u003c/span\u003e","displayNoNewLineWarning":false,"position":7,"left":122,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":123,"text":"-\t */","html":"-\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":8,"left":123,"right":118},{"stylingDirective":null,"type":"DELETION","blobLineNumber":124,"text":"-\tLockTupleMode lockmode;","html":"-\t\u003cspan class=pl-smi\u003eLockTupleMode\u003c/span\u003e \u003cspan class=pl-c1\u003elockmode\u003c/span\u003e;","displayNoNewLineWarning":false,"position":9,"left":124,"right":118},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":119,"text":" } ModifyTableContext;","html":" } \u003cspan class=pl-smi\u003eModifyTableContext\u003c/span\u003e;","displayNoNewLineWarning":false,"position":10,"left":125,"right":119},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":120,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":11,"left":126,"right":120},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":121,"text":" /*","html":" \u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":12,"left":127,"right":121},{"stylingDirective":null,"type":"HUNK","blobLineNumber":125,"text":"@@ -132,6 +126,12 @@ typedef struct UpdateContext","html":"@@ -132,6 +126,12 @@ typedef struct UpdateContext","displayNoNewLineWarning":false,"position":13,"left":131,"right":125},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":126,"text":" \tbool\t\tupdated;\t\t/* did UPDATE actually occur? */","html":" \t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-c1\u003eupdated\u003c/span\u003e;\t\t\u003cspan class=pl-c\u003e/* did UPDATE actually occur? */\u003c/span\u003e","displayNoNewLineWarning":false,"position":14,"left":132,"right":126},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":127,"text":" \tbool\t\tupdateIndexes;\t/* index update required? */","html":" \t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-c1\u003eupdateIndexes\u003c/span\u003e;\t\u003cspan class=pl-c\u003e/* index update required? */\u003c/span\u003e","displayNoNewLineWarning":false,"position":15,"left":133,"right":127},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":128,"text":" \tbool\t\tcrossPartUpdate;\t/* was it a cross-partition update? */","html":" \t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\t\u003cspan class=pl-c1\u003ecrossPartUpdate\u003c/span\u003e;\t\u003cspan class=pl-c\u003e/* was it a cross-partition update? */\u003c/span\u003e","displayNoNewLineWarning":false,"position":16,"left":134,"right":128},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":129,"text":"+","html":"+","displayNoNewLineWarning":false,"position":17,"left":134,"right":129},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":130,"text":"+\t/*","html":"+\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":18,"left":134,"right":130},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":131,"text":"+\t * Lock mode to acquire on the latest tuple version before performing","html":"+\u003cspan class=pl-c\u003e\t * Lock mode to acquire on the latest tuple version before performing\u003c/span\u003e","displayNoNewLineWarning":false,"position":19,"left":134,"right":131},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":132,"text":"+\t * EvalPlanQual on it","html":"+\u003cspan class=pl-c\u003e\t * EvalPlanQual on it\u003c/span\u003e","displayNoNewLineWarning":false,"position":20,"left":134,"right":132},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":133,"text":"+\t */","html":"+\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":21,"left":134,"right":133},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":134,"text":"+\tLockTupleMode lockmode;","html":"+\t\u003cspan class=pl-smi\u003eLockTupleMode\u003c/span\u003e \u003cspan class=pl-c1\u003elockmode\u003c/span\u003e;","displayNoNewLineWarning":false,"position":22,"left":134,"right":134},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":135,"text":" } UpdateContext;","html":" } \u003cspan class=pl-smi\u003eUpdateContext\u003c/span\u003e;","displayNoNewLineWarning":false,"position":23,"left":135,"right":135},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":136,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":24,"left":136,"right":136},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":137,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":25,"left":137,"right":137},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1970,"text":"@@ -1971,7 +1971,7 @@ lreplace:;","html":"@@ -1971,7 +1971,7 @@ lreplace:;","displayNoNewLineWarning":false,"position":26,"left":1970,"right":1970},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1971,"text":" \t\t\t\t\t\t\t\testate-\u003ees_snapshot,","html":" \t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003eestate\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ees_snapshot\u003c/span\u003e,","displayNoNewLineWarning":false,"position":27,"left":1971,"right":1971},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1972,"text":" \t\t\t\t\t\t\t\testate-\u003ees_crosscheck_snapshot,","html":" \t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003eestate\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ees_crosscheck_snapshot\u003c/span\u003e,","displayNoNewLineWarning":false,"position":28,"left":1972,"right":1972},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1973,"text":" \t\t\t\t\t\t\t\ttrue /* wait for commit */ ,","html":" \t\t\t\t\t\t\t\ttrue \u003cspan class=pl-c\u003e/* wait for commit */\u003c/span\u003e ,","displayNoNewLineWarning":false,"position":29,"left":1973,"right":1973},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1974,"text":"-\t\t\t\t\t\t\t\t\u0026context-\u003etmfd, \u0026context-\u003elockmode,","html":"-\t\t\t\t\t\t\t\t\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003econtext\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003etmfd\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1 x x-first x-last\"\u003econtext\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003elockmode\u003c/span\u003e,","displayNoNewLineWarning":false,"position":30,"left":1974,"right":1973},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1974,"text":"+\t\t\t\t\t\t\t\t\u0026context-\u003etmfd, \u0026updateCxt-\u003elockmode,","html":"+\t\t\t\t\t\t\t\t\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003econtext\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003etmfd\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1 x x-first x-last\"\u003eupdateCxt\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003elockmode\u003c/span\u003e,","displayNoNewLineWarning":false,"position":31,"left":1974,"right":1974},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1975,"text":" \t\t\t\t\t\t\t\t\u0026updateCxt-\u003eupdateIndexes);","html":" \t\t\t\t\t\t\t\t\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003eupdateCxt\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eupdateIndexes\u003c/span\u003e);","displayNoNewLineWarning":false,"position":32,"left":1975,"right":1975},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1976,"text":" \tif (result == TM_Ok)","html":" \t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003eresult\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-s1\u003eTM_Ok\u003c/span\u003e)","displayNoNewLineWarning":false,"position":33,"left":1976,"right":1976},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1977,"text":" \t\tupdateCxt-\u003eupdated = true;","html":" \t\t\u003cspan class=pl-s1\u003eupdateCxt\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eupdated\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e true;","displayNoNewLineWarning":false,"position":34,"left":1977,"right":1977},{"stylingDirective":null,"type":"HUNK","blobLineNumber":2250,"text":"@@ -2251,7 +2251,7 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,","html":"@@ -2251,7 +2251,7 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,","displayNoNewLineWarning":false,"position":35,"left":2250,"right":2250},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2251,"text":" \t\t\t\t\tresult = table_tuple_lock(resultRelationDesc, tupleid,","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003eresult\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003etable_tuple_lock\u003c/span\u003e(\u003cspan class=pl-s1\u003eresultRelationDesc\u003c/span\u003e, \u003cspan class=pl-s1\u003etupleid\u003c/span\u003e,","displayNoNewLineWarning":false,"position":36,"left":2251,"right":2251},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2252,"text":" \t\t\t\t\t\t\t\t\t\t\t estate-\u003ees_snapshot,","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-s1\u003eestate\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ees_snapshot\u003c/span\u003e,","displayNoNewLineWarning":false,"position":37,"left":2252,"right":2252},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2253,"text":" \t\t\t\t\t\t\t\t\t\t\t inputslot, estate-\u003ees_output_cid,","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-s1\u003einputslot\u003c/span\u003e, \u003cspan class=pl-s1\u003eestate\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ees_output_cid\u003c/span\u003e,","displayNoNewLineWarning":false,"position":38,"left":2253,"right":2253},{"stylingDirective":null,"type":"DELETION","blobLineNumber":2254,"text":"-\t\t\t\t\t\t\t\t\t\t\t context-\u003elockmode, LockWaitBlock,","html":"-\t\t\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first\"\u003econtext\u003c/span\u003e\u003cspan class=\"pl-c1 x x-last\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003elockmode\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eLockWaitBlock\u003c/span\u003e,","displayNoNewLineWarning":false,"position":39,"left":2254,"right":2253},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2254,"text":"+\t\t\t\t\t\t\t\t\t\t\t updateCxt.lockmode, LockWaitBlock,","html":"+\t\t\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first\"\u003eupdateCxt\u003c/span\u003e\u003cspan class=\"x x-last\"\u003e.\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003elockmode\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eLockWaitBlock\u003c/span\u003e,","displayNoNewLineWarning":false,"position":40,"left":2254,"right":2254},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2255,"text":" \t\t\t\t\t\t\t\t\t\t\t TUPLE_LOCK_FLAG_FIND_LAST_VERSION,","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003eTUPLE_LOCK_FLAG_FIND_LAST_VERSION\u003c/span\u003e,","displayNoNewLineWarning":false,"position":41,"left":2255,"right":2255},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2256,"text":" \t\t\t\t\t\t\t\t\t\t\t \u0026context-\u003etmfd);","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003econtext\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003etmfd\u003c/span\u003e);","displayNoNewLineWarning":false,"position":42,"left":2256,"right":2256},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2257,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":43,"left":2257,"right":2257},{"stylingDirective":null,"type":"HUNK","blobLineNumber":3556,"text":"@@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate)","html":"@@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate)","displayNoNewLineWarning":false,"position":44,"left":3556,"right":3556},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3557,"text":" \t\t\t\t{","html":" \t\t\t\t{","displayNoNewLineWarning":false,"position":45,"left":3557,"right":3557},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3558,"text":" \t\t\t\t\tEvalPlanQualSetSlot(\u0026node-\u003emt_epqstate, context.planSlot);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eEvalPlanQualSetSlot\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003emt_epqstate\u003c/span\u003e, \u003cspan class=pl-s1\u003econtext\u003c/span\u003e.\u003cspan class=pl-c1\u003eplanSlot\u003c/span\u003e);","displayNoNewLineWarning":false,"position":46,"left":3558,"right":3558},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3559,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":47,"left":3559,"right":3559},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3560,"text":"-\t\t\t\t\tcontext.lockmode = 0;","html":"-\t\t\t\t\t\u003cspan class=pl-s1\u003econtext\u003c/span\u003e.\u003cspan class=pl-c1\u003elockmode\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e;","displayNoNewLineWarning":false,"position":48,"left":3560,"right":3559},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3561,"text":"-","html":"-","displayNoNewLineWarning":false,"position":49,"left":3561,"right":3559},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3560,"text":" \t\t\t\t\tExecMerge(\u0026context, node-\u003eresultRelInfo, NULL, node-\u003ecanSetTag);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eExecMerge\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003econtext\u003c/span\u003e, \u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eresultRelInfo\u003c/span\u003e, \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e, \u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ecanSetTag\u003c/span\u003e);","displayNoNewLineWarning":false,"position":50,"left":3562,"right":3560},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3561,"text":" \t\t\t\t\tcontinue;\t/* no RETURNING support yet */","html":" \t\t\t\t\t\u003cspan class=pl-k\u003econtinue\u003c/span\u003e;\t\u003cspan class=pl-c\u003e/* no RETURNING support yet */\u003c/span\u003e","displayNoNewLineWarning":false,"position":51,"left":3563,"right":3561},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3562,"text":" \t\t\t\t}","html":" \t\t\t\t}","displayNoNewLineWarning":false,"position":52,"left":3564,"right":3562},{"stylingDirective":null,"type":"HUNK","blobLineNumber":3634,"text":"@@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate)","html":"@@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate)","displayNoNewLineWarning":false,"position":53,"left":3636,"right":3634},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3635,"text":" \t\t\t\t\t{","html":" \t\t\t\t\t{","displayNoNewLineWarning":false,"position":54,"left":3637,"right":3635},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3636,"text":" \t\t\t\t\t\tEvalPlanQualSetSlot(\u0026node-\u003emt_epqstate, context.planSlot);","html":" \t\t\t\t\t\t\u003cspan class=pl-en\u003eEvalPlanQualSetSlot\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003emt_epqstate\u003c/span\u003e, \u003cspan class=pl-s1\u003econtext\u003c/span\u003e.\u003cspan class=pl-c1\u003eplanSlot\u003c/span\u003e);","displayNoNewLineWarning":false,"position":55,"left":3638,"right":3636},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3637,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":56,"left":3639,"right":3637},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3640,"text":"-\t\t\t\t\t\tcontext.lockmode = 0;","html":"-\t\t\t\t\t\t\u003cspan class=pl-s1\u003econtext\u003c/span\u003e.\u003cspan class=pl-c1\u003elockmode\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e;","displayNoNewLineWarning":false,"position":57,"left":3640,"right":3637},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3641,"text":"-","html":"-","displayNoNewLineWarning":false,"position":58,"left":3641,"right":3637},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3638,"text":" \t\t\t\t\t\tExecMerge(\u0026context, node-\u003eresultRelInfo, NULL, node-\u003ecanSetTag);","html":" \t\t\t\t\t\t\u003cspan class=pl-en\u003eExecMerge\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003econtext\u003c/span\u003e, \u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eresultRelInfo\u003c/span\u003e, \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e, \u003cspan class=pl-s1\u003enode\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003ecanSetTag\u003c/span\u003e);","displayNoNewLineWarning":false,"position":59,"left":3642,"right":3638},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3639,"text":" \t\t\t\t\t\tcontinue;\t/* no RETURNING support yet */","html":" \t\t\t\t\t\t\u003cspan class=pl-k\u003econtinue\u003c/span\u003e;\t\u003cspan class=pl-c\u003e/* no RETURNING support yet */\u003c/span\u003e","displayNoNewLineWarning":false,"position":60,"left":3643,"right":3639},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3640,"text":" \t\t\t\t\t}","html":" \t\t\t\t\t}","displayNoNewLineWarning":false,"position":61,"left":3644,"right":3640},{"stylingDirective":null,"type":"HUNK","blobLineNumber":3689,"text":"@@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate)","html":"@@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate)","displayNoNewLineWarning":false,"position":62,"left":3693,"right":3689},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3690,"text":" \t\t\t}","html":" \t\t\t}","displayNoNewLineWarning":false,"position":63,"left":3694,"right":3690},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3691,"text":" \t\t}","html":" \t\t}","displayNoNewLineWarning":false,"position":64,"left":3695,"right":3691},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3692,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":65,"left":3696,"right":3692},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3697,"text":"-\t\t/* complete context setup */","html":"-\t\t\u003cspan class=pl-c\u003e/* complete context setup */\u003c/span\u003e","displayNoNewLineWarning":false,"position":66,"left":3697,"right":3692},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3698,"text":"-\t\tcontext.lockmode = 0;","html":"-\t\t\u003cspan class=pl-s1\u003econtext\u003c/span\u003e.\u003cspan class=pl-c1\u003elockmode\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e;","displayNoNewLineWarning":false,"position":67,"left":3698,"right":3692},{"stylingDirective":null,"type":"DELETION","blobLineNumber":3699,"text":"-","html":"-","displayNoNewLineWarning":false,"position":68,"left":3699,"right":3692},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3693,"text":" \t\tswitch (operation)","html":" \t\t\u003cspan class=pl-k\u003eswitch\u003c/span\u003e (\u003cspan class=pl-s1\u003eoperation\u003c/span\u003e)","displayNoNewLineWarning":false,"position":69,"left":3700,"right":3693},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3694,"text":" \t\t{","html":" \t\t{","displayNoNewLineWarning":false,"position":70,"left":3701,"right":3694},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":3695,"text":" \t\t\tcase CMD_INSERT:","html":" \t\t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eCMD_INSERT\u003c/span\u003e:","displayNoNewLineWarning":false,"position":71,"left":3702,"right":3695}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":4402,"linesChanged":23,"newTreeEntry":{"lineCount":4402,"path":"src/backend/executor/nodeModifyTable.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/executor/nodeModifyTable.c","mode":100644},"linesAdded":8,"linesDeleted":15,"path":"src/backend/executor/nodeModifyTable.c","pathDigest":"08af8c53c4fe685f813673454d48447222d490bccd75b0c88f2f6a9b83f66fab","status":"MODIFIED","truncatedReason":null,"oldOid":"3dcc6bf4068a29be2bebee80bb919f8057af0fd9","newOid":"a87e75956926f966d90bdd1a6bd495cf59cdc3ad","copilotChatReference":null,"deletedSha":"3dcc6bf4068a29be2bebee80bb919f8057af0fd9","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/a87e75956926f966d90bdd1a6bd495cf59cdc3ad","fileTreeExpanded":true,"headerInfo":{"additions":8,"deletions":15,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":2161,"lineShownCount":72},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"DVEtowmMk72ew5JLhqypg_YAQwCvIsD8e4TB1HY9A5IVYcNWWh_00kzKpnaZQnrkGsrhNyZoEnBgsRG_YsE04A"},"/users/diffview?diff=unified":{"post":"XK7uzOt3KN6UOlFrAmwUpAYbPnhi_1E-cbX_zH68xWVEngA5uORPsUYzZVYdgsfD6tGcT-u1g7JqgC-nakDyFw"},"/notifications/thread":{"post":"3RE3RCu81i1fldHAJDe7s-1a7WIdp85U_9AHKoiUIga1Srukmi9DPFXWD0zd17nNEC44Tbx8s0jRbc5-ORxzoA"}}},"title":"Move ModifyTableContext-\u003elockmode to UpdateContext · postgres/postgres@a87e759","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit a87e759

Browse files
committed
Move ModifyTableContext->lockmode to UpdateContext
Should have been done this way to start with, but I failed to notice This way we avoid some pointless initialization, and better contains the variable to exist in the scope where it is really used. Reviewed-by: Michaël Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql
1 parent 3dcc6bf commit a87e759

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ typedef struct ModifyTableContext
116116
* cross-partition UPDATE
117117
*/
118118
TupleTableSlot *cpUpdateReturningSlot;
119-
120-
/*
121-
* Lock mode to acquire on the latest tuple version before performing
122-
* EvalPlanQual on it
123-
*/
124-
LockTupleMode lockmode;
125119
} ModifyTableContext;
126120

127121
/*
@@ -132,6 +126,12 @@ typedef struct UpdateContext
132126
bool updated; /* did UPDATE actually occur? */
133127
bool updateIndexes; /* index update required? */
134128
bool crossPartUpdate; /* was it a cross-partition update? */
129+
130+
/*
131+
* Lock mode to acquire on the latest tuple version before performing
132+
* EvalPlanQual on it
133+
*/
134+
LockTupleMode lockmode;
135135
} UpdateContext;
136136

137137

@@ -1971,7 +1971,7 @@ lreplace:;
19711971
estate->es_snapshot,
19721972
estate->es_crosscheck_snapshot,
19731973
true /* wait for commit */ ,
1974-
&context->tmfd, &context->lockmode,
1974+
&context->tmfd, &updateCxt->lockmode,
19751975
&updateCxt->updateIndexes);
19761976
if (result == TM_Ok)
19771977
updateCxt->updated = true;
@@ -2251,7 +2251,7 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
22512251
result = table_tuple_lock(resultRelationDesc, tupleid,
22522252
estate->es_snapshot,
22532253
inputslot, estate->es_output_cid,
2254-
context->lockmode, LockWaitBlock,
2254+
updateCxt.lockmode, LockWaitBlock,
22552255
8000 TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
22562256
&context->tmfd);
22572257

@@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate)
35573557
{
35583558
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
35593559

3560-
context.lockmode = 0;
3561-
35623560
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
35633561
continue; /* no RETURNING support yet */
35643562
}
@@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate)
36373635
{
36383636
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
36393637

3640-
context.lockmode = 0;
3641-
36423638
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
36433639
continue; /* no RETURNING support yet */
36443640
}
@@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate)
36943690
}
36953691
}
36963692

3697-
/* complete context setup */
3698-
context.lockmode = 0;
3699-
37003693
switch (operation)
37013694
{
37023695
case CMD_INSERT:

0 commit comments

Comments
 (0)
0