85 foreach(cell, options_list)
96 const char *closest_match;
98 bool has_valid_options =
false;
105 has_valid_options =
true;
112 (
errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
114 has_valid_options ? closest_match ?
115 errhint(
"Perhaps you meant the option \"%s\".",
117 errhint(
"There are no valid options in this context.")));
123 if (strcmp(def->
defname,
"use_remote_estimate") == 0 ||
124 strcmp(def->
defname,
"updatable") == 0 ||
125 strcmp(def->
defname,
"truncatable") == 0 ||
126 strcmp(def->
defname,
"async_capable") == 0 ||
127 strcmp(def->
defname,
"parallel_commit") == 0 ||
128 strcmp(def->
defname,
"parallel_abort") == 0 ||
129 strcmp(def->
defname,
"keep_connections") == 0)
134 else if (strcmp(def->
defname,
"fdw_startup_cost") == 0 ||
135 strcmp(def->
defname,
"fdw_tuple_cost") == 0)
150 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
151 errmsg(
"invalid value for floating point option \"%s\": %s",
156 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
157 errmsg(
"\"%s\" must be a floating point value greater than or equal to zero",
160 else if (strcmp(def->
defname,
"extensions") == 0)
165 else if (strcmp(def->
defname,
"fetch_size") == 0 ||
166 strcmp(def->
defname,
"batch_size") == 0)
177 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
178 errmsg(
"invalid value for integer option \"%s\": %s",
183 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
184 errmsg(
"\"%s\" must be an integer value greater than zero",
187 else if (strcmp(def->
defname,
"password_required") == 0)
200 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
201 errmsg(
"password_required=false is superuser-only"),
202 errhint(
"User mappings with the password_required option set to false may only be created or modified by the superuser.")));
204 else if (strcmp(def->
defname,
"sslcert") == 0 ||
205 strcmp(def->
defname,
"sslkey") == 0)
208 if (catalog == UserMappingRelationId && !
superuser())
210 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
211 errmsg(
"sslcert and sslkey are superuser-only"),
212 errhint(
"User mappings with the sslcert or sslkey options set may only be created or modified by the superuser.")));
214 else if (strcmp(def->
defname,
"analyze_sampling") == 0)
221 if (strcmp(
value,
"off") != 0 &&
222 strcmp(
value,
"auto") != 0 &&
223 strcmp(
value,
"random") != 0 &&
224 strcmp(
value,
"system") != 0 &&
225 strcmp(
value,
"bernoulli") != 0)
227 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
228 errmsg(
"invalid value for string option \"%s\": %s",
248 {
"schema_name", ForeignTableRelationId,
false},
249 {
"table_name", ForeignTableRelationId,
false},
250 {
"column_name", AttributeRelationId,
false},
252 {
"use_remote_estimate", ForeignServerRelationId,
false},
253 {
"use_remote_estimate", ForeignTableRelationId,
false},
255 {
"fdw_startup_cost", ForeignServerRelationId,
false},
256 {
"fdw_tuple_cost", ForeignServerRelationId,
false},
258 {
"extensions", ForeignServerRelationId,
false},
260 {
"updatable", ForeignServerRelationId,
false},
261 {
"updatable", ForeignTableRelationId,
false},
263 {
"truncatable", ForeignServerRelationId,
false},
264 {
"truncatable", ForeignTableRelationId,
false},
266 {
"fetch_size", ForeignServerRelationId,
false},
267 {
"fetch_size", ForeignTableRelationId,
false},
269 {
"batch_size", ForeignServerRelationId,
false},
270 {
"batch_size", ForeignTableRelationId,
false},
272 {
"async_capable", ForeignServerRelationId,
false},
273 {
"async_capable", ForeignTableRelationId,
false},
274 {
"parallel_commit", ForeignServerRelationId,
false},
275 {
"parallel_abort", ForeignServerRelationId,
false},
276 {
"keep_connections", ForeignServerRelationId,
false},
277 {
"password_required", UserMappingRelationId,
false},
280 {
"analyze_sampling", ForeignServerRelationId,
false},
281 {
"analyze_sampling", ForeignTableRelationId,
false},
288 {
"sslcert", UserMappingRelationId,
true},
289 {
"sslkey", UserMappingRelationId,
true},
295 {
"gssdelegation", UserMappingRelationId,
true},
314 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
316 errdetail(
"Could not get libpq's default connection options.")));
334 sizeof(non_libpq_options));
337 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
338 errmsg(
"out of memory")));
345 strcmp(lopt->
keyword,
"fallback_application_name") == 0 ||
346 strcmp(lopt->
keyword,
"client_encoding") == 0)
366 memcpy(popt, non_libpq_options,
sizeof(non_libpq_options));
424 foreach(lc, defelems)
456 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
457 errmsg(
"parameter \"%s\" must be a list of extension names",
463 const char *extension_name = (
const char *)
lfirst(lc);
468 extensionOids =
lappend_oid(extensionOids, extension_oid);
470 else if (warnOnMissing)
473 (
errcode(ERRCODE_UNDEFINED_OBJECT),
474 errmsg(
"extension \"%s\" is not installed",
480 return extensionOids;
498 for (p = appname; *p !=
'\0'; p++)
579 "Sets the application name to be used on the remote server.",
static Datum values[MAXATTR]
#define OidIsValid(objectId)
char * process_pgfdw_appname(const char *appname)
static bool is_valid_option(const char *keyword, Oid context)
static PQconninfoOption * libpq_options
int ExtractConnectionOptions(List *defelems, const char **keywords, const char **values)
static bool is_libpq_option(const char *keyword)
List * ExtractExtensionList(const char *extensionsString, bool warnOnMissing)
Datum postgres_fdw_validator(PG_FUNCTION_ARGS)
static PgFdwOption * postgres_fdw_options
struct PgFdwOption PgFdwOption
PG_FUNCTION_INFO_V1(postgres_fdw_validator)
char * pgfdw_application_name
static void InitPgFdwOptions(void)
bool defGetBoolean(DefElem *def)
char * defGetString(DefElem *def)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Oid get_extension_oid(const char *extname, bool missing_ok)
PQconninfoOption * PQconndefaults(void)
#define PG_GETARG_DATUM(n)
bool parse_int(const char *value, int *result, int flags, const char **hintmsg)
void DefineCustomStringVariable(const char *name, const char *short_desc, const char *long_desc, char **valueAddr, const char *bootValue, GucContext context, int flags, GucStringCheckHook check_hook, GucStringAssignHook assign_hook, GucShowHook show_hook)
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
void MarkGUCPrefixReserved(const char *className)
struct parser_state match_state[5]
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
char * pstrdup(const char *in)
List * untransformRelOptions(Datum options)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
const char * getClosestMatch(ClosestMatchState *state)
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
void initClosestMatch(ClosestMatchState *state, const char *source, int max_d)
void updateClosestMatch(ClosestMatchState *state, const char *candidate)