cvs: php4 /ext/interbase interbase.c php_interbase.h

From: Date: Sat, 24 Jun 2000 16:24:30 +0000
Subject: cvs: php4 /ext/interbase interbase.c php_interbase.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-427@lists.php.net to get a copy of this message
jah Sat Jun 24 09:24:30 2000 EDT Modified files: /php4/ext/interbase interbase.c php_interbase.h Log: - Close cursor immediately before reuse so that calling ibase_free_result is not necessary anymore. Seems to also prevent a a situation where at request shutdown cursor was first dropped and tried to close it afterwards when all the resources were not manually freed, and could occasionally segfault. Index: php4/ext/interbase/interbase.c diff -u php4/ext/interbase/interbase.c:1.36 php4/ext/interbase/interbase.c:1.37 --- php4/ext/interbase/interbase.c:1.36 Sat Jun 24 08:31:08 2000 +++ php4/ext/interbase/interbase.c Sat Jun 24 09:24:29 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.36 2000/06/24 15:31:08 sas Exp $ */ +/* $Id: interbase.c,v 1.37 2000/06/24 16:24:29 jah Exp $ */ /* TODO: Arrays, roles? @@ -356,10 +356,15 @@ _php_ibase_error(); } } else { + /* Shouldn't be here unless query was select and had parameter + placeholders, in which case ibase_execute handles this??? + */ IBDEBUG("Closing statement handle..."); + /* if (isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, DSQL_close)) { _php_ibase_error(); } + */ } if (ib_result->out_array) { efree(ib_result->out_array); @@ -524,24 +529,24 @@ php_info_print_table_start(); php_info_print_table_row(2, "Interbase Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.36 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.37 $"); #ifdef COMPILE_DL_INTERBASE php_info_print_table_row(2, "Dynamic Module", "yes"); #endif php_info_print_table_row(2, "Allow Persistent Links", (IBG(allow_persistent)?"Yes":"No") ); if (IBG(max_persistent) == -1) { - snprintf(tmp, 31, "%d/unlimited", IBG(num_persistent)); + snprintf(tmp, 31, "%ld/unlimited", IBG(num_persistent)); } else { - snprintf(tmp, 31, "%d/%ld", IBG(num_persistent), IBG(max_persistent)); + snprintf(tmp, 31, "%ld/%ld", IBG(num_persistent), IBG(max_persistent)); } tmp[31]=0; php_info_print_table_row(2, "Persistent Links", tmp ); if (IBG(max_links) == -1) { - snprintf(tmp, 31, "%d/unlimited", IBG(num_links)); + snprintf(tmp, 31, "%ld/unlimited", IBG(num_links)); } else { - snprintf(tmp, 31, "%d/%ld", IBG(num_links), IBG(max_links)); + snprintf(tmp, 31, "%ld/%ld", IBG(num_links), IBG(max_links)); } tmp[31]=0; php_info_print_table_row(2, "Total Links", tmp ); @@ -2128,6 +2133,7 @@ if (_php_ibase_alloc_query(&ib_query, ib_link->link, ib_link->trans[trans_n], query, ib_link->dialect) == FAILURE) { RETURN_FALSE; } + ib_query->cursor_open = 0; zend_list_addref(link_id); @@ -2165,16 +2171,27 @@ bind_args = args[1]; } + /* Have we used this cursor before and it's still open? */ + if (ib_query->cursor_open) { + IBDEBUG("Implicitly closing a cursor"); + if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_close)){ + efree(args); + _php_ibase_error(); + } + } + if ( _php_ibase_exec(&ib_result, ib_query, ZEND_NUM_ARGS()-1, bind_args) == FAILURE) { efree(args); RETURN_FALSE; } efree(args); - + if (ib_result) { /* select statement */ + ib_query->cursor_open = 1; ZEND_REGISTER_RESOURCE(return_value, ib_result, IBG(le_result)); } else { + ib_query->cursor_open = 0; RETURN_TRUE; } } @@ -2268,7 +2285,6 @@ PHP_FUNCTION(ibase_num_fields) { pval **result; - int type; ibase_result *ib_result; Index: php4/ext/interbase/php_interbase.h diff -u php4/ext/interbase/php_interbase.h:1.12 php4/ext/interbase/php_interbase.h:1.13 --- php4/ext/interbase/php_interbase.h:1.12 Sat Jun 10 01:47:57 2000 +++ php4/ext/interbase/php_interbase.h Sat Jun 24 09:24:29 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_interbase.h,v 1.12 2000/06/10 08:47:57 andi Exp $ */ +/* $Id: php_interbase.h,v 1.13 2000/06/24 16:24:29 jah Exp $ */ #ifndef _PHP_IBASE_H #define _PHP_IBASE_H @@ -122,6 +122,7 @@ ibase_array *in_array, *out_array; int in_array_cnt, out_array_cnt; int dialect; + int cursor_open; } ibase_query; typedef struct {

« previous php.cvs (#427) next »