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

Function validate_format_params

contrib/formatter_fixedwidth/fixedwidth.c:336–377  ·  view source on GitHub ↗

* validate_format_params * * verifies that every field specified in the table creation list is also present in the formatting string * and vice versa */

Source from the content-addressed store, hash-verified

334 * and vice versa
335 */
336static void
337validate_format_params(FormatConfig *format_in_config, TupleDesc tupdesc)
338{
339 ListCell *l;
340 int num_fields_in_format_string = list_length(format_in_config->fldNames);
341 int num_fields_in_table_list = tupdesc->natts;
342
343 if (num_fields_in_format_string != num_fields_in_table_list)
344 {
345 ereport(ERROR,
346 (errcode(ERRCODE_UNDEFINED_COLUMN),
347 errmsg("mismatch in column length specification"),
348 errdetail("The fixed width formatter requires a length specification for each one of the "
349 "external table columns being used (currently %d, however format string has %d).",
350 num_fields_in_table_list, num_fields_in_format_string)));
351 }
352
353 foreach(l, format_in_config->fldNames)
354 {
355 int i;
356 bool is_in_both_lists = false;
357 char *name = strVal(lfirst(l));
358 for (i = 0; i < num_fields_in_table_list; i++)
359 {
360 if (namestrcmp(&(TupleDescAttr(tupdesc, i)->attname), name) == 0)
361 {
362 is_in_both_lists = true;
363 break;
364 }
365 }
366
367 if (is_in_both_lists == false)
368 {
369 ereport(ERROR,
370 (errcode(ERRCODE_UNDEFINED_COLUMN),
371 errmsg("missing column definition in length specification"),
372 errdetail("The fixed width formatter requires a length specification for each one of the "
373 "external table columns being used (missing field \"%s\").",
374 name)));
375 }
376 }
377}
378
379static void
380init_format_in_config(FormatConfig *format_in_config, int ncolumns, TupleDesc tupdesc, FunctionCallInfo fcinfo)

Callers 2

init_format_in_configFunction · 0.85
init_format_out_configFunction · 0.85

Calls 6

list_lengthFunction · 0.85
namestrcmpFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected