pgsql: Create an RTE field to record the query's lock mode for each rel

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Create an RTE field to record the query's lock mode for each rel
Date: 2018-09-30 17:55:57
Message-ID: E1g6fwj-0003Cs-F2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fdba460a26af919c0b366755d119f384706e670a

Modified Files
--------------
src/backend/catalog/dependency.c | 1 +
src/backend/catalog/heap.c | 1 +
src/backend/commands/copy.c | 9 +++---
src/backend/commands/createas.c | 1 +
src/backend/commands/policy.c | 23 +++++++++-----
src/backend/commands/tablecmds.c | 3 +-
src/backend/commands/trigger.c | 2 ++
src/backend/commands/view.c | 4 ++-
src/backend/executor/execMain.c | 11 +++++++
src/backend/executor/execUtils.c | 20 +++++++++---
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/equalfuncs.c | 1 +
src/backend/nodes/outfuncs.c | 1 +
src/backend/nodes/readfuncs.c | 1 +
src/backend/optimizer/plan/planner.c | 2 ++
src/backend/parser/analyze.c | 1 +
src/backend/parser/parse_clause.c | 1 +
src/backend/parser/parse_relation.c | 28 +++++++++++++++--
src/backend/parser/parse_utilcmd.c | 9 +++++-
src/backend/replication/logical/tablesync.c | 3 +-
src/backend/replication/logical/worker.c | 1 +
src/backend/rewrite/rewriteHandler.c | 39 ++++++++++++++++++------
src/backend/utils/adt/ri_triggers.c | 2 ++
src/backend/utils/adt/ruleutils.c | 3 ++
src/backend/utils/cache/plancache.c | 6 +++-
src/include/catalog/catversion.h | 2 +-
src/include/nodes/parsenodes.h | 12 ++++++++
src/include/parser/parse_relation.h | 1 +
src/test/modules/test_rls_hooks/test_rls_hooks.c | 8 ++---
29 files changed, 159 insertions(+), 38 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-09-30 20:25:22 pgsql: Fix detection of the result type of strerror_r().
Previous Message Stephen Frost 2018-09-28 23:05:50 pgsql: Add application_name to connection authorized msg