@@ -6548,13 +6548,37 @@ select * from rem1;
6548
6548
-- ===================================================================
6549
6549
-- test generated columns
6550
6550
-- ===================================================================
6551
- create table gloc1 (a int, b int);
6551
+ create table gloc1 (
6552
+ a int,
6553
+ b int generated always as (a * 2) stored);
6552
6554
alter table gloc1 set (autovacuum_enabled = 'false');
6553
6555
create foreign table grem1 (
6554
6556
a int,
6555
6557
b int generated always as (a * 2) stored)
6556
6558
server loopback options(table_name 'gloc1');
6559
+ explain (verbose, costs off)
6560
+ insert into grem1 (a) values (1), (2);
6561
+ QUERY PLAN
6562
+ -------------------------------------------------------------------
6563
+ Insert on public.grem1
6564
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6565
+ Batch Size: 1
6566
+ -> Values Scan on "*VALUES*"
6567
+ Output: "*VALUES*".column1, NULL::integer
6568
+ (5 rows)
6569
+
6557
6570
insert into grem1 (a) values (1), (2);
6571
+ explain (verbose, costs off)
6572
+ update grem1 set a = 22 where a = 2;
6573
+ QUERY PLAN
6574
+ ------------------------------------------------------------------------------------
6575
+ Update on public.grem1
6576
+ Remote SQL: UPDATE public.gloc1 SET a = $2, b = DEFAULT WHERE ctid = $1
6577
+ -> Foreign Scan on public.grem1
6578
+ Output: 22, ctid, grem1.*
6579
+ Remote SQL: SELECT a, b, ctid FROM public.gloc1 WHERE ((a = 2)) FOR UPDATE
6580
+ (5 rows)
6581
+
6558
6582
update grem1 set a = 22 where a = 2;
6559
6583
select * from gloc1;
6560
6584
a | b
@@ -6570,6 +6594,54 @@ select * from grem1;
6570
6594
22 | 44
6571
6595
(2 rows)
6572
6596
6597
+ delete from grem1;
6598
+ -- test copy from
6599
+ copy grem1 from stdin;
6600
+ select * from gloc1;
6601
+ a | b
6602
+ ---+---
6603
+ 1 | 2
6604
+ 2 | 4
6605
+ (2 rows)
6606
+
6607
+ select * from grem1;
6608
+ a | b
6609
+ ---+---
6610
+ 1 | 2
6611
+ 2 | 4
6612
+ (2 rows)
6613
+
6614
+ delete from grem1;
6615
+ -- test batch insert
6616
+ alter server loopback options (add batch_size '10');
6617
+ explain (verbose, costs off)
6618
+ insert into grem1 (a) values (1), (2);
6619
+ QUERY PLAN
6620
+ -------------------------------------------------------------------
6621
+ Insert on public.grem1
6622
+ Remote SQL: INSERT INTO public.gloc1(a, b) VALUES ($1, DEFAULT)
6623
+ Batch Size: 10
6624
+ -> Values Scan on "*VALUES*"
6625
+ Output: "*VALUES*".column1, NULL::integer
6626
+ (5 rows)
6627
+
6628
+ insert into grem1 (a) values (1), (2);
6629
+ select * from gloc1;
6630
+ a | b
6631
+ ---+---
6632
+ 1 | 2
6633
+ 2 | 4
6634
+ (2 rows)
6635
+
6636
+ select * from grem1;
6637
+ a | b
6638
+ ---+---
6639
+ 1 | 2
6640
+ 2 | 4
6641
+ (2 rows)
6642
+
6643
+ delete from grem1;
6644
+ alter server loopback options (drop batch_size);
6573
6645
-- ===================================================================
6574
6646
-- test local triggers
6575
6647
-- ===================================================================
@@ -8656,6 +8728,7 @@ CREATE TABLE import_source.t3 (c1 timestamptz default now(), c2 typ1);
8656
8728
CREATE TABLE import_source."x 4" (c1 float8, "C 2" text, c3 varchar(42));
8657
8729
CREATE TABLE import_source."x 5" (c1 float8);
8658
8730
ALTER TABLE import_source."x 5" DROP COLUMN c1;
8731
+ CREATE TABLE import_source."x 6" (c1 int, c2 int generated always as (c1 * 2) stored);
8659
8732
CREATE TABLE import_source.t4 (c1 int) PARTITION BY RANGE (c1);
8660
8733
CREATE TABLE import_source.t4_part PARTITION OF import_source.t4
8661
8734
FOR VALUES FROM (1) TO (100);
@@ -8673,7 +8746,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
8673
8746
import_dest1 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8674
8747
import_dest1 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8675
8748
import_dest1 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8676
- (6 rows)
8749
+ import_dest1 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8750
+ (7 rows)
8677
8751
8678
8752
\d import_dest1.*
8679
8753
Foreign table "import_dest1.t1"
@@ -8723,6 +8797,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8723
8797
Server: loopback
8724
8798
FDW options: (schema_name 'import_source', table_name 'x 5')
8725
8799
8800
+ Foreign table "import_dest1.x 6"
8801
+ Column | Type | Collation | Nullable | Default | FDW options
8802
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8803
+ c1 | integer | | | | (column_name 'c1')
8804
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8805
+ Server: loopback
8806
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8807
+
8726
8808
-- Options
8727
8809
CREATE SCHEMA import_dest2;
8728
8810
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
@@ -8737,7 +8819,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
8737
8819
import_dest2 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8738
8820
import_dest2 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8739
8821
import_dest2 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8740
- (6 rows)
8822
+ import_dest2 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8823
+ (7 rows)
8741
8824
8742
8825
\d import_dest2.*
8743
8826
Foreign table "import_dest2.t1"
@@ -8787,9 +8870,17 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8787
8870
Server: loopback
8788
8871
FDW options: (schema_name 'import_source', table_name 'x 5')
8789
8872
8873
+ Foreign table "import_dest2.x 6"
8874
+ Column | Type | Collation | Nullable | Default | FDW options
8875
+ --------+---------+-----------+----------+-------------------------------------+--------------------
8876
+ c1 | integer | | | | (column_name 'c1')
8877
+ c2 | integer | | | generated always as (c1 * 2) stored | (column_name 'c2')
8878
+ Server: loopback
8879
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8880
+
8790
8881
CREATE SCHEMA import_dest3;
8791
8882
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8792
- OPTIONS (import_collate 'false', import_not_null 'false');
8883
+ OPTIONS (import_collate 'false', import_generated 'false', import_not_null 'false');
8793
8884
\det+ import_dest3.*
8794
8885
List of foreign tables
8795
8886
Schema | Table | Server | FDW options | Description
@@ -8800,7 +8891,8 @@ IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
8800
8891
import_dest3 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8801
8892
import_dest3 | x 4 | loopback | (schema_name 'import_source', table_name 'x 4') |
8802
8893
import_dest3 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8803
- (6 rows)
8894
+ import_dest3 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8895
+ (7 rows)
8804
8896
8805
8897
\d import_dest3.*
8806
8898
Foreign table "import_dest3.t1"
@@ -8850,6 +8942,14 @@ FDW options: (schema_name 'import_source', table_name 'x 4')
8850
8942
Server: loopback
8851
8943
FDW options: (schema_name 'import_source', table_name 'x 5')
8852
8944
8945
+ Foreign table "import_dest3.x 6"
8946
+ Column | Type | Collation | Nullable | Default | FDW options
8947
+ --------+---------+-----------+----------+---------+--------------------
8948
+ c1 | integer | | | | (column_name 'c1')
8949
+ c2 | integer | | | | (column_name 'c2')
8950
+ Server: loopback
8951
+ FDW options: (schema_name 'import_source', table_name 'x 6')
8952
+
8853
8953
-- Check LIMIT TO and EXCEPT
8854
8954
CREATE SCHEMA import_dest4;
8855
8955
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch, t4_part)
@@ -8874,7 +8974,8 @@ IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch, t4_part)
8874
8974
import_dest4 | t4 | loopback | (schema_name 'import_source', table_name 't4') |
8875
8975
import_dest4 | t4_part | loopback | (schema_name 'import_source', table_name 't4_part') |
8876
8976
import_dest4 | x 5 | loopback | (schema_name 'import_source', table_name 'x 5') |
8877
- (6 rows)
8977
+ import_dest4 | x 6 | loopback | (schema_name 'import_source', table_name 'x 6') |
8978
+ (7 rows)
8878
8979
8879
8980
-- Assorted error cases
8880
8981
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest4;
0 commit comments