From: paul dot robinson at groupbc dot com
Operating system: Linux (RHEL 4)
PHP version: 5.0.4
PHP Bug Type: MSSQL related
Bug description: Binding some stored procedure parameters fails
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 bug report at http://bugs.php.net/?id=33963&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33963&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33963&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33963&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33963&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33963&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33963&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33963&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33963&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33963&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33963&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33963&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33963&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33963&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33963&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33963&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33963&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33963&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33963&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33963&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33963&r=mysqlcfg