[freetds] SP input parameter problem on 0.63
Allan Kim
akim at freedom.com
Tue Aug 9 14:07:30 EDT 2005
I'm seeing the same thing ... After looking through the source for
mssql_bind() in php_mssql.c it seems the problem is that the same rules
are applied to both input and output parameters starting at line 2018.
The result is that for input parameters of variable-length type, maxlen
is passed unchanged and never gets set to -1 (non-null values) or 0
(null values).
I've tried a patch to php_mssql.c almost identical to yours with good
results so far ... it's just a bit easier for my coffee-poisoned brain
to read:
*** 2016,2021 ****
--- 2016,2033 ----
mssql_ptr=statement->link;
/* modify datalen and maxlen according to dbrpcparam
documentation */
+
+ /* handle maxlen for input parameters */
+
+ if (!is_output) {
+ if (is_null) {
+ maxlen=0;
+ }
+ else {
+ maxlen=-1;
+ }
+ }
+
if ( (type==SQLVARCHAR) || (type==SQLCHAR) || (type==SQLTEXT) )
{ /* variable-length type */
if (is_null) {
maxlen=0;
Between that and the previously posted patches I'm guessing this takes
care of things without breaking any existing PHP/ADODB code.
Wow, this open-source stuff is exciting :-)
Thanks a 10^6 everyone!
ZIGLIO, Frediano, VF-IT wrote:
> Try removing
>
> if (maxlen != -1 && maxlen != 0)
> return FAIL;
>
> lines. However PHP is passing wrong parameters... maxlen should not be
> 4000 for input parameters but -1 (0 from MS specification is string is
> null...)
>
> It would be correct to change these line in php_mssql.c (mssql_bind)
>
> if (is_output) {
> status=DBRPCRETURN;
> }
>
> to
>
> if (is_output) {
> status=DBRPCRETURN;
> } else {
> maxlen = -1;
> }
>
> Or change these lines
>
> case 7: {
> zval **yyis_output, **yyis_null, **yymaxlen;
>
> if (zend_get_parameters_ex(7, &stmt, ¶m_name, &var, &yytype,
> &yyis_output, &yyis_null, &yymaxlen)==FAILURE){
> RETURN_FALSE;
> }
> convert_to_long_ex(yytype);
> convert_to_long_ex(yyis_output);
> convert_to_long_ex(yyis_null);
> convert_to_long_ex(yymaxlen);
> type=Z_LVAL_PP(yytype);
> is_output=Z_LVAL_PP(yyis_output);
> is_null=Z_LVAL_PP(yyis_null);
> maxlen=Z_LVAL_PP(yymaxlen);
> }
> break;
>
> with
>
> case 7: {
> zval **yyis_output, **yyis_null, **yymaxlen;
>
> if (zend_get_parameters_ex(7, &stmt, ¶m_name, &var, &yytype,
> &yyis_output, &yyis_null, &yymaxlen)==FAILURE) {
> RETURN_FALSE;
> }
> convert_to_long_ex(yytype);
> convert_to_long_ex(yyis_output);
> convert_to_long_ex(yyis_null);
> convert_to_long_ex(yymaxlen);
> type=Z_LVAL_PP(yytype);
> is_output=Z_LVAL_PP(yyis_output);
> is_null=Z_LVAL_PP(yyis_null);
> maxlen=Z_LVAL_PP(yymaxlen);
> if (!is_output)
> maxlen = -1;
> }
> break;
>
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
More information about the FreeTDS
mailing list