diff options
author | Tatsuo Ishii <ishii@postgresql.org> | 2005-05-24 23:02:54 +0000 |
---|---|---|
committer | Tatsuo Ishii <ishii@postgresql.org> | 2005-05-24 23:02:54 +0000 |
commit | 2a99455ca7f56cef0f0d77dee4c72ff430363668 (patch) | |
tree | 44da89320b45153fd3617ddf1a64536190c672ac /src/backend/parser/parse_expr.c | |
parent | a94ace0796b8719c6685351b02fe93459c206c38 (diff) | |
download | postgresql-2a99455ca7f56cef0f0d77dee4c72ff430363668.tar.gz postgresql-2a99455ca7f56cef0f0d77dee4c72ff430363668.zip |
Inserting 5 characters into char(10) does not produce 5 padding spaces
if they are two-byte multibyte characters. Same thing can be happen
if octet_length(multibyte_chars) == n where n is char(n).
Long standing bug since 7.3 days. Per report and fix from Yoshiyuki Asaba.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r-- | src/backend/parser/parse_expr.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 6676ae0a4bd..44936996508 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.179 2005/01/12 17:32:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.179.4.1 2005/05/24 23:02:54 ishii Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ #include "catalog/pg_operator.h" #include "catalog/pg_proc.h" #include "commands/dbcommands.h" +#include "mb/pg_wchar.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "nodes/params.h" @@ -34,7 +35,6 @@ #include "utils/lsyscache.h" #include "utils/syscache.h" - bool Transform_null_equals = false; static Node *transformColumnRef(ParseState *pstate, ColumnRef *cref); @@ -1491,7 +1491,13 @@ exprTypmod(Node *expr) { case BPCHAROID: if (!con->constisnull) - return VARSIZE(DatumGetPointer(con->constvalue)); + { + int32 len = VARSIZE(DatumGetPointer(con->constvalue)); + + if (pg_database_encoding_max_length() > 1) + len = pg_mbstrlen_with_len(VARDATA(DatumGetPointer(con->constvalue)), len); + return len; + } break; default: break; |