Commit 620dbc98 authored by Tatsuo Ishii's avatar Tatsuo Ishii

make namein multibyte aware

parent 9310caf5
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.36 2002/06/11 13:40:52 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.37 2002/06/13 06:19:45 ishii Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "mb/pg_wchar.h"
/***************************************************************************** /*****************************************************************************
* USER I/O ROUTINES (none) * * USER I/O ROUTINES (none) *
...@@ -43,16 +43,20 @@ namein(PG_FUNCTION_ARGS) ...@@ -43,16 +43,20 @@ namein(PG_FUNCTION_ARGS)
char *s = PG_GETARG_CSTRING(0); char *s = PG_GETARG_CSTRING(0);
NameData *result; NameData *result;
int len; int len;
char *ermsg;
/* veryfy encoding */
len = strlen(s);
if ((ermsg = pg_verifymbstr(s, len)))
elog(ERROR, "%s", ermsg);
len = pg_mbcliplen(s, len, NAMEDATALEN-1);
result = (NameData *) palloc(NAMEDATALEN); result = (NameData *) palloc(NAMEDATALEN);
/* always keep it null-padded */ /* always keep it null-padded */
StrNCpy(NameStr(*result), s, NAMEDATALEN); memset(result, 0, NAMEDATALEN);
len = strlen(NameStr(*result)); memcpy(NameStr(*result), s, len);
while (len < NAMEDATALEN)
{
*(NameStr(*result) + len) = '\0';
len++;
}
PG_RETURN_NAME(result); PG_RETURN_NAME(result);
} }
......
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