Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "type" and "status" a reserved word in MySQL?

I can't find these in words in the MySQL manual for reserved words but apparently phpMyAdmin says they're reserved:

enter image description here

like image 673
IMB Avatar asked May 16 '13 16:05

IMB


1 Answers

This is, technically, a bug in phpMyAdmin. From libraries/sqlparser.data.php:

/**
 * words forbidden to be used as column or table name wihtout quotes
 * as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
 *
 * @global array MySQL forbidden words
 */
$PMA_SQPdata_forbidden_word = array (

(list includes 'STATUS' and 'TYPE', which are clearly not on the referenced manual page).

Bug #948 identified that phpMyAdmin at that time capitalised certain column names (including STATUS) due to (erroneously) being identified as reserved words from this list; those keywords were initially removed from the list as a result, but that commit was subsequently reversed, for the reasons explained by Alexander Turek:

Your fix messes up the pretty-printer! This is rather an analyzer problem.

FIRST and STATUS have been inside this reserved words array because they are part of MySQL commands. STATUS is used in "SHOW STATUS" and FIRST part of the ALTER sytax.

Furthermore, this bug affects a lot more words than just STATUS and FIRST. I do not want to know what happens if we remove them all from the reserved words array...

Because of your change, both queries are not highlighted well anymore.

That is to say, phpMyAdmin uses the same list of words to conduct syntax highlighting in its pretty printer as it does for detecting reserved words; this is erroneous and leads to the warnings you observe.

like image 190
eggyal Avatar answered Sep 26 '22 14:09

eggyal