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
5ce8ab96
Commit
5ce8ab96
authored
Dec 05, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regress test case for INSERT ... SELECT in rules.
parent
a51f004d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
0 deletions
+99
-0
src/test/regress/expected/rules.out
src/test/regress/expected/rules.out
+61
-0
src/test/regress/sql/rules.sql
src/test/regress/sql/rules.sql
+38
-0
No files found.
src/test/regress/expected/rules.out
View file @
5ce8ab96
...
...
@@ -1200,6 +1200,67 @@ drop rule foorule;
drop table foo;
drop table foo2;
--
-- Test rules containing INSERT ... SELECT, which is a very ugly special
-- case as of 7.1. Example is based on bug report from Joel Burton.
--
create table pparent (pid int, txt text);
insert into pparent values (1,'parent1');
insert into pparent values (2,'parent2');
create table cchild (pid int, descrip text);
insert into cchild values (1,'descrip1');
create view vview as
select pparent.pid, txt, descrip from
pparent left join cchild using (pid);
create rule rrule as
on update to vview do instead
(
insert into cchild (pid, descrip)
select old.pid, new.descrip where old.descrip isnull;
update cchild set descrip = new.descrip where cchild.pid = old.pid;
);
select * from vview;
pid | txt | descrip
-----+---------+----------
1 | parent1 | descrip1
2 | parent2 |
(2 rows)
update vview set descrip='test1' where pid=1;
select * from vview;
pid | txt | descrip
-----+---------+---------
1 | parent1 | test1
2 | parent2 |
(2 rows)
update vview set descrip='test2' where pid=2;
select * from vview;
pid | txt | descrip
-----+---------+---------
1 | parent1 | test1
2 | parent2 | test2
(2 rows)
update vview set descrip='test3' where pid=3;
select * from vview;
pid | txt | descrip
-----+---------+---------
1 | parent1 | test1
2 | parent2 | test2
(2 rows)
select * from cchild;
pid | descrip
-----+---------
1 | test1
2 | test2
(2 rows)
drop rule rrule;
drop view vview;
drop table pparent;
drop table cchild;
--
-- Check that ruleutils are working
--
SELECT viewname, definition FROM pg_views ORDER BY viewname;
...
...
src/test/regress/sql/rules.sql
View file @
5ce8ab96
...
...
@@ -719,6 +719,44 @@ drop table foo;
drop
table
foo2
;
--
-- Test rules containing INSERT ... SELECT, which is a very ugly special
-- case as of 7.1. Example is based on bug report from Joel Burton.
--
create
table
pparent
(
pid
int
,
txt
text
);
insert
into
pparent
values
(
1
,
'parent1'
);
insert
into
pparent
values
(
2
,
'parent2'
);
create
table
cchild
(
pid
int
,
descrip
text
);
insert
into
cchild
values
(
1
,
'descrip1'
);
create
view
vview
as
select
pparent
.
pid
,
txt
,
descrip
from
pparent
left
join
cchild
using
(
pid
);
create
rule
rrule
as
on
update
to
vview
do
instead
(
insert
into
cchild
(
pid
,
descrip
)
select
old
.
pid
,
new
.
descrip
where
old
.
descrip
isnull
;
update
cchild
set
descrip
=
new
.
descrip
where
cchild
.
pid
=
old
.
pid
;
);
select
*
from
vview
;
update
vview
set
descrip
=
'test1'
where
pid
=
1
;
select
*
from
vview
;
update
vview
set
descrip
=
'test2'
where
pid
=
2
;
select
*
from
vview
;
update
vview
set
descrip
=
'test3'
where
pid
=
3
;
select
*
from
vview
;
select
*
from
cchild
;
drop
rule
rrule
;
drop
view
vview
;
drop
table
pparent
;
drop
table
cchild
;
--
-- Check that ruleutils are working
--
...
...
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