Bug #62054 [Com]: Column size is not reserved for all UNION
Edit report at https://bugs.php.net/bug.php?id=62054&edit=1
ID: 62054
Comment by: s-php at ertel-net dot de
Reported by: s-php at ertel-net dot de
Summary: Column size is not reserved for all UNION
Status: Feedback
Type: Bug
Package: MySQLi related
Operating System: Ubuntu
PHP Version: 5.3.13
Block user comment: N
Private report: N
New Comment:
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
mysql> status WHEN 0 THEN 'request-received' WHEN 1 THEN 'confirmed' WHEN 2 THEN
mysql> '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
Flags:
+------------------+
| Action |
+------------------+
| read |
| confirmed |
| request-received |
| x |
+------------------+
4 rows in set (0.00 sec)
Previous Comments:
------------------------------------------------------------------------
[2012-07-02 13:36:15] uw@php.net
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-05-17 13:28:21] s-php at ertel-net dot de
Description:
------------
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
UNION
SELECT CASE status WHEN 0 THEN 'request-received' WHEN 1 THEN 'confirmed' WHEN 2
THEN 'x' END AS Action FROM tbl2");
$stmt->bind_result($action);
$stmt->execute();
while($stmt->fetch())
{
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!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62054&edit=1
Thread (5 messages)