Bug #8992 Enums and quotes
Submitted: 6 Mar 2005 15:13 Modified: 7 Mar 2005 10:37
Reporter: Erik Wijdemans Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Information schema Severity:S4 (Feature request)
Version:* OS:Any (*)
Assigned to: CPU Architecture:Any

[6 Mar 2005 15:13] Erik Wijdemans
The description is pretty simple:

See here, an ENUM field:
enum('Fysiotherapeut', 'Arts', 'Foo\'s')

When i run this query:
SHOW COLUMNS FROM `status` LIKE 'Vooropleiding'

I get the following result:
 Field  	 Type  	 Null  	 Key  	 Default  	 Extra
Vooropleiding 	enum('Fysiotherapeut','Arts','Foo\'s') 	YES NULL 	 

Note the extra escape quote. I've read it's a normal escape method but when i echo it in normal php the extra quote is still there.

I made my own function in PHP to get rid of the extra quote but i there somekind of configuration to make to get this working?

How to repeat:
Make a table with the enum field mentioned above.
Run the query mentioned above.
[6 Mar 2005 20:28] Erik Wijdemans
I heared that it's not a bug but still it's a weird method of escaping.
[7 Mar 2005 6:05] Aleksey Kishkin
If you want to change this behaviour please set 'severity' of this bug report to 'feature request' (and 'status' to 'open' again)
[7 Mar 2005 7:46] Sergei Golubchik
How do you want it to be escaped ?
[7 Mar 2005 9:05] Erik Wijdemans
Just like any other escaping -> \'
This way i can use stripslashes.
[7 Mar 2005 9:20] Sergei Golubchik
Ok, I understand.
You original posting was wrong - the output is not

 Field  	 Type  	 Null  	 Key  	 Default  	 Extra
Vooropleiding 	enum('Fysiotherapeut','Arts','Foo\'s') 	YES NULL 	 


 Field  	 Type  	 Null  	 Key  	 Default  	 Extra
Vooropleiding 	enum('Fysiotherapeut','Arts','Foo''s') 	YES NULL 	 

while you want \' instead of ''
[7 Mar 2005 10:37] Erik Wijdemans
Ah shite.. and then i think i'm taking care of writing down the problem.. sorry. The output was indeed the double quote. And yes, i would make sense if the output was like \' instead of ''.
[6 Apr 2006 13:52] Jim MacDonald
This problem can make it quite complicated to determine the values of an enum can take. For example: 

create table e_test (e  enum('foo','bar'''',''''bas') );

How many values can e take, 2 or 3? you must count the number or quotes. This makes parsing the output quite complicated.

It would be nice to have another way to determine the values an enum can take rather than relying on parsing the output from SHOW COLUMNS FROM e_test;