summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2005-05-24 23:15:05 +0000
committerTatsuo Ishii <ishii@postgresql.org>2005-05-24 23:15:05 +0000
commitde212f4910dd9b75641a572b68a3fec5509974e3 (patch)
tree6cd5b20630607493e8544a9f6c987ec8086fca07
parent0a7b3a3649c7a03c432ef172f6b9efb3adc52868 (diff)
downloadpostgresql-de212f4910dd9b75641a572b68a3fec5509974e3.tar.gz
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.
-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 b40e895327..ce9ec2177c 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.163.2.1 2004/04/18 18:13:31 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.163.2.2 2005/05/24 23:15:05 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"
@@ -1356,7 +1357,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;