#33963 [Opn->Fbk]: Binding some stored procedure parameters fails
| From: | sniper@php.net | Date: | Tue, 02 Aug 2005 17:13:45 +0000 |
| Subject: | #33963 [Opn->Fbk]: Binding some stored procedure parameters fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82841@lists.php.net to get a copy of this message | ||
ID: 33963
Updated by: sniper@php.net
Reported By: paul dot robinson at groupbc dot com
-Status: Open
+Status: Feedback
Bug Type: MSSQL related
Operating System: Linux (RHEL 4)
PHP Version: 5.0.4
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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