summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2005-05-24 23:52:02 +0000
committerTatsuo Ishii <ishii@postgresql.org>2005-05-24 23:52:02 +0000
commit8f5702ebd514faf5ddcd4c3443567bfa9bd9f98a (patch)
treec9a5aae10c2126a01679de5e1276927dd485c2df /src
parente3d0bd8d48a4ba9aa236e6cc901676ad0198ea95 (diff)
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')
-rw-r--r--src/backend/parser/parse_expr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index ebb418ee904..745bc9e7877 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.129.2.1 2002/12/27 20:06:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.129.2.2 2005/05/24 23:52:02 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
+#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/params.h"
@@ -979,7 +980,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;