]> granicus.if.org Git - postgresql/commit
Create an RTE field to record the query's lock mode for each relation.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Sep 2018 17:55:51 +0000 (13:55 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 30 Sep 2018 17:55:51 +0000 (13:55 -0400)
commitfdba460a26af919c0b366755d119f384706e670a
treed29dc7abd8af7d67e0920ad0ee19215568ac4312
parent8bddc864000f56d396621d4ad0f13e8e1872ddf5
Create an RTE field to record the query's lock mode for each relation.

Add RangeTblEntry.rellockmode, which records the appropriate lock mode for
each RTE_RELATION rangetable entry (either AccessShareLock, RowShareLock,
or RowExclusiveLock depending on the RTE's role in the query).

This patch creates the field and makes all creators of RTE nodes fill it
in reasonably, but for the moment nothing much is done with it.  The plan
is to replace assorted post-parser logic that re-determines the right
lockmode to use with simple uses of rte->rellockmode.  For now, just add
Asserts in each of those places that the rellockmode matches what they are
computing today.  (In some cases the match isn't perfect, so the Asserts
are weaker than you might expect; but this seems OK, as per discussion.)

This passes check-world for me, but it seems worth pushing in this state
to see if the buildfarm finds any problems in cases I failed to test.

catversion bump due to change of stored rules.

Amit Langote, reviewed by David Rowley and Jesper Pedersen,
and whacked around a bit more by me

Discussion: https://postgr.es/m/468c85d9-540e-66a2-1dde-fec2b741e688@lab.ntt.co.jp
29 files changed:
src/backend/catalog/dependency.c
src/backend/catalog/heap.c
src/backend/commands/copy.c
src/backend/commands/createas.c
src/backend/commands/policy.c
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/commands/view.c
src/backend/executor/execMain.c
src/backend/executor/execUtils.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/plan/planner.c
src/backend/parser/analyze.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_utilcmd.c
src/backend/replication/logical/tablesync.c
src/backend/replication/logical/worker.c
src/backend/rewrite/rewriteHandler.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/plancache.c
src/include/catalog/catversion.h
src/include/nodes/parsenodes.h
src/include/parser/parse_relation.h
src/test/modules/test_rls_hooks/test_rls_hooks.c