List:General Discussion« Previous MessageNext Message »
From:robbat2 Date:July 10 2002 4:01am
Subject:Token parsing incorrect behavior
View as plain text  
>Description:
	I have been writing an SQL tokenizer for the phpMyAdmin project, on which I am a core
developer.
I used this page (Manual 6.1.2 Database, Table, Index, Column, and Alias Names) for
reference 
as to what a valid token was. As well as this reference on SQL User Variables (Manual
6.1.4 User Variables).

Most specificly, it states that an identifier CAN start with a number.
Ergo,
0xff could be an identifer or a hexadecimal number.

However,
0xgff and 0xffg
are not valid hexadecimal numbers, and are only valid as identifiers.

Use my SQL fragment below, and note the results of the two SELECT queries.  

While the 0xgff column produces correct results, The 0xfffffge column does not. The column
title is garbled.

>How-To-Repeat:
CREATE TABLE `strtest` (
  `0xfffffge` int(10) unsigned zerofill NOT NULL auto_increment,
  `0xgff` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`0xfffffge`)
) TYPE=MyISAM;
INSERT INTO strtest VALUES (0000000001, 'Foo');

SELECT * FROM strtest;
SELECT 0xfffffge,0xgff FROM strtest;
	
>Fix:
	Make tokens that fail as being hexadecimal numbers be recognized as identifiers only.

>Submitter-Id:	<submitter ID>
>Originator:	Robin Johnson
>Organization:
	Orbis-Terrarum Networks
	
>MySQL support: none
>Synopsis:	Token parsing incorrect behavior with hexadecimal like identifiers	
>Severity:	serious	
>Priority:	medium	
>Category:	mysql
>Class:		sw-bug	
>Release:	mysql-3.23.51-robbat2 (yes)
	The -robbat2 extra tag on the version is just an identifer I use to identify all of my
MySQL servers.

>Environment:
	
System: Linux matchbox 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/local/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc-3.1/configure --enable-languages=c,c++,f77,objc,java
Thread model: single
gcc version 3.1
Compilation info: CC='gcc'  CFLAGS='-O3 -DUSE_SYMDIR'  CXX='gcc'  CXXFLAGS='-O3
-felide-constructors -fno-exceptions -fno-rtti'  LDFLAGS=''
LIBC: 
lrwxrwxrwx    1 root     root           13 Jun 24 16:51 /lib/libc.so.6 -> libc-2.2.5.so
-rwxr-xr-x    1 root     root      1260480 Apr 15 06:44 /lib/libc-2.2.5.so
-rw-r--r--    1 root     root      2310808 Apr 15 07:02 /usr/lib/libc.a
-rw-r--r--    1 root     root          178 Apr 15 06:55 /usr/lib/libc.so
Configure command: ./configure --prefix=/usr/local/mysql --with-innodb --with-comment
--with-extra-charsets=all --with-server-suffix=-robbat2 --enable-local-infile
--enable-assembler --with-mysqld-ldflags=-all-static --with-bdb 'CFLAGS=-O3 -DUSE_SYMDIR'
'CXXFLAGS=-O3 -felide-constructors -fno-exceptions -fno-rtti' CXX=gcc

Thread
Token parsing incorrect behaviorrobbat210 Jul
  • Re: Token parsing incorrect behaviorEgor Egorov10 Jul