Skip to content

Commit 84d0865

Browse files
committed
Make scanner multibyte aware. Currently it may produce an incorrect
multibyte sequence while truncating identifiers.
1 parent bc2cf76 commit 84d0865

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/backend/parser/scan.l

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.75 2000/08/12 05:15:21 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.76 2000/08/22 13:01:20 ishii Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -31,6 +31,10 @@
3131
#include "parser/scansup.h"
3232
#include "utils/builtins.h"
3333

34+
#ifdef MULTIBYTE
35+
#include "mb/pg_wchar.h"
36+
#endif
37+
3438
extern char *parseString;
3539
static char *parseCh;
3640

@@ -345,9 +349,17 @@ other .
345349
BEGIN(INITIAL);
346350
if (strlen(literalbuf) >= NAMEDATALEN)
347351
{
352+
#ifdef MULTIBYTE
353+
int len;
354+
len = pg_mbcliplen(literalbuf,strlen(literalbuf),NAMEDATALEN-1);
355+
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
356+
literalbuf, len, literalbuf);
357+
literalbuf[len] = '\0';
358+
#else
348359
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
349360
literalbuf, NAMEDATALEN-1, literalbuf);
350361
literalbuf[NAMEDATALEN-1] = '\0';
362+
#endif
351363
}
352364
yylval.str = pstrdup(literalbuf);
353365
return IDENT;
@@ -471,9 +483,17 @@ other .
471483
yytext[i] = tolower(yytext[i]);
472484
if (i >= NAMEDATALEN)
473485
{
486+
#ifdef MULTIBYTE
487+
int len;
488+
len = pg_mbcliplen(yytext,i,NAMEDATALEN-1);
489+
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
490+
yytext, len, yytext);
491+
yytext[len] = '\0';
492+
#else
474493
elog(NOTICE, "identifier \"%s\" will be truncated to \"%.*s\"",
475494
yytext, NAMEDATALEN-1, yytext);
476495
yytext[NAMEDATALEN-1] = '\0';
496+
#endif
477497
}
478498
keyword = ScanKeywordLookup((char*)yytext);
479499
if (keyword != NULL) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy