mysql:177
From: Kengo Jinno <Kengo Jinno <kengo@xxxxxxxxxx>>
Date: Mon, 08 Jun 1998 19:37:39 +0900
Subject: [mysql 177] MB char in identifier which starts with digit char
神野です。
#Subjectはデタラメです(^_^;
MySQLをMultiByte環境で使っている時、次のようなフィールド名を持つテーブルが
作成できませんでした。
create table ほげほげ (
1回あたり integer
)
「1」を「1」とかに変えたら解決するんですが、「数字やアルファベットは
ASCIIを使う」というルールでやっているので、そうもいきません。
ソース(sql/sql_lex.cc)を見ると、数字から始まる識別子の場合、数字の後に
使えるキャラクタとしては、アルファベットかアンダーバーしか認めていない
ようでした。
そこで次のようなパッチをあてて対処しました。(mysql-3.21.30です)
diff -p old/sql_lex.cc new/sql_lex.cc
*** old/sql_lex.cc Mon May 4 05:03:06 1998
--- new/sql_lex.cc Mon Jun 8 16:15:46 1998
*************** int yylex(void *arg)
*** 785,791 ****
--- 785,795 ----
case STATE_NUMBER_IDENT: // number or ident which starts with num
while (isdigit((c = yyGet()))) ;
+ #if defined(USE_MB) && defined(USE_MB_IDENT)
+ if (!isalpha(c) && c != '_' && !ismbhead(c))
+ #else
if (!isalpha(c) && c != '_')
+ #endif
{ // Can't be identifier
state=STATE_INT_OR_REAL;
break;
これでうまく行ってる雰囲気なんですが、別の問題が判明しました。
こちらはMB文字でなくても発生します。
create table foo (
1st integer not null,
2nd double not null,
primary key foo_i1 (1st)
)
go
-> 問題なし
select 1st,2nd from foo
go
-> 問題なし
select bar.1st,bar.2nd from foo bar
go
-> ERROR 1064: parse error near '.1st,bar.2nd from foo bar' at line 1
同じく、sql/sql_lex.ccのyylex()あたりだろうと思うのですが、関係しそうな
箇所が多いのと副作用が恐いので手が出せてません(^_^;
-----------------------------
神野健吾 <kengo@xxxxxxxxxx>
-> 177 1998-06-08 19:37 [Kengo Jinno <kengo@x] MB char in identifier which starts with digit char 178 1998-06-11 17:40 ┣[<takeshi@xxxxxxxxxx>] 1246 1999-09-20 16:25 ┗[朝日生命主計部数理課] パック形式のデータロードについて 1247 1999-09-20 22:53 ┗[Satoshi Koiwa <koiwa]