Bug #52388 [NEW]: pg_fetch return space char on empty field
| From: | michael at jmslondon dot com | Date: | Wed, 21 Jul 2010 11:41:40 +0000 |
| Subject: | Bug #52388 [NEW]: pg_fetch return space char on empty field | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152567@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.2.13
Package: PostgreSQL related
Bug Type: Bug
Bug description:pg_fetch return space char on empty field
Description:
------------
pg_fetch_* returns space string (e.g. ' ') when returning a
empty sting ''
Postgres is
returning an empty string and pg_fetch is changing the return
value.
Empty string is only return if the result is
caste as a varchar in the sql

e.g."SELECT test_thing::varchar".
Test script:
---------------
//In DB
CREATE TABLE test ( test_thing VARCHAR(5) NOT NULL
DEFAULT '');
INSERT INTO test VALUES
('');

//code
$testing
= pg_query($db_conn,"SELECT test_thing FROM test WHERE
test_thing='');
print_r(pg_fetch_all($testing));
print
'testing'.pg_fetch_result($testing,0,0).'this';
Expected result:
----------------
array(1) {
[0]=
 array(1)
{

['test_thing']=
 string(0)
''
}
}

testingthis

Actual result:
--------------
array(1) {
[0]=
 array(1)
{

['test_thing']=
 string(1)
'
'
}
}

testing
this
--
Edit bug report at http://bugs.php.net/bug.php?id=52388&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52388&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52388&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52388&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52388&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52388&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52388&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52388&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52388&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52388&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52388&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52388&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52388&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52388&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52388&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52388&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52388&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52388&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52388&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52388&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52388&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52388&r=mysqlcfg