/*
* Describes the valid options for postgresql FDW, server, and user mapping.
*/
-struct ConnectionOption
+struct FdwOption
{
- const char *optname;
+ const char *optname; /* name of the option */
Oid optcontext; /* Oid of catalog in which option may appear */
+ bool is_conninfo; /* T if the option is a libpq conninfo option */
};
/*
*
* The list is small - don't bother with bsearch if it stays so.
*/
-static struct ConnectionOption libpq_conninfo_options[] = {
- {"authtype", ForeignServerRelationId},
- {"service", ForeignServerRelationId},
- {"user", UserMappingRelationId},
- {"password", UserMappingRelationId},
- {"connect_timeout", ForeignServerRelationId},
- {"dbname", ForeignServerRelationId},
- {"host", ForeignServerRelationId},
- {"hostaddr", ForeignServerRelationId},
- {"port", ForeignServerRelationId},
- {"tty", ForeignServerRelationId},
- {"options", ForeignServerRelationId},
- {"requiressl", ForeignServerRelationId},
- {"sslmode", ForeignServerRelationId},
- {"gsslib", ForeignServerRelationId},
- {NULL, InvalidOid}
+static struct FdwOption postgresql_fdw_options[] = {
+ /* libpq connection options */
+ {"authtype", ForeignServerRelationId, true},
+ {"service", ForeignServerRelationId, true},
+ {"user", UserMappingRelationId, true},
+ {"password", UserMappingRelationId, true},
+ {"connect_timeout", ForeignServerRelationId, true},
+ {"dbname", ForeignServerRelationId, true},
+ {"host", ForeignServerRelationId, true},
+ {"hostaddr", ForeignServerRelationId, true},
+ {"port", ForeignServerRelationId, true},
+ {"tty", ForeignServerRelationId, true},
+ {"options", ForeignServerRelationId, true},
+ {"requiressl", ForeignServerRelationId, true},
+ {"sslmode", ForeignServerRelationId, true},
+ {"gsslib", ForeignServerRelationId, true},
+ /* catalog options */
+ {"nspname", ForeignTableRelationId, false},
+ {"relname", ForeignTableRelationId, false},
+ {NULL, InvalidOid, false}
};
* context is the Oid of the catalog the option came from, or 0 if we
* don't care.
*/
-static bool
-is_conninfo_option(const char *option, Oid context)
+bool
+is_conninfo_option(const char *option)
{
- struct ConnectionOption *opt;
+ struct FdwOption *opt;
- for (opt = libpq_conninfo_options; opt->optname; opt++)
- if (context == opt->optcontext && strcmp(opt->optname, option) == 0)
+ for (opt = postgresql_fdw_options; opt->optname; opt++)
+ if (strcmp(opt->optname, option) == 0)
return true;
return false;
}
-
-/*
- * Valid options for postgresql_fdw objects.
- *
- * The list is small - don't bother with bsearch if it stays so.
- */
-static struct ConnectionOption fdw_options[] = {
- {"relname", ForeignTableRelationId},
- {"nspname", ForeignTableRelationId},
- {NULL, InvalidOid}
-};
-
-
/*
- * Check if the provided option is one of fdw options.
+ * Check if the provided option is one of postgresql_fdw options.
* context is the Oid of the catalog the option came from, or 0 if we
* don't care.
*/
static bool
-is_fdw_option(const char *option, Oid context)
+is_postgresql_fdw_option(const char *option, Oid context)
{
- struct ConnectionOption *opt;
+ struct FdwOption *opt;
- for (opt = fdw_options; opt->optname; opt++)
+ for (opt = postgresql_fdw_options; opt->optname; opt++)
if (context == opt->optcontext && strcmp(opt->optname, option) == 0)
return true;
return false;
{
DefElem *def = lfirst(cell);
- if (!is_conninfo_option(def->defname, catalog) &&
- !is_fdw_option(def->defname, catalog))
+ if (!is_postgresql_fdw_option(def->defname, catalog))
{
- struct ConnectionOption *opt;
+ struct FdwOption *opt;
StringInfoData buf;
/*
* with list of valid options for the object.
*/
initStringInfo(&buf);
- for (opt = libpq_conninfo_options; opt->optname; opt++)
+ for (opt = postgresql_fdw_options; opt->optname; opt++)
if (catalog == opt->optcontext)
appendStringInfo(&buf, "%s%s", (buf.len > 0) ? ", " : "",
opt->optname);