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

Function exec_command_encoding

src/bin/psql/command.c:1260–1294  ·  view source on GitHub ↗

* \encoding -- set/show client side encoding */

Source from the content-addressed store, hash-verified

1258 * \encoding -- set/show client side encoding
1259 */
1260static backslashResult
1261exec_command_encoding(PsqlScanState scan_state, bool active_branch)
1262{
1263 if (active_branch)
1264 {
1265 char *encoding = psql_scan_slash_option(scan_state,
1266 OT_NORMAL, NULL, false);
1267
1268 if (!encoding)
1269 {
1270 /* show encoding */
1271 puts(pg_encoding_to_char(pset.encoding));
1272 }
1273 else
1274 {
1275 /* set encoding */
1276 if (PQsetClientEncoding(pset.db, encoding) == -1)
1277 pg_log_error("%s: invalid encoding name or conversion procedure not found", encoding);
1278 else
1279 {
1280 /* save encoding info into psql internal data */
1281 pset.encoding = PQclientEncoding(pset.db);
1282 pset.popt.topt.encoding = pset.encoding;
1283 setFmtEncoding(pset.encoding);
1284 SetVariable(pset.vars, "ENCODING",
1285 pg_encoding_to_char(pset.encoding));
1286 }
1287 free(encoding);
1288 }
1289 }
1290 else
1291 ignore_slash_options(scan_state);
1292
1293 return PSQL_CMD_SKIP_LINE;
1294}
1295
1296/*
1297 * \errverbose -- display verbose message from last failed query

Callers 1

exec_commandFunction · 0.85

Calls 6

pg_encoding_to_charFunction · 0.85
PQsetClientEncodingFunction · 0.85
PQclientEncodingFunction · 0.85
setFmtEncodingFunction · 0.85
SetVariableFunction · 0.85
ignore_slash_optionsFunction · 0.85

Tested by

no test coverage detected