diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 6 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 15 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 294843ed8b0..4256ae5c0cc 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -4101,7 +4101,8 @@ PQescapeStringInternal(PGconn *conn, } /* Slow path for possible multibyte characters */ - charlen = pg_encoding_mblen(encoding, source); + charlen = pg_encoding_mblen_or_incomplete(encoding, + source, remaining); if (remaining < charlen || pg_encoding_verifymbchar(encoding, source, charlen) == -1) @@ -4245,7 +4246,8 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident) int charlen; /* Slow path for possible multibyte characters */ - charlen = pg_encoding_mblen(conn->client_encoding, s); + charlen = pg_encoding_mblen_or_incomplete(conn->client_encoding, + s, remaining); if (charlen > remaining) { diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index d78445c70af..2648df93813 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -1221,13 +1221,9 @@ PQgetCurrentTimeUSec(void) */ /* - * Returns the byte length of the character beginning at s, using the - * specified encoding. - * - * Caution: when dealing with text that is not certainly valid in the - * specified encoding, the result may exceed the actual remaining - * string length. Callers that are not prepared to deal with that - * should use PQmblenBounded() instead. + * Like pg_encoding_mblen(). Use this in callers that want the + * dynamically-linked libpq's stance on encodings, even if that means + * different behavior in different startups of the executable. */ int PQmblen(const char *s, int encoding) @@ -1236,8 +1232,9 @@ PQmblen(const char *s, int encoding) } /* - * Returns the byte length of the character beginning at s, using the - * specified encoding; but not more than the distance to end of string. + * Like pg_encoding_mblen_bounded(). Use this in callers that want the + * dynamically-linked libpq's stance on encodings, even if that means + * different behavior in different startups of the executable. */ int PQmblenBounded(const char *s, int encoding) |