diff options
| author | Tom Lane | 2023-01-18 18:23:57 +0000 |
|---|---|---|
| committer | Tom Lane | 2023-01-18 18:23:57 +0000 |
| commit | 47bb9db75996232ea71fc1e1888ffb0e70579b54 (patch) | |
| tree | 745e1a7755802a7e92cd267bce642358a1f37a0a /src/bin | |
| parent | 8d83a5d0a2673174dc478e707de1f502935391a5 (diff) | |
Get rid of the "new" and "old" entries in a view's rangetable.
The rule system needs "old" and/or "new" pseudo-RTEs in rule actions
that are ON INSERT/UPDATE/DELETE. Historically it's put such entries
into the ON SELECT rules of views as well, but those are really quite
vestigial. The only thing we've used them for is to carry the
view's relid forward to AcquireExecutorLocks (so that we can
re-lock the view to verify it hasn't changed before re-using a plan)
and to carry its relid and permissions data forward to execution-time
permissions checks. What we can do instead of that is to retain
these fields of the RTE_RELATION RTE for the view even after we
convert it to an RTE_SUBQUERY RTE. This requires a tiny amount of
extra complication in the planner and AcquireExecutorLocks, but on
the other hand we can get rid of the logic that moves that data from
one place to another.
The principal immediate benefit of doing this, aside from a small
saving in the pg_rewrite data for views, is that these pseudo-RTEs
no longer trigger ruleutils.c's heuristic about qualifying variable
names when the rangetable's length is more than 1. That results
in quite a number of small simplifications in regression test outputs,
which are all to the good IMO.
Bump catversion because we need to dump a few more fields of
RTE_SUBQUERY RTEs. While those will always be zeroes anyway in
stored rules (because we'd never populate them until query rewrite)
they are useful for debugging, and it seems like we'd better make
sure to transmit such RTEs accurately in plans sent to parallel
workers. I don't think the executor actually examines these fields
after startup, but someday it might.
This is a second attempt at committing 1b4d280ea. The difference
from the first time is that now we can add some filtering rules to
AdjustUpgrade.pm to allow cross-version upgrade testing to pass
despite all the cosmetic changes in CREATE VIEW outputs.
Amit Langote (filtering rules by me)
Discussion: https://postgr.es/m/CA+HiwqEf7gPN4Hn+LoZ4tP2q_Qt7n3vw7-6fJKOf92tSEnX6Gg@mail.gmail.com
Discussion: https://postgr.es/m/891521.1673657296@sss.pgh.pa.us
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/pg_dump/t/002_pg_dump.pl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2eeef2a4783..d92247c915c 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2280,7 +2280,7 @@ my %tests = ( SELECT col1 FROM dump_test.test_table;', regexp => qr/^ \QCREATE MATERIALIZED VIEW dump_test.matview AS\E - \n\s+\QSELECT test_table.col1\E + \n\s+\QSELECT col1\E \n\s+\QFROM dump_test.test_table\E \n\s+\QWITH NO DATA;\E /xm, @@ -2296,7 +2296,7 @@ my %tests = ( SELECT * FROM dump_test.matview;', regexp => qr/^ \QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E - \n\s+\QSELECT matview.col1\E + \n\s+\QSELECT col1\E \n\s+\QFROM dump_test.matview\E \n\s+\QWITH NO DATA;\E /xm, @@ -2312,7 +2312,7 @@ my %tests = ( SELECT * FROM dump_test.matview_second WITH NO DATA;', regexp => qr/^ \QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E - \n\s+\QSELECT matview_second.col1\E + \n\s+\QSELECT col1\E \n\s+\QFROM dump_test.matview_second\E \n\s+\QWITH NO DATA;\E /xm, @@ -2328,7 +2328,7 @@ my %tests = ( SELECT * FROM dump_test.matview_third WITH NO DATA;', regexp => qr/^ \QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E - \n\s+\QSELECT matview_third.col1\E + \n\s+\QSELECT col1\E \n\s+\QFROM dump_test.matview_third\E \n\s+\QWITH NO DATA;\E /xm, @@ -2346,7 +2346,7 @@ my %tests = ( ALTER COLUMN col2 SET COMPRESSION lz4;', regexp => qr/^ \QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E - \n\s+\QSELECT test_table.col2\E + \n\s+\QSELECT col2\E \n\s+\QFROM dump_test.test_table\E \n\s+\QWITH NO DATA;\E .* @@ -3342,7 +3342,7 @@ my %tests = ( SELECT col1 FROM dump_test.test_table;', regexp => qr/^ \QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E - \n\s+\QSELECT test_table.col1\E + \n\s+\QSELECT col1\E \n\s+\QFROM dump_test.test_table\E \n\s+\QWITH LOCAL CHECK OPTION;\E/xm, like => |
