Bug #74621 cannot reference parameterized select column in derived table
Submitted: 29 Oct 2014 16:08 Modified: 6 Sep 2017 10:07
Reporter: Eric B Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Prepared statements Severity:S3 (Non-critical)
Version:5.1.56-rel12.7, 5.6.23 OS:Any
Assigned to: CPU Architecture:Any

[29 Oct 2014 16:08] Eric B
Description:
mysql is not giving me visibility in to a parmeterized column from a derived table. 

How to repeat:
In the following example, I'd expect both column1Value and column2Value returned, but it's not returning column2Value, the parameterized value.

mysql> PREPARE stmt1 FROM 'select a.* from (select "column1value" as column1, ? as column2) a';
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> SET @a = 'column2Value';
Query OK, 0 rows affected (0.00 sec)

mysql> EXECUTE stmt1 USING @a;
+--------------+
| column1      |
+--------------+
| column1value |
+--------------+
1 row in set (0.00 sec)
[29 Oct 2014 16:12] Eric B
Before reporting here, I searched pre-existing bug reports and posted to stackoverflow:
http://stackoverflow.com/questions/26569937/mysql-trouble-referencing-parameterized-select...
[10 Nov 2014 12:09] MySQL Verification Team
Hello Eric B,

Thank you for the report.

Thanks,
Umesh
[10 Nov 2014 12:09] MySQL Verification Team
// 5.6.23

// MySQL 

mysql> show variables like '%version%';
+-------------------------+---------------------------------------------------------------+
| Variable_name           | Value                                                         |
+-------------------------+---------------------------------------------------------------+
| innodb_version          | 5.6.23                                                        |
| protocol_version        | 10                                                            |
| slave_type_conversions  |                                                               |
| version                 | 5.6.23-enterprise-commercial-advanced-debug                   |
| version_comment         | MySQL Enterprise Server - Advanced Edition Debug (Commercial) |
| version_compile_machine | x86_64                                                        |
| version_compile_os      | Linux                                                         |
+-------------------------+---------------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> PREPARE stmt1 FROM 'select a.* from (select "column1value" as column1, ? as column2) a';
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> SET @a = 'column2Value';
Query OK, 0 rows affected (0.00 sec)

mysql> EXECUTE stmt1 USING @a;
+--------------+
| column1      |
+--------------+
| column1value |
+--------------+
1 row in set (0.00 sec)
[6 Sep 2017 10:07] Roy Lyseng
This problem is not reproducible in 5.7 and 8.0.