Bug #20377 enum implemented incorrectly?
| Submitted: | 10 Jun 2006 23:17 | Modified: | 11 Jun 2006 8:24 |
|---|---|---|---|
| Reporter: | Roman Lamotkin | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Data Types | Severity: | S4 (Feature request) |
| Version: | 5.0.22 | OS: | Windows (Windows 98 SE) |
| Assigned to: | CPU Architecture: | Any |
[10 Jun 2006 23:17]
Roman Lamotkin
[11 Jun 2006 6:58]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but you can not use expressions (including user variables and even CAST) in ENUM. Take a look at sources (syntax specification, similar to BNF), sql/sql_yacc.yy:
field_spec:
...
| ENUM {Lex->interval_list.empty();} '(' string_list ')' opt_binary
{ $$=FIELD_TYPE_ENUM; }
...
string_list:
text_string { Lex->interval_list.push_back($1); }
| string_list ',' text_string { Lex->interval_list.push_back($3); };
So, it is not a bug, but intended behaviour. I can mark this as verified feature request, if you want, or a documentation request (to describe this clearly at http://dev.mysql.com/doc/refman/5.0/en/enum.html).
[11 Jun 2006 8:19]
Roman Lamotkin
Well, let me turn it into feature request ... (and documentation clarification request as well)
[11 Jun 2006 8:24]
Valeriy Kravchuk
So, it is a reasonable and verified feature request to support constant-based expressions in ENUM(...) data type declaration. This page, http://dev.mysql.com/doc/refman/5.0/en/enum.html, should also clearly state that expressions are not allowed now.
[11 Jun 2006 23:21]
Jon Stephens
The Manual already says:
An ENUM is a string object with a value chosen from a list
of allowed values that are enumerated explicitly in the column
specification at table creation time.
"Enumerated explicitly" means that you can't imply a string value, you must provide one. However, I have added the following to the ENUM section:
An enumeration value must be a quoted string literal; it may not
be an expression, even one that evaluates to a string value.
This means that you also may not employ a user variable as an
enumeration value.
[10 Oct 2008 11:17]
Alexander Barkov
Using CAST in create statement is perhaps too complex. Adding this syntax would be enough: CREATE TABLE t1 (a enum(_cp1251'str1','str2','str3')) charset utf8; Currently it returns syntax error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_cp1251'test','test1','test2')) charset utf8' at line 1
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.