Skip to Content.
Sympa Menu

freetds - Re: [freetds] SP input parameter problem on 0.63

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Allan Kim <akim AT freedom.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] SP input parameter problem on 0.63
  • Date: Tue, 09 Aug 2005 11:07:30 -0700

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, &param_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, &param_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







Archive powered by MHonArc 2.6.24.

Top of Page