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

Function appendStringLiteralConn

src/fe_utils/string_utils.c:466–492  ·  view source on GitHub ↗

* Convert a string value to an SQL string literal and append it to * the given buffer. Encoding and string syntax rules are as indicated * by current settings of the PGconn. */

Source from the content-addressed store, hash-verified

464 * by current settings of the PGconn.
465 */
466void
467appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
468{
469 size_t length = strlen(str);
470
471 /*
472 * XXX This is a kluge to silence escape_string_warning in our utility
473 * programs. It should go away someday.
474 */
475 if (strchr(str, '\\') != NULL && PQserverVersion(conn) >= 80100)
476 {
477 /* ensure we are not adjacent to an identifier */
478 if (buf->len > 0 && buf->data[buf->len - 1] != ' ')
479 appendPQExpBufferChar(buf, ' ');
480 appendPQExpBufferChar(buf, ESCAPE_STRING_SYNTAX);
481 appendStringLiteral(buf, str, PQclientEncoding(conn), false);
482 return;
483 }
484 /* XXX end kluge */
485
486 if (!enlargePQExpBuffer(buf, 2 * length + 2))
487 return;
488 appendPQExpBufferChar(buf, '\'');
489 buf->len += PQescapeStringConn(conn, buf->data + buf->len,
490 str, length, NULL);
491 appendPQExpBufferChar(buf, '\'');
492}
493
494
495/*

Callers 15

processSQLNamePatternFunction · 0.85
exec_command_passwordFunction · 0.85
lookup_object_oidFunction · 0.85
dumpRolesFunction · 0.85
dumpTablespacesFunction · 0.85
dumpTagsFunction · 0.85
dumpUserConfigFunction · 0.85
dumpProfilesFunction · 0.85
emitShSecLabelsFunction · 0.85
makeAlterConfigCommandFunction · 0.85
setup_connectionFunction · 0.85
getTablesFunction · 0.85

Calls 6

PQserverVersionFunction · 0.85
appendPQExpBufferCharFunction · 0.85
appendStringLiteralFunction · 0.85
PQclientEncodingFunction · 0.85
enlargePQExpBufferFunction · 0.85
PQescapeStringConnFunction · 0.85

Tested by

no test coverage detected