diff --git a/src/gausskernel/optimizer/commands/createas.cpp b/src/gausskernel/optimizer/commands/createas.cpp index 09bcbc52e..cef9eaf9e 100644 --- a/src/gausskernel/optimizer/commands/createas.cpp +++ b/src/gausskernel/optimizer/commands/createas.cpp @@ -327,7 +327,7 @@ static void intorel_startup(DestReceiver* self, int operation, TupleDesc typeinf create->inhRelations = NIL; create->ofTypename = NULL; create->constraints = NIL; - create->options = into->options; + create->options = (List*)copyObject(into->options); create->oncommit = into->onCommit; create->row_compress = into->row_compress; create->tablespacename = into->tableSpaceName; diff --git a/src/gausskernel/optimizer/commands/matview.cpp b/src/gausskernel/optimizer/commands/matview.cpp index 14918b55b..5859a3e30 100755 --- a/src/gausskernel/optimizer/commands/matview.cpp +++ b/src/gausskernel/optimizer/commands/matview.cpp @@ -67,8 +67,8 @@ typedef struct { Query* viewParse; /* the query which defines/populates data */ /* These fields are filled by intorel_startup: */ Relation rel; /* relation to write to */ - ObjectAddress reladdr; /* address of rel, for ExecCreateTableAs */ CommandId output_cid; /* cmin to insert in output tuples */ + ObjectAddress reladdr; /* address of rel, for ExecCreateTableAs */ int hi_options; /* heap_insert performance options */ BulkInsertState bistate; /* bulk insert state */ } DR_intorel; diff --git a/src/test/regress/expected/matview_with_event_trigger.out b/src/test/regress/expected/matview_with_event_trigger.out new file mode 100644 index 000000000..8279e35a8 --- /dev/null +++ b/src/test/regress/expected/matview_with_event_trigger.out @@ -0,0 +1,67 @@ +create database matview_with_event_trigger; +\c matview_with_event_trigger +create table testTab1 +( + menu_name text, + menu_id varchar2(100), + ISLEAF varchar(100), + LEVELS varchar(100), + function_url varchar2(500), + menu_parent varchar2(100), + menu_listorder clob, + menu_departmentid char(5), + menu_functionid numeric, + menu_disabled int, + primary key(menu_name,menu_parent) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "testtab1_pkey" for table "testtab1" +create table testTab2 ( + function_moduleid int, + function_id numeric, + function_interact varchar(100), + function_name varchar(100), + function_description varchar(100) +); +insert into testTab1 values('蔬菜','1','0','0','https://www.tapd.cn/60475194/sparrow/tcase/view/1160475194001155488?url_cache_key=from_urlaaaaa%23','6','ASD-20240112001','A1','3.14159',0); +insert into testTab1 values('土豆','2','1','1','https://www.tapd.cn/60475194/sparrow/tcase/view/11604755488?url_cache_key=from_urlaaaaa%23','6','ASD-20240112001','A1','3.1415926535',0); +insert into testTab1 values('动物','3','0','0','htt4788?url_cache_key=from_urlaaaaa%23%%','3','ASD-20240112002','A2','3.14159',0); +insert into testTab1 values('蜗牛','4','1','1','http://4788?url_cache_key=from_urlaaaaa%23%%','3','ASD-20240112002','A2','3.14159',0); +insert into testTab1 values('青菜','5','1','1','http://4788?url_cache_key=fr_%23%%---//###@!','1','ASD-20240112003','A2','3.1415926535',0); +create publication pub_test for all tables with (ddl='all'); +CREATE MATERIALIZED VIEW test_mv1 +( + NAME, + ROOT, + ISLEAF, + LEVELS, + PATH, + URL, + ID, + PID, + FUNCTION_MODULEID, + FUNCTION_ID, + LISTORDER, + DEPARTMENTID, + INTERACT, + MENU_DEPARTMENTID, + FUNCTION_NAME, + FUNCTION_DESCRIPTION +) with (STORAGE_TYPE=ustore, INIT_TD=40) +AS +SELECT menu_name AS name, null, null, null, null, function_url AS url +, menu_id AS id, menu_parent AS pid, f.function_moduleid, f.function_id, menu_listorder AS listorder +, m.menu_departmentid AS departmentid, f.function_interact AS interact, menu_departmentid, f.function_name, f.function_description +FROM testTab1 m +LEFT JOIN testTab2 f ON m.menu_functionid = f.function_id; +select * from test_mv1; + name | root | isleaf | levels | path | url | id | pid | function_moduleid | function_id | listorder | departmentid | interact | menu_departmentid | function_name | function_description +------+------+--------+--------+------+----------------------------------------------------------------------------------------------------+----+-----+-------------------+-------------+-----------------+--------------+----------+-------------------+---------------+---------------------- + 蜗牛 | | | | | http://4788?url_cache_key=from_urlaaaaa%23%% | 4 | 3 | | | ASD-20240112002 | A2 | | A2 | | + 动物 | | | | | htt4788?url_cache_key=from_urlaaaaa%23%% | 3 | 3 | | | ASD-20240112002 | A2 | | A2 | | + 蔬菜 | | | | | https://www.tapd.cn/60475194/sparrow/tcase/view/1160475194001155488?url_cache_key=from_urlaaaaa%23 | 1 | 6 | | | ASD-20240112001 | A1 | | A1 | | + 青菜 | | | | | http://4788?url_cache_key=fr_%23%%---//###@! | 5 | 1 | | | ASD-20240112003 | A2 | | A2 | | + 土豆 | | | | | https://www.tapd.cn/60475194/sparrow/tcase/view/11604755488?url_cache_key=from_urlaaaaa%23 | 2 | 6 | | | ASD-20240112001 | A1 | | A1 | | +(5 rows) + +\c regression +drop database matview_with_event_trigger; diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 3c3d14dfa..ccea135b1 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -728,7 +728,7 @@ test: string_digit_to_numeric tablesample_3 tablesample_4 # Another group of parallel tests # ---------- #test: collate tablesample tablesample_1 tablesample_2 matview -test: matview_single +test: matview_single matview_with_event_trigger # ---------- # Another group of parallel tests diff --git a/src/test/regress/parallel_schedule0B b/src/test/regress/parallel_schedule0B index 54763a70b..aa8de33f0 100644 --- a/src/test/regress/parallel_schedule0B +++ b/src/test/regress/parallel_schedule0B @@ -247,7 +247,7 @@ test: string_digit_to_numeric tablesample_3 tablesample_4 # Another group of parallel tests # ---------- #test: collate tablesample tablesample_1 tablesample_2 matview -test: matview_single +test: matview_single matview_with_event_trigger # ---------- # Another group of parallel tests diff --git a/src/test/regress/sql/matview_with_event_trigger.sql b/src/test/regress/sql/matview_with_event_trigger.sql new file mode 100644 index 000000000..3d7f85b96 --- /dev/null +++ b/src/test/regress/sql/matview_with_event_trigger.sql @@ -0,0 +1,65 @@ +create database matview_with_event_trigger; + +\c matview_with_event_trigger + +create table testTab1 +( + menu_name text, + menu_id varchar2(100), + ISLEAF varchar(100), + LEVELS varchar(100), + function_url varchar2(500), + menu_parent varchar2(100), + menu_listorder clob, + menu_departmentid char(5), + menu_functionid numeric, + menu_disabled int, + primary key(menu_name,menu_parent) +); + +create table testTab2 ( + function_moduleid int, + function_id numeric, + function_interact varchar(100), + function_name varchar(100), + function_description varchar(100) +); + +insert into testTab1 values('蔬菜','1','0','0','https://www.tapd.cn/60475194/sparrow/tcase/view/1160475194001155488?url_cache_key=from_urlaaaaa%23','6','ASD-20240112001','A1','3.14159',0); +insert into testTab1 values('土豆','2','1','1','https://www.tapd.cn/60475194/sparrow/tcase/view/11604755488?url_cache_key=from_urlaaaaa%23','6','ASD-20240112001','A1','3.1415926535',0); +insert into testTab1 values('动物','3','0','0','htt4788?url_cache_key=from_urlaaaaa%23%%','3','ASD-20240112002','A2','3.14159',0); +insert into testTab1 values('蜗牛','4','1','1','http://4788?url_cache_key=from_urlaaaaa%23%%','3','ASD-20240112002','A2','3.14159',0); +insert into testTab1 values('青菜','5','1','1','http://4788?url_cache_key=fr_%23%%---//###@!','1','ASD-20240112003','A2','3.1415926535',0); + +create publication pub_test for all tables with (ddl='all'); + +CREATE MATERIALIZED VIEW test_mv1 +( + NAME, + ROOT, + ISLEAF, + LEVELS, + PATH, + URL, + ID, + PID, + FUNCTION_MODULEID, + FUNCTION_ID, + LISTORDER, + DEPARTMENTID, + INTERACT, + MENU_DEPARTMENTID, + FUNCTION_NAME, + FUNCTION_DESCRIPTION +) with (STORAGE_TYPE=ustore, INIT_TD=40) +AS +SELECT menu_name AS name, null, null, null, null, function_url AS url +, menu_id AS id, menu_parent AS pid, f.function_moduleid, f.function_id, menu_listorder AS listorder +, m.menu_departmentid AS departmentid, f.function_interact AS interact, menu_departmentid, f.function_name, f.function_description +FROM testTab1 m +LEFT JOIN testTab2 f ON m.menu_functionid = f.function_id; + +select * from test_mv1; + +\c regression +drop database matview_with_event_trigger;