Debian Codegraph @

contrib/spi/expected/autoinc.out

raw
1 CREATE EXTENSION autoinc;
2 create sequence aitest_seq increment 10 start 0 minvalue 0;
3 create table aitest (
4 price_id int4,
5 price_val int4,
6 price_on int4
7 );
8 create trigger aiserial
9 before insert or update on aitest
10 for each row
11 execute procedure
12 autoinc (price_on, aitest_seq);
13 insert into aitest values (1, 1, null);
14 insert into aitest values (2, 2, 0);
15 insert into aitest values (3, 3, 1);
16 select * from aitest;
17 price_id | price_val | price_on
18 ----------+-----------+----------
19 1 | 1 | 10
20 2 | 2 | 20
21 3 | 3 | 1
22 (3 rows)
23
24 update aitest set price_on = 11;
25 select * from aitest;
26 price_id | price_val | price_on
27 ----------+-----------+----------
28 1 | 1 | 11
29 2 | 2 | 11
30 3 | 3 | 11
31 (3 rows)
32
33 update aitest set price_on = 0;
34 select * from aitest;
35 price_id | price_val | price_on
36 ----------+-----------+----------
37 1 | 1 | 30
38 2 | 2 | 40
39 3 | 3 | 50
40 (3 rows)
41
42 update aitest set price_on = null;
43 select * from aitest;
44 price_id | price_val | price_on
45 ----------+-----------+----------
46 1 | 1 | 60
47 2 | 2 | 70
48 3 | 3 | 80
49 (3 rows)
50