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

Function transformStorageGenericOptions

src/backend/commands/storagecmds.c:237–309  ·  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. * * Returns the array in the form of a Datum, or PointerGetDatum(NULL) * if the list is empty. * * This is used by CREATE/ALTER of STORAGE SE

Source from the content-addressed store, hash-verified

235 * This is used by CREATE/ALTER of STORAGE SERVER/USER MAPPING
236 */
237Datum
238transformStorageGenericOptions(Oid catalogId,
239 Datum oldOptions,
240 List *options)
241{
242 List *resultOptions = untransformRelOptions(oldOptions);
243 ListCell *optcell;
244 Datum result;
245
246 foreach(optcell, options)
247 {
248 DefElem *od = lfirst(optcell);
249 ListCell *cell;
250
251 /*
252 * Find the element in resultOptions. We need this for validation in
253 * all cases.
254 */
255 foreach(cell, resultOptions)
256 {
257 DefElem *def = lfirst(cell);
258
259 if (strcmp(def->defname, od->defname) == 0)
260 break;
261 }
262
263 /*
264 * It is possible to perform multiple SET/DROP actions on the same
265 * option. The standard permits this, as long as the options to be
266 * added are unique. Note that an unspecified action is taken to be
267 * ADD.
268 */
269 switch (od->defaction)
270 {
271 case DEFELEM_DROP:
272 if (!cell)
273 ereport(ERROR,
274 (errcode(ERRCODE_UNDEFINED_OBJECT),
275 errmsg("option \"%s\" not found",
276 od->defname)));
277 resultOptions = list_delete_cell(resultOptions, cell);
278 break;
279
280 case DEFELEM_SET:
281 if (!cell)
282 ereport(ERROR,
283 (errcode(ERRCODE_UNDEFINED_OBJECT),
284 errmsg("option \"%s\" not found",
285 od->defname)));
286 lfirst(cell) = od;
287 break;
288
289 case DEFELEM_ADD:
290 case DEFELEM_UNSPEC:
291 if (cell)
292 ereport(ERROR,
293 (errcode(ERRCODE_DUPLICATE_OBJECT),
294 errmsg("option \"%s\" provided more than once",

Callers 4

CreateStorageServerFunction · 0.85
AlterStorageServerFunction · 0.85
CreateStorageUserMappingFunction · 0.85
AlterStorageUserMappingFunction · 0.85

Calls 7

untransformRelOptionsFunction · 0.85
list_delete_cellFunction · 0.85
lappendFunction · 0.85
optionListToArrayFunction · 0.70
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected