Bug #111532 SQL DELETE statement example has an error in Section "3.6.6 Using Foreign Keys"
Submitted: 22 Jun 2023 9:51 Modified: 29 Jun 2023 13:06
Reporter: Ted Zhu Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:ALL OS:Any
Assigned to: Jon Stephens CPU Architecture:Any

[22 Jun 2023 9:51] Ted Zhu
Description:
On MySQL Server documentation page 3.6.6 Using Foreign Keys: 

    https://dev.mysql.com/doc/refman/8.0/en/example-foreign-keys.html

An SQL DELETE statement example is offered that has a syntax error:

    mysql> DELETE FROM parent WHERE id VALUES = 1;

There is an extraneous "VALUES" keyword. This should instead be corrected to:

    mysql> DELETE FROM parent WHERE id = 1;

How to repeat:
Informally, just go to the documentation page: 

    https://dev.mysql.com/doc/refman/8.0/en/example-foreign-keys.html 

and observe a basic syntax error with the DELETE example:

    mysql> DELETE FROM parent WHERE id VALUES = 1;

More formally:

Method 1:

Go to the documentation page: 

    https://dev.mysql.com/doc/refman/8.0/en/example-foreign-keys.html

Observe the offered delete example:

    mysql> DELETE FROM parent WHERE id VALUES = 1;

Go to the DELETE statement documentation page:

    https://dev.mysql.com/doc/refman/8.0/en/delete.html

Observe that the 'VALUES' keyword is not a part of the 'DELETE" statement syntax.

Method 2:

Go to the documentation page: 

    https://dev.mysql.com/doc/refman/8.0/en/example-foreign-keys.html

Execute SQL instructions provided by the page. Observe that when you get to the suggested example:

    mysql> DELETE FROM parent WHERE id VALUES = 1;

A syntax error gets emitted:

    ERROR 1064 (42000): 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 'VALUES = 1' at line 1 

This is different from the foreign key constraint fail error that's supposed to be emitted by this SQL example.

Suggested fix:
Correct the example SQL statement to:

    mysql> DELETE FROM parent WHERE id = 1;
[22 Jun 2023 13:35] MySQL Verification Team
Hi Mr. Zhu,

Thank you for your documentation bug.

We have checked the manual and indeed, the queries are wrongly written.

This is a very small bug, but still a bug.

Verified as reported.
[23 Jun 2023 10:40] Ted Zhu
Hi MySQL Verification Team,

Thank you for confirming this documentation issue.

Best regards,
Ted
[23 Jun 2023 12:12] MySQL Verification Team
Hi Mr. Zhu,

You are truly welcome .....
[29 Jun 2023 13:06] Jon Stephens
Fixed in mysqldoc rev 76026, in all current versions of the Manual.

This fix also updates examples in the FK section to use VALUES ROW() and TABLE syntax in 8.0/8.1 versions and makes numerous additional wording and other fixes.

Thanks!
[29 Jun 2023 13:07] MySQL Verification Team
Thank you , Jon.