Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
5ce8ab96
Commit
5ce8ab96
authored
24 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Add regress test case for INSERT ... SELECT in rules.
parent
a51f004d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/regress/expected/rules.out
+61
-0
61 additions, 0 deletions
src/test/regress/expected/rules.out
src/test/regress/sql/rules.sql
+38
-0
38 additions, 0 deletions
src/test/regress/sql/rules.sql
with
99 additions
and
0 deletions
src/test/regress/expected/rules.out
+
61
−
0
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;
...
...
This diff is collapsed.
Click to expand it.
src/test/regress/sql/rules.sql
+
38
−
0
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
--
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment