78 foreach(cell, options_list)
92 for (opt = postgres_fdw_options; opt->
keyword; opt++)
100 (
errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
102 errhint(
"Valid options in this context are: %s",
109 if (strcmp(def->
defname,
"use_remote_estimate") == 0 ||
110 strcmp(def->
defname,
"updatable") == 0 ||
111 strcmp(def->
defname,
"truncatable") == 0 ||
112 strcmp(def->
defname,
"async_capable") == 0 ||
113 strcmp(def->
defname,
"keep_connections") == 0)
118 else if (strcmp(def->
defname,
"fdw_startup_cost") == 0 ||
119 strcmp(def->
defname,
"fdw_tuple_cost") == 0)
126 if (*endp || val < 0)
128 (
errcode(ERRCODE_SYNTAX_ERROR),
129 errmsg(
"%s requires a non-negative numeric value",
132 else if (strcmp(def->
defname,
"extensions") == 0)
137 else if (strcmp(def->
defname,
"fetch_size") == 0)
144 (
errcode(ERRCODE_SYNTAX_ERROR),
145 errmsg(
"%s requires a non-negative integer value",
148 else if (strcmp(def->
defname,
"batch_size") == 0)
155 (
errcode(ERRCODE_SYNTAX_ERROR),
156 errmsg(
"%s requires a non-negative integer value",
159 else if (strcmp(def->
defname,
"password_required") == 0)
172 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
173 errmsg(
"password_required=false is superuser-only"),
174 errhint(
"User mappings with the password_required option set to false may only be created or modified by the superuser")));
176 else if (strcmp(def->
defname,
"sslcert") == 0 ||
177 strcmp(def->
defname,
"sslkey") == 0)
180 if (catalog == UserMappingRelationId && !
superuser())
182 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
183 errmsg(
"sslcert and sslkey are superuser-only"),
184 errhint(
"User mappings with the sslcert or sslkey options set may only be created or modified by the superuser")));
203 {
"schema_name", ForeignTableRelationId,
false},
204 {
"table_name", ForeignTableRelationId,
false},
205 {
"column_name", AttributeRelationId,
false},
207 {
"use_remote_estimate", ForeignServerRelationId,
false},
208 {
"use_remote_estimate", ForeignTableRelationId,
false},
210 {
"fdw_startup_cost", ForeignServerRelationId,
false},
211 {
"fdw_tuple_cost", ForeignServerRelationId,
false},
213 {
"extensions", ForeignServerRelationId,
false},
215 {
"updatable", ForeignServerRelationId,
false},
216 {
"updatable", ForeignTableRelationId,
false},
218 {
"truncatable", ForeignServerRelationId,
false},
219 {
"truncatable", ForeignTableRelationId,
false},
221 {
"fetch_size", ForeignServerRelationId,
false},
222 {
"fetch_size", ForeignTableRelationId,
false},
224 {
"batch_size", ForeignServerRelationId,
false},
225 {
"batch_size", ForeignTableRelationId,
false},
227 {
"async_capable", ForeignServerRelationId,
false},
228 {
"async_capable", ForeignTableRelationId,
false},
229 {
"keep_connections", ForeignServerRelationId,
false},
230 {
"password_required", UserMappingRelationId,
false},
237 {
"sslcert", UserMappingRelationId,
true},
238 {
"sslkey", UserMappingRelationId,
true},
244 if (postgres_fdw_options)
257 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
259 errdetail(
"Could not get libpq's default connection options.")));
263 for (lopt = libpq_options; lopt->
keyword; lopt++)
277 sizeof(non_libpq_options));
278 if (postgres_fdw_options == NULL)
280 (
errcode(ERRCODE_FDW_OUT_OF_MEMORY),
281 errmsg(
"out of memory")));
284 for (lopt = libpq_options; lopt->
keyword; lopt++)
288 strcmp(lopt->
keyword,
"fallback_application_name") == 0 ||
289 strcmp(lopt->
keyword,
"client_encoding") == 0)
309 memcpy(popt, non_libpq_options,
sizeof(non_libpq_options));
321 Assert(postgres_fdw_options);
323 for (opt = postgres_fdw_options; opt->
keyword; opt++)
340 Assert(postgres_fdw_options);
342 for (opt = postgres_fdw_options; opt->
keyword; opt++)
367 foreach(lc, defelems)
399 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
400 errmsg(
"parameter \"%s\" must be a list of extension names",
406 const char *extension_name = (
const char *)
lfirst(lc);
411 extensionOids =
lappend_oid(extensionOids, extension_oid);
413 else if (warnOnMissing)
416 (
errcode(ERRCODE_UNDEFINED_OBJECT),
417 errmsg(
"extension \"%s\" is not installed",
423 return extensionOids;
PG_FUNCTION_INFO_V1(postgres_fdw_validator)
int errhint(const char *fmt,...)
#define PG_GETARG_DATUM(n)
char * pstrdup(const char *in)
static bool is_valid_option(const char *keyword, Oid context)
int errcode(int sqlerrcode)
List * lappend_oid(List *list, Oid datum)
#define OidIsValid(objectId)
static PgFdwOption * postgres_fdw_options
struct PgFdwOption PgFdwOption
bool defGetBoolean(DefElem *def)
int ExtractConnectionOptions(List *defelems, const char **keywords, const char **values)
void appendStringInfo(StringInfo str, const char *fmt,...)
char * defGetString(DefElem *def)
List * ExtractExtensionList(const char *extensionsString, bool warnOnMissing)
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
int errdetail(const char *fmt,...)
void initStringInfo(StringInfo str)
List * untransformRelOptions(Datum options)
Datum postgres_fdw_validator(PG_FUNCTION_ARGS)
#define ereport(elevel,...)
#define Assert(condition)
PQconninfoOption * PQconndefaults(void)
static Datum values[MAXATTR]
Oid get_extension_oid(const char *extname, bool missing_ok)
int errmsg(const char *fmt,...)
void list_free(List *list)
static bool is_libpq_option(const char *keyword)
static PQconninfoOption * libpq_options
static void InitPgFdwOptions(void)