Bug #93994 Parameter marker aliases in inner SELECTs are not propagated to outer SELECTs

Submitted: 21 Jan 2019 15:08 Modified: 7 Feb 2019 14:25
Reporter: GC GC Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.17 OS:Any
Assigned to: CPU Architecture:Any

[21 Jan 2019 15:08] GC GC
Description:
A call to SQLPrepare with:
const char *sql = "SELECT X, Y FROM (SELECT 1 X, ? AS Y) Q";
fails with "[MySQL][ODBC 5.3(a) Driver][mysqld-5.6.17] Unknown column 'Y' in 'field list'"

Workaround (replace single parameter with 2 inside a COALESCE):
const char *sql = "SELECT X, Y FROM (SELECT 1 X, COALESCE(?, ?) Y) Q";

Also works: sql without the outer select

Also fails (with "Unknown column 'Q.Y' in 'field list'"): 
const char *sql = "SELECT Q.X, Q.Y FROM (SELECT 1 X, ? Y) Q";

So the bug seems to be that parameter marker aliases in inner SELECTs are not propagated to the outer SELECTs.

How to repeat:
Execute the aforementioned SQL statement using a MySQL ODBC driver.
[24 Jan 2019 19:50] GC GC
Discovered that the bug does not occur against a MySQL server version 5.6.40.
[7 Feb 2019 14:25] MySQL Verification Team
Thank you for the feedback. Closed according your last comment.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.061 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.