Posted by ax on December 11, 2002 at 9:36pm
3 followers
Jump to:
| Project: | Drupal core |
| Version: | x.y.z |
| Component: | Other |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
> mysql drupal-4_1_0 < databasedatabase.mysql
ERROR 1064 at line 236: You have an error in your SQL syntax near 'mid (mid)
) TYPE=MyISAM' at line 6line 236 is this:
CREATE TABLE moderation_roles (
rid int(10) unsigned NOT NULL default '0',
mid int(10) unsigned NOT NULL default '0',
value tinyint(4) NOT NULL default '0',
KEY rid (rid),
KEY mid (mid)
) TYPE=MyISAM;reason: well - MID() is a mysql-function ...
fix:
CREATE TABLE moderation_roles (
rid int(10) unsigned NOT NULL default '0',
mid int(10) unsigned NOT NULL default '0',
value tinyint(4) NOT NULL default '0',
INDEX idx_rid (rid),
INDEX idx_mid (mid)
) TYPE=MyISAM;notes:
- i suggest to always name indexes idx_<col_name> to avoid such errors in the future
- i renamed KEY to INDEX because this is more standard
Comments
#1
this still doesn't work in latest cvs - please fix (it's just some chars to add). thanks
#2
just a clarification: "mysql --ansi" means mysql running in ansi mode
another issue i just noticed with the latest rc: when importing database.mysql with phpMyAdmin, i get the following error:
You have an error in your SQL syntax near '------------------------[...]
--
--
CREATE TABLE ac' at line 2
this is reasonable as the manual states: Note that the -- (double-dash) comment style requires you to have at least one space after the second dash - which isn't the case in the latest database.mysql
#3
- Drupal 4.1.0: bug fixed. Patch by Ax.
- Drupal CVS: bug open. We should rename "mid" to "vid" (vote ID).
#4
thanks dries. two remarks:
#5
a phpMyAdmin fix went into cvs today - this issue is almost solved now. now we only need to decide what to do with "KEY mid (mid)" in cvs database.mysql which is invalid because "mid()" is a function. dries suggested to just rename "mid" to "vid"; i suggest to change "KEY mid (mid)" to "INDEX idx_mid (mid)" (or "idx_vid (vid)" - i don't care) /and to apply this naming scheme to all indexes/ - see above / below for why.
see also http://www.ss64.demon.co.uk/orasyntax/naming.html and http://vyaskn.tripod.com/object_naming.htm/ for some background, rationales, and suggestions for database naming schemes (which i'd like too see, at least to a certain extend, to be applied to drupal).
#6
note that the PostgreSQL database.pgsql scheme already uses a similar convention: "CREATE INDEX book_nid_idx ON book(nid);"
#7
For the table or colum names the manual suggests to enclose them in ` (backtick) - ie. SELECT `CREATE` FROM `SELECT`. phpMyAdmin has an option to add these to all names when exporting (including indexes).
#8
Is this issue resolved?
#9
no - dries want's a patch. see http://lists.drupal.org/pipermail/drupal-devel/2003-February/022204.html .
#10
fixed (completely) on 2003/03/16 (KEY mid (mid) -> KEY idx_mid (mid)). closing.