[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-committers
Subject:    pgsql: Create an RTE field to record the query's lock mode for each rel
From:       Tom Lane <tgl () sss ! pgh ! pa ! us>
Date:       2018-09-30 17:55:57
Message-ID: E1g6fwj-0003Cs-F2 () gemulon ! postgresql ! org
[Download RAW message or body]

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(-)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic