Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
5.1.67, 5.2.14, 5.3.12, 10.3.4, 5.5(EOL), 10.0(EOL), 10.1(EOL)
Description
USING and TYPE are supposed to be synonyms in the key algorithm type clause,
and both work fine in the following two scripts:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
ALTER TABLE t1 ADD INDEX type USING BTREE (a);
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
ALTER TABLE t1 ADD INDEX type TYPE BTREE (a);
|
However, if I remove the index name (which is optional, according to the grammar), USING still works fine:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
ALTER TABLE t1 ADD INDEX USING BTREE (a);
|
but TYPE fails:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
ALTER TABLE t1 ADD INDEX TYPE BTREE (a);
|
It returns the following error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1
|
The problem is obviously in this piece of grammar in sql_yacc.yy:
key_def:
|
normal_key_type opt_if_not_exists_opt_table_element_name
|
key_alg '(' key_list ')'
|
{ Lex->option_list= NULL; }
|
normal_key_options
|
{
|
if (add_create_index (Lex, $1, $2, Lex->check_exists))
|
MYSQL_YYABORT;
|
}
|
When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE".
There are more parser related problems:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT) ENGINE=HEAP;
|
CREATE INDEX i1 USING HASH ON t1 (a) USING BTREE;
|
SHOW CREATE TABLE t1;
|
The above script ignores the first USING and returns:
+-------+---------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+---------------------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`a` int(11) DEFAULT NULL,
|
KEY `i1` (`a`) USING BTREE
|
) ENGINE=MEMORY DEFAULT CHARSET=latin1 |
|
+-------+---------------------------------------------------------------------------------------------------------------------+
|
The expected behaviour would be to return an error telling about conflicting declarations.
Attachments
Issue Links
- relates to
-
MDEV-20729 Fix REFERENCES constraint in column definition
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} The problem is obviously in this piece of grammar in sql_yacc.yy: {code} key_def: normal_key_type opt_if_not_exists_opt_table_element_name key_alg '(' key_list ')' { Lex->option_list= NULL; } normal_key_options { if (add_create_index (Lex, $1, $2, Lex->check_exists)) MYSQL_YYABORT; } {code} When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE". |
Description |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} The problem is obviously in this piece of grammar in sql_yacc.yy: {code} key_def: normal_key_type opt_if_not_exists_opt_table_element_name key_alg '(' key_list ')' { Lex->option_list= NULL; } normal_key_options { if (add_create_index (Lex, $1, $2, Lex->check_exists)) MYSQL_YYABORT; } {code} When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE". |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} The problem is obviously in this piece of grammar in sql_yacc.yy: {code} key_def: normal_key_type opt_if_not_exists_opt_table_element_name key_alg '(' key_list ')' { Lex->option_list= NULL; } normal_key_options { if (add_create_index (Lex, $1, $2, Lex->check_exists)) MYSQL_YYABORT; } {code} When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE". There are more parser related problems: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT) ENGINE=HEAP; CREATE INDEX i1 USING HASH ON t1 (a) USING BTREE; SHOW CREATE TABLE t1; {code} ignores the first USING and returns: {code} +-------+---------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, KEY `i1` (`a`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 | +-------+---------------------------------------------------------------------------------------------------------------------+ {code} The expected behaviour would be to return an error telling about conflicting declarations. |
Description |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} The problem is obviously in this piece of grammar in sql_yacc.yy: {code} key_def: normal_key_type opt_if_not_exists_opt_table_element_name key_alg '(' key_list ')' { Lex->option_list= NULL; } normal_key_options { if (add_create_index (Lex, $1, $2, Lex->check_exists)) MYSQL_YYABORT; } {code} When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE". There are more parser related problems: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT) ENGINE=HEAP; CREATE INDEX i1 USING HASH ON t1 (a) USING BTREE; SHOW CREATE TABLE t1; {code} ignores the first USING and returns: {code} +-------+---------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, KEY `i1` (`a`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 | +-------+---------------------------------------------------------------------------------------------------------------------+ {code} The expected behaviour would be to return an error telling about conflicting declarations. |
USING and TYPE are supposed to be synonyms in the key algorithm type clause, and both work fine in the following two scripts: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type USING BTREE (a); {code} {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX type TYPE BTREE (a); {code} However, if I remove the index name (which is optional, according to the grammar), USING still works fine: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX USING BTREE (a); {code} but TYPE fails: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); ALTER TABLE t1 ADD INDEX TYPE BTREE (a); {code} It returns the following error: {noformat} ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BTREE (a)' at line 1 {noformat} The problem is obviously in this piece of grammar in sql_yacc.yy: {code} key_def: normal_key_type opt_if_not_exists_opt_table_element_name key_alg '(' key_list ')' { Lex->option_list= NULL; } normal_key_options { if (add_create_index (Lex, $1, $2, Lex->check_exists)) MYSQL_YYABORT; } {code} When it gets the word TYPE, it does no know if it is the index name, or the start of the key algorithm clause, such as "TYPE BTREE". There are more parser related problems: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT) ENGINE=HEAP; CREATE INDEX i1 USING HASH ON t1 (a) USING BTREE; SHOW CREATE TABLE t1; {code} The above script ignores the first USING and returns: {code} +-------+---------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, KEY `i1` (`a`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 | +-------+---------------------------------------------------------------------------------------------------------------------+ {code} The expected behaviour would be to return an error telling about conflicting declarations. |
Component/s | Data Definition - Alter Table [ 10114 ] | |
Affects Version/s | 5.3.12 [ 12000 ] | |
Affects Version/s | 5.2.14 [ 12101 ] | |
Affects Version/s | 5.1.67 [ 12100 ] | |
Affects Version/s | 10.1 [ 16100 ] | |
Affects Version/s | 10.0 [ 16000 ] | |
Affects Version/s | 5.5 [ 15800 ] | |
Labels | upstream verified |
Workflow | MariaDB v2 [ 60156 ] | MariaDB v3 [ 66731 ] |
Priority | Major [ 3 ] | Minor [ 4 ] |
Affects Version/s | 10.3.4 [ 22904 ] |
Link |
This issue relates to |
Workflow | MariaDB v3 [ 66731 ] | MariaDB v4 [ 139789 ] |