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
c13454ed
Commit
c13454ed
authored
Sep 24, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Timetravel tests.
parent
76271543
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
3 deletions
+209
-3
src/test/regress/expected/triggers.out
src/test/regress/expected/triggers.out
+119
-0
src/test/regress/input/create_function_1.source
src/test/regress/input/create_function_1.source
+12
-0
src/test/regress/output/create_function_1.source
src/test/regress/output/create_function_1.source
+13
-3
src/test/regress/sql/triggers.sql
src/test/regress/sql/triggers.sql
+65
-0
No files found.
src/test/regress/expected/triggers.out
View file @
c13454ed
...
...
@@ -159,3 +159,122 @@ count
(1 row)
QUERY: DROP TABLE dup17;
QUERY: create sequence ttdummy_seq increment 10 start 0 minvalue 0;
QUERY: create table tttest (
price_id int4,
price_val int4,
price_on int4 default nextval('ttdummy_seq'),
price_off int4 default 999999
);
QUERY: insert into tttest values (1, 1, null, null);
QUERY: insert into tttest values (2, 2, null, null);
QUERY: insert into tttest values (3, 3, null, null);
QUERY: create trigger ttdummy
before delete or update on tttest
for each row
execute procedure
ttdummy (price_on, price_off);
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
2| 2| 10| 999999
3| 3| 20| 999999
(3 rows)
QUERY: delete from tttest where price_id = 2;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
3| 3| 20| 999999
2| 2| 10| 30
(3 rows)
QUERY: select * from tttest where price_off = 999999;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
3| 3| 20| 999999
(2 rows)
QUERY: update tttest set price_val = 30 where price_id = 3;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
2| 2| 10| 30
3| 30| 40| 999999
3| 3| 20| 40
(4 rows)
QUERY: update tttest set price_id = 5 where price_id = 3;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
2| 2| 10| 30
3| 3| 20| 40
5| 30| 50| 999999
3| 30| 40| 50
(5 rows)
QUERY: select set_ttdummy(0);
set_ttdummy
-----------
1
(1 row)
QUERY: delete from tttest where price_id = 5;
QUERY: update tttest set price_off = 999999 where price_val = 30;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
2| 2| 10| 30
3| 3| 20| 40
3| 30| 40| 999999
(4 rows)
QUERY: update tttest set price_id = 5 where price_id = 3;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
1| 1| 0| 999999
2| 2| 10| 30
5| 3| 20| 40
5| 30| 40| 999999
(4 rows)
QUERY: select set_ttdummy(1);
set_ttdummy
-----------
0
(1 row)
QUERY: update tttest set price_on = -1 where price_id = 1;
WARN:ttdummy (tttest): you can't change price_on and/or price_off columns (use set_ttdummy)
QUERY: select set_ttdummy(0);
set_ttdummy
-----------
1
(1 row)
QUERY: update tttest set price_on = -1 where price_id = 1;
QUERY: select * from tttest;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
2| 2| 10| 30
5| 3| 20| 40
5| 30| 40| 999999
1| 1| -1| 999999
(4 rows)
QUERY: select * from tttest where price_on <= 25 and price_off > 25 and price_id = 5;
price_id|price_val|price_on|price_off
--------+---------+--------+---------
5| 3| 20| 40
(1 row)
QUERY: drop table tttest;
QUERY: drop sequence ttdummy_seq;
src/test/regress/input/create_function_1.source
View file @
c13454ed
...
...
@@ -30,3 +30,15 @@ CREATE FUNCTION funny_dup17 ()
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
CREATE FUNCTION ttdummy ()
RETURNS opaque
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
CREATE FUNCTION set_ttdummy (int4)
RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
src/test/regress/output/create_function_1.source
View file @
c13454ed
...
...
@@ -9,16 +9,26 @@ QUERY: CREATE FUNCTION widget_out(opaque)
LANGUAGE 'c';
QUERY: CREATE FUNCTION check_primary_key ()
RETURNS opaque
AS '_OBJWD_/../../../contrib/spi/refint
.so
'
AS '_OBJWD_/../../../contrib/spi/refint
_DLSUFFIX_
'
LANGUAGE 'c'
;
QUERY: CREATE FUNCTION check_foreign_key ()
RETURNS opaque
AS '_OBJWD_/../../../contrib/spi/refint
.so
'
AS '_OBJWD_/../../../contrib/spi/refint
_DLSUFFIX_
'
LANGUAGE 'c'
;
QUERY: CREATE FUNCTION funny_dup17 ()
RETURNS opaque
AS '_OBJWD_/regress.so'
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
QUERY: CREATE FUNCTION ttdummy ()
RETURNS opaque
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
QUERY: CREATE FUNCTION set_ttdummy (int4)
RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'
;
src/test/regress/sql/triggers.sql
View file @
c13454ed
...
...
@@ -116,3 +116,68 @@ insert into dup17 values (13);
select
count
(
*
)
from
dup17
where
x
=
13
;
DROP
TABLE
dup17
;
create
sequence
ttdummy_seq
increment
10
start
0
minvalue
0
;
create
table
tttest
(
price_id
int4
,
price_val
int4
,
price_on
int4
default
nextval
(
'ttdummy_seq'
),
price_off
int4
default
999999
);
insert
into
tttest
values
(
1
,
1
,
null
,
null
);
insert
into
tttest
values
(
2
,
2
,
null
,
null
);
insert
into
tttest
values
(
3
,
3
,
null
,
null
);
create
trigger
ttdummy
before
delete
or
update
on
tttest
for
each
row
execute
procedure
ttdummy
(
price_on
,
price_off
);
select
*
from
tttest
;
delete
from
tttest
where
price_id
=
2
;
select
*
from
tttest
;
-- what do we see ?
-- get current prices
select
*
from
tttest
where
price_off
=
999999
;
-- change price for price_id == 3
update
tttest
set
price_val
=
30
where
price_id
=
3
;
select
*
from
tttest
;
-- now we want to change pric_id in ALL tuples
-- this gets us not what we need
update
tttest
set
price_id
=
5
where
price_id
=
3
;
select
*
from
tttest
;
-- restore data as before last update:
select
set_ttdummy
(
0
);
delete
from
tttest
where
price_id
=
5
;
update
tttest
set
price_off
=
999999
where
price_val
=
30
;
select
*
from
tttest
;
-- and try change price_id now!
update
tttest
set
price_id
=
5
where
price_id
=
3
;
select
*
from
tttest
;
-- isn't it what we need ?
select
set_ttdummy
(
1
);
-- we want to correct some "date"
update
tttest
set
price_on
=
-
1
where
price_id
=
1
;
-- but this doesn't work
-- try in this way
select
set_ttdummy
(
0
);
update
tttest
set
price_on
=
-
1
where
price_id
=
1
;
select
*
from
tttest
;
-- isn't it what we need ?
-- get price for price_id == 5 as it was @ "date" 25
select
*
from
tttest
where
price_on
<=
25
and
price_off
>
25
and
price_id
=
5
;
drop
table
tttest
;
drop
sequence
ttdummy_seq
;
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