diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 21a2ef5..01ea77d 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -8650,3 +8650,28 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700 -- Clean-up RESET enable_partitionwise_aggregate; +-- =================================================================== +-- test for options option +-- =================================================================== +BEGIN; +CREATE SERVER workmem1 FOREIGN DATA WRAPPER postgres_fdw OPTIONS( options '-c work_mem=64kB' ); +SELECT count(*) +FROM pg_foreign_server +WHERE srvname = 'workmem1' +AND srvoptions @> array['options=-c work_mem=64kB']; + count +------- + 1 +(1 row) + +ALTER SERVER workmem1 OPTIONS( SET options '-c work_mem=8MB' ); +SELECT count(*) +FROM pg_foreign_server +WHERE srvname = 'workmem1' +AND srvoptions @> array['options=-c work_mem=8MB']; + count +------- + 1 +(1 row) + +ROLLBACK; diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index 88c4cb4..c37c001 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -2354,3 +2354,24 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700 -- Clean-up RESET enable_partitionwise_aggregate; + +-- =================================================================== +-- test for options option +-- =================================================================== +BEGIN; + +CREATE SERVER workmem1 FOREIGN DATA WRAPPER postgres_fdw OPTIONS( options '-c work_mem=64kB' ); + +SELECT count(*) +FROM pg_foreign_server +WHERE srvname = 'workmem1' +AND srvoptions @> array['options=-c work_mem=64kB']; + +ALTER SERVER workmem1 OPTIONS( SET options '-c work_mem=8MB' ); + +SELECT count(*) +FROM pg_foreign_server +WHERE srvname = 'workmem1' +AND srvoptions @> array['options=-c work_mem=8MB']; + +ROLLBACK; diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml index 54b5e98..310f5ec 100644 --- a/doc/src/sgml/postgres-fdw.sgml +++ b/doc/src/sgml/postgres-fdw.sgml @@ -313,6 +313,17 @@ + + options + + + This option specifies the command-line options to send to the server at connection start. + For example, setting this to -c geqo=off sets the session's value of the geqo parameter to off. + To set more than one option, specify -c param=value repeatedly. + + + + diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index a8048ff..e85e67e 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -236,7 +236,7 @@ static const internalPQconninfoOption PQconninfoOptions[] = { offsetof(struct pg_conn, pgtty)}, {"options", "PGOPTIONS", DefaultOption, NULL, - "Backend-Debug-Options", "D", 40, + "Backend-Debug-Options", "", 40, offsetof(struct pg_conn, pgoptions)}, {"application_name", "PGAPPNAME", NULL, NULL,