@@ -7255,6 +7255,92 @@ select * from bar where f1 in (select f1 from foo) for share;
7255
7255
4 | 44
7256
7256
(4 rows)
7257
7257
7258
+ -- Now check SELECT FOR UPDATE/SHARE with an inherited source table,
7259
+ -- where the parent is itself a foreign table
7260
+ create table loct4 (f1 int, f2 int, f3 int);
7261
+ create foreign table foo2child (f3 int) inherits (foo2)
7262
+ server loopback options (table_name 'loct4');
7263
+ NOTICE: moving and merging column "f3" with inherited definition
7264
+ DETAIL: User-specified column moved to the position of the inherited column.
7265
+ explain (verbose, costs off)
7266
+ select * from bar where f1 in (select f1 from foo2) for share;
7267
+ QUERY PLAN
7268
+ --------------------------------------------------------------------------------------
7269
+ LockRows
7270
+ Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.tableoid
7271
+ -> Hash Join
7272
+ Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.tableoid
7273
+ Inner Unique: true
7274
+ Hash Cond: (bar.f1 = foo2.f1)
7275
+ -> Append
7276
+ -> Seq Scan on public.bar bar_1
7277
+ Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid
7278
+ -> Foreign Scan on public.bar2 bar_2
7279
+ Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid
7280
+ Remote SQL: SELECT f1, f2, f3, ctid FROM public.loct2 FOR SHARE
7281
+ -> Hash
7282
+ Output: foo2.*, foo2.f1, foo2.tableoid
7283
+ -> HashAggregate
7284
+ Output: foo2.*, foo2.f1, foo2.tableoid
7285
+ Group Key: foo2.f1
7286
+ -> Append
7287
+ -> Foreign Scan on public.foo2 foo2_1
7288
+ Output: foo2_1.*, foo2_1.f1, foo2_1.tableoid
7289
+ Remote SQL: SELECT f1, f2, f3 FROM public.loct1
7290
+ -> Foreign Scan on public.foo2child foo2_2
7291
+ Output: foo2_2.*, foo2_2.f1, foo2_2.tableoid
7292
+ Remote SQL: SELECT f1, f2, f3 FROM public.loct4
7293
+ (24 rows)
7294
+
7295
+ select * from bar where f1 in (select f1 from foo2) for share;
7296
+ f1 | f2
7297
+ ----+----
7298
+ 2 | 22
7299
+ 4 | 44
7300
+ (2 rows)
7301
+
7302
+ drop foreign table foo2child;
7303
+ -- And with a local child relation of the foreign table parent
7304
+ create table foo2child (f3 int) inherits (foo2);
7305
+ NOTICE: moving and merging column "f3" with inherited definition
7306
+ DETAIL: User-specified column moved to the position of the inherited column.
7307
+ explain (verbose, costs off)
7308
+ select * from bar where f1 in (select f1 from foo2) for share;
7309
+ QUERY PLAN
7310
+ -------------------------------------------------------------------------------------------------
7311
+ LockRows
7312
+ Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.ctid, foo2.tableoid
7313
+ -> Hash Join
7314
+ Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.ctid, foo2.tableoid
7315
+ Inner Unique: true
7316
+ Hash Cond: (bar.f1 = foo2.f1)
7317
+ -> Append
7318
+ -> Seq Scan on public.bar bar_1
7319
+ Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid
7320
+ -> Foreign Scan on public.bar2 bar_2
7321
+ Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid
7322
+ Remote SQL: SELECT f1, f2, f3, ctid FROM public.loct2 FOR SHARE
7323
+ -> Hash
7324
+ Output: foo2.*, foo2.f1, foo2.ctid, foo2.tableoid
7325
+ -> HashAggregate
7326
+ Output: foo2.*, foo2.f1, foo2.ctid, foo2.tableoid
7327
+ Group Key: foo2.f1
7328
+ -> Append
7329
+ -> Foreign Scan on public.foo2 foo2_1
7330
+ Output: foo2_1.*, foo2_1.f1, foo2_1.ctid, foo2_1.tableoid
7331
+ Remote SQL: SELECT f1, f2, f3, ctid FROM public.loct1
7332
+ -> Seq Scan on public.foo2child foo2_2
7333
+ Output: foo2_2.*, foo2_2.f1, foo2_2.ctid, foo2_2.tableoid
7334
+ (23 rows)
7335
+
7336
+ select * from bar where f1 in (select f1 from foo2) for share;
7337
+ f1 | f2
7338
+ ----+----
7339
+ 2 | 22
7340
+ 4 | 44
7341
+ (2 rows)
7342
+
7343
+ drop table foo2child;
7258
7344
-- Check UPDATE with inherited target and an inherited source table
7259
7345
explain (verbose, costs off)
7260
7346
update bar set f2 = f2 + 100 where f1 in (select f1 from foo);
0 commit comments