Bug #94129 The description of "13.1.8 ALTER TABLE Syntax" chapter is ambiguous
Submitted: 30 Jan 7:05 Modified: 31 Jan 13:27
Reporter: JianJun Shi Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Documentation Severity:S4 (Feature request)
Version:5.7 OS:Linux
Assigned to: CPU Architecture:Any

[30 Jan 7:05] JianJun Shi
Description:
"13.1.8 ALTER TABLE Syntax" chapter in the "MySQL 5.7 Reference Manual" was describe as following:

...
index_col_name:
col_name [(length)] [ASC | DESC]
...
An index_col_name specification can end with ASC or DESC. These keywords are permitted for future extensions for specifying ascending or descending index value storage. Currently, they are parsed but ignored; index values are always stored in ascending order.
...

In a word, in "index_col_name" syntax, "col_name" can be combined with "ASC" or "DESC", and it will not gonna be a problem.

Actually, i get back an error message "ERROR 1215 (HY000): Cannot add foreign key constraint".

How to repeat:
use test;
create table Table_Parent_ALTER_TABLE_FOREIGN_008(C_ID INT,C_D_ID INTEGER NOT NULL,C_W_ID BIGINT NOT NULL,C_DOUBLE DOUBLE NOT NULL,C_DECIMAL DECIMAL NOT NULL,C_FIRST VARCHAR(64) NOT NULL,C_MIDDLE CHAR(2),C_LAST VARCHAR(64) NOT NULL,C_STREET_1 VARCHAR(20) NOT NULL,C_STREET_2 VARCHAR(20),C_CITY VARCHAR(64) NOT NULL,C_STATE CHAR(2) NOT NULL,C_ZIP CHAR(9) NOT NULL,C_PHONE CHAR(16) NOT NULL,C_SINCE TIMESTAMP,C_CREDIT CHAR(2) NOT NULL,C_CREDIT_LIM NUMERIC(12,2),C_DISCOUNT NUMERIC(4,4),C_BALANCE NUMERIC(12,2),C_YTD_PAYMENT REAL NOT NULL,C_PAYMENT_CNT FLOAT NOT NULL,C_DELIVERY_CNT BOOLEAN NOT NULL,C_END DATE NOT NULL,C_VCHAR VARCHAR(1000),C_DATA TEXT,C_TEXT BLOB,C_TINYTEXT TINYTEXT,C_MEDIUMBLOB MEDIUMBLOB,C_LONGBLOB LONGBLOB,UNIQUE(C_ID,C_D_ID,C_W_ID));
create table Table_Child_ALTER_TABLE_FOREIGN_008(C_ID INT DEFAULT NULL,C_D_ID INTEGER NOT NULL,C_W_ID BIGINT NOT NULL,C_DOUBLE DOUBLE NOT NULL,C_DECIMAL DECIMAL NOT NULL,C_FIRST VARCHAR(64) NOT NULL,C_MIDDLE CHAR(2),C_LAST VARCHAR(64) NOT NULL,C_STREET_1 VARCHAR(20) NOT NULL,C_STREET_2 VARCHAR(20),C_CITY VARCHAR(64) NOT NULL,C_STATE CHAR(2) NOT NULL,C_ZIP CHAR(9) NOT NULL,C_PHONE CHAR(16) NOT NULL,C_SINCE TIMESTAMP,C_CREDIT CHAR(2) NOT NULL,C_CREDIT_LIM NUMERIC(12,2),C_DISCOUNT NUMERIC(4,4),C_BALANCE NUMERIC(12,2),C_YTD_PAYMENT REAL NOT NULL,C_PAYMENT_CNT FLOAT NOT NULL,C_DELIVERY_CNT BOOLEAN NOT NULL,C_END DATE NOT NULL,C_VCHAR VARCHAR(1000),C_DATA TEXT,C_TEXT BLOB,C_TINYTEXT TINYTEXT,C_MEDIUMBLOB MEDIUMBLOB,C_LONGBLOB LONGBLOB);

ALTER TABLE Table_Child_ALTER_TABLE_FOREIGN_008 ADD FOREIGN KEY (C_ID ASC) REFERENCES Table_Parent_ALTER_TABLE_FOREIGN_008 (C_ID) MATCH SIMPLE ON UPDATE SET NULL;
ALTER TABLE Table_Child_ALTER_TABLE_FOREIGN_008 ADD FOREIGN KEY (C_ID DESC REFERENCES Table_Parent_ALTER_TABLE_FOREIGN_008 (C_ID) MATCH SIMPLE ON UPDATE SET NULL;
ALTER TABLE Table_Child_ALTER_TABLE_FOREIGN_008 ADD FOREIGN KEY (C_ID) REFERENCES Table_Parent_ALTER_TABLE_FOREIGN_008 (C_ID) MATCH SIMPLE ON UPDATE SET NULL;
[30 Jan 14:11] Sinisa Milivojevic
Hi,

Leaving the order of index in the parser and documentation for future use is not a bug.

What I do not understand is the foreign key error that follows. Can you let us know how is it an error in our documentation ?????
[31 Jan 6:09] JianJun Shi
Hello Sinisa,

Thank you for your reply. After your explanation, I probably understand these description's true meaning.

Because of understand deviation, I thought it want to tell me "you can use order of index's keywords or not. In 5.7 version, they do not have actual use, at the same time, they will not throw out any error message."

However, It's true meaning is "you can not use order of index's keywords, and you can use them in future version". right?
[31 Jan 13:27] Sinisa Milivojevic
Yes, that is correct.