[freetds] Problem with return value from PHP's mssql_query() when calling a stored procedure that returns an empty result set
michaels at crye-leike.com
Wed Mar 31 18:37:10 EST 2004
(Sorry for the long subject line. I couldn't think of a better way to sum
First of all I'd like to say that I'm a happy long time FreeTDS user (been
using 0.53rc1 for about a year and a half with no issues). I'd like to
thank all of the developers and contributors who have made this great piece
of software available to the community.
As I said, I've been using FreeTDS 0.53rc1 for the past year and a half with
various versions of PHP (compiled --with-sybase, using dblib) to access a
MS-SQL 7.0 server. It's always worked great, so I never bothered to upgrade
FreeTDS (following the "if it ain't broke, don't fix it" principle).
Recently I had to convert my web server's OS from RH 7.2 to RH Enterprise
Linux 2.1, and after I did this I started noticing intermittent problems
with SQL connections from my PHP scripts. In an effort to troubleshoot
these intermittent problems, I decided to first upgrade to the latest
version of FreeTDS in case that would make a difference.
I've compiled the current stable version of FreeTDS (0.62.1) , along with
PHP 4.3.3 using the --with-sybase option . 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. This causes an error in my
scripts when I later try to call a fetch function (such as
mssql_fetch_object()) on that result. Previously, with FreeTDS 0.53rc1,
mssql_query() would either return a result resource, or false in the case of
I've seen various references to this problem in the list archives , but
it isn't clear to me if it was ever addressed completely.
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). I then tried various older versions of
FreeTDS (compiling PHP against each of them using --with-sybase (dblib)),
just to see when the problem was introduced. Version 0.61.2 appears to be
the latest version that did not have this problem (although for some reason
it introduced an 8 second delay on each query that I perform). So, it
appears that this problem was introduced somewhere between versions 0.61.2
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...
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.
So, does anyone have an recommendations on what I should do? Is this
problem something that can be corrected in FreeTDS, or should I just switch
to using "--with-mssql" or "--with-sybase-ct"? I'd be grateful for any
advice or insight. I can also provide additional information, including
sample scripts, if required. Thanks in advance...
with: --with-tdsver=4.2 --enable-msdblib --enable-dbmfix --with-gnu-ld --ena
with: --with-mysql=/usr/local/mysql/ --enable-track-vars --enable-trans-sid
--with-sybase=/usr/local/ --with-pgsql=/usr/local/pgsql/ --enable-xslt --wit
h-xslt-sablot --with-zlib --with-ldap --with-apxs=/usr/local/apache/bin/apxs
Project Analyst - Information Technology
Office: (901)758-5648 Pager: (901)769-3722
More information about the FreeTDS