Opened 9 years ago
Closed 9 years ago
#36422 closed defect (bug) (fixed)
Specific table prefixes causes sql errors
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Database | Keywords: | has-patch |
Focuses: | Cc: |
Description
$table_prefix = '7e1_';
WordPress database error: [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 '7e1_users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varch' at line 1]
It seems that mysql is trying to parse 7e1_users in engineering notation (numeric value), instead of as an allowed table name. This requires the table name to always be quoted to force correct parsing. Unsure what the path forward is, i.e. detect and display a better error message, or auto quote the table name.
Attachments (1)
Change History (6)
#2
@
9 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 4.6
- Owner set to pento
- Status changed from new to assigned
Taking suggestions for a better error message before I commit this. :-)
#3
@
9 years ago
Can we do it earlier without MySQL as well? is_numeric( $prefix )
?
Re: message, I wouldn't quote table prefix, just ERROR: Table prefix is invalid.
The correct thing to do would be to always quote the table names, but realistically that's not an option here (plugins, etc).
Maybe we can preflight the prefix name during the DB credentials checks somehow? just check that the DB interprets an unquoted prefix the same as it would a quoted one?
I assume we'd just say it's an invalid prefix if it failed, I'd err on the side of not trying to explain why it's invalid though.