Skip to Content.
Sympa Menu

freetds - Re: [freetds] mssql_query() returns boolean when stored procedure returns empty result set

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] mssql_query() returns boolean when stored procedure returns empty result set
  • Date: Wed, 31 Mar 2004 19:41:22 -0500

On Wed, 31 Mar 2004 <michaels AT crye-leike.com> wrote:
> I'd like to
> thank all of the developers and contributors who have made this great
> piece of software available to the community.

:-)

> I've compiled the current stable version of FreeTDS (0.62.1) [1], along
> with PHP 4.3.3 using the --with-sybase option [2]. I'm noticing a
> problem with the return value of PHP's mssql_query() function when the
> query calls a stored procedure that returns an empty result set (0
> rows). Normally the return value of this function should be a result
> resource, but in this case the function is returning a boolean true.

Based on what you found, and on my knowledge of our db-lib implementation,
it's very hard to see how (or if) this is caused by FreeTDS. The
--with-mssql extension resolves to the very same db-lib call, and works
correctly. Perhaps the older with-sybase handling expects dbresults() to
behave a little differently?

I hope someone here who's more familiar with PHP can help you.

> I tried the latest snapshot as of yesterday (0.63.dev.20040329), just to
> see if the issue was addressed there, but unfortunately I cannot get PHP
> to compile against it (due to various "undeclared" errors with
> SYBDATETIMN, SYBFLTN, SYBINTN, and SYBMONEYN).

That's looks like a problem. We're pruning our header files; maybe we've
gone too far.

> So, it
> appears that this problem was introduced somewhere between versions
> 0.61.2 and 0.62.1.

You will find 0.62.2 in our current directory (next to the snapshot). I
haven't officially announced it yet, but as no one's complained, I guess
it will become official soon.

> At the time I first starting using PHP with FreeTDS, it was generally
> recommended to go with --with-sybase and dblib, as this was considered
> more mature than ctlib. For kicks, I decided to compile PHP
> using --with-sybase-ct against 0.62.1, and the problem does not appear
> in that configuration. So it seems that using sybase-ct is now an
> option. Does anyone know if this combination (PHP/FreeTDS/ctlib) is now
> considered mature enough for production servers? This isn't strictly a
> FreeTDS question, because my understanding was that PHP's ctlib
> extension was also a bit rough a while back...

I don't have any opinion about PHP, because I don't use it. I can say
that our ct-lib is much further along, almost unrecognizably changed,
since 0.53. It's used by DBD::Sybase (Perl) with pretty good success.

> Also, thanks to the list I recently discovered that it's possible to
> compile PHP using --with-mssql against FreeTDS. I tried this and the
> problem also does not appear. It's interesting to me that this approach
> seems to also use dblib, at least according to ldd, but the error does
> not occur. This suggests to me that this may not be a FreeTDS bug, but
> may be an issue with the way PHP's sybase extension interacts with
> FreeTDS, since the mssql extension seems to work.

I agree. I'm not saying it's a PHP bug; I wouldn't be surprised if it
turned out to be some way in which what we're doing is slightly different
than what Sybase's db-lib does. Someone will have to look at the PHP
code to see why it thinks it should return a boolean when there are no
results.

> So, does anyone have an recommendations on what I should do?

I'm going to leave that to the PHP experts here, except to tell you that
many people successfully use the msssql extension.

> I can also provide additional information, including
> sample scripts, if required.

If you want to add a sample script to our samples/ directory, or extend
what's there, I'll be happy to include it. Eventually, we really should
have a PHP regression test.

> [1] Configured
> with: --with-tdsver=4.2 --enable-msdblib --enable-dbmfix --with-gnu-ld
> --ena ble-shared --enable-static

--enable-dbmfix has no effect anymore.

Nice to hear from a long time happy user. Too bad you had to write. ;-)

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page