Commit a90e9d66 authored by Tatsuo Ishii's avatar Tatsuo Ishii

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.
parent 11a0c374
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.181 2005/04/06 16:34:06 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.182 2005/05/24 15:45:34 ishii Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "catalog/pg_operator.h" #include "catalog/pg_operator.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "nodes/params.h" #include "nodes/params.h"
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
bool Transform_null_equals = false; bool Transform_null_equals = false;
static Node *transformParamRef(ParseState *pstate, ParamRef *pref); static Node *transformParamRef(ParseState *pstate, ParamRef *pref);
...@@ -1553,7 +1553,13 @@ exprTypmod(Node *expr) ...@@ -1553,7 +1553,13 @@ exprTypmod(Node *expr)
{ {
case BPCHAROID: case BPCHAROID:
if (!con->constisnull) if (!con->constisnull)
return VARSIZE(DatumGetPointer(con->constvalue)); {
int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ;
if (pg_database_encoding_max_length() > 1)
len = pg_mbstrlen_with_len(VARDATA(DatumGetPointer(con->constvalue)), len);
return len + VARHDRSZ;
}
break; break;
default: default:
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment