mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Fix subquery reference to non-populated MV in CMV.
A subquery reference to a matview should be allowed by CREATE MATERIALIZED VIEW WITH NO DATA, just like a direct reference is. Per bug report from Laurent Sartran. Backpatch to 9.3.
This commit is contained in:
parent
24ace4053d
commit
be420fa02e
@ -865,7 +865,8 @@ InitPlan(QueryDesc *queryDesc, int eflags)
|
|||||||
* it is a parameterless subplan (not initplan), we suggest that it be
|
* it is a parameterless subplan (not initplan), we suggest that it be
|
||||||
* prepared to handle REWIND efficiently; otherwise there is no need.
|
* prepared to handle REWIND efficiently; otherwise there is no need.
|
||||||
*/
|
*/
|
||||||
sp_eflags = eflags & EXEC_FLAG_EXPLAIN_ONLY;
|
sp_eflags = eflags
|
||||||
|
& (EXEC_FLAG_EXPLAIN_ONLY | EXEC_FLAG_WITH_NO_DATA);
|
||||||
if (bms_is_member(i, plannedstmt->rewindPlanIDs))
|
if (bms_is_member(i, plannedstmt->rewindPlanIDs))
|
||||||
sp_eflags |= EXEC_FLAG_REWIND;
|
sp_eflags |= EXEC_FLAG_REWIND;
|
||||||
|
|
||||||
|
@ -424,6 +424,12 @@ REFRESH MATERIALIZED VIEW mv;
|
|||||||
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
|
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
|
||||||
DROP TABLE foo CASCADE;
|
DROP TABLE foo CASCADE;
|
||||||
NOTICE: drop cascades to materialized view mv
|
NOTICE: drop cascades to materialized view mv
|
||||||
|
-- allow subquery to reference unpopulated matview if WITH NO DATA is specified
|
||||||
|
CREATE MATERIALIZED VIEW mv1 AS SELECT 1 AS col1 WITH NO DATA;
|
||||||
|
CREATE MATERIALIZED VIEW mv2 AS SELECT * FROM mv1
|
||||||
|
WHERE col1 = (SELECT LEAST(col1) FROM mv1) WITH NO DATA;
|
||||||
|
DROP MATERIALIZED VIEW mv1 CASCADE;
|
||||||
|
NOTICE: drop cascades to materialized view mv2
|
||||||
-- make sure that types with unusual equality tests work
|
-- make sure that types with unusual equality tests work
|
||||||
CREATE TABLE boxes (id serial primary key, b box);
|
CREATE TABLE boxes (id serial primary key, b box);
|
||||||
INSERT INTO boxes (b) VALUES
|
INSERT INTO boxes (b) VALUES
|
||||||
|
@ -155,6 +155,12 @@ REFRESH MATERIALIZED VIEW mv;
|
|||||||
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
|
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
|
||||||
DROP TABLE foo CASCADE;
|
DROP TABLE foo CASCADE;
|
||||||
|
|
||||||
|
-- allow subquery to reference unpopulated matview if WITH NO DATA is specified
|
||||||
|
CREATE MATERIALIZED VIEW mv1 AS SELECT 1 AS col1 WITH NO DATA;
|
||||||
|
CREATE MATERIALIZED VIEW mv2 AS SELECT * FROM mv1
|
||||||
|
WHERE col1 = (SELECT LEAST(col1) FROM mv1) WITH NO DATA;
|
||||||
|
DROP MATERIALIZED VIEW mv1 CASCADE;
|
||||||
|
|
||||||
-- make sure that types with unusual equality tests work
|
-- make sure that types with unusual equality tests work
|
||||||
CREATE TABLE boxes (id serial primary key, b box);
|
CREATE TABLE boxes (id serial primary key, b box);
|
||||||
INSERT INTO boxes (b) VALUES
|
INSERT INTO boxes (b) VALUES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user