@@ -1428,3 +1428,55 @@ DETAIL: Key (id3a,id3c)=(1,13) is not present in table "rule_and_refint_t2".
1428
1428
insert into rule_and_refint_t3 values (1, 13, 11, 'row8');
1429
1429
ERROR: insert or update on table "rule_and_refint_t3" violates foreign key constraint "rule_and_refint_t3_id3a_fkey"
1430
1430
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;
0 commit comments