Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fba397

Browse files
committed
Add test case exercising formerly-unreached code in inheritance_planner.
There was some debate about whether the code I'd added to remapAppendRelInfos obtained from the initial SELECT planning run isactually necessary. Add a test case demonstrating that it is.Discussion:https://postgr.es/m/23831.1553873385@sss.pgh.pa.us
1 parent9fd4de1 commit8fba397

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

‎src/test/regress/expected/updatable_views.out

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,10 +1542,67 @@ SELECT * FROM base_tbl_child ORDER BY a;
15421542
20
15431543
(6 rows)
15441544

1545+
CREATE TABLE other_tbl_parent (id int);
1546+
CREATE TABLE other_tbl_child () INHERITS (other_tbl_parent);
1547+
INSERT INTO other_tbl_parent VALUES (7),(200);
1548+
INSERT INTO other_tbl_child VALUES (8),(100);
1549+
EXPLAIN (costs off)
1550+
UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id;
1551+
QUERY PLAN
1552+
--------------------------------------------------------------
1553+
Update on base_tbl_parent
1554+
Update on base_tbl_parent
1555+
Update on base_tbl_child
1556+
-> Hash Join
1557+
Hash Cond: (other_tbl_parent.id = base_tbl_parent.a)
1558+
-> Append
1559+
-> Seq Scan on other_tbl_parent
1560+
-> Seq Scan on other_tbl_child
1561+
-> Hash
1562+
-> Seq Scan on base_tbl_parent
1563+
-> Merge Join
1564+
Merge Cond: (base_tbl_child.a = other_tbl_parent.id)
1565+
-> Sort
1566+
Sort Key: base_tbl_child.a
1567+
-> Seq Scan on base_tbl_child
1568+
-> Sort
1569+
Sort Key: other_tbl_parent.id
1570+
-> Append
1571+
-> Seq Scan on other_tbl_parent
1572+
-> Seq Scan on other_tbl_child
1573+
(20 rows)
1574+
1575+
UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id;
1576+
SELECT * FROM ONLY base_tbl_parent ORDER BY a;
1577+
a
1578+
------
1579+
-200
1580+
-100
1581+
-40
1582+
-30
1583+
-20
1584+
-10
1585+
1100
1586+
1200
1587+
(8 rows)
1588+
1589+
SELECT * FROM base_tbl_child ORDER BY a;
1590+
a
1591+
------
1592+
3
1593+
4
1594+
10
1595+
20
1596+
1007
1597+
1008
1598+
(6 rows)
1599+
15451600
DROP TABLE base_tbl_parent, base_tbl_child CASCADE;
15461601
NOTICE: drop cascades to 2 other objects
15471602
DETAIL: drop cascades to view rw_view1
15481603
drop cascades to view rw_view2
1604+
DROP TABLE other_tbl_parent CASCADE;
1605+
NOTICE: drop cascades to table other_tbl_child
15491606
-- simple WITH CHECK OPTION
15501607
CREATE TABLE base_tbl (a int, b int DEFAULT 10);
15511608
INSERT INTO base_tbl VALUES (1,2), (2,3), (1,-1);

‎src/test/regress/sql/updatable_views.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,20 @@ DELETE FROM ONLY rw_view2 WHERE a IN (-8, 8); -- Should delete -8 only
713713
SELECT*FROM ONLY base_tbl_parentORDER BY a;
714714
SELECT*FROM base_tbl_childORDER BY a;
715715

716+
CREATETABLEother_tbl_parent (idint);
717+
CREATETABLEother_tbl_child () INHERITS (other_tbl_parent);
718+
INSERT INTO other_tbl_parentVALUES (7),(200);
719+
INSERT INTO other_tbl_childVALUES (8),(100);
720+
721+
EXPLAIN (costs off)
722+
UPDATE rw_view1SET a= a+1000FROM other_tbl_parentWHERE a= id;
723+
UPDATE rw_view1SET a= a+1000FROM other_tbl_parentWHERE a= id;
724+
725+
SELECT*FROM ONLY base_tbl_parentORDER BY a;
726+
SELECT*FROM base_tbl_childORDER BY a;
727+
716728
DROPTABLE base_tbl_parent, base_tbl_child CASCADE;
729+
DROPTABLE other_tbl_parent CASCADE;
717730

718731
-- simple WITH CHECK OPTION
719732

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp