@@ -6365,13 +6365,36 @@ select * from rem1;
6365
6365
-- ===================================================================
6366
6366
-- test generated columns
6367
6367
-- ===================================================================
6368
- create table gloc1 (a int, b int);
6368
+ create table gloc1 (
6369
+ a int,
6370
+ b int generated always as (a * 2) stored);
6369
6371
alter table gloc1 set (autovacuum_enabled = 'false');
6370
6372
create foreign table grem1 (
6371
6373
a int,
6372
6374
b int generated always as (a * 2) stored)
6373
6375
server loopback options(table_name 'gloc1');
6376
+ explain (verbose, costs off)
6377
+ insert into grem1 (a) values (1), (2);
6378
+ QUERY PLAN
6379
+ -------------------------------------------------------------------
6380
+ Insert on public.grem1
6381
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6382
+ -> Values Scan on "*VALUES*"
6383
+ Output: "*VALUES*".column1, NULL::integer
6384
+ (4 rows)
6385
+
6374
6386
insert into grem1 (a) values (1), (2);
6387
+ explain (verbose, costs off)
6388
+ update grem1 set a = 22 where a = 2;
6389
+ QUERY PLAN
6390
+ ---------------------------------------------------------------------------------
6391
+ Update on public.grem1
6392
+ Remote SQL: UPDATE public.gloc1 SET a = $2, b = DEFAULT WHERE ctid = $1
6393
+ -> Foreign Scan on public.grem1
6394
+ Output: 22, b, ctid
6395
+ Remote SQL: SELECT b, ctid FROM public.gloc1 WHERE ((a = 2)) FOR UPDATE
6396
+ (5 rows)
6397
+
6375
6398
update grem1 set a = 22 where a = 2;
6376
6399
select * from gloc1;
6377
6400
a | b
@@ -6387,6 +6410,24 @@ select * from grem1;
6387
6410
22 | 44
6388
6411
(2 rows)
6389
6412
6413
+ delete from grem1;
6414
+ -- test copy from
6415
+ copy grem1 from stdin;
6416
+ select * from gloc1;
6417
+ a | b
6418
+ ---+---
6419
+ 1 | 2
6420
+ 2 | 4
6421
+ (2 rows)
6422
+
6423
+ select * from grem1;
6424
+ a | b
6425
+ ---+---
6426
+ 1 | 2
6427
+ 2 | 4
6428
+ (2 rows)
6429
+
6430
+ delete from grem1;
6390
6431
-- ===================================================================
6391
6432
-- test local triggers
6392
6433
-- ===================================================================
@@ -8286,6 +8327,7 @@ CREATE TABLE import_source.t3 (c1 timestamptz default now(), c2 typ1);
8286
8327
CREATE TABLE import_source."x 4" (c1 float8, "C 2" text, c3 varchar(42));
8287
8328
CREATE TABLE import_source."x 5" (c1 float8);
8288
8329
ALTER TABLE import_source."x 5" DROP COLUMN c1;
8330
+ CREATE TABLE import_source."x 6" (c1 int, c2 int generated always as (c1 * 2) stored);
8289
8331
CREATE TABLE import_source.t4 (c1 int) PARTITION BY RANGE (c1);
8290
8332
CREATE TABLE import_source.t4_part PARTITION OF import_source.t4
8291
8333
FOR VALUES FROM (1) TO (100);
@@ -8301,7 +8343,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
8301
8343
import_dest1 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8302
8344
import_dest1 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8303
8345
import_dest1 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8304
- (6 rows)
8346
+ import_dest1 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8347
+ (7 rows)
8305
8348
8306
8349
\d import_dest1.*
8307
8350
Foreign table "import_dest1.t1"
@@ -8351,6 +8394,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8351
8394
Server: loopback
8352
8395
FDW options: (schema_name 'import_source', table_name 'x 5')
8353
8396
8397
+ Foreign table "import_dest1.x 6"
8398
+ Column | Type | Collation | Nullable | Default | FDW options
8399
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8400
+ c1 | integer | | | | (column_name 'c1')
8401
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8402
+ Server: loopback
8403
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8404
+
8354
8405
-- Options
8355
8406
CREATE SCHEMA import_dest2;
8356
8407
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
@@ -8365,7 +8416,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
8365
8416
import_dest2 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8366
8417
import_dest2 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8367
8418
import_dest2 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8368
- (6 rows)
8419
+ import_dest2 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8420
+ (7 rows)
8369
8421
8370
8422
\d import_dest2.*
8371
8423
Foreign table "import_dest2.t1"
@@ -8415,9 +8467,17 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8415
8467
Server: loopback
8416
8468
FDW options: (schema_name 'import_source', table_name 'x 5')
8417
8469
8470
+ Foreign table "import_dest2.x 6"
8471
+ Column | Type | Collation | Nullable | Default | FDW options
8472
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8473
+ c1 | integer | | | | (column_name 'c1')
8474
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8475
+ Server: loopback
8476
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8477
+
8418
8478
CREATE SCHEMA import_dest3;
8419
8479
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8420
- OPTIONS (import_collate 'false', import_not_null 'false');
8480
+ OPTIONS (import_collate 'false', import_generated 'false', import_not_null 'false');
8421
8481
\det+ import_dest3.*
8422
8482
List of foreign tables
8423
8483
Schema | Table | Server | FDW options | Description
@@ -8428,7 +8488,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8428
8488
import_dest3 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8429
8489
import_dest3 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8430
8490
import_dest3 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8431
- (6 rows)
8491
+ import_dest3 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8492
+ (7 rows)
8432
8493
8433
8494
\d import_dest3.*
8434
8495
Foreign table "import_dest3.t1"
@@ -8478,6 +8539,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8478
8539
Server: loopback
8479
8540
FDW options: (schema_name 'import_source', table_name 'x 5')
8480
8541
8542
+ Foreign table "import_dest3.x 6"
8543
+ Column | Type | Collation | Nullable | Default | FDW options
8544
+ --------+---------+-----------+----------+---------+--------------------
8545
+ c1 | integer | | | | (column_name 'c1')
8546
+ c2 | integer | | | | (column_name 'c2')
8547
+ Server: loopback
8548
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8549
+
8481
8550
-- Check LIMIT TO and EXCEPT
8482
8551
CREATE SCHEMA import_dest4;
8483
8552
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch)
@@ -8500,7 +8569,8 @@ IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch)
8500
8569
import_dest4 | t3 | loopback | (schema_name 'import_source', table_name 't3') |
8501
8570
import_dest4 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8502
8571
import_dest4 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8503
- (5 rows)
8572
+ import_dest4 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8573
+ (6 rows)
8504
8574
8505
8575
-- Assorted error cases
8506
8576
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest4;
0 commit comments