84 foreach(cell, options_list)
95 const char *closest_match;
97 bool has_valid_options =
false;
104 has_valid_options =
true;
111 (
errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
113 has_valid_options ? closest_match ?
114 errhint(
"Perhaps you meant the option \"%s\".",
116 errhint(
"There are no valid options in this context.")));
122 if (strcmp(def->
defname,
"use_remote_estimate") == 0 ||
123 strcmp(def->
defname,
"updatable") == 0 ||
124 strcmp(def->
defname,
"truncatable") == 0 ||
125 strcmp(def->
defname,
"async_capable") == 0 ||
126 strcmp(def->
defname,
"parallel_commit") == 0 ||
127 strcmp(def->
defname,
"parallel_abort") == 0 ||
128 strcmp(def->
defname,
"keep_connections") == 0)
133 else if (strcmp(def->
defname,
"fdw_startup_cost") == 0 ||
134 strcmp(def->
defname,
"fdw_tuple_cost") == 0)
149 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
150 errmsg(
"invalid value for floating point option \"%s\": %s",
155 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
156 errmsg(
"\"%s\" must be a floating point value greater than or equal to zero",
159 else if (strcmp(def->
defname,
"extensions") == 0)
164 else if (strcmp(def->
defname,
"fetch_size") == 0 ||
165 strcmp(def->
defname,
"batch_size") == 0)
176 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
177 errmsg(
"invalid value for integer option \"%s\": %s",
182 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
183 errmsg(
"\"%s\" must be an integer value greater than zero",
186 else if (strcmp(def->
defname,
"password_required") == 0)
199 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
200 errmsg(
"password_required=false is superuser-only"),
201 errhint(
"User mappings with the password_required option set to false may only be created or modified by the superuser.")));
203 else if (strcmp(def->
defname,
"sslcert") == 0 ||
204 strcmp(def->
defname,
"sslkey") == 0)
207 if (catalog == UserMappingRelationId && !
superuser())
209 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
210 errmsg(
"sslcert and sslkey are superuser-only"),
211 errhint(
"User mappings with the sslcert or sslkey options set may only be created or modified by the superuser.")));
213 else if (strcmp(def->
defname,
"analyze_sampling") == 0)
220 if (strcmp(
value,
"off") != 0 &&
221 strcmp(
value,
"auto") != 0 &&
222 strcmp(
value,
"random") != 0 &&
223 strcmp(
value,
"system") != 0 &&
224 strcmp(
value,
"bernoulli") != 0)
226 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
227 errmsg(
"invalid value for string option \"%s\": %s",
247 {
"schema_name", ForeignTableRelationId,
false},
248 {
"table_name", ForeignTableRelationId,
false},
249 {
"column_name", AttributeRelationId,
false},
251 {
"use_remote_estimate", ForeignServerRelationId,
false},
252 {
"use_remote_estimate", ForeignTableRelationId,
false},
254 {
"fdw_startup_cost", ForeignServerRelationId,
false},
255 {
"fdw_tuple_cost", ForeignServerRelationId,
false},
257 {
"extensions", ForeignServerRelationId,
false},
259 {
"updatable", ForeignServerRelationId,
false},
260 {
"updatable", ForeignTableRelationId,
false},
262 {
"truncatable", ForeignServerRelationId,
false},
263 {
"truncatable", ForeignTableRelationId,
false},
265 {
"fetch_size", ForeignServerRelationId,
false},
266 {
"fetch_size", ForeignTableRelationId,
false},
268 {
"batch_size", ForeignServerRelationId,
false},
269 {
"batch_size", ForeignTableRelationId,
false},
271 {
"async_capable", ForeignServerRelationId,
false},
272 {
"async_capable", ForeignTableRelationId,
false},
273 {
"parallel_commit", ForeignServerRelationId,
false},
274 {
"parallel_abort", ForeignServerRelationId,
false},
275 {
"keep_connections", ForeignServerRelationId,
false},
276 {
"password_required", UserMappingRelationId,
false},
279 {
"analyze_sampling", ForeignServerRelationId,
false},
280 {
"analyze_sampling", ForeignTableRelationId,
false},
287 {
"sslcert", UserMappingRelationId,
true},
288 {
"sslkey", UserMappingRelationId,
true},
294 {
"gssdelegation", UserMappingRelationId,
true},
313 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
315 errdetail(
"Could not get libpq's default connection options.")));
333 sizeof(non_libpq_options));
336 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
337 errmsg(
"out of memory")));
344 strcmp(lopt->
keyword,
"fallback_application_name") == 0 ||
345 strcmp(lopt->
keyword,
"client_encoding") == 0)
365 memcpy(popt, non_libpq_options,
sizeof(non_libpq_options));
423 foreach(lc, defelems)
455 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
456 errmsg(
"parameter \"%s\" must be a list of extension names",
462 const char *extension_name = (
const char *)
lfirst(lc);
467 extensionOids =
lappend_oid(extensionOids, extension_oid);
469 else if (warnOnMissing)
472 (
errcode(ERRCODE_UNDEFINED_OBJECT),
473 errmsg(
"extension \"%s\" is not installed",
479 return extensionOids;
497 for (p = appname; *p !=
'\0'; p++)
578 "Sets the application name to be used on the remote server.",
static Datum values[MAXATTR]
#define Assert(condition)
#define OidIsValid(objectId)
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)
Datum postgres_fdw_validator(PG_FUNCTION_ARGS)
List * ExtractExtensionList(const char *extensionsString, bool warnOnMissing)
static PgFdwOption * postgres_fdw_options
struct PgFdwOption PgFdwOption
PG_FUNCTION_INFO_V1(postgres_fdw_validator)
char * pgfdw_application_name
char * process_pgfdw_appname(const char *appname)
static void InitPgFdwOptions(void)
char * defGetString(DefElem *def)
bool defGetBoolean(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]
static const JsonPathKeyword keywords[]
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)