Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe420fa

Browse files
committed
Fix subquery reference to non-populated MV in CMV.
A subquery reference to a matview should be allowed by CREATEMATERIALIZED VIEW WITH NO DATA, just like a direct reference is.Per bug report from Laurent Sartran.Backpatch to 9.3.
1 parent24ace40 commitbe420fa

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ InitPlan(QueryDesc *queryDesc, int eflags)
865865
* it is a parameterless subplan (not initplan), we suggest that it be
866866
* prepared to handle REWIND efficiently; otherwise there is no need.
867867
*/
868-
sp_eflags=eflags&EXEC_FLAG_EXPLAIN_ONLY;
868+
sp_eflags=eflags
869+
& (EXEC_FLAG_EXPLAIN_ONLY |EXEC_FLAG_WITH_NO_DATA);
869870
if (bms_is_member(i,plannedstmt->rewindPlanIDs))
870871
sp_eflags |=EXEC_FLAG_REWIND;
871872

‎src/test/regress/expected/matview.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ REFRESH MATERIALIZED VIEW mv;
424424
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
425425
DROP TABLE foo CASCADE;
426426
NOTICE: drop cascades to materialized view mv
427+
-- allow subquery to reference unpopulated matview if WITH NO DATA is specified
428+
CREATE MATERIALIZED VIEW mv1 AS SELECT 1 AS col1 WITH NO DATA;
429+
CREATE MATERIALIZED VIEW mv2 AS SELECT * FROM mv1
430+
WHERE col1 = (SELECT LEAST(col1) FROM mv1) WITH NO DATA;
431+
DROP MATERIALIZED VIEW mv1 CASCADE;
432+
NOTICE: drop cascades to materialized view mv2
427433
-- make sure that types with unusual equality tests work
428434
CREATE TABLE boxes (id serial primary key, b box);
429435
INSERT INTO boxes (b) VALUES

‎src/test/regress/sql/matview.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ REFRESH MATERIALIZED VIEW mv;
155155
REFRESH MATERIALIZED VIEW CONCURRENTLY mv;
156156
DROPTABLE foo CASCADE;
157157

158+
-- allow subquery to reference unpopulated matview if WITH NO DATA is specified
159+
CREATE MATERIALIZED VIEW mv1ASSELECT1AS col1 WITH NO DATA;
160+
CREATE MATERIALIZED VIEW mv2ASSELECT*FROM mv1
161+
WHERE col1= (SELECT LEAST(col1)FROM mv1) WITH NO DATA;
162+
DROP MATERIALIZED VIEW mv1 CASCADE;
163+
158164
-- make sure that types with unusual equality tests work
159165
CREATETABLEboxes (idserialprimary key, bbox);
160166
INSERT INTO boxes (b)VALUES

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp