diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/encode.c | 20 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonpath_gram.y | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/regexp.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/varbit.c | 16 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 8 |
5 files changed, 29 insertions, 23 deletions
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index 61d318d93ca..a609d49c12c 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -15,6 +15,7 @@ #include <ctype.h> +#include "mb/pg_wchar.h" #include "utils/builtins.h" #include "utils/memutils.h" @@ -171,17 +172,19 @@ hex_encode(const char *src, size_t len, char *dst) } static inline char -get_hex(char c) +get_hex(const char *cp) { + unsigned char c = (unsigned char) *cp; int res = -1; - if (c > 0 && c < 127) - res = hexlookup[(unsigned char) c]; + if (c < 127) + res = hexlookup[c]; if (res < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid hexadecimal digit: \"%c\"", c))); + errmsg("invalid hexadecimal digit: \"%.*s\"", + pg_mblen(cp), cp))); return (char) res; } @@ -205,13 +208,15 @@ hex_decode(const char *src, size_t len, char *dst) s++; continue; } - v1 = get_hex(*s++) << 4; + v1 = get_hex(s) << 4; + s++; if (s >= srcend) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid hexadecimal data: odd number of digits"))); - v2 = get_hex(*s++); + v2 = get_hex(s); + s++; *p++ = v1 | v2; } @@ -338,7 +343,8 @@ pg_base64_decode(const char *src, size_t len, char *dst) if (b < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid symbol \"%c\" while decoding base64 sequence", (int) c))); + errmsg("invalid symbol \"%.*s\" found while decoding base64 sequence", + pg_mblen(s - 1), s - 1))); } /* add it to buffer */ buf = (buf << 6) + b; diff --git a/src/backend/utils/adt/jsonpath_gram.y b/src/backend/utils/adt/jsonpath_gram.y index f87db8ccf6b..88ef9550e9d 100644 --- a/src/backend/utils/adt/jsonpath_gram.y +++ b/src/backend/utils/adt/jsonpath_gram.y @@ -526,8 +526,8 @@ makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid input syntax for type %s", "jsonpath"), - errdetail("unrecognized flag character \"%c\" in LIKE_REGEX predicate", - flags->val[i]))); + errdetail("unrecognized flag character \"%.*s\" in LIKE_REGEX predicate", + pg_mblen(flags->val + i), flags->val + i))); break; } } diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 06f808652a4..c70c5eeeb37 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -423,8 +423,8 @@ parse_re_flags(pg_re_flags *flags, text *opts) default: ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid regular expression option: \"%c\"", - opt_p[i]))); + errmsg("invalid regular expression option: \"%.*s\"", + pg_mblen(opt_p + i), opt_p + i))); break; } } diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index f0c6a44b842..3c03459f519 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -230,8 +230,8 @@ bit_in(PG_FUNCTION_ARGS) else if (*sp != '0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("\"%c\" is not a valid binary digit", - *sp))); + errmsg("\"%.*s\" is not a valid binary digit", + pg_mblen(sp), sp))); x >>= 1; if (x == 0) @@ -255,8 +255,8 @@ bit_in(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("\"%c\" is not a valid hexadecimal digit", - *sp))); + errmsg("\"%.*s\" is not a valid hexadecimal digit", + pg_mblen(sp), sp))); if (bc) { @@ -531,8 +531,8 @@ varbit_in(PG_FUNCTION_ARGS) else if (*sp != '0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("\"%c\" is not a valid binary digit", - *sp))); + errmsg("\"%.*s\" is not a valid binary digit", + pg_mblen(sp), sp))); x >>= 1; if (x == 0) @@ -556,8 +556,8 @@ varbit_in(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("\"%c\" is not a valid hexadecimal digit", - *sp))); + errmsg("\"%.*s\" is not a valid hexadecimal digit", + pg_mblen(sp), sp))); if (bc) { diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 2eaabd6231d..df10bfb906e 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -5586,8 +5586,8 @@ text_format(PG_FUNCTION_ARGS) if (strchr("sIL", *cp) == NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("unrecognized format() type specifier \"%c\"", - *cp), + errmsg("unrecognized format() type specifier \"%.*s\"", + pg_mblen(cp), cp), errhint("For a single \"%%\" use \"%%%%\"."))); /* If indirect width was specified, get its value */ @@ -5707,8 +5707,8 @@ text_format(PG_FUNCTION_ARGS) /* should not get here, because of previous check */ ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("unrecognized format() type specifier \"%c\"", - *cp), + errmsg("unrecognized format() type specifier \"%.*s\"", + pg_mblen(cp), cp), errhint("For a single \"%%\" use \"%%%%\"."))); break; } |