diff --git a/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp b/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp index a672b3ef9..0cce979ae 100755 --- a/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp @@ -585,7 +585,7 @@ void DefineQueryRewrite( heap_freetuple_ext(classTup); heap_close(relationRelation, RowExclusiveLock); -#ifdef PGXC +#ifdef ENABLE_MULTIPLE_NODES RemovePgxcClass(event_relid); (void)deleteDependencyRecordsFor(PgxcClassRelationId, event_relid, false); if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index 2eedf9d36..51026a421 100644 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -4242,10 +4242,10 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi } break; case T_RuleStmt: /* CREATE RULE */ -#ifdef PGXC +#ifdef ENABLE_MULTIPLE_NODES if (!IsInitdb && !u_sess->attr.attr_sql.enable_cluster_resize && !u_sess->exec_cxt.extension_is_valid) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("RULE is not yet supported."))); -#endif /* PGXC */ +#endif /* ENABLE_MULTIPLE_NODES */ DefineRule((RuleStmt*)parse_tree, query_string); #ifdef PGXC if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { @@ -8548,9 +8548,11 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string) case OBJECT_COLLATION: tag = "COLLATION"; break; +#ifdef ENABLE_MULTIPLE_NODES case OBJECT_RULE: tag = "RULE"; break; +#endif case OBJECT_TSDICTIONARY: case OBJECT_TSCONFIGURATION: ts_check_feature_disable(); @@ -8599,6 +8601,7 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string) */ bool CheckExtensionInWhiteList(const char* extension_name, uint32 hash_value, bool hash_check) { +#ifdef ENABLE_MULTIPLE_NODES /* 2902411162 hash for fastcheck, the sql file is much shorter than published version. */ uint32 postgisHashHistory[POSTGIS_VERSION_NUM] = {2902411162, 2959454932}; @@ -8620,7 +8623,7 @@ bool CheckExtensionInWhiteList(const char* extension_name, uint32 hash_value, bo return true; } } - +#endif return true; } diff --git a/src/test/regress/expected/alter_table_002.out b/src/test/regress/expected/alter_table_002.out index 30af2f841..c359cd6df 100644 --- a/src/test/regress/expected/alter_table_002.out +++ b/src/test/regress/expected/alter_table_002.out @@ -487,7 +487,6 @@ create view def_view_test as select * from def_test; create rule def_view_test_ins as on insert to def_view_test do instead insert into def_test select new.*; -ERROR: RULE is not yet supported. insert into def_view_test default values; ERROR: cannot insert into view "def_view_test" HINT: You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger. @@ -509,7 +508,6 @@ select * from def_view_test order by 1, 2; (4 rows) drop rule def_view_test_ins on def_view_test; -ERROR: rule "def_view_test_ins" for relation "def_view_test" does not exist drop view def_view_test; drop table def_test; -- alter table / drop column tests diff --git a/src/test/regress/expected/create_view3.out b/src/test/regress/expected/create_view3.out index bd70100ba..86c02146a 100644 --- a/src/test/regress/expected/create_view3.out +++ b/src/test/regress/expected/create_view3.out @@ -50,26 +50,18 @@ SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON ( (0 rows) CREATE RULE "_RETURN" AS ON SELECT TO RULE_TABLE_001 DO INSTEAD SELECT * FROM RULE_TABLE_001_01; -ERROR: RULE is not yet supported. RESET SEARCH_PATH; SELECT RELNAME,RELKIND FROM PG_CLASS WHERE RELNAME LIKE 'rule_table_001%' ORDER BY 1; relname | relkind -------------------+--------- - rule_table_001 | r + rule_table_001 | v rule_table_001_01 | r (2 rows) SELECT RELNAME, ATTNAME FROM PG_ATTRIBUTE A, PG_CLASS C WHERE C.OID = A.ATTRELID AND C.RELNAME LIKE 'rule_table_001%' ORDER BY 1, 2; relname | attname -------------------+------------ - rule_table_001 | cmax - rule_table_001 | cmin rule_table_001 | col_int - rule_table_001 | ctid - rule_table_001 | tableoid - rule_table_001 | xc_node_id - rule_table_001 | xmax - rule_table_001 | xmin rule_table_001_01 | cmax rule_table_001_01 | cmin rule_table_001_01 | col_int @@ -78,7 +70,7 @@ SELECT RELNAME, ATTNAME FROM PG_ATTRIBUTE A, PG_CLASS C WHERE C.OID = A.ATTRELID rule_table_001_01 | xc_node_id rule_table_001_01 | xmax rule_table_001_01 | xmin -(16 rows) +(9 rows) SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON (C.OID = X.PCRELID) WHERE PCRELID IN (SELECT OID FROM PG_CLASS WHERE RELNAME LIKE 'rule_table_001%') ORDER BY 1; relname | pclocatortype | pgroup @@ -86,6 +78,7 @@ SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON ( (0 rows) DROP TABLE DTS_STORAGE.RULE_TABLE_001_01 CASCADE; +NOTICE: drop cascades to view dts_storage.rule_table_001 SET SEARCH_PATH TO DTS_STORAGE; CREATE TABLE "RULE_TABLE_001"(COL_INT INTEGER); CREATE TABLE "RULE_TABLE_001_01"(COL_INT INTEGER); @@ -123,26 +116,18 @@ SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON ( (0 rows) CREATE RULE "_RETURN" AS ON SELECT TO "RULE_TABLE_001" DO INSTEAD SELECT * FROM "RULE_TABLE_001_01"; -ERROR: RULE is not yet supported. RESET SEARCH_PATH; SELECT RELNAME,RELKIND FROM PG_CLASS WHERE RELNAME LIKE 'RULE_TABLE_001%' ORDER BY 1; relname | relkind -------------------+--------- - RULE_TABLE_001 | r + RULE_TABLE_001 | v RULE_TABLE_001_01 | r (2 rows) SELECT RELNAME, ATTNAME FROM PG_ATTRIBUTE A, PG_CLASS C WHERE C.OID = A.ATTRELID AND C.RELNAME LIKE 'RULE_TABLE_001%' ORDER BY 1, 2; relname | attname -------------------+------------ - RULE_TABLE_001 | cmax - RULE_TABLE_001 | cmin RULE_TABLE_001 | col_int - RULE_TABLE_001 | ctid - RULE_TABLE_001 | tableoid - RULE_TABLE_001 | xc_node_id - RULE_TABLE_001 | xmax - RULE_TABLE_001 | xmin RULE_TABLE_001_01 | cmax RULE_TABLE_001_01 | cmin RULE_TABLE_001_01 | col_int @@ -151,7 +136,7 @@ SELECT RELNAME, ATTNAME FROM PG_ATTRIBUTE A, PG_CLASS C WHERE C.OID = A.ATTRELID RULE_TABLE_001_01 | xc_node_id RULE_TABLE_001_01 | xmax RULE_TABLE_001_01 | xmin -(16 rows) +(9 rows) SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON (C.OID = X.PCRELID) WHERE PCRELID IN (SELECT OID FROM PG_CLASS WHERE RELNAME LIKE 'RULE_TABLE_001%') ORDER BY 1; relname | pclocatortype | pgroup @@ -159,7 +144,6 @@ SELECT RELNAME, X.PCLOCATORTYPE, X.PGROUP FROM PGXC_CLASS X JOIN PG_CLASS C ON ( (0 rows) DROP SCHEMA DTS_STORAGE CASCADE; -NOTICE: drop cascades to 3 other objects -DETAIL: drop cascades to table dts_storage.rule_table_001 -drop cascades to table dts_storage."RULE_TABLE_001" -drop cascades to table dts_storage."RULE_TABLE_001_01" +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to table dts_storage."RULE_TABLE_001_01" +drop cascades to view dts_storage."RULE_TABLE_001" diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out index 012c26826..4e5bad098 100644 --- a/src/test/regress/expected/drop_if_exists.out +++ b/src/test/regress/expected/drop_if_exists.out @@ -197,9 +197,7 @@ ERROR: relation "no_such_table" does not exist CREATE RULE test_rule_exists AS ON INSERT TO test_exists DO INSTEAD INSERT INTO test_exists VALUES (NEW.a, NEW.b || NEW.a::text); -ERROR: RULE is not yet supported. DROP RULE test_rule_exists ON test_exists; -ERROR: rule "test_rule_exists" for relation "test_exists" does not exist -- foreign data wrapper DROP FOREIGN DATA WRAPPER test_fdw_exists; ERROR: foreign-data wrapper "test_fdw_exists" does not exist diff --git a/src/test/regress/expected/llt_atc.out b/src/test/regress/expected/llt_atc.out index f082ccc5a..40aafae4e 100644 --- a/src/test/regress/expected/llt_atc.out +++ b/src/test/regress/expected/llt_atc.out @@ -62,15 +62,15 @@ CREATE or replace RULE "_RETURN" AS ON SELECT TO llt_make_ruledef_t1 DO INSTEAD SELECT * FROM llt_make_ruledef_t2; -ERROR: RULE is not yet supported. select pg_get_ruledef(oid, true) from pg_rewrite where rulename='_RETURN' and ev_class in (select oid from pg_class where relname='llt_make_ruledef_t1'); pg_get_ruledef ----------------- -(0 rows) +-------------------------------------------------------------------------------- + CREATE RULE "_RETURN" AS + + ON SELECT TO llt_make_ruledef_t1 DO INSTEAD SELECT llt_make_ruledef_t2.q1+ + FROM llt_make_ruledef_t2; +(1 row) drop view llt_make_ruledef_t1; -ERROR: "llt_make_ruledef_t1" is not a view -HINT: Use DROP TABLE to remove a table. drop table llt_make_ruledef_t2; -- add test case for function byteane select 'a'::bytea <> 'b'::bytea; diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out index 0a3745376..6e251bdd7 100644 --- a/src/test/regress/expected/rangefuncs.out +++ b/src/test/regress/expected/rangefuncs.out @@ -786,7 +786,6 @@ select * from tt order by 1, 2; create table tt_log(f1 int, data text); create rule insert_tt_rule as on insert to tt do also insert into tt_log values(new.*); -ERROR: RULE is not yet supported. select insert_tt2('foollog','barlog') limit 1; NOTICE: noticetrigger foollog CONTEXT: SQL function "insert_tt2" statement 1 diff --git a/src/test/regress/expected/subselect_part1.out b/src/test/regress/expected/subselect_part1.out index aa416bc14..0b4413516 100644 --- a/src/test/regress/expected/subselect_part1.out +++ b/src/test/regress/expected/subselect_part1.out @@ -419,7 +419,6 @@ create view shipped_view as select * from shipped where ttype = 'wt'; create rule shipped_view_insert as on insert to shipped_view do instead insert into shipped values('wt', new.ordnum, new.partnum, new.value); -ERROR: RULE is not yet supported. insert into parts (partnum, cost) values (1, 1234.56); insert into shipped_view (ordnum, partnum, value) values (0, 1, (select cost from parts where partnum = '1')); @@ -433,7 +432,6 @@ select * from shipped_view; create rule shipped_view_update as on update to shipped_view do instead update shipped set partnum = new.partnum, value = new.value where ttype = new.ttype and ordnum = new.ordnum; -ERROR: RULE is not yet supported. update shipped_view set value = 11 from int4_tbl a join int4_tbl b on (a.f1 = (select f1 from int4_tbl c where c.f1=b.f1)) diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out index fdeebd711..03bc3bc1c 100644 --- a/src/test/regress/expected/with.out +++ b/src/test/regress/expected/with.out @@ -1012,7 +1012,7 @@ HINT: Cast the output of the non-recursive term to the correct type. CREATE TABLE x (n integer); CREATE RULE r2 AS ON UPDATE TO x DO INSTEAD WITH t AS (SELECT OLD.*) UPDATE y SET a = t.n FROM t; -ERROR: RULE is not yet supported. +ERROR: cannot refer to OLD within WITH query -- -- test for bug #4902 -- @@ -1457,7 +1457,6 @@ SELECT * FROM y order by 1; -- unconditional DO INSTEAD rule CREATE RULE y_rule AS ON DELETE TO y DO INSTEAD INSERT INTO y VALUES(42) RETURNING *; -ERROR: RULE is not yet supported. WITH t AS ( DELETE FROM y RETURNING * ) @@ -1486,7 +1485,6 @@ SELECT * FROM y order by 1; (0 rows) DROP RULE y_rule ON y; -ERROR: rule "y_rule" for relation "y" does not exist -- check merging of outer CTE with CTE in a rule action CREATE TABLE bug6051 AS select i from generate_series(1,3) as t(i); @@ -1512,7 +1510,6 @@ CREATE TABLE bug6051_2 (i int); CREATE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD INSERT INTO bug6051_2 SELECT NEW.i; -ERROR: RULE is not yet supported. WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) INSERT INTO bug6051 SELECT * FROM t1; SELECT * FROM bug6051 ORDER BY 1; @@ -1889,7 +1886,6 @@ LINE 2: WITH t AS (UPDATE y SET a=a+1 RETURNING *) ^ -- most variants of rules aren't allowed CREATE RULE y_rule AS ON INSERT TO y WHERE a=0 DO INSTEAD DELETE FROM y; -ERROR: RULE is not yet supported. WITH t AS ( INSERT INTO y VALUES(0) ) @@ -1900,7 +1896,6 @@ VALUES(FALSE); (1 row) DROP RULE y_rule ON y; -ERROR: rule "y_rule" for relation "y" does not exist -- check cte replace when pulling up -- case 1: exists/any sublink create table t_cte(a int, b int); diff --git a/src/test/regress/expected/xc_alter_table.out b/src/test/regress/expected/xc_alter_table.out index 2551bce0a..1f5f1e8ad 100644 --- a/src/test/regress/expected/xc_alter_table.out +++ b/src/test/regress/expected/xc_alter_table.out @@ -196,7 +196,6 @@ INSERT INTO xc_alter_table_3 VALUES (10, 'aaaaaaaaaa'); -- Create some objects to check the effect of redistribution CREATE VIEW xc_alter_table_3_v AS SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; CREATE RULE xc_alter_table_3_insert AS ON UPDATE TO xc_alter_table_3 WHERE OLD.a = 11 DO INSERT INTO xc_alter_table_3 VALUES (OLD.a + 1, 'nnn'); -ERROR: RULE is not yet supported. PREPARE xc_alter_table_insert AS INSERT INTO xc_alter_table_3 VALUES ($1, $2); PREPARE xc_alter_table_delete AS DELETE FROM xc_alter_table_3 WHERE a = $1; PREPARE xc_alter_table_update AS UPDATE xc_alter_table_3 SET b = $2 WHERE a = $1; @@ -417,6 +416,7 @@ SELECT * FROM xc_alter_table_3_v; -- Drop column on table ALTER TABLE xc_alter_table_3 DROP COLUMN b CASCADE; +NOTICE: drop cascades to rule xc_alter_table_3_insert on table xc_alter_table_3 SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; count | sum | avg -------+-----+-------------------- diff --git a/src/test/regress/expected/xc_returning_step1.out b/src/test/regress/expected/xc_returning_step1.out index b8f2b353b..7e54796b5 100644 --- a/src/test/regress/expected/xc_returning_step1.out +++ b/src/test/regress/expected/xc_returning_step1.out @@ -143,7 +143,6 @@ INSERT INTO foo (f2,f3) VALUES ('test', DEFAULT), ('More', 11), (upper('more'), create VIEW voo AS SELECT f1, f2 FROM foo; create OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD INSERT INTO foo VALUES(new.*, 57) RETURNING f1, f2; -ERROR: RULE is not yet supported. INSERT INTO voo VALUES(11,'zit'); ERROR: cannot insert into view "voo" HINT: You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger. @@ -385,7 +384,6 @@ truncate table fp; INSERT INTO foo (f2,f3) VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9); create VIEW voo AS SELECT f1, f3 FROM foo; create OR REPLACE RULE voo_u AS ON UPDATE TO voo DO INSTEAD UPDATE foo SET f3 = new.f3 WHERE f1 = old.f1 RETURNING f3, f1; -ERROR: RULE is not yet supported. update voo set f3 = f1 + 1; ERROR: cannot update view "voo" HINT: You need an unconditional ON UPDATE DO INSTEAD rule or an INSTEAD OF UPDATE trigger. @@ -591,7 +589,6 @@ truncate table fp; INSERT INTO foo (f2,f3) VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9); create VIEW voo AS SELECT f1, f2 FROM foo; create OR REPLACE RULE voo_d AS ON DELETE TO voo DO INSTEAD DELETE FROM foo WHERE f1 = old.f1 RETURNING f1, f2; -ERROR: RULE is not yet supported. DELETE FROM foo WHERE f1 = 1; DELETE FROM foo WHERE f1 < 2 RETURNING *, f3-f1; f1 | f2 | f3 | ?column?