Skip to Content.
Sympa Menu

freetds - Re: Insert/update returns failure using PHP sybase_query

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: James Cameron <cameron AT stl.dec.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Insert/update returns failure using PHP sybase_query
  • Date: Fri, 02 Nov 2001 09:45:57 +1100

G'day Dave,

This matches my problem of a few days ago. The ctlib interface used by
PHP will fail on any statement that returns no result set. An update or
insert is such a statement. The statement is executed by the database
server, but the result as seen by PHP is a failure.

To confirm, try doing a 'set rowcount 10' prior to a 'select @@version',
and you should see that the connection dies after the first query.

A fix has been committed into CVS. I've attached the patch (with the
Debian bug report).

--
James Cameron (cameron AT stl.dec.com)

http://www.linux.org/ http://www.linux.org.au/ http://www.freshmeat.net/Subject: freetds0: 'SET ROWCOUNT' before 'SELECT' in PHP fails
Package: freetds0
Version: 0.53-1
Severity: important
Tags: patch

When used with php4-sybase and php4, the library fails to properly
emulate the Sybase ctlib interface relied upon by php4-sybase, such
that queries that return no results (such as SET ROWCOUNT) cause the
connection to the database to abort.

SET ROWCOUNT and other such no-result queries are an essential part
of normal database operations. Without this patch, the freetds0
Debian package is not very useful.

Patch has been applied to FreeTDS CVS, revision 1.6 of src/ctlib/ct.c

Index: ct.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/ctlib/ct.c,v
retrieving revision 1.4
retrieving revision 1.6
diff -u -u -r1.4 -r1.6
--- ct.c 2001/10/26 11:16:26 1.4
+++ ct.c 2001/10/31 01:38:24 1.6
@@ -23,7 +23,7 @@
#include <ctpublic.h>
#include <ctlib.h>

-static char software_version[] = "$Id: ct.c,v 1.4 2001/10/26 11:16:26
brianb Exp $";
+static char software_version[] = "$Id: ct.c,v 1.6 2001/10/31 01:38:24
quozl Exp $";
static void *no_unused_var_warn[] = {software_version,
no_unused_var_warn};

@@ -413,6 +413,17 @@
}
return CS_SUCCEED;
case TDS_NO_MORE_RESULTS:
+ if (! tds->res_info) {
+ if (cmd->empty_res_hack) {
+ cmd->empty_res_hack=0;
+ *result_type = CS_CMD_DONE;
+ return CS_END_RESULTS;
+ } else {
+ cmd->empty_res_hack=1;
+ *result_type = CS_CMD_SUCCEED;
+ return CS_SUCCEED;
+ }
+ }
if (tds->res_info && !tds->res_info->rows_exist) {
if (cmd->empty_res_hack) {
cmd->empty_res_hack=0;
@@ -846,7 +857,11 @@
}
switch(type) {
case CS_NUMDATA:
- int_val = resinfo->num_cols;
+ if (!resinfo) {
+ int_val = 0;
+ } else {
+ int_val = resinfo->num_cols;
+ }
memcpy(buffer, &int_val, sizeof(CS_INT));
break;
case CS_ROW_COUNT:

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux quozl 2.4.8-686 #1 Sun Aug 12 11:18:19 EST 2001 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages freetds0 depends on:
ii debconf 1.0.13 Debian configuration management
sy
ii libc6 2.2.4-3 GNU C Library: Shared libraries
an



Archive powered by MHonArc 2.6.24.

Top of Page