ID: 33963
Updated by: sniper@php.net
-Summary: Binding some stored procedure parameters fails
Reported By: paul dot robinson at groupbc dot com
-Status: Open
+Status: Assigned
Bug Type: MSSQL related
Operating System: Linux (RHEL 4)
-PHP Version: 5.0.4
+PHP Version: 5CVS-2005-08-06
-Assigned To:
+Assigned To: fmk
New Comment:
Frank, check this out too..
Previous Comments:
------------------------------------------------------------------------
[2005-08-05 16:52:00] paul dot robinson at groupbc dot com
Patch against php_mssql.c CVS version 1.149 can be found here:
http://cobweb.businesscollaborator.com/pdr/33963.patch
The values of maxlen and datalen set here have been verified to work
with FreeTDS 0.63 and the latest CVS code as of 5/8/2005.
------------------------------------------------------------------------
[2005-08-02 19:13:45] sniper@php.net
Provide patches in unified diff format (diff -u) and against PHP CVS
HEAD (we're not likely to release any 5.0.x versions anymore). Put the
diffs somewhere were people can download it and put the URLs here.
------------------------------------------------------------------------
[2005-08-02 18:51:03] paul dot robinson at groupbc dot com
Patches suggested are against Snapshot:
php5-STABLE-200508021038.tar.gz
Although I haven't actually built an example using that snapshot today
I have looked at the code which since it is unchanged would seem to
exhibit the same problem.
------------------------------------------------------------------------
[2005-08-02 18:34:32] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-08-02 13:39:23] paul dot robinson at groupbc dot com
Description:
------------
Using FreeTDS 0.63 (latest stable release), calling mssql_bind can fail
due to the restrictions placed on parameters by the dbrpcparam function
from FreeTDS.
One specific example is an input parameter must have maxlen==-1. With
the code as is in PHP 5.0.4 a NULL valued variable length type input
parameter will always have maxlen==0 thereby always failing.
Diff below shows changes to ext/mssql/php_mssql.c that address this
parameter mismatch.
2025,2026c2025,2029
< maxlen=0;
< datalen=0;
---
> datalen = 0;> if (is_output)> maxlen = -1;> else> maxlen = -1;
2030d2032
< datalen=Z_STRLEN_PP(var);
2031a2034,2046
> > if (is_output) {> if ((maxlen > 0 ) && (maxlen < 256))> datalen = maxlen;> else {> maxlen = 255;> datalen = 255;> }> }> else {> maxlen = -1;> datalen=Z_STRLEN_PP(var);> }
Reproduce code:
---------------
mssql_bind($query, "@varchar1", $varchar1, SQLVARCHAR);
or
mssql_bind($query, "@varchar1", $varchar1, SQLVARCHAR, false, true,
57);
Expected result:
----------------
Sucessfully bind input variable.
Actual result:
--------------
"Unable to set parameter"
i.e. FAIL is returned by the call to dbrpcparam in
PHP_FUNCTION(mssql_bind).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33963&edit=1