MCPcopy Create free account
hub / github.com/apache/cloudberry / postgres_fdw_validator

Function postgres_fdw_validator

contrib/postgres_fdw/option.c:65–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63PG_FUNCTION_INFO_V1(postgres_fdw_validator);
64
65Datum
66postgres_fdw_validator(PG_FUNCTION_ARGS)
67{
68 List *options_list = untransformRelOptions(PG_GETARG_DATUM(0));
69 Oid catalog = PG_GETARG_OID(1);
70 ListCell *cell;
71
72 /* Build our options lists if we didn't yet. */
73 InitPgFdwOptions();
74
75 /*
76 * Check that only options supported by postgres_fdw, and allowed for the
77 * current object type, are given.
78 */
79 foreach(cell, options_list)
80 {
81 DefElem *def = (DefElem *) lfirst(cell);
82
83 if (!is_valid_option(def->defname, catalog))
84 {
85 /*
86 * Unknown option specified, complain about it. Provide a hint
87 * with list of valid options for the object.
88 */
89 PgFdwOption *opt;
90 StringInfoData buf;
91
92 initStringInfo(&buf);
93 for (opt = postgres_fdw_options; opt->keyword; opt++)
94 {
95 if (catalog == opt->optcontext)
96 appendStringInfo(&buf, "%s%s", (buf.len > 0) ? ", " : "",
97 opt->keyword);
98 }
99
100 ereport(ERROR,
101 (errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
102 errmsg("invalid option \"%s\"", def->defname),
103 errhint("Valid options in this context are: %s",
104 buf.data)));
105 }
106
107 /*
108 * Validate option value, when we can do so without any context.
109 */
110 if (strcmp(def->defname, "use_remote_estimate") == 0 ||
111 strcmp(def->defname, "updatable") == 0 ||
112 strcmp(def->defname, "truncatable") == 0 ||
113 strcmp(def->defname, "async_capable") == 0 ||
114 strcmp(def->defname, "keep_connections") == 0)
115 {
116 /* these accept only boolean values */
117 (void) defGetBoolean(def);
118 }
119 else if (strcmp(def->defname, "fdw_startup_cost") == 0 ||
120 strcmp(def->defname, "fdw_tuple_cost") == 0)
121 {
122 /*

Callers

nothing calls this directly

Calls 15

untransformRelOptionsFunction · 0.85
InitPgFdwOptionsFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
defGetBooleanFunction · 0.85
defGetStringFunction · 0.85
parse_realFunction · 0.85
ExtractExtensionListFunction · 0.85
parse_intFunction · 0.85
superuserFunction · 0.85
is_valid_optionFunction · 0.70
foreachFunction · 0.50

Tested by

no test coverage detected