| -- |
| -- Test foreign-data wrapper and server management. Cloudberry MPP specific |
| -- |
| CREATE FOREIGN DATA WRAPPER dummy OPTIONS (mpp_execute 'coordinator');; |
| COMMENT ON FOREIGN DATA WRAPPER dummy IS 'useless'; |
| ALTER FOREIGN DATA WRAPPER dummy OPTIONS (SET mpp_execute 'all segments'); |
| ERROR: "mpp_execute" of foreign data wrapper is not allowed to be altered |
| -- CREATE FOREIGN TABLE |
| CREATE SERVER s0 FOREIGN DATA WRAPPER dummy; |
| CREATE FOREIGN TABLE ft2 ( |
| c1 int |
| ) SERVER s0 OPTIONS (delimiter ',', mpp_execute 'a'); -- ERROR |
| ERROR: "a" is not a valid mpp_execute value |
| CREATE FOREIGN TABLE ft2 ( |
| c1 int |
| ) SERVER s0 OPTIONS (delimiter ',', mpp_execute 'any'); |
| \d+ ft2 |
| Foreign table "public.ft2" |
| Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description |
| --------+---------+-----------+----------+---------+-------------+---------+--------------+------------- |
| c1 | integer | | | | | plain | | |
| Server: s0 |
| FDW options: (delimiter ',', mpp_execute 'any') |
| |
| CREATE FOREIGN TABLE ft3 ( |
| c1 int |
| ) SERVER s0 OPTIONS (delimiter ',', mpp_execute 'master'); |
| CREATE FOREIGN TABLE ft4 ( |
| c1 int |
| ) SERVER s0 OPTIONS (delimiter ',', mpp_execute 'all segments'); |
| -- Test num_segments option |
| CREATE SERVER s1 FOREIGN DATA WRAPPER dummy OPTIONS (num_segments '3'); |
| CREATE FOREIGN TABLE ft5 ( |
| c1 int |
| ) SERVER s1 OPTIONS (delimiter ',', mpp_execute 'all segments', num_segments '5'); |
| \d+ ft5 |
| Foreign table "public.ft5" |
| Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description |
| --------+---------+-----------+----------+---------+-------------+---------+--------------+------------- |
| c1 | integer | | | | | plain | | |
| Server: s1 |
| FDW options: (delimiter ',', mpp_execute 'all segments', num_segments '5') |
| |
| -- CREATE FOREIGN TABLE LIKE |
| CREATE TABLE ft_source_table(a INT, b INT, c INT) DISTRIBUTED BY (b); |
| CREATE FOREIGN TABLE ft_like (LIKE ft_source_table) SERVER s0; |
| \d+ ft_like |
| Foreign table "public.ft_like" |
| Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description |
| --------+---------+-----------+----------+---------+-------------+---------+--------------+------------- |
| a | integer | | | | | plain | | |
| b | integer | | | | | plain | | |
| c | integer | | | | | plain | | |
| Server: s0 |
| |
| -- shoule be null |
| SELECT * FROM gp_distribution_policy WHERE localoid = 'ft_like'::regclass::oid; |
| localoid | policytype | numsegments | distkey | distclass |
| ----------+------------+-------------+---------+----------- |
| (0 rows) |
| |
| CREATE FOREIGN TABLE ft_like1 (LIKE ft_source_table) SERVER s0 |
| OPTIONS (delimiter ',', mpp_execute 'all segments', num_segments '3'); |
| \d+ ft_like1 |
| Foreign table "public.ft_like1" |
| Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description |
| --------+---------+-----------+----------+---------+-------------+---------+--------------+------------- |
| a | integer | | | | | plain | | |
| b | integer | | | | | plain | | |
| c | integer | | | | | plain | | |
| Server: s0 |
| FDW options: (delimiter ',', mpp_execute 'all segments', num_segments '3') |
| |
| SELECT * FROM gp_distribution_policy WHERE localoid = 'ft_like1'::regclass::oid; |
| localoid | policytype | numsegments | distkey | distclass |
| ----------+------------+-------------+---------+----------- |
| (0 rows) |
| |
| DROP TABLE ft_source_table; |
| DROP FOREIGN TABLE ft_like; |
| DROP FOREIGN TABLE ft_like1; |
| --start_ignore |
| DROP FOREIGN DATA WRAPPER dummy CASCADE; |
| --end_ignore |