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: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Cc: "Frank M. Kromann" <frank AT kromann.info>
  • Subject: Re: [freetds] SP input parameter problem on 0.63
  • Date: Tue, 9 Aug 2005 08:46:23 +0200

>
> First of all, thanks so much everyone for your help so far.
>
> I applied Frediano Zigliano's patch to rpc.c in 0.63 and added some
> crude debugging code of my own ... I'm still running into problems at
> that one particular spot (maxlen fails validation) but I'm
> also running
> into unexpected results that involve ADODB.
>
> Just for review, here's the SP I'm working with:
>
> CREATE proc sp_Team_WLT
> @TeamAllocId int,
> @LeagueId int,
> @SeasonID int,
> @BUId int,
> @SportId int,
> @TeamGenderCd char(4),
> @RS varchar(8000) OUTPUT
> AS (etc. etc. etc.)
>
> Now by my understanding maxlen should have a value of -1 for
> non-OUTPUT
> parameters. But for some reason ADODB calls mssql_bind with maxlen =
> 4000 by default for all parameters (at least in 4.60 and 4.65
> it does).
> Sometimes it doesn't seem to matter, but sometimes it does
> matter as you
> can see below:
>
> 17:24:29.003317 dbrpcinit() added rpcname "sp_Team_WLT"
> 17:24:29.003649 Trying to bind parameter "@TeamAllocId"
> 17:24:29.003726 dbrpcparam() added parameter "@TeamAllocId"
> 17:24:29.003953 Trying to bind parameter "@LeagueId"
> 17:24:29.004017 dbrpcparam() added parameter "@LeagueId"
> 17:24:29.004217 Trying to bind parameter "@SeasonID"
> 17:24:29.004273 Died at 191 Trying to bind parameter with maxlen 4000
> 17:24:29.004822 Trying to bind parameter "@BUid"
> 17:24:29.004903 dbrpcparam() added parameter "@BUid"
> 17:24:29.005112 Trying to bind parameter "@SportId"
> 17:24:29.005169 Died at 191 Trying to bind parameter with maxlen 4000
> 17:24:29.005579 Trying to bind parameter "@TeamGenderCd"
> 17:24:29.005680 Died at 191 Trying to bind parameter with maxlen 4000
> 17:24:29.006220 Trying to bind parameter "@RS"
> 17:24:29.006304 dbrpcparam() added parameter "@RS"
> 17:24:29.006507 dbrpcsend()
>
> Note that line 191 reported above corresponds to this line of the
> patched version of rpc.c.
>
> + if (maxlen != -1 && maxlen != 0)
>
> As you can see all parameters bind successfully except for @SeasonID,
> @SportId and @TeamGenderCd. One thing in common with those three
> parameters: data type. The developer is passing string
> arguments to the
> PHP ADODB InParameter() method.
>
> Any insight would be greatly appreciated. Thanks!
>

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




Archive powered by MHonArc 2.6.24.

Top of Page