Bug #48292 ROW() operator does not accept single values (inconsistency)
Submitted: 25 Oct 2009 19:04 Modified: 27 Oct 2009 6:04
Reporter: Shawn Green Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:any OS:Any
Assigned to: Jon Stephens CPU Architecture:Any

[25 Oct 2009 19:04] Shawn Green
Description:
We document that ROW(<tuple>) is identical to (<tuple>):
http://dev.mysql.com/doc/refman/5.0/en/row-subqueries.html

And the following test verifies that duality:

mysql> select row(3,1) = (3,1);
+------------------+
| row(3,1) = (3,1) |
+------------------+
|                1 |
+------------------+
1 row in set (0.00 sec)

However a tuple of 1 (one element) fails in this duality:
mysql> select row(3) = (3);
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 ') = (3)' at line 1

The case of a single element tuple should be perfectly legal. 

How to repeat:
see description. 

Suggested fix:
modify the yacc file from 

ROW_SYM '(' expr ',' expr_list ')'

to 

ROW_SYM '(' expr_list ')'
[25 Oct 2009 19:16] Valeriy Kravchuk
Verified just as described with recent 5.1.41 from bzr.

I should note that manual on that very page says:

"The normal use of row constructors is for comparisons with subqueries that return two or more columns."

So, maybe all works as intended and only manual should state this more clearly.
[27 Oct 2009 6:00] Jon Stephens
A row constructor work on a row.

A subquery that returns a single column does not return a row, but rather a single value. This is why it's referred to as a scalar subquery.

So this is a Docs bug.
[27 Oct 2009 6:04] Jon Stephens
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.