@@ -6395,13 +6395,36 @@ select * from rem1;
6395
6395
-- ===================================================================
6396
6396
-- test generated columns
6397
6397
-- ===================================================================
6398
- create table gloc1 (a int, b int);
6398
+ create table gloc1 (
6399
+ a int,
6400
+ b int generated always as (a * 2) stored);
6399
6401
alter table gloc1 set (autovacuum_enabled = 'false');
6400
6402
create foreign table grem1 (
6401
6403
a int,
6402
6404
b int generated always as (a * 2) stored)
6403
6405
server loopback options(table_name 'gloc1');
6406
+ explain (verbose, costs off)
6407
+ insert into grem1 (a) values (1), (2);
6408
+ QUERY PLAN
6409
+ -------------------------------------------------------------------
6410
+ Insert on public.grem1
6411
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6412
+ -> Values Scan on "*VALUES*"
6413
+ Output: "*VALUES*".column1, NULL::integer
6414
+ (4 rows)
6415
+
6404
6416
insert into grem1 (a) values (1), (2);
6417
+ explain (verbose, costs off)
6418
+ update grem1 set a = 22 where a = 2;
6419
+ QUERY PLAN
6420
+ ---------------------------------------------------------------------------------
6421
+ Update on public.grem1
6422
+ Remote SQL: UPDATE public.gloc1 SET a = $2, b = DEFAULT WHERE ctid = $1
6423
+ -> Foreign Scan on public.grem1
6424
+ Output: 22, b, ctid
6425
+ Remote SQL: SELECT b, ctid FROM public.gloc1 WHERE ((a = 2)) FOR UPDATE
6426
+ (5 rows)
6427
+
6405
6428
update grem1 set a = 22 where a = 2;
6406
6429
select * from gloc1;
6407
6430
a | b
@@ -6417,6 +6440,24 @@ select * from grem1;
6417
6440
22 | 44
6418
6441
(2 rows)
6419
6442
6443
+ delete from grem1;
6444
+ -- test copy from
6445
+ copy grem1 from stdin;
6446
+ select * from gloc1;
6447
+ a | b
6448
+ ---+---
6449
+ 1 | 2
6450
+ 2 | 4
6451
+ (2 rows)
6452
+
6453
+ select * from grem1;
6454
+ a | b
6455
+ ---+---
6456
+ 1 | 2
6457
+ 2 | 4
6458
+ (2 rows)
6459
+
6460
+ delete from grem1;
6420
6461
-- ===================================================================
6421
6462
-- test local triggers
6422
6463
-- ===================================================================
@@ -8316,6 +8357,7 @@ CREATE TABLE import_source.t3 (c1 timestamptz default now(), c2 typ1);
8316
8357
CREATE TABLE import_source."x 4" (c1 float8, "C 2" text, c3 varchar(42));
8317
8358
CREATE TABLE import_source."x 5" (c1 float8);
8318
8359
ALTER TABLE import_source."x 5" DROP COLUMN c1;
8360
+ CREATE TABLE import_source."x 6" (c1 int, c2 int generated always as (c1 * 2) stored);
8319
8361
CREATE TABLE import_source.t4 (c1 int) PARTITION BY RANGE (c1);
8320
8362
CREATE TABLE import_source.t4_part PARTITION OF import_source.t4
8321
8363
FOR VALUES FROM (1) TO (100);
@@ -8331,7 +8373,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
8331
8373
import_dest1 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8332
8374
import_dest1 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8333
8375
import_dest1 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8334
- (6 rows)
8376
+ import_dest1 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8377
+ (7 rows)
8335
8378
8336
8379
\d import_dest1.*
8337
8380
Foreign table "import_dest1.t1"
@@ -8381,6 +8424,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8381
8424
Server: loopback
8382
8425
FDW options: (schema_name 'import_source', table_name 'x 5')
8383
8426
8427
+ Foreign table "import_dest1.x 6"
8428
+ Column | Type | Collation | Nullable | Default | FDW options
8429
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8430
+ c1 | integer | | | | (column_name 'c1')
8431
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8432
+ Server: loopback
8433
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8434
+
8384
8435
-- Options
8385
8436
CREATE SCHEMA import_dest2;
8386
8437
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
@@ -8395,7 +8446,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
8395
8446
import_dest2 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8396
8447
import_dest2 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8397
8448
import_dest2 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8398
- (6 rows)
8449
+ import_dest2 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8450
+ (7 rows)
8399
8451
8400
8452
\d import_dest2.*
8401
8453
Foreign table "import_dest2.t1"
@@ -8445,9 +8497,17 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8445
8497
Server: loopback
8446
8498
FDW options: (schema_name 'import_source', table_name 'x 5')
8447
8499
8500
+ Foreign table "import_dest2.x 6"
8501
+ Column | Type | Collation | Nullable | Default | FDW options
8502
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8503
+ c1 | integer | | | | (column_name 'c1')
8504
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8505
+ Server: loopback
8506
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8507
+
8448
8508
CREATE SCHEMA import_dest3;
8449
8509
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8450
- OPTIONS (import_collate 'false', import_not_null 'false');
8510
+ OPTIONS (import_collate 'false', import_generated 'false', import_not_null 'false');
8451
8511
\det+ import_dest3.*
8452
8512
List of foreign tables
8453
8513
Schema | Table | Server | FDW options | Description
@@ -8458,7 +8518,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8458
8518
import_dest3 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8459
8519
import_dest3 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8460
8520
import_dest3 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8461
- (6 rows)
8521
+ import_dest3 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8522
+ (7 rows)
8462
8523
8463
8524
\d import_dest3.*
8464
8525
Foreign table "import_dest3.t1"
@@ -8508,6 +8569,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8508
8569
Server: loopback
8509
8570
FDW options: (schema_name 'import_source', table_name 'x 5')
8510
8571
8572
+ Foreign table "import_dest3.x 6"
8573
+ Column | Type | Collation | Nullable | Default | FDW options
8574
+ --------+---------+-----------+----------+---------+--------------------
8575
+ c1 | integer | | | | (column_name 'c1')
8576
+ c2 | integer | | | | (column_name 'c2')
8577
+ Server: loopback
8578
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8579
+
8511
8580
-- Check LIMIT TO and EXCEPT
8512
8581
CREATE SCHEMA import_dest4;
8513
8582
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch)
@@ -8530,7 +8599,8 @@ IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch)
8530
8599
import_dest4 | t3 | loopback | (schema_name 'import_source', table_name 't3') |
8531
8600
import_dest4 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8532
8601
import_dest4 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8533
- (5 rows)
8602
+ import_dest4 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8603
+ (6 rows)
8534
8604
8535
8605
-- Assorted error cases
8536
8606
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest4;
0 commit comments