mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Implement a solution to the 'Turkish locale downcases I incorrectly'
problem, per previous discussion. Make some additional changes to centralize the knowledge of just how identifier downcasing is done, in hopes of simplifying any future tweaking in this area.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.113 2004/02/19 19:11:30 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.114 2004/02/21 00:34:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "parser/keywords.h"
|
||||
/* Not needed now that this file is compiled as part of gram.y */
|
||||
/* #include "parser/parse.h" */
|
||||
#include "parser/scansup.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
|
||||
@@ -395,23 +396,15 @@ other .
|
||||
startlit();
|
||||
}
|
||||
<xd>{xdstop} {
|
||||
char *ident;
|
||||
|
||||
BEGIN(INITIAL);
|
||||
if (literallen == 0)
|
||||
yyerror("zero-length delimited identifier");
|
||||
ident = litbufdup();
|
||||
if (literallen >= NAMEDATALEN)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = pg_mbcliplen(literalbuf, literallen,
|
||||
NAMEDATALEN-1);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_NAME_TOO_LONG),
|
||||
errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
|
||||
literalbuf, len, literalbuf)));
|
||||
literalbuf[len] = '\0';
|
||||
literallen = len;
|
||||
}
|
||||
yylval.str = litbufdup();
|
||||
truncate_identifier(ident, literallen, true);
|
||||
yylval.str = ident;
|
||||
return IDENT;
|
||||
}
|
||||
<xd>{xddouble} {
|
||||
@@ -537,7 +530,6 @@ other .
|
||||
{identifier} {
|
||||
const ScanKeyword *keyword;
|
||||
char *ident;
|
||||
int i;
|
||||
|
||||
/* Is it a keyword? */
|
||||
keyword = ScanKeywordLookup(yytext);
|
||||
@@ -550,28 +542,8 @@ other .
|
||||
/*
|
||||
* No. Convert the identifier to lower case, and truncate
|
||||
* if necessary.
|
||||
*
|
||||
* Note: here we use a locale-dependent case conversion,
|
||||
* which seems appropriate under standard SQL rules, whereas
|
||||
* the keyword comparison was NOT locale-dependent.
|
||||
*/
|
||||
ident = pstrdup(yytext);
|
||||
for (i = 0; ident[i]; i++)
|
||||
{
|
||||
if (isupper((unsigned char) ident[i]))
|
||||
ident[i] = tolower((unsigned char) ident[i]);
|
||||
}
|
||||
if (i >= NAMEDATALEN)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = pg_mbcliplen(ident, i, NAMEDATALEN-1);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_NAME_TOO_LONG),
|
||||
errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
|
||||
ident, len, ident)));
|
||||
ident[len] = '\0';
|
||||
}
|
||||
ident = downcase_truncate_identifier(yytext, yyleng, true);
|
||||
yylval.str = ident;
|
||||
return IDENT;
|
||||
}
|
||||
|
Reference in New Issue
Block a user