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

Function transformGenericOptions

src/backend/commands/foreigncmds.c:120–216  ·  view source on GitHub ↗

* Transform a list of DefElem into text array format. This is substantially * the same thing as optionListToArray(), except we recognize SET/ADD/DROP * actions for modifying an existing list of options, which is passed in * Datum form as oldOptions. Also, if fdwvalidator isn't InvalidOid * it specifies a validator function to call on the result. * * Returns the array in the form of a Datum

Source from the content-addressed store, hash-verified

118 * FOREIGN TABLE.
119 */
120Datum
121transformGenericOptions(Oid catalogId,
122 Datum oldOptions,
123 List *options,
124 Oid fdwvalidator)
125{
126 List *resultOptions = untransformRelOptions(oldOptions);
127 ListCell *optcell;
128 Datum result;
129
130 foreach(optcell, options)
131 {
132 DefElem *od = lfirst(optcell);
133 ListCell *cell;
134
135 /*
136 * Find the element in resultOptions. We need this for validation in
137 * all cases.
138 */
139 foreach(cell, resultOptions)
140 {
141 DefElem *def = lfirst(cell);
142
143 if (strcmp(def->defname, od->defname) == 0)
144 break;
145 }
146
147 /*
148 * It is possible to perform multiple SET/DROP actions on the same
149 * option. The standard permits this, as long as the options to be
150 * added are unique. Note that an unspecified action is taken to be
151 * ADD.
152 */
153 switch (od->defaction)
154 {
155 case DEFELEM_DROP:
156 if (!cell)
157 ereport(ERROR,
158 (errcode(ERRCODE_UNDEFINED_OBJECT),
159 errmsg("option \"%s\" not found",
160 od->defname)));
161 resultOptions = list_delete_cell(resultOptions, cell);
162 break;
163
164 case DEFELEM_SET:
165 if (!cell)
166 ereport(ERROR,
167 (errcode(ERRCODE_UNDEFINED_OBJECT),
168 errmsg("option \"%s\" not found",
169 od->defname)));
170 lfirst(cell) = od;
171 break;
172
173 case DEFELEM_ADD:
174 case DEFELEM_UNSPEC:
175 if (cell)
176 ereport(ERROR,
177 (errcode(ERRCODE_DUPLICATE_OBJECT),

Callers 10

CreateForeignDataWrapperFunction · 0.85
AlterForeignDataWrapperFunction · 0.85
CreateForeignServerFunction · 0.85
AlterForeignServerFunction · 0.85
CreateUserMappingFunction · 0.85
AlterUserMappingFunction · 0.85
AddForeignSegFunction · 0.85
CreateForeignTableFunction · 0.85
ATExecGenericOptionsFunction · 0.85

Calls 11

untransformRelOptionsFunction · 0.85
list_delete_cellFunction · 0.85
lappendFunction · 0.85
SeparateOutMppExecuteFunction · 0.85
SeparateOutNumSegmentsFunction · 0.85
construct_empty_arrayFunction · 0.85
ObjectIdGetDatumFunction · 0.85
optionListToArrayFunction · 0.70
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected