mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Really fix the ambiguity in REFRESH MATERIALIZED VIEW CONCURRENTLY.
Rather than trying to pick table aliases that won't conflict with
any possible user-defined matview column name, adjust the queries'
syntax so that the aliases are only used in places where they can't be
mistaken for column names. Mostly this consists of writing "alias.*"
not just "alias", which adds clarity for humans as well as machines.
We do have the issue that "SELECT alias.*" acts differently from
"SELECT alias", but we can use the same hack ruleutils.c uses for
whole-row variables in SELECT lists: write "alias.*::compositetype".
We might as well revert to the original aliases after doing this;
they're a bit easier to read.
Like 75d66d10e
, back-patch to all supported branches.
Discussion: https://postgr.es/m/2488325.1628261320@sss.pgh.pa.us
This commit is contained in:
@@ -551,7 +551,15 @@ NOTICE: drop cascades to materialized view mvtest_mv_v
|
||||
-- make sure running as superuser works when MV owned by another role (bug #11208)
|
||||
CREATE ROLE regress_user_mvtest;
|
||||
SET ROLE regress_user_mvtest;
|
||||
CREATE TABLE mvtest_foo_data AS SELECT i, md5(random()::text)
|
||||
-- this test case also checks for ambiguity in the queries issued by
|
||||
-- refresh_by_match_merge(), by choosing column names that intentionally
|
||||
-- duplicate all the aliases used in those queries
|
||||
CREATE TABLE mvtest_foo_data AS SELECT i,
|
||||
i+1 AS tid,
|
||||
md5(random()::text) AS mv,
|
||||
md5(random()::text) AS newdata,
|
||||
md5(random()::text) AS newdata2,
|
||||
md5(random()::text) AS diff
|
||||
FROM generate_series(1, 10) i;
|
||||
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;
|
||||
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;
|
||||
|
@@ -211,7 +211,15 @@ DROP TABLE mvtest_v CASCADE;
|
||||
-- make sure running as superuser works when MV owned by another role (bug #11208)
|
||||
CREATE ROLE regress_user_mvtest;
|
||||
SET ROLE regress_user_mvtest;
|
||||
CREATE TABLE mvtest_foo_data AS SELECT i, md5(random()::text)
|
||||
-- this test case also checks for ambiguity in the queries issued by
|
||||
-- refresh_by_match_merge(), by choosing column names that intentionally
|
||||
-- duplicate all the aliases used in those queries
|
||||
CREATE TABLE mvtest_foo_data AS SELECT i,
|
||||
i+1 AS tid,
|
||||
md5(random()::text) AS mv,
|
||||
md5(random()::text) AS newdata,
|
||||
md5(random()::text) AS newdata2,
|
||||
md5(random()::text) AS diff
|
||||
FROM generate_series(1, 10) i;
|
||||
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;
|
||||
CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data;
|
||||
|
Reference in New Issue
Block a user