Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
943eae92
Commit
943eae92
authored
Mar 09, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ALSO keyword to CREATE RULE.
Fabien COELHO
parent
53cd7cd8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
21 deletions
+29
-21
doc/src/sgml/keywords.sgml
doc/src/sgml/keywords.sgml
+7
-1
doc/src/sgml/rules.sgml
doc/src/sgml/rules.sgml
+9
-9
src/backend/parser/gram.y
src/backend/parser/gram.y
+3
-2
src/backend/parser/keywords.c
src/backend/parser/keywords.c
+2
-1
src/test/regress/expected/rules.out
src/test/regress/expected/rules.out
+4
-4
src/test/regress/sql/rules.sql
src/test/regress/sql/rules.sql
+4
-4
No files found.
doc/src/sgml/keywords.sgml
View file @
943eae92
<!-- $PostgreSQL: pgsql/doc/src/sgml/keywords.sgml,v 2.1
2 2003/11/29 19:51:37 pgsql
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/keywords.sgml,v 2.1
3 2004/03/09 05:05:40 momjian
Exp $ -->
<appendix id="sql-keywords-appendix">
<title><acronym>SQL</acronym> Key Words</title>
...
...
@@ -170,6 +170,12 @@
<entry>reserved</entry>
<entry>reserved</entry>
</row>
<row>
<entry><token>ALSO</token></entry>
<entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><token>ALTER</token></entry>
<entry>non-reserved</entry>
...
...
doc/src/sgml/rules.sgml
View file @
943eae92
<!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.3
3 2003/12/13 23:59:06 neilc
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.3
4 2004/03/09 05:05:40 momjian
Exp $ -->
<Chapter Id="rules">
<Title>The Rule System</Title>
...
...
@@ -873,7 +873,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
<ListItem>
<Para>
They can be <literal>INSTEAD</> or
not
.
They can be <literal>INSTEAD</> or
<literal>ALSO</> (default)
.
</Para>
</ListItem>
...
...
@@ -904,7 +904,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
<ProgramListing>
CREATE RULE <replaceable>rule_name</> AS ON <replaceable>event</>
TO <replaceable>object</> [WHERE <replaceable>rule_qualification</>]
DO [INSTEAD] [<replaceable>action</> | (<replaceable>actions</>) | NOTHING];
DO [
ALSO|
INSTEAD] [<replaceable>action</> | (<replaceable>actions</>) | NOTHING];
</ProgramListing>
in mind.
...
...
@@ -920,7 +920,7 @@ CREATE RULE <replaceable>rule_name</> AS ON <replaceable>event</>
Initially the query-tree list is empty.
There can be zero (<literal>NOTHING</> key word), one, or multiple actions.
To simplify, we will look at a rule with one action. This rule
can have a qualification or not and it can be <literal>INSTEAD</> or
not
.
can have a qualification or not and it can be <literal>INSTEAD</> or
<literal>ALSO</> (default)
.
</Para>
<Para>
...
...
@@ -937,7 +937,7 @@ CREATE RULE <replaceable>rule_name</> AS ON <replaceable>event</>
<variablelist>
<varlistentry>
<term>No qualification and
not <literal>INSTEAD
</></term>
<term>No qualification and
<literal>ALSO
</></term>
<listitem>
<para>
the query tree from the rule action with the original query
...
...
@@ -957,7 +957,7 @@ CREATE RULE <replaceable>rule_name</> AS ON <replaceable>event</>
</varlistentry>
<varlistentry>
<term>Qualification given and
not <literal>INSTEAD
</></term>
<term>Qualification given and
<literal>ALSO
</></term>
<listitem>
<para>
the query tree from the rule action with the rule
...
...
@@ -980,7 +980,7 @@ CREATE RULE <replaceable>rule_name</> AS ON <replaceable>event</>
</varlistentry>
</variablelist>
Finally, if the rule is
not <literal>INSTEAD
</>, the unchanged original query tree is
Finally, if the rule is
<literal>ALSO
</>, the unchanged original query tree is
added to the list. Since only qualified <literal>INSTEAD</> rules already add the
original query tree, we end up with either one or two output query trees
for a rule with one action.
...
...
@@ -1111,7 +1111,7 @@ INSERT INTO shoelace_log VALUES (
</Para>
<Para>
The rule is a qualified
non-<literal>INSTEAD
</> rule, so the rule system
The rule is a qualified
<literal>ALSO
</> rule, so the rule system
has to return two query trees: the modified rule action and the original
query tree. In step 1, the range table of the original query is
incorporated into the rule's action query tree. This results in:
...
...
@@ -1190,7 +1190,7 @@ INSERT INTO shoelace_log VALUES (
</para>
<para>
That's it. Since the rule is
not <literal>INSTEAD
</>, we also output the
That's it. Since the rule is
<literal>ALSO
</>, we also output the
original query tree. In short, the output from the rule system
is a list of two query trees that correspond to these statements:
...
...
src/backend/parser/gram.y
View file @
943eae92
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.44
6 2004/01/11 04:58:17 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.44
7 2004/03/09 05:05:41 momjian
Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -332,7 +332,7 @@ static void doNegateFloat(Value *v);
/* ordinary key words in alphabetical order */
%token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
AGGREGATE ALL AL
SO AL
TER ANALYSE ANALYZE AND ANY ARRAY AS ASC
ASSERTION ASSIGNMENT AT AUTHORIZATION
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
...
...
@@ -3610,6 +3610,7 @@ event: SELECT { $$ = CMD_SELECT; }
opt_instead:
INSTEAD { $$ = TRUE; }
| ALSO { $$ = FALSE; }
| /*EMPTY*/ { $$ = FALSE; }
;
...
...
src/backend/parser/keywords.c
View file @
943eae92
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.14
5 2004/02/21 00:34:52 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.14
6 2004/03/09 05:05:41 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -38,6 +38,7 @@ static const ScanKeyword ScanKeywords[] = {
{
"after"
,
AFTER
},
{
"aggregate"
,
AGGREGATE
},
{
"all"
,
ALL
},
{
"also"
,
ALSO
},
{
"alter"
,
ALTER
},
{
"analyse"
,
ANALYSE
},
/* British spelling */
{
"analyze"
,
ANALYZE
},
...
...
src/test/regress/expected/rules.out
View file @
943eae92
...
...
@@ -34,19 +34,19 @@ create table rtest_system (sysname text, sysdesc text);
create table rtest_interface (sysname text, ifname text);
create table rtest_person (pname text, pdesc text);
create table rtest_admin (pname text, sysname text);
create rule rtest_sys_upd as on update to rtest_system do (
create rule rtest_sys_upd as on update to rtest_system do
also
(
update rtest_interface set sysname = new.sysname
where sysname = old.sysname;
update rtest_admin set sysname = new.sysname
where sysname = old.sysname
);
create rule rtest_sys_del as on delete to rtest_system do (
create rule rtest_sys_del as on delete to rtest_system do
also
(
delete from rtest_interface where sysname = old.sysname;
delete from rtest_admin where sysname = old.sysname;
);
create rule rtest_pers_upd as on update to rtest_person do
create rule rtest_pers_upd as on update to rtest_person do
also
update rtest_admin set pname = new.pname where pname = old.pname;
create rule rtest_pers_del as on delete to rtest_person do
create rule rtest_pers_del as on delete to rtest_person do
also
delete from rtest_admin where pname = old.pname;
--
-- Tables and rules for the logging test
...
...
src/test/regress/sql/rules.sql
View file @
943eae92
...
...
@@ -36,22 +36,22 @@ create table rtest_interface (sysname text, ifname text);
create
table
rtest_person
(
pname
text
,
pdesc
text
);
create
table
rtest_admin
(
pname
text
,
sysname
text
);
create
rule
rtest_sys_upd
as
on
update
to
rtest_system
do
(
create
rule
rtest_sys_upd
as
on
update
to
rtest_system
do
also
(
update
rtest_interface
set
sysname
=
new
.
sysname
where
sysname
=
old
.
sysname
;
update
rtest_admin
set
sysname
=
new
.
sysname
where
sysname
=
old
.
sysname
);
create
rule
rtest_sys_del
as
on
delete
to
rtest_system
do
(
create
rule
rtest_sys_del
as
on
delete
to
rtest_system
do
also
(
delete
from
rtest_interface
where
sysname
=
old
.
sysname
;
delete
from
rtest_admin
where
sysname
=
old
.
sysname
;
);
create
rule
rtest_pers_upd
as
on
update
to
rtest_person
do
create
rule
rtest_pers_upd
as
on
update
to
rtest_person
do
also
update
rtest_admin
set
pname
=
new
.
pname
where
pname
=
old
.
pname
;
create
rule
rtest_pers_del
as
on
delete
to
rtest_person
do
create
rule
rtest_pers_del
as
on
delete
to
rtest_person
do
also
delete
from
rtest_admin
where
pname
=
old
.
pname
;
--
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment