87 foreach(cell, options_list)
109 (
errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
112 ?
errhint(
"Valid options in this context are: %s",
114 :
errhint(
"There are no valid options in this context.")));
120 if (strcmp(def->
defname,
"use_remote_estimate") == 0 ||
121 strcmp(def->
defname,
"updatable") == 0 ||
122 strcmp(def->
defname,
"truncatable") == 0 ||
123 strcmp(def->
defname,
"async_capable") == 0 ||
124 strcmp(def->
defname,
"parallel_commit") == 0 ||
125 strcmp(def->
defname,
"keep_connections") == 0)
130 else if (strcmp(def->
defname,
"fdw_startup_cost") == 0 ||
131 strcmp(def->
defname,
"fdw_tuple_cost") == 0)
146 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
147 errmsg(
"invalid value for floating point option \"%s\": %s",
152 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
153 errmsg(
"\"%s\" must be a floating point value greater than or equal to zero",
156 else if (strcmp(def->
defname,
"extensions") == 0)
161 else if (strcmp(def->
defname,
"fetch_size") == 0 ||
162 strcmp(def->
defname,
"batch_size") == 0)
173 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
174 errmsg(
"invalid value for integer option \"%s\": %s",
179 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
180 errmsg(
"\"%s\" must be an integer value greater than zero",
183 else if (strcmp(def->
defname,
"password_required") == 0)
196 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
197 errmsg(
"password_required=false is superuser-only"),
198 errhint(
"User mappings with the password_required option set to false may only be created or modified by the superuser")));
200 else if (strcmp(def->
defname,
"sslcert") == 0 ||
201 strcmp(def->
defname,
"sslkey") == 0)
204 if (catalog == UserMappingRelationId && !
superuser())
206 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
207 errmsg(
"sslcert and sslkey are superuser-only"),
208 errhint(
"User mappings with the sslcert or sslkey options set may only be created or modified by the superuser")));
227 {
"schema_name", ForeignTableRelationId,
false},
228 {
"table_name", ForeignTableRelationId,
false},
229 {
"column_name", AttributeRelationId,
false},
231 {
"use_remote_estimate", ForeignServerRelationId,
false},
232 {
"use_remote_estimate", ForeignTableRelationId,
false},
234 {
"fdw_startup_cost", ForeignServerRelationId,
false},
235 {
"fdw_tuple_cost", ForeignServerRelationId,
false},
237 {
"extensions", ForeignServerRelationId,
false},
239 {
"updatable", ForeignServerRelationId,
false},
240 {
"updatable", ForeignTableRelationId,
false},
242 {
"truncatable", ForeignServerRelationId,
false},
243 {
"truncatable", ForeignTableRelationId,
false},
245 {
"fetch_size", ForeignServerRelationId,
false},
246 {
"fetch_size", ForeignTableRelationId,
false},
248 {
"batch_size", ForeignServerRelationId,
false},
249 {
"batch_size", ForeignTableRelationId,
false},
251 {
"async_capable", ForeignServerRelationId,
false},
252 {
"async_capable", ForeignTableRelationId,
false},
253 {
"parallel_commit", ForeignServerRelationId,
false},
254 {
"keep_connections", ForeignServerRelationId,
false},
255 {
"password_required", UserMappingRelationId,
false},
262 {
"sslcert", UserMappingRelationId,
true},
263 {
"sslkey", UserMappingRelationId,
true},
282 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
284 errdetail(
"Could not get libpq's default connection options.")));
302 sizeof(non_libpq_options));
305 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
306 errmsg(
"out of memory")));
313 strcmp(lopt->
keyword,
"fallback_application_name") == 0 ||
314 strcmp(lopt->
keyword,
"client_encoding") == 0)
334 memcpy(popt, non_libpq_options,
sizeof(non_libpq_options));
392 foreach(lc, defelems)
424 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
425 errmsg(
"parameter \"%s\" must be a list of extension names",
431 const char *extension_name = (
const char *)
lfirst(lc);
436 extensionOids =
lappend_oid(extensionOids, extension_oid);
438 else if (warnOnMissing)
441 (
errcode(ERRCODE_UNDEFINED_OBJECT),
442 errmsg(
"extension \"%s\" is not installed",
448 return extensionOids;
468 for (p = appname; *p !=
'\0'; p++)
533 "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)
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)
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)