* This is used by CREATE/ALTER of FOREIGN DATA WRAPPER/SERVER/USER MAPPING.
*/
static Datum
-transformGenericOptions(Datum oldOptions,
+transformGenericOptions(Oid catalogId,
+ Datum oldOptions,
List *options,
Oid fdwvalidator)
{
result = optionListToArray(resultOptions);
if (fdwvalidator)
- OidFunctionCall2(fdwvalidator, result, (Datum) 0);
+ OidFunctionCall2(fdwvalidator, result, ObjectIdGetDatum(catalogId));
return result;
}
nulls[Anum_pg_foreign_data_wrapper_fdwacl - 1] = true;
- fdwoptions = transformGenericOptions(PointerGetDatum(NULL), stmt->options,
+ fdwoptions = transformGenericOptions(ForeignDataWrapperRelationId,
+ PointerGetDatum(NULL),
+ stmt->options,
fdwvalidator);
if (PointerIsValid(DatumGetPointer(fdwoptions)))
datum = PointerGetDatum(NULL);
/* Transform the options */
- datum = transformGenericOptions(datum, stmt->options, fdwvalidator);
+ datum = transformGenericOptions(ForeignDataWrapperRelationId,
+ datum,
+ stmt->options,
+ fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
repl_val[Anum_pg_foreign_data_wrapper_fdwoptions - 1] = datum;
nulls[Anum_pg_foreign_server_srvacl - 1] = true;
/* Add server options */
- srvoptions = transformGenericOptions(PointerGetDatum(NULL), stmt->options,
+ srvoptions = transformGenericOptions(ForeignServerRelationId,
+ PointerGetDatum(NULL),
+ stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(srvoptions)))
datum = PointerGetDatum(NULL);
/* Prepare the options array */
- datum = transformGenericOptions(datum, stmt->options,
+ datum = transformGenericOptions(ForeignServerRelationId,
+ datum,
+ stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
values[Anum_pg_user_mapping_umserver - 1] = ObjectIdGetDatum(srv->serverid);
/* Add user options */
- useoptions = transformGenericOptions(PointerGetDatum(NULL), stmt->options,
+ useoptions = transformGenericOptions(UserMappingRelationId,
+ PointerGetDatum(NULL),
+ stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(useoptions)))
datum = PointerGetDatum(NULL);
/* Prepare the options array */
- datum = transformGenericOptions(datum, stmt->options,
+ datum = transformGenericOptions(UserMappingRelationId,
+ datum,
+ stmt->options,
fdw->fdwvalidator);
if (PointerIsValid(DatumGetPointer(datum)))
CREATE SERVER s7 TYPE 'oracle' VERSION '17.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b');
CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (foo '1'); -- ERROR
ERROR: invalid option "foo"
-HINT: Valid options in this context are: authtype, service, user, password, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
+HINT: Valid options in this context are: authtype, service, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 's8db');
\des+
List of foreign servers
RESET ROLE;
ALTER SERVER s8 OPTIONS (foo '1'); -- ERROR option validation
ERROR: invalid option "foo"
-HINT: Valid options in this context are: authtype, service, user, password, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
+HINT: Valid options in this context are: authtype, service, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
ALTER SERVER s8 OPTIONS (connect_timeout '30', SET dbname 'db1', DROP host);
SET ROLE regress_test_role;
ALTER SERVER s1 OWNER TO regress_test_indirect; -- ERROR
CREATE USER MAPPING FOR public SERVER s4 OPTIONS (mapping 'is public');
CREATE USER MAPPING FOR user SERVER s8 OPTIONS (username 'test', password 'secret'); -- ERROR
ERROR: invalid option "username"
-HINT: Valid options in this context are: authtype, service, user, password, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
+HINT: Valid options in this context are: user, password
CREATE USER MAPPING FOR user SERVER s8 OPTIONS (user 'test', password 'secret');
ALTER SERVER s5 OWNER TO regress_test_role;
ALTER SERVER s6 OWNER TO regress_test_indirect;
ERROR: user mapping "public" does not exist for the server
ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (username 'test'); -- ERROR
ERROR: invalid option "username"
-HINT: Valid options in this context are: authtype, service, user, password, connect_timeout, dbname, host, hostaddr, port, tty, options, requiressl, sslmode, gsslib
+HINT: Valid options in this context are: user, password
ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (DROP user, SET password 'public');
SET ROLE regress_test_role;
ALTER USER MAPPING FOR current_user SERVER s5 OPTIONS (ADD modified '1');