|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62054 Column size is not reserved for all UNION
Submitted: 2012-05-17 13:28 UTC Modified: 2013-02-18 00:35 UTC
From: s-php at ertel-net dot de Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: 5.3.13 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: s-php at ertel-net dot de
New email:
PHP Version: OS:


 [2012-05-17 13:28 UTC] s-php at ertel-net dot de
When I concatenate two queries with UNION an there are static strings in the queries, mysqli only reserves a big enough variable for the strings in the first query.
If there are static strings in the other queries after the UNION, the strings are just cut off.

Test script:
$stmt = $this->mysqli->prepare("SELECT 'read' AS Action FROM tbl1
SELECT CASE status WHEN 0 THEN 'request-received' WHEN 1 THEN 'confirmed' WHEN 2 THEN 'x' END AS Action FROM tbl2");


  echo $action . " ";

Expected result:
expected output is: read request-received confirmed

Actual result:
actual output is: read request-recei confirmed

The "request-received" is cut off!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-02 13:36 UTC]
-Status: Open +Status: Feedback
 [2012-07-02 13:36 UTC]
99% sure: Server bug, not a client issue.

Please, report column type information retrieved on the MySQL prompt when preparing the statement using SQL PREPARE and then executing it. Log in to the MySQL prompt using --column-type-info option to see the meta data reported by the server.
 [2012-07-02 18:47 UTC] s-php at ertel-net dot de
Sorry, column names changed. But I guess this should be no problem for you.

mysql> PREPARE x from "SELECT 'read' AS Action FROM friends UNION SELECT CASE status WHEN 0 THEN 'request-received' WHEN 1 THEN 'confirmed' WHEN 2 THEN 'x' END AS Action FROM friends";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> execute x;
Field   1:  `Action`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     48
Max_length: 16
Decimals:   0

| Action           |
| read             |
| confirmed        |
| request-received |
| x                |
4 rows in set (0.00 sec)
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 [2013-02-19 13:01 UTC] s-php at ertel-net dot de
The bug still exists in PHP.
I provided all information as requested. What do you still need?
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Feb 04 19:05:50 2023 UTC