Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b3c4d69

Browse files
committed
Add regression test inspired by Sebastian Böck.
1 parent 47aa95e commit b3c4d69

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/test/regress/expected/rules.out

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,3 +1428,55 @@ DETAIL: Key (id3a,id3c)=(1,13) is not present in table "rule_and_refint_t2".
14281428
insert into rule_and_refint_t3 values (1, 13, 11, 'row8');
14291429
ERROR: insert or update on table "rule_and_refint_t3" violates foreign key constraint "rule_and_refint_t3_id3a_fkey"
14301430
DETAIL: Key (id3a,id3b)=(1,13) is not present in table "rule_and_refint_t1".
1431+
--
1432+
-- check for planner problems with complex inherited UPDATES
1433+
--
1434+
create table id (id serial primary key, name text);
1435+
NOTICE: CREATE TABLE will create implicit sequence "id_id_seq" for serial column "id.id"
1436+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "id_pkey" for table "id"
1437+
-- currently, must respecify PKEY for each inherited subtable
1438+
create table test_1 (id integer primary key) inherits (id);
1439+
NOTICE: merging column "id" with inherited definition
1440+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_1_pkey" for table "test_1"
1441+
create table test_2 (id integer primary key) inherits (id);
1442+
NOTICE: merging column "id" with inherited definition
1443+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_2_pkey" for table "test_2"
1444+
create table test_3 (id integer primary key) inherits (id);
1445+
NOTICE: merging column "id" with inherited definition
1446+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_3_pkey" for table "test_3"
1447+
insert into test_1 (name) values ('Test 1');
1448+
insert into test_1 (name) values ('Test 2');
1449+
insert into test_2 (name) values ('Test 3');
1450+
insert into test_2 (name) values ('Test 4');
1451+
insert into test_3 (name) values ('Test 5');
1452+
insert into test_3 (name) values ('Test 6');
1453+
create view id_ordered as select * from id order by id;
1454+
create rule update_id_ordered as on update to id_ordered
1455+
do instead update id set name = new.name where id = old.id;
1456+
select * from id_ordered;
1457+
id | name
1458+
----+--------
1459+
1 | Test 1
1460+
2 | Test 2
1461+
3 | Test 3
1462+
4 | Test 4
1463+
5 | Test 5
1464+
6 | Test 6
1465+
(6 rows)
1466+
1467+
update id_ordered set name = 'update 2' where id = 2;
1468+
update id_ordered set name = 'update 4' where id = 4;
1469+
update id_ordered set name = 'update 5' where id = 5;
1470+
select * from id_ordered;
1471+
id | name
1472+
----+----------
1473+
1 | Test 1
1474+
2 | update 2
1475+
3 | Test 3
1476+
4 | update 4
1477+
5 | update 5
1478+
6 | Test 6
1479+
(6 rows)
1480+
1481+
set client_min_messages to warning; -- suppress cascade notices
1482+
drop table id cascade;

src/test/regress/sql/rules.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,3 +848,34 @@ create rule rule_and_refint_t3_ins as on insert to rule_and_refint_t3
848848

849849
insert into rule_and_refint_t3 values (1, 11, 13, 'row7');
850850
insert into rule_and_refint_t3 values (1, 13, 11, 'row8');
851+
852+
--
853+
-- check for planner problems with complex inherited UPDATES
854+
--
855+
856+
create table id (id serial primary key, name text);
857+
-- currently, must respecify PKEY for each inherited subtable
858+
create table test_1 (id integer primary key) inherits (id);
859+
create table test_2 (id integer primary key) inherits (id);
860+
create table test_3 (id integer primary key) inherits (id);
861+
862+
insert into test_1 (name) values ('Test 1');
863+
insert into test_1 (name) values ('Test 2');
864+
insert into test_2 (name) values ('Test 3');
865+
insert into test_2 (name) values ('Test 4');
866+
insert into test_3 (name) values ('Test 5');
867+
insert into test_3 (name) values ('Test 6');
868+
869+
create view id_ordered as select * from id order by id;
870+
871+
create rule update_id_ordered as on update to id_ordered
872+
do instead update id set name = new.name where id = old.id;
873+
874+
select * from id_ordered;
875+
update id_ordered set name = 'update 2' where id = 2;
876+
update id_ordered set name = 'update 4' where id = 4;
877+
update id_ordered set name = 'update 5' where id = 5;
878+
select * from id_ordered;
879+
880+
set client_min_messages to warning; -- suppress cascade notices
881+
drop table id cascade;

0 commit comments

Comments
 (0)