ID: 20510
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: MySQL related
Operating System: Linux
PHP Version: 4.3.0RC1
New Comment:
Works fine here:
[derick@kossu derick]$ mysqldump -u root -p bug20510
Enter password:
-- MySQL dump 8.21
--
-- Host: localhost Database: bug20510
---------------------------------------------------------
-- Server version 3.23.49a
--
-- Table structure for table 'table1'
--
CREATE TABLE table1 (
record int(10) unsigned NOT NULL auto_increment,
field1 varchar(30) NOT NULL default '',
PRIMARY KEY (record)
) TYPE=MyISAM;
--
-- Dumping data for table 'table1'
--
INSERT INTO table1 VALUES (1,'test');
--
-- Table structure for table 'table2'
--
CREATE TABLE table2 (
record int(10) unsigned NOT NULL auto_increment,
joinID int(10) unsigned NOT NULL default '0',
field2 varchar(30) NOT NULL default '',
PRIMARY KEY (record)
) TYPE=MyISAM;
--
-- Dumping data for table 'table2'
--
INSERT INTO table2 VALUES (1,1,'join one');
INSERT INTO table2 VALUES (3,1,'join two');
[derick@kossu derick]$ cat bug20510.php
<?php
mysql_connect('localhost', 'root', 'mypassword');
mysql_select_db('bug20510');
$res = mysql_query ("SELECT RPAD(t1.field1,15, ' '), RPAD(t2.field2,
15, ' ') FROM table1 as t1 LEFT JOIN table2 AS t2 ON
t1.record=t2.joinID ORDER BY t1.record DESC");
while ($row = mysql_fetch_row($res)) {
var_dump ($row);
}
?>
[derick@kossu derick]$ php -v
PHP 4.3.0-dev (cli) (built: Nov 19 2002 21:39:05)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
[derick@kossu derick]$ php bug20510.php
array(2) {
[0]=>
string(15) "test "
[1]=>
string(15) "join one "
}
array(2) {
[0]=>
string(15) "test "
[1]=>
string(15) "join two "
}
Compiled against the bundled library, using mysql 3.23.49a as server.
Which versions do you use?
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-11-20 11:47:24] [EMAIL PROTECTED]
Ok, here is the dump schema of the tables. My hunch now is that it is
a MySQL problem in general, because a similar happens from the MySQL
command line.
Anyhow, I've put in a thread about it over at mysql.com. However, I
don't think as a bug it's Bogus, because I'm not talking about putting
data into a VARCHAR field, but rather padding any type of field on the
fly on it's way out. And the data as you'll see if you run the test,
is padded without the ORDER BY, but not padded when the ORDER BY is
present. Oh, and one more wierd caveat I discovered. The query has
to be joining on more than one row, if it only joins on one row it
works fine....wierd. So, the dump schema:
# start test table schema.
USE DATABASE test;
#
# Table structure for table `table1`
#
CREATE TABLE table1 (
record int(10) unsigned NOT NULL auto_increment,
field1 varchar(30) NOT NULL default '',
PRIMARY KEY (record)
) TYPE=MyISAM;
#
# Dumping data for table `table1`
#
INSERT INTO table1 VALUES (1, 'test');
#
# Table structure for table `table2`
#
CREATE TABLE table2 (
record int(10) unsigned NOT NULL auto_increment,
joinID int(10) unsigned NOT NULL default '0',
field2 varchar(30) NOT NULL default '',
PRIMARY KEY (record)
) TYPE=MyISAM;
#
# Dumping data for table `table2`
#
INSERT INTO table2 VALUES (1, 1, 'join one');
INSERT INTO table2 VALUES (3, 1, 'join two');
------------------------------------------------------------------------
[2002-11-20 07:34:32] [EMAIL PROTECTED]
Read the 2nd paragraph on:
http://www.mysql.com/doc/en/CHAR.html
"When CHAR values are stored, they are right-padded with spaces to the
specified length. When CHAR values are retrieved, trailing spaces are
removed. "
Not a bug -> bogus
------------------------------------------------------------------------
[2002-11-19 20:27:01] [EMAIL PROTECTED]
<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.
------------------------------------------------------------------------
[2002-11-19 20:07:13] [EMAIL PROTECTED]
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] [EMAIL PROTECTED]
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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/20510
--
Edit this bug report at http://bugs.php.net/?id=20510&edit=1