diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-21 00:35:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-21 00:35:13 +0000 |
commit | 8c99671a3b2e5b90d263cfd883c9cdeba63d6cc4 (patch) | |
tree | 2b529b95daa1fd6ee92c72f91a68b1b4e426a514 /src/backend/parser/scan.l | |
parent | fe92ed8b78ce527739547fcd233c63debb2f3538 (diff) | |
download | postgresql-8c99671a3b2e5b90d263cfd883c9cdeba63d6cc4.tar.gz postgresql-8c99671a3b2e5b90d263cfd883c9cdeba63d6cc4.zip |
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.
Diffstat (limited to 'src/backend/parser/scan.l')
-rw-r--r-- | src/backend/parser/scan.l | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l index b10d4531851..c3a423a7f4a 100644 --- a/src/backend/parser/scan.l +++ b/src/backend/parser/scan.l @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.111 2003/10/09 19:13:23 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.111.2.1 2004/02/21 00:35:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -26,6 +26,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" @@ -394,23 +395,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} { @@ -532,7 +525,6 @@ other . {identifier} { const ScanKeyword *keyword; char *ident; - int i; /* Is it a keyword? */ keyword = ScanKeywordLookup(yytext); @@ -545,28 +537,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; } |