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

Function escape_replace

src/test/modules/test_escape/test_escape.c:185–209  ·  view source on GitHub ↗

* Escape via s/'/''/. Non-core drivers invariably wrap libpq or use this * method. It suffices iff the input passes encoding validation, so it's * marked as supports_only_valid. */

Source from the content-addressed store, hash-verified

183 * marked as supports_only_valid.
184 */
185static bool
186escape_replace(PGconn *conn, PQExpBuffer target,
187 const char *unescaped, size_t unescaped_len,
188 PQExpBuffer escape_err)
189{
190 const char *s = unescaped;
191
192 appendPQExpBufferChar(target, '\'');
193
194 for (int i = 0; i < unescaped_len; i++)
195 {
196 char c = *s;
197
198 if (c == '\'')
199 {
200 appendPQExpBufferStr(target, "''");
201 }
202 else
203 appendPQExpBufferChar(target, c);
204 s++;
205 }
206 appendPQExpBufferChar(target, '\'');
207
208 return true;
209}
210
211static bool
212escape_append_literal(PGconn *conn, PQExpBuffer target,

Callers

nothing calls this directly

Calls 2

appendPQExpBufferCharFunction · 0.85
appendPQExpBufferStrFunction · 0.85

Tested by

no test coverage detected