failover脑裂 && rule相关语法再合入
This commit is contained in:
16
doc/src/sgml/alter_rule.sgmlin
Normal file
16
doc/src/sgml/alter_rule.sgmlin
Normal file
@ -0,0 +1,16 @@
|
||||
<refentry id="SQL-ALTER_RULE">
|
||||
<refmeta>
|
||||
<refentrytitle>ALTER RULE</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>ALTER RULE</refname>
|
||||
<refpurpose>change the definition of a rule</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
ALTER RULE name ON table_name RENAME TO new_name
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
</refentry>
|
23
doc/src/sgml/create_rule.sgmlin
Normal file
23
doc/src/sgml/create_rule.sgmlin
Normal file
@ -0,0 +1,23 @@
|
||||
<refentry id="SQL-CREATE_RULE">
|
||||
<refmeta>
|
||||
<refentrytitle>ALTER TABLE</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>CREATE RULE</refname>
|
||||
<refpurpose>define a new rewrite rule</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
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
|
||||
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
</refentry>
|
16
doc/src/sgml/drop_rule.sgmlin
Normal file
16
doc/src/sgml/drop_rule.sgmlin
Normal file
@ -0,0 +1,16 @@
|
||||
<refentry id="SQL-DROP_RULE">
|
||||
<refmeta>
|
||||
<refentrytitle>ALTER TABLE</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>DROP RULE</refname>
|
||||
<refpurpose>remove a rewrite rule</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
</refentry>
|
@ -42,6 +42,7 @@ Complete list of usable sgml source files in this directory.
|
||||
<!ENTITY alterUser SYSTEM "alter_user.sgml">
|
||||
<!ENTITY alterUserMapping SYSTEM "alter_user_mapping.sgml">
|
||||
<!ENTITY alterView SYSTEM "alter_view.sgml">
|
||||
<!ENTITY alterRule SYSTEM "alter_rule.sgml">
|
||||
<!ENTITY analyze SYSTEM "analyze.sgml">
|
||||
<!ENTITY begin SYSTEM "begin.sgml">
|
||||
<!## XC>
|
||||
|
@ -45,10 +45,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
|
||||
|
@ -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
|
||||
|
@ -825,9 +825,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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -228,9 +228,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
|
||||
@ -261,9 +262,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
|
||||
@ -294,9 +296,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
|
||||
@ -327,9 +330,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
|
||||
@ -360,9 +364,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
|
||||
@ -395,9 +400,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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user