* 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. */
| 183 | * marked as supports_only_valid. |
| 184 | */ |
| 185 | static bool |
| 186 | escape_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 | |
| 211 | static bool |
| 212 | escape_append_literal(PGconn *conn, PQExpBuffer target, |
nothing calls this directly
no test coverage detected