diff --git a/doc/src/sgml/ref/allfiles.sgmlin b/doc/src/sgml/ref/allfiles.sgmlin index 1dd60c3da..1c6f59e1b 100644 --- a/doc/src/sgml/ref/allfiles.sgmlin +++ b/doc/src/sgml/ref/allfiles.sgmlin @@ -42,6 +42,7 @@ Complete list of usable sgml source files in this directory. + diff --git a/doc/src/sgml/ref/alter_rule.sgmlin b/doc/src/sgml/ref/alter_rule.sgmlin new file mode 100644 index 000000000..75fb7cac1 --- /dev/null +++ b/doc/src/sgml/ref/alter_rule.sgmlin @@ -0,0 +1,16 @@ + + +ALTER RULE +7 +SQL - Language Statements + + +ALTER RULE +change the definition of a rule + + + +ALTER RULE name ON table_name RENAME TO new_name + + + diff --git a/doc/src/sgml/ref/alter_table.sgmlin b/doc/src/sgml/ref/alter_table.sgmlin index 894c02f14..4aa4e330d 100755 --- a/doc/src/sgml/ref/alter_table.sgmlin +++ b/doc/src/sgml/ref/alter_table.sgmlin @@ -1,96 +1,101 @@ - - -ALTER TABLE -7 -SQL - Language Statements - - -ALTER TABLE -change the definition of a table - - - -ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} - action [, ... ]; -ALTER TABLE [ IF EXISTS ] table_name - ADD ( { column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ]} [, ...] ); -ALTER TABLE [ IF EXISTS ] table_name - MODIFY ( { column_name data_type | column_name [ CONSTRAINT constraint_name ] NOT NULL [ ENABLE ] | column_name [ CONSTRAINT constraint_name ] NULL } [, ...] ); -ALTER TABLE [ IF EXISTS ] table_name - RENAME TO new_table_name; -ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} - RENAME [ COLUMN ] column_name TO new_column_name; -ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} - RENAME CONSTRAINT constraint_name TO new_constraint_name; -ALTER TABLE [ IF EXISTS ] table_name - SET SCHEMA new_schema; - -where action can be: -column_clause - | ADD table_constraint [ NOT VALID ] - | ADD table_constraint_using_index - | VALIDATE CONSTRAINT constraint_name - | DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ] - | CLUSTER ON index_name - | SET WITHOUT CLUSTER - | SET ( {storage_parameter = value} [, ... ] ) - | RESET ( storage_parameter [, ... ] ) - | OWNER TO new_owner - | SET TABLESPACE new_tablespace - | SET {COMPRESS|NOCOMPRESS} - | TO { GROUP groupname | NODE ( nodename [, ... ] ) } - | ADD NODE ( nodename [, ... ] ) - | DELETE NODE ( nodename [, ... ] ) - | DISABLE TRIGGER [ trigger_name | ALL | USER ] - | ENABLE TRIGGER [ trigger_name | ALL | USER ] - | ENABLE REPLICA TRIGGER trigger_name - | ENABLE ALWAYS TRIGGER trigger_name - | ENABLE ROW LEVEL SECURITY - | DISABLE ROW LEVEL SECURITY - | FORCE ROW LEVEL SECURITY - | NO FORCE ROW LEVEL SECURITY -where column_clause can be: -ADD [ COLUMN ] column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ] - | MODIFY column_name data_type - | MODIFY column_name [ CONSTRAINT constraint_name ] NOT NULL [ ENABLE ] - | MODIFY column_name [ CONSTRAINT constraint_name ] NULL - | DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ] - | ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ] - | ALTER [ COLUMN ] column_name { SET DEFAULT expression | DROP DEFAULT } - | ALTER [ COLUMN ] column_name { SET | DROP } NOT NULL - | ALTER [ COLUMN ] column_name SET STATISTICS [PERCENT] integer - | ADD STATISTICS (( column_1_name, column_2_name [, ...] )) - | DELETE STATISTICS (( column_1_name, column_2_name [, ...] )) - | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] ) - | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] ) - | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } -where column_constraint can be: -[ CONSTRAINT constraint_name ] - { NOT NULL | - NULL | - CHECK ( expression ) | - DEFAULT default_expr | - UNIQUE index_parameters | - PRIMARY KEY index_parameters } - [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] -where compress_mode can be: -{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } -where table_constraint can be: -[ CONSTRAINT constraint_name ] - { CHECK ( expression ) | - UNIQUE ( column_name [, ... ] ) index_parameters | - PRIMARY KEY ( column_name [, ... ] ) index_parameters | - PARTIAL CLUSTER KEY ( column_name [, ... ] ) | - FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] - [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } - [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] -where index_parameters can be: -[ WITH ( {storage_parameter = value} [, ... ] ) ] - [ USING INDEX TABLESPACE tablespace_name ] -where table_constraint_using_index can be: -[ CONSTRAINT constraint_name ] - { UNIQUE | PRIMARY KEY } USING INDEX index_name - [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] - - - + + +ALTER TABLE +7 +SQL - Language Statements + + +ALTER TABLE +change the definition of a table + + + +ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} + action [, ... ]; +ALTER TABLE [ IF EXISTS ] table_name + ADD ( { column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ]} [, ...] ); +ALTER TABLE [ IF EXISTS ] table_name + MODIFY ( { column_name data_type | column_name [ CONSTRAINT constraint_name ] NOT NULL [ ENABLE ] | column_name [ CONSTRAINT constraint_name ] NULL } [, ...] ); +ALTER TABLE [ IF EXISTS ] table_name + RENAME TO new_table_name; +ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} + RENAME [ COLUMN ] column_name TO new_column_name; +ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )} + RENAME CONSTRAINT constraint_name TO new_constraint_name; +ALTER TABLE [ IF EXISTS ] table_name + SET SCHEMA new_schema; + +where action can be: +column_clause + | ADD table_constraint [ NOT VALID ] + | ADD table_constraint_using_index + | VALIDATE CONSTRAINT constraint_name + | DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ] + | CLUSTER ON index_name + | SET WITHOUT CLUSTER + | SET ( {storage_parameter = value} [, ... ] ) + | RESET ( storage_parameter [, ... ] ) + | OWNER TO new_owner + | SET TABLESPACE new_tablespace + | SET {COMPRESS|NOCOMPRESS} + | TO { GROUP groupname | NODE ( nodename [, ... ] ) } + | ADD NODE ( nodename [, ... ] ) + | DELETE NODE ( nodename [, ... ] ) + | DISABLE TRIGGER [ trigger_name | ALL | USER ] + | ENABLE TRIGGER [ trigger_name | ALL | USER ] + | ENABLE REPLICA TRIGGER trigger_name + | ENABLE ALWAYS TRIGGER trigger_name + | DISABLE RULE rewrite_rule_name + | ENABLE RULE rewrite_rule_name + | ENABLE REPLICA RULE rewrite_rule_name + | ENABLE ALWAYS RULE rewrite_rule_name + | ENABLE ROW LEVEL SECURITY + | DISABLE ROW LEVEL SECURITY + | FORCE ROW LEVEL SECURITY + | NO FORCE ROW LEVEL SECURITY + | REPLICA IDENTITY {DEFAULT | USING INDEX index_name | FULL | NOTHING} +where column_clause can be: +ADD [ COLUMN ] column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ] + | MODIFY column_name data_type + | MODIFY column_name [ CONSTRAINT constraint_name ] NOT NULL [ ENABLE ] + | MODIFY column_name [ CONSTRAINT constraint_name ] NULL + | DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ] + | ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ] + | ALTER [ COLUMN ] column_name { SET DEFAULT expression | DROP DEFAULT } + | ALTER [ COLUMN ] column_name { SET | DROP } NOT NULL + | ALTER [ COLUMN ] column_name SET STATISTICS [PERCENT] integer + | ADD STATISTICS (( column_1_name, column_2_name [, ...] )) + | DELETE STATISTICS (( column_1_name, column_2_name [, ...] )) + | ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] ) + | ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] ) + | ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } +where column_constraint can be: +[ CONSTRAINT constraint_name ] + { NOT NULL | + NULL | + CHECK ( expression ) | + DEFAULT default_expr | + UNIQUE index_parameters | + PRIMARY KEY index_parameters } + [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] +where compress_mode can be: +{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS } +where table_constraint can be: +[ CONSTRAINT constraint_name ] + { CHECK ( expression ) | + UNIQUE ( column_name [, ... ] ) index_parameters | + PRIMARY KEY ( column_name [, ... ] ) index_parameters | + PARTIAL CLUSTER KEY ( column_name [, ... ] ) | + FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] + [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } + [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] +where index_parameters can be: +[ WITH ( {storage_parameter = value} [, ... ] ) ] + [ USING INDEX TABLESPACE tablespace_name ] +where table_constraint_using_index can be: +[ CONSTRAINT constraint_name ] + { UNIQUE | PRIMARY KEY } USING INDEX index_name + [ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ] + + + diff --git a/doc/src/sgml/ref/create_rule.sgmlin b/doc/src/sgml/ref/create_rule.sgmlin new file mode 100644 index 000000000..21c432aed --- /dev/null +++ b/doc/src/sgml/ref/create_rule.sgmlin @@ -0,0 +1,23 @@ + + +ALTER TABLE +7 +SQL - Language Statements + + +CREATE RULE +define a new rewrite rule + + + +CREATE [ OR REPLACE ] RULE name AS ON event + TO table_name [ WHERE condition ] + DO [ ALSO | INSTEAD ] { NOTHING | command | ( command ; command ... ) } + +where event can be one of: + + SELECT | INSERT | UPDATE | DELETE + + + + diff --git a/doc/src/sgml/ref/drop_rule.sgmlin b/doc/src/sgml/ref/drop_rule.sgmlin new file mode 100644 index 000000000..8affa0fa8 --- /dev/null +++ b/doc/src/sgml/ref/drop_rule.sgmlin @@ -0,0 +1,16 @@ + + +ALTER TABLE +7 +SQL - Language Statements + + +DROP RULE +remove a rewrite rule + + + +DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ] + + + diff --git a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp index 8e49e3de3..4c13d99f5 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp @@ -2373,7 +2373,7 @@ static List* RewriteQuery(Query* parsetree, List* rewrite_events) #ifdef PGXC List* product_queries = NIL; - if (IS_PGXC_COORDINATOR) + if (IS_SINGLE_NODE || IS_PGXC_COORDINATOR) #else List* product_queries; #endif diff --git a/src/test/regress/expected/alter_table_000.out b/src/test/regress/expected/alter_table_000.out index 0d3d8f50e..e93e69fb1 100644 --- a/src/test/regress/expected/alter_table_000.out +++ b/src/test/regress/expected/alter_table_000.out @@ -41,10 +41,15 @@ column_clause | ENABLE TRIGGER [ trigger_name | ALL | USER ] | ENABLE REPLICA TRIGGER trigger_name | ENABLE ALWAYS TRIGGER trigger_name + | DISABLE RULE rewrite_rule_name + | ENABLE RULE rewrite_rule_name + | ENABLE REPLICA RULE rewrite_rule_name + | ENABLE ALWAYS RULE rewrite_rule_name | ENABLE ROW LEVEL SECURITY | DISABLE ROW LEVEL SECURITY | FORCE ROW LEVEL SECURITY | NO FORCE ROW LEVEL SECURITY + | REPLICA IDENTITY {DEFAULT | USING INDEX index_name | FULL | NOTHING} where column_clause can be: ADD [ COLUMN ] column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ] | MODIFY column_name data_type diff --git a/src/test/regress/expected/alter_table_002.out b/src/test/regress/expected/alter_table_002.out index c359cd6df..c4d3376be 100644 --- a/src/test/regress/expected/alter_table_002.out +++ b/src/test/regress/expected/alter_table_002.out @@ -488,24 +488,21 @@ create rule def_view_test_ins as on insert to def_view_test do instead insert into def_test select new.*; 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. alter table def_view_test alter column c1 set default 45; 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. alter table def_view_test alter column c2 set default 'view_default'; 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. select * from def_view_test order by 1, 2; c1 | c2 ----+----------------- 5 | initial_default 10 | new_default + 45 | view_default + 45 | | initial_default | -(4 rows) + | +(7 rows) drop rule def_view_test_ins on def_view_test; drop view def_view_test; diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out index e1f48146c..74fdda494 100644 --- a/src/test/regress/expected/rangefuncs.out +++ b/src/test/regress/expected/rangefuncs.out @@ -828,9 +828,11 @@ select * from tt order by 1, 2; -- note that nextval() gets executed a second time in the rule expansion, -- which is expected. select * from tt_log order by 1, 2; - f1 | data -----+------ -(0 rows) + f1 | data +----+--------- + | barlog + | foollog +(2 rows) -- test case for a whole-row-variable bug create function foo1(n integer, out a text, out b text) diff --git a/src/test/regress/expected/subselect_part1.out b/src/test/regress/expected/subselect_part1.out index 0b4413516..73aa9b88a 100644 --- a/src/test/regress/expected/subselect_part1.out +++ b/src/test/regress/expected/subselect_part1.out @@ -422,12 +422,11 @@ create rule shipped_view_insert as on insert to shipped_view do instead 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')); -ERROR: cannot insert into view "shipped_view" -HINT: You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger. select * from shipped_view; - ttype | ordnum | partnum | value --------+--------+---------+------- -(0 rows) + ttype | ordnum | partnum | value +-------+--------+---------+--------- + wt | 0 | 1 | 1234.56 +(1 row) create rule shipped_view_update as on update to shipped_view do instead update shipped set partnum = new.partnum, value = new.value @@ -436,12 +435,11 @@ 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)) where ordnum = a.f1; -ERROR: cannot update view "shipped_view" -HINT: You need an unconditional ON UPDATE DO INSTEAD rule or an INSTEAD OF UPDATE trigger. select * from shipped_view; ttype | ordnum | partnum | value -------+--------+---------+------- -(0 rows) + wt | 0 | 1 | 11 +(1 row) select f1, ss1 as relabel from (select *, (select sum(f1) from int4_tbl b where f1 >= a.f1) as ss1 diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out index 03bc3bc1c..1b5d75d46 100644 --- a/src/test/regress/expected/with.out +++ b/src/test/regress/expected/with.out @@ -1462,6 +1462,12 @@ WITH t AS ( ) SELECT * FROM t; a +---- + 42 +(1 row) + +SELECT * FROM y order by 1; + a ---- 0 1 @@ -1470,19 +1476,15 @@ SELECT * FROM t; 4 5 6 - 11 7 - 12 8 - 13 9 + 11 + 12 + 13 14 -(14 rows) - -SELECT * FROM y order by 1; - a ---- -(0 rows) + 42 +(15 rows) DROP RULE y_rule ON y; -- check merging of outer CTE with CTE in a rule action @@ -1514,18 +1516,21 @@ WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) INSERT INTO bug6051 SELECT * FROM t1; SELECT * FROM bug6051 ORDER BY 1; i +--- +(0 rows) + +SELECT * FROM bug6051_2 ORDER BY 1; + i --- 1 2 3 (3 rows) -SELECT * FROM bug6051_2 ORDER BY 1; - i ---- -(0 rows) - -- a truly recursive CTE in the same list +DROP TABLE y; +CREATE TABLE y (a INTEGER PRIMARY KEY INITIALLY DEFERRED); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "y_pkey" for table "y" WITH RECURSIVE t(a) AS ( SELECT 0 UNION ALL @@ -1890,11 +1895,7 @@ WITH t AS ( INSERT INTO y VALUES(0) ) VALUES(FALSE); - column1 ---------- - f -(1 row) - +ERROR: conditional DO INSTEAD rules are not supported for data-modifying statements in WITH DROP RULE y_rule ON y; -- check cte replace when pulling up -- case 1: exists/any sublink diff --git a/src/test/regress/expected/xc_alter_table.out b/src/test/regress/expected/xc_alter_table.out index 029e20130..3540e492e 100644 --- a/src/test/regress/expected/xc_alter_table.out +++ b/src/test/regress/expected/xc_alter_table.out @@ -230,9 +230,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; -- Check on tuple presence @@ -263,9 +264,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; -- Check on tuple presence @@ -296,9 +298,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; -- Check on tuple presence @@ -329,9 +332,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); SELECT count(*), sum(a), avg(a) FROM xc_alter_table_3; -- Check on tuple presence @@ -362,9 +366,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); -- Index and redistribution @@ -397,9 +402,10 @@ SELECT b FROM xc_alter_table_3 WHERE a = 11; EXECUTE xc_alter_table_delete(11); SELECT b FROM xc_alter_table_3 WHERE a = 11 or a = 12; - b ---- -(0 rows) + b +----- + nnn +(1 row) EXECUTE xc_alter_table_delete(12); -- Add column on table diff --git a/src/test/regress/expected/xc_returning_step1.out b/src/test/regress/expected/xc_returning_step1.out index c1cf2a7c3..d8d45f6a1 100644 --- a/src/test/regress/expected/xc_returning_step1.out +++ b/src/test/regress/expected/xc_returning_step1.out @@ -142,11 +142,12 @@ 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; 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. INSERT INTO voo VALUES(12,'zoo') RETURNING *, f1*2; -ERROR: cannot insert into view "voo" -HINT: You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger. + f1 | f2 | ?column? +----+-----+---------- + 12 | zoo | 24 +(1 row) + drop view voo; truncate table foo; alter sequence foo_f1_seq restart with 1; @@ -382,11 +383,12 @@ INSERT INTO foo (f2,f3) VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 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; 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. update voo set f3 = f1 + 1 where f1 < 2 RETURNING *; -ERROR: cannot update view "voo" -HINT: You need an unconditional ON UPDATE DO INSTEAD rule or an INSTEAD OF UPDATE trigger. + f1 | f3 +----+---- + 2 | 1 +(1 row) + drop view voo; truncate table foo; alter sequence foo_f1_seq restart with 1; diff --git a/src/test/regress/sql/with.sql b/src/test/regress/sql/with.sql index b7faa3eb4..1ef5517c5 100644 --- a/src/test/regress/sql/with.sql +++ b/src/test/regress/sql/with.sql @@ -748,6 +748,8 @@ SELECT * FROM bug6051 ORDER BY 1; SELECT * FROM bug6051_2 ORDER BY 1; -- a truly recursive CTE in the same list +DROP TABLE y; +CREATE TABLE y (a INTEGER PRIMARY KEY INITIALLY DEFERRED); WITH RECURSIVE t(a) AS ( SELECT 0 UNION ALL @@ -759,7 +761,6 @@ WITH RECURSIVE t(a) AS ( SELECT * FROM t2 JOIN y USING (a) ORDER BY a; SELECT * FROM y order by 1; - -- data-modifying WITH in a modifying statement WITH t AS ( DELETE FROM y