#20510 [Csd->Opn]: All spaces on a right padded string getting chopped

From: Date: Wed, 20 Nov 2002 02:27:02 +0000
Subject: #20510 [Csd->Opn]: All spaces on a right padded string getting chopped
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-25314@lists.php.net to get a copy of this message
ID: 20510 Updated by: nicos@php.net Reported By: jrust@php.net -Status: Closed +Status: Open Bug Type: MySQL related Operating System: Linux PHP Version: 4.3.0RC1 New Comment: <Zeev> it *seems* like a MySQL issue, but it could be some obscure PHP issue. Lets see. C API should be tested with MySQL 3 and MySQL4. Same for the PHP extension. I will do some tests and give feedbacks. Previous Comments: ------------------------------------------------------------------------ [2002-11-19 20:07:13] nicos@php.net I never said it's not a bug. It is, the fact is that it's not PHP related but MySQL related, so bugs mysql.com ------------------------------------------------------------------------ [2002-11-19 20:02:09] philip@php.net The posted details make it sound like a bug to me so unless you truly know the answer nicos I don't think this should be closed. jrust, maybe it'd be helpful if you provide a small db schema that'll go along with a query so others can easily test it. ------------------------------------------------------------------------ [2002-11-19 19:38:43] nicos@php.net I really don't think that can be PHP related... Post a MySQL bug instead? Did you tried that with MySQL 4 (C API)? Anyway if someone feels that I'm wrong, open it again. Thank you for the report. ------------------------------------------------------------------------ [2002-11-19 19:22:04] jrust@php.net The following mysql query should return the data padded with spaces on the right: <?php $query = ' SELECT RPAD(t1.f_field1,15,\' \'), RPAD(t2.f_field2, 15, \' \') FROM test.table1 as t1 LEFT JOIN test.table2 AS t2 ON t1.record=t2.joinID ORDER BY t1.record DESC'; $link = mysql_connect('localhost', 'root', 'password'); $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { var_dump($row); } ?> However, the all spaces to the right of the string are chopped off, as if PHP (or maybe the MySQL api?) is doing an rtrim on the data. Some details: * The exact same query run from the MySQL console returns the correctly padded data. * If the ORDER BY is commented out the data comes back padded correctly. * If the query does not contain a JOIN the data comes back padded correctly (even if there is an ORDER BY) * It doesn't matter what the data is for table1 and table2 so long as the two tables can be joined and have some data in the fields * I am using MySQL version 3.23.52 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20510&edit=1

« previous php.bugs (#25314) next »