ID:               31641
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tomasz at biznespolska dot pl
-Status:           Open
+Status:           Assigned
 Bug Type:         MSSQL related
 Operating System: win32
 PHP Version:      4.3.10
-Assigned To:      
+Assigned To:      iliaa
 New Comment:

Ilia, you 'broke' it.. :)



Previous Comments:
------------------------------------------------------------------------

[2005-01-22 10:38:51] tomasz at biznespolska dot pl

I know that this bug have been already reported, but wasn't solved!
This bug is very problematic. Many developers is still using  old
version 4.3.3, because of this very bug!

I cannot add my comments there, because another sentence says: 
"You can not add comments for bugs with the statuses:Closed, Duplicate,
Wont fix, Bogus, Stale"
I thought that I explain it in 3rd line of my description.

Now I am suggesting new solution, to fix bug which is located in
underlying MS DBLib.

------------------------------------------------------------------------

[2005-01-22 01:01:46] [EMAIL PROTECTED]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

The first line in the bug reporting page says:

"Before you report a bug, make sure to search for similar bugs using
the form at the top of the page or our advanced search page."

There are many reports about this already, add your comments to those
(all of them have status closed or bogus)


------------------------------------------------------------------------

[2005-01-21 17:20:38] tomasz at biznespolska dot pl

Ofcourse I mean "empty strings" not "empty spaces". Should be: 
"It is very rare that someone will store in database single space, but
storing empty string is very common."

------------------------------------------------------------------------

[2005-01-21 17:12:44] tomasz at biznespolska dot pl

Description:
------------
I'd like to continue thread:
http://bugs.php.net/bug.php?id=25777
Because it's already closed I wasn't able to add my comments there.

By disabling rtriming of text fields, new bug was introduced - empty
strings are returned as single space. I know that is because of MS
DBLib, but there is no problem to fix that in PHP.

It is very rare that someone will store in database single space, but
storing empty spaces is very common. So in my opinion most common usage
should be considered.
For example: if ( empty($text_from_db) ) { // do something }

In my opinion ' ' should replaced by ''. 

I don't how to submit this to CVS, so I put it here:

ext/mssql/mssql.c line 805:

case SQLTEXT: {
        int length;
        char *data = charcol(offset);

        length=dbdatlen(mssql_ptr->link,offset);
#if ilia_0
        while (length>0 && data[length-1] == ' ') { /* nuke trailing
whitespace */
                length--;
        }
#endif
        if ( length==1 && data[0]==' ' ) { /* single space to empty string */
                length=0;
        }
        
        Z_STRVAL_P(result) = estrndup(data,length);
        Z_STRLEN_P(result) = length;
        Z_TYPE_P(result) = IS_STRING;
        break;
}


Reproduce code:
---------------
//mssql_connect(...);
var_dump(mssql_fetch_row(mssql_query("SELECT ''")));

Expected result:
----------------
array(1) { [0]=> string(0) "" }

Actual result:
--------------
array(1) { [0]=> string(1) " " }


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31641&edit=1

Reply via email to