Make scanner multibyte aware. Currently it may produce an incorrect
multibyte sequence while truncating identifiers.
This commit is contained in:
parent
bc2cf76a59
commit
84d0865d03
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.75 2000/08/12 05:15:21 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.76 2000/08/22 13:01:20 ishii Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -31,6 +31,10 @@
|
||||||
#include "parser/scansup.h"
|
#include "parser/scansup.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
|
#ifdef MULTIBYTE
|
||||||
|
#include "mb/pg_wchar.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char *parseString;
|
extern char *parseString;
|
||||||
static char *parseCh;
|
static char *parseCh;
|
||||||
|
|
||||||
|
@ -345,9 +349,17 @@ other .
|
||||||
BEGIN(INITIAL);
|
BEGIN(INITIAL);
|
||||||
if (strlen(literalbuf) >= NAMEDATALEN)
|
if (strlen(literalbuf) >= NAMEDATALEN)
|
||||||
{
|
{
|
||||||
|
#ifdef MULTIBYTE
|
||||||
|
int len;
|
||||||
|
len = pg_mbcliplen(literalbuf,strlen(literalbuf),NAMEDATALEN-1);
|
||||||
|
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
||||||
|
literalbuf, len, literalbuf);
|
||||||
|
literalbuf[len] = '\0';
|
||||||
|
#else
|
||||||
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
||||||
literalbuf, NAMEDATALEN-1, literalbuf);
|
literalbuf, NAMEDATALEN-1, literalbuf);
|
||||||
literalbuf[NAMEDATALEN-1] = '\0';
|
literalbuf[NAMEDATALEN-1] = '\0';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
yylval.str = pstrdup(literalbuf);
|
yylval.str = pstrdup(literalbuf);
|
||||||
return IDENT;
|
return IDENT;
|
||||||
|
@ -471,9 +483,17 @@ other .
|
||||||
yytext[i] = tolower(yytext[i]);
|
yytext[i] = tolower(yytext[i]);
|
||||||
if (i >= NAMEDATALEN)
|
if (i >= NAMEDATALEN)
|
||||||
{
|
{
|
||||||
|
#ifdef MULTIBYTE
|
||||||
|
int len;
|
||||||
|
len = pg_mbcliplen(yytext,i,NAMEDATALEN-1);
|
||||||
|
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
||||||
|
yytext, len, yytext);
|
||||||
|
yytext[len] = '\0';
|
||||||
|
#else
|
||||||
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
|
||||||
yytext, NAMEDATALEN-1, yytext);
|
yytext, NAMEDATALEN-1, yytext);
|
||||||
yytext[NAMEDATALEN-1] = '\0';
|
yytext[NAMEDATALEN-1] = '\0';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
keyword = ScanKeywordLookup((char*)yytext);
|
keyword = ScanKeywordLookup((char*)yytext);
|
||||||
if (keyword != NULL) {
|
if (keyword != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue