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

Commitcb1ca4d

Browse files
committed
Allow foreign tables to participate in inheritance.
Foreign tables can now be inheritance children, or parents. Much of thesystem was already ready for this, but we had to fix a few things ofcourse, mostly in the area of planner and executor handling of row locks.As side effects of this, allow foreign tables to have NOT VALID CHECKconstraints (and hence to accept ALTER ... VALIDATE CONSTRAINT), and toaccept ALTER SET STORAGE and ALTER SET WITH/WITHOUT OIDS. Continuing todisallow these things would've required bizarre and inconsistent specialcases in inheritance behavior. Since foreign tables don't enforce CHECKconstraints anyway, a NOT VALID one is a complete no-op, but that doesn'tmean we shouldn't allow it. And it's possible that some FDWs might haveuse for SET STORAGE or SET WITH OIDS, though doubtless they will be no-opsfor most.An additional change in support of this is that when a ModifyTable nodehas multiple target tables, they will all now be explicitly identifiedin EXPLAIN output, for example: Update on pt1 (cost=0.00..321.05 rows=3541 width=46) Update on pt1 Foreign Update on ft1 Foreign Update on ft2 Update on child3 -> Seq Scan on pt1 (cost=0.00..0.00 rows=1 width=46) -> Foreign Scan on ft1 (cost=100.00..148.03 rows=1170 width=46) -> Foreign Scan on ft2 (cost=100.00..148.03 rows=1170 width=46) -> Seq Scan on child3 (cost=0.00..25.00 rows=1200 width=46)This was done mainly to provide an unambiguous place to attach "Remote SQL"fields, but it is useful for inherited updates even when no foreign tablesare involved.Shigeru Hanada and Etsuro Fujita, reviewed by Ashutosh Bapat and KyotaroHoriguchi, some additional hacking by me
1 parent8ac356c commitcb1ca4d

File tree

29 files changed

+1761
-185
lines changed

29 files changed

+1761
-185
lines changed

‎contrib/file_fdw/input/file_fdw.source

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ SELECT tableoid::regclass, b FROM agg_csv;
133133
INSERT INTO agg_csv VALUES(1,2.0);
134134
UPDATE agg_csv SET a = 1;
135135
DELETE FROM agg_csv WHERE a = 100;
136-
-- but this should beignored
136+
-- but this should beallowed
137137
SELECT * FROM agg_csv FOR UPDATE;
138138

139139
-- constraint exclusion tests
@@ -148,6 +148,20 @@ EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_csv WHERE a < 0;
148148
SELECT * FROM agg_csv WHERE a < 0;
149149
RESET constraint_exclusion;
150150

151+
-- table inheritance tests
152+
CREATE TABLE agg (a int2, b float4);
153+
ALTER FOREIGN TABLE agg_csv INHERIT agg;
154+
SELECT tableoid::regclass, * FROM agg;
155+
SELECT tableoid::regclass, * FROM agg_csv;
156+
SELECT tableoid::regclass, * FROM ONLY agg;
157+
-- updates aren't supported
158+
UPDATE agg SET a = 1;
159+
DELETE FROM agg WHERE a = 100;
160+
-- but this should be allowed
161+
SELECT tableoid::regclass, * FROM agg FOR UPDATE;
162+
ALTER FOREIGN TABLE agg_csv NO INHERIT agg;
163+
DROP TABLE agg;
164+
151165
-- privilege tests
152166
SET ROLE file_fdw_superuser;
153167
SELECT * FROM agg_text ORDER BY a;

‎contrib/file_fdw/output/file_fdw.source

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ UPDATE agg_csv SET a = 1;
212212
ERROR: cannot update foreign table "agg_csv"
213213
DELETE FROM agg_csv WHERE a = 100;
214214
ERROR: cannot delete from foreign table "agg_csv"
215-
-- but this should beignored
215+
-- but this should beallowed
216216
SELECT * FROM agg_csv FOR UPDATE;
217217
a | b
218218
-----+---------
@@ -249,6 +249,46 @@ SELECT * FROM agg_csv WHERE a < 0;
249249
(0 rows)
250250

251251
RESET constraint_exclusion;
252+
-- table inheritance tests
253+
CREATE TABLE agg (a int2, b float4);
254+
ALTER FOREIGN TABLE agg_csv INHERIT agg;
255+
SELECT tableoid::regclass, * FROM agg;
256+
tableoid | a | b
257+
----------+-----+---------
258+
agg_csv | 100 | 99.097
259+
agg_csv | 0 | 0.09561
260+
agg_csv | 42 | 324.78
261+
(3 rows)
262+
263+
SELECT tableoid::regclass, * FROM agg_csv;
264+
tableoid | a | b
265+
----------+-----+---------
266+
agg_csv | 100 | 99.097
267+
agg_csv | 0 | 0.09561
268+
agg_csv | 42 | 324.78
269+
(3 rows)
270+
271+
SELECT tableoid::regclass, * FROM ONLY agg;
272+
tableoid | a | b
273+
----------+---+---
274+
(0 rows)
275+
276+
-- updates aren't supported
277+
UPDATE agg SET a = 1;
278+
ERROR: cannot update foreign table "agg_csv"
279+
DELETE FROM agg WHERE a = 100;
280+
ERROR: cannot delete from foreign table "agg_csv"
281+
-- but this should be allowed
282+
SELECT tableoid::regclass, * FROM agg FOR UPDATE;
283+
tableoid | a | b
284+
----------+-----+---------
285+
agg_csv | 100 | 99.097
286+
agg_csv | 0 | 0.09561
287+
agg_csv | 42 | 324.78
288+
(3 rows)
289+
290+
ALTER FOREIGN TABLE agg_csv NO INHERIT agg;
291+
DROP TABLE agg;
252292
-- privilege tests
253293
SET ROLE file_fdw_superuser;
254294
SELECT * FROM agg_text ORDER BY a;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp