Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit ea614bb

Browse files
authored
Separate out option 'num_segments' for foreign server validators (#15970)
We forgot to separate out the option 'num_segments' for the foreign server validators, which is supposed to be a public option for the FDW server layer. The test cases have been added in this commit: greenplum-db/gpdb@4eda660
1 parent 67f87c4 commit ea614bb

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

contrib/postgres_fdw/expected/gp_postgres_fdw.out

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ CREATE FOREIGN TABLE gp_ft1 (
8181
f2 text,
8282
f3 text
8383
) SERVER loopback OPTIONS (schema_name 'postgres_fdw_gp', table_name 'GP 1', mpp_execute 'all segments');
84+
CREATE FOREIGN TABLE gp_ft2 ( f1 int ) SERVER loopback OPTIONS (num_segments '3');
85+
ERROR: invalid option "num_segments"
86+
HINT: Valid options in this context are: schema_name, table_name, use_remote_estimate, updatable, fetch_size
8487
-- ===================================================================
8588
-- validate parallel writes (mpp_execute set to all segments)
8689
-- ===================================================================

contrib/postgres_fdw/expected/gp_postgres_fdw_optimizer.out

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ CREATE FOREIGN TABLE gp_ft1 (
8181
f2 text,
8282
f3 text
8383
) SERVER loopback OPTIONS (schema_name 'postgres_fdw_gp', table_name 'GP 1', mpp_execute 'all segments');
84+
CREATE FOREIGN TABLE gp_ft2 ( f1 int ) SERVER loopback OPTIONS (num_segments '3');
85+
ERROR: invalid option "num_segments"
86+
HINT: Valid options in this context are: schema_name, table_name, use_remote_estimate, updatable, fetch_size
8487
-- ===================================================================
8588
-- validate parallel writes (mpp_execute set to all segments)
8689
-- ===================================================================

contrib/postgres_fdw/option.c

-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ InitPgFdwOptions(void)
180180
/* fetch_size is available on both server and table */
181181
{"fetch_size", ForeignServerRelationId, false},
182182
{"fetch_size", ForeignTableRelationId, false},
183-
/* num_segments is available on server only */
184-
{"num_segments", ForeignServerRelationId, false},
185183
{NULL, InvalidOid, false}
186184
};
187185

contrib/postgres_fdw/sql/gp_postgres_fdw.sql

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ CREATE FOREIGN TABLE gp_ft1 (
9494
f3 text
9595
) SERVER loopback OPTIONS (schema_name 'postgres_fdw_gp', table_name 'GP 1', mpp_execute 'all segments');
9696

97+
CREATE FOREIGN TABLE gp_ft2 ( f1 int ) SERVER loopback OPTIONS (num_segments '3');
98+
9799
-- ===================================================================
98100
-- validate parallel writes (mpp_execute set to all segments)
99101
-- ===================================================================

src/backend/commands/foreigncmds.c

+5
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ transformGenericOptions(Oid catalogId,
196196
SeparateOutMppExecute(&resultOptions);
197197
}
198198

199+
if (catalogId == ForeignServerRelationId)
200+
{
201+
SeparateOutNumSegments(&resultOptions);
202+
}
203+
199204
if (OidIsValid(fdwvalidator))
200205
{
201206
Datum valarg = optionListToArray(resultOptions);

0 commit comments

Comments
 (0)