@@ -6458,13 +6458,37 @@ select * from rem1;
6458
6458
-- ===================================================================
6459
6459
-- test generated columns
6460
6460
-- ===================================================================
6461
- create table gloc1 (a int, b int);
6461
+ create table gloc1 (
6462
+ a int,
6463
+ b int generated always as (a * 2) stored);
6462
6464
alter table gloc1 set (autovacuum_enabled = 'false');
6463
6465
create foreign table grem1 (
6464
6466
a int,
6465
6467
b int generated always as (a * 2) stored)
6466
6468
server loopback options(table_name 'gloc1');
6469
+ explain (verbose, costs off)
6470
+ insert into grem1 (a) values (1), (2);
6471
+ QUERY PLAN
6472
+ -------------------------------------------------------------------
6473
+ Insert on public.grem1
6474
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6475
+ Batch Size: 1
6476
+ -> Values Scan on "*VALUES*"
6477
+ Output: "*VALUES*".column1, NULL::integer
6478
+ (5 rows)
6479
+
6467
6480
insert into grem1 (a) values (1), (2);
6481
+ explain (verbose, costs off)
6482
+ update grem1 set a = 22 where a = 2;
6483
+ QUERY PLAN
6484
+ ------------------------------------------------------------------------------------
6485
+ Update on public.grem1
6486
+ Remote SQL: UPDATE public.gloc1 SET a = $2, b = DEFAULT WHERE ctid = $1
6487
+ -> Foreign Scan on public.grem1
6488
+ Output: 22, ctid, grem1.*
6489
+ Remote SQL: SELECT a, b, ctid FROM public.gloc1 WHERE ((a = 2)) FOR UPDATE
6490
+ (5 rows)
6491
+
6468
6492
update grem1 set a = 22 where a = 2;
6469
6493
select * from gloc1;
6470
6494
a | b
@@ -6480,6 +6504,54 @@ select * from grem1;
6480
6504
22 | 44
6481
6505
(2 rows)
6482
6506
6507
+ delete from grem1;
6508
+ -- test copy from
6509
+ copy grem1 from stdin;
6510
+ select * from gloc1;
6511
+ a | b
6512
+ ---+---
6513
+ 1 | 2
6514
+ 2 | 4
6515
+ (2 rows)
6516
+
6517
+ select * from grem1;
6518
+ a | b
6519
+ ---+---
6520
+ 1 | 2
6521
+ 2 | 4
6522
+ (2 rows)
6523
+
6524
+ delete from grem1;
6525
+ -- test batch insert
6526
+ alter server loopback options (add batch_size '10');
6527
+ explain (verbose, costs off)
6528
+ insert into grem1 (a) values (1), (2);
6529
+ QUERY PLAN
6530
+ -------------------------------------------------------------------
6531
+ Insert on public.grem1
6532
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6533
+ Batch Size: 10
6534
+ -> Values Scan on "*VALUES*"
6535
+ Output: "*VALUES*".column1, NULL::integer
6536
+ (5 rows)
6537
+
6538
+ insert into grem1 (a) values (1), (2);
6539
+ select * from gloc1;
6540
+ a | b
6541
+ ---+---
6542
+ 1 | 2
6543
+ 2 | 4
6544
+ (2 rows)
6545
+
6546
+ select * from grem1;
6547
+ a | b
6548
+ ---+---
6549
+ 1 | 2
6550
+ 2 | 4
6551
+ (2 rows)
6552
+
6553
+ delete from grem1;
6554
+ alter server loopback options (drop batch_size);
6483
6555
-- ===================================================================
6484
6556
-- test local triggers
6485
6557
-- ===================================================================
@@ -8566,6 +8638,7 @@ CREATE TABLE import_source.t3 (c1 timestamptz default now(), c2 typ1);
8566
8638
CREATE TABLE import_source."x 4" (c1 float8, "C 2" text, c3 varchar(42));
8567
8639
CREATE TABLE import_source."x 5" (c1 float8);
8568
8640
ALTER TABLE import_source."x 5" DROP COLUMN c1;
8641
+ CREATE TABLE import_source."x 6" (c1 int, c2 int generated always as (c1 * 2) stored);
8569
8642
CREATE TABLE import_source.t4 (c1 int) PARTITION BY RANGE (c1);
8570
8643
CREATE TABLE import_source.t4_part PARTITION OF import_source.t4
8571
8644
FOR VALUES FROM (1) TO (100);
@@ -8583,7 +8656,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
8583
8656
import_dest1 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8584
8657
import_dest1 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8585
8658
import_dest1 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8586
- (6 rows)
8659
+ import_dest1 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8660
+ (7 rows)
8587
8661
8588
8662
\d import_dest1.*
8589
8663
Foreign table "import_dest1.t1"
@@ -8633,6 +8707,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8633
8707
Server: loopback
8634
8708
FDW options: (schema_name 'import_source', table_name 'x 5')
8635
8709
8710
+ Foreign table "import_dest1.x 6"
8711
+ Column | Type | Collation | Nullable | Default | FDW options
8712
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8713
+ c1 | integer | | | | (column_name 'c1')
8714
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8715
+ Server: loopback
8716
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8717
+
8636
8718
-- Options
8637
8719
CREATE SCHEMA import_dest2;
8638
8720
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
@@ -8647,7 +8729,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
8647
8729
import_dest2 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8648
8730
import_dest2 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8649
8731
import_dest2 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8650
- (6 rows)
8732
+ import_dest2 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8733
+ (7 rows)
8651
8734
8652
8735
\d import_dest2.*
8653
8736
Foreign table "import_dest2.t1"
@@ -8697,9 +8780,17 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8697
8780
Server: loopback
8698
8781
FDW options: (schema_name 'import_source', table_name 'x 5')
8699
8782
8783
+ Foreign table "import_dest2.x 6"
8784
+ Column | Type | Collation | Nullable | Default | FDW options
8785
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8786
+ c1 | integer | | | | (column_name 'c1')
8787
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8788
+ Server: loopback
8789
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8790
+
8700
8791
CREATE SCHEMA import_dest3;
8701
8792
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8702
- OPTIONS (import_collate 'false', import_not_null 'false');
8793
+ OPTIONS (import_collate 'false', import_generated 'false', import_not_null 'false');
8703
8794
\det+ import_dest3.*
8704
8795
List of foreign tables
8705
8796
Schema | Table | Server | FDW options | Description
@@ -8710,7 +8801,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8710
8801
import_dest3 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8711
8802
import_dest3 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8712
8803
import_dest3 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8713
- (6 rows)
8804
+ import_dest3 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8805
+ (7 rows)
8714
8806
8715
8807
\d import_dest3.*
8716
8808
Foreign table "import_dest3.t1"
@@ -8760,6 +8852,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8760
8852
Server: loopback
8761
8853
FDW options: (schema_name 'import_source', table_name 'x 5')
8762
8854
8855
+ Foreign table "import_dest3.x 6"
8856
+ Column | Type | Collation | Nullable | Default | FDW options
8857
+ --------+---------+-----------+----------+---------+--------------------
8858
+ c1 | integer | | | | (column_name 'c1')
8859
+ c2 | integer | | | | (column_name 'c2')
8860
+ Server: loopback
8861
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8862
+
8763
8863
-- Check LIMIT TO and EXCEPT
8764
8864
CREATE SCHEMA import_dest4;
8765
8865
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch, t4_part)
@@ -8784,7 +8884,8 @@ IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch, t4_part)
8784
8884
import_dest4 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8785
8885
import_dest4 | t4_part | loopback | (schema_name 'import_source', table_name 't4_part') |
8786
8886
import_dest4 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8787
- (6 rows)
8887
+ import_dest4 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8888
+ (7 rows)
8788
8889
8789
8890
-- Assorted error cases
8790
8891
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest4;
0 commit comments