Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/backend/catalog/gp_matview_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "catalog/dependency.h"
#include "catalog/gp_matview_aux.h"
#include "catalog/gp_matview_tables.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_type.h"
#include "catalog/indexing.h"
#include "cdb/cdbvars.h"
Expand Down Expand Up @@ -91,6 +92,17 @@ GetViewBaseRelids(const Query *viewQuery)
if (get_rel_relkind(rte->relid) != RELKIND_RELATION)
return NIL;

/*
* inherit tables are not supported.
* FIXME: left a door for partition table which will be supported soon.
*/
bool can_be_partition = (get_rel_relkind(rte->relid) == RELKIND_PARTITIONED_TABLE) ||
get_rel_relispartition(rte->relid);

if (!can_be_partition &&
(has_superclass(rte->relid) || has_subclass(rte->relid)))
return NIL;

relids = list_make1_oid(rte->relid);

return relids;
Expand Down
23 changes: 23 additions & 0 deletions src/test/regress/expected/matview_data.out
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,29 @@ select datastatus from gp_matview_aux where mvname = 'mv2';
i
(1 row)

--
-- test issue https://github.com/cloudberrydb/cloudberrydb/issues/582
-- test inherits
--
begin;
create table tp_issue_582(i int, j int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Cloudberry Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
create table tc_issue_582(i int) inherits (tp_issue_582);
NOTICE: table has parent, setting distribution columns to match parent table
NOTICE: merging column "i" with inherited definition
insert into tp_issue_582 values(1, 1), (2, 2);
insert into tc_issue_582 values(1, 1);
create materialized view mv_tp_issue_582 as select * from tp_issue_582;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'i' as the Cloudberry Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-- should be null.
select mvname, datastatus from gp_matview_aux where mvname = 'mv_tp_issue_582';
mvname | datastatus
--------+------------
(0 rows)

abort;
-- test drop table
select mvname, datastatus from gp_matview_aux where mvname in ('mv0','mv1', 'mv2', 'mv3');
mvname | datastatus
Expand Down
14 changes: 14 additions & 0 deletions src/test/regress/sql/matview_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ COPY t2 from stdin;
\.
select datastatus from gp_matview_aux where mvname = 'mv2';

--
-- test issue https://github.com/cloudberrydb/cloudberrydb/issues/582
-- test inherits
--
begin;
create table tp_issue_582(i int, j int);
create table tc_issue_582(i int) inherits (tp_issue_582);
insert into tp_issue_582 values(1, 1), (2, 2);
insert into tc_issue_582 values(1, 1);
create materialized view mv_tp_issue_582 as select * from tp_issue_582;
-- should be null.
select mvname, datastatus from gp_matview_aux where mvname = 'mv_tp_issue_582';
abort;

-- test drop table
select mvname, datastatus from gp_matview_aux where mvname in ('mv0','mv1', 'mv2', 'mv3');
drop materialized view mv2;
Expand Down