php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52388 pg_fetch return space char on empty field
Submitted: 2010-07-21 13:41 UTC Modified: 2010-07-21 13:43 UTC
From: michael at jmslondon dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.13 OS: Linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael at jmslondon dot com
New email:
PHP Version: OS:

 

 [2010-07-21 13:41 UTC] michael at jmslondon dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-21 13:43 UTC] michael at jmslondon dot com
-Status: Open +Status: Closed
 [2010-07-21 13:43 UTC] michael at jmslondon dot com
The submission has altered this so it is unreadable. Closing it as make no sense
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC