add some conflicting cimv test

cimv
Sait Talha Nisanci 2021-01-10 20:04:33 +03:00
parent aa4c44b495
commit f622647037
3 changed files with 73 additions and 4 deletions

View File

@ -473,8 +473,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,
(RefreshMatViewStmt *) parsetree); (RefreshMatViewStmt *) parsetree);
} }
bool switchToExtensionOwner = false;
if (IsA(parsetree, DropStmt)) if (IsA(parsetree, DropStmt))
{ {
DropStmt *dropStatement = (DropStmt *) parsetree; DropStmt *dropStatement = (DropStmt *) parsetree;

View File

@ -780,7 +780,7 @@ ORDER BY a, d_hour;
(60 rows) (60 rows)
DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW mv;
NOTICE: drop cascades to trigger mv_INSERT on table events NOTICE: drop cascades to trigger mv_3_INSERT on table events
CREATE MATERIALIZED VIEW mv WITH (citus.cimv, citus.insertonlycapture) AS CREATE MATERIALIZED VIEW mv WITH (citus.cimv, citus.insertonlycapture) AS
SELECT a, SELECT a,
date_trunc('hour', d) AS d_hour, date_trunc('hour', d) AS d_hour,
@ -794,7 +794,7 @@ SELECT * FROM mv;
(0 rows) (0 rows)
DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW mv;
NOTICE: drop cascades to trigger mv_INSERT on table events NOTICE: drop cascades to trigger mv_4_INSERT on table events
SELECT create_distributed_table('events', 'a'); SELECT create_distributed_table('events', 'a');
NOTICE: Copying data from local table... NOTICE: Copying data from local table...
NOTICE: copying the data has completed NOTICE: copying the data has completed
@ -1676,6 +1676,51 @@ SELECT * FROM mv;
--------------------------------------------------------------------- ---------------------------------------------------------------------
(0 rows) (0 rows)
-- make sure same mv can be created in different schemas without overlap
CREATE SCHEMA another_schema;
SET search_path to another_schema;
SET citus.shard_count TO 4;
CREATE TABLE events (a int, b int, c double precision, d timestamp, e bigint);
CREATE MATERIALIZED VIEW mv WITH (citus.cimv) AS
SELECT a,
date_trunc('hour', d) AS d_hour,
min(b) AS min_b,
max(b) AS max_b,
avg(b) AS avg_b,
min(c) AS min_c,
max(c) AS max_c,
avg(c) AS avg_c,
min(e) AS min_e,
max(e) AS max_e,
avg(e) AS avg_e
FROM events
WHERE b > 10
GROUP BY a, d_hour;
DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW mv;
NOTICE: drop cascades to 4 other objects
-- test that another user can create CIMV as well
CREATE USER new_user;
NOTICE: not propagating CREATE ROLE/USER commands to worker nodes
CREATE SCHEMA another_schema2;
SET search_path to another_schema2;
CREATE TABLE events (a int, b int, c double precision, d timestamp, e bigint);
CREATE MATERIALIZED VIEW mv WITH (citus.cimv) AS
SELECT a,
date_trunc('hour', d) AS d_hour,
min(b) AS min_b,
max(b) AS max_b,
avg(b) AS avg_b,
min(c) AS min_c,
max(c) AS max_c,
avg(c) AS avg_c,
min(e) AS min_e,
max(e) AS max_e,
avg(e) AS avg_e
FROM events
WHERE b > 10
GROUP BY a, d_hour;
REFRESH MATERIALIZED VIEW mv;
DROP MATERIALIZED VIEW mv CASCADE;
NOTICE: drop cascades to 4 other objects
SET client_min_messages TO WARNING; -- suppress cascade messages SET client_min_messages TO WARNING; -- suppress cascade messages
DROP SCHEMA cimv CASCADE; DROP SCHEMA cimv CASCADE;

View File

@ -379,5 +379,31 @@ GROUP BY a, d_hour;
DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW mv;
-- test that another user can create CIMV as well
CREATE USER new_user;
CREATE SCHEMA another_schema2;
SET search_path to another_schema2;
CREATE TABLE events (a int, b int, c double precision, d timestamp, e bigint);
CREATE MATERIALIZED VIEW mv WITH (citus.cimv) AS
SELECT a,
date_trunc('hour', d) AS d_hour,
min(b) AS min_b,
max(b) AS max_b,
avg(b) AS avg_b,
min(c) AS min_c,
max(c) AS max_c,
avg(c) AS avg_c,
min(e) AS min_e,
max(e) AS max_e,
avg(e) AS avg_e
FROM events
WHERE b > 10
GROUP BY a, d_hour;
REFRESH MATERIALIZED VIEW mv;
DROP MATERIALIZED VIEW mv CASCADE;
SET client_min_messages TO WARNING; -- suppress cascade messages SET client_min_messages TO WARNING; -- suppress cascade messages
DROP SCHEMA cimv CASCADE; DROP SCHEMA cimv CASCADE;