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

Function ProcessCopyDirectoryTableOptions

src/backend/commands/copy.c:1072–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070}
1071
1072void
1073ProcessCopyDirectoryTableOptions(ParseState *pstate,
1074 CopyFormatOptions *opts_out,
1075 bool is_from,
1076 List *options,
1077 Oid rel_oid)
1078{
1079 bool format_specified = false;
1080 ListCell *option;
1081
1082 /* Support external use for option sanity checking */
1083 if (opts_out == NULL)
1084 opts_out = (CopyFormatOptions *) palloc0(sizeof(CopyFormatOptions));
1085
1086 opts_out->file_encoding = -1;
1087
1088 /* Extract options from the statement node tree */
1089 foreach(option, options)
1090 {
1091 DefElem *defel = lfirst_node(DefElem, option);
1092
1093 if (strcmp(defel->defname, "format") == 0)
1094 {
1095 char *fmt = defGetString(defel);
1096
1097 if (format_specified)
1098 ereport(ERROR,
1099 (errcode(ERRCODE_SYNTAX_ERROR),
1100 errmsg("conflicting or redundant options"),
1101 parser_errposition(pstate, defel->location)));
1102 format_specified = true;
1103 if (strcmp(fmt, "binary") == 0)
1104 opts_out->binary = true;
1105 else
1106 ereport(ERROR,
1107 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1108 errmsg("format option is not allowed in copy binary from directory table."),
1109 parser_errposition(pstate, defel->location)));
1110 }
1111 else if (strcmp(defel->defname, "tag") == 0)
1112 {
1113 if (opts_out->tags)
1114 ereport(ERROR,
1115 (errcode(ERRCODE_SYNTAX_ERROR),
1116 errmsg("conflicting or redundant options"),
1117 parser_errposition(pstate, defel->location)));
1118 opts_out->tags = defGetString(defel);
1119 }
1120 else
1121 ereport(ERROR,
1122 (errcode(ERRCODE_SYNTAX_ERROR),
1123 errmsg("option \"%s\" not recognized",
1124 defel->defname),
1125 parser_errposition(pstate, defel->location)));
1126 }
1127
1128 opts_out->eol_type = EOL_UNKNOWN;
1129

Callers 2

Calls 6

defGetStringFunction · 0.85
parser_errpositionFunction · 0.85
palloc0Function · 0.50
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected