summaryrefslogtreecommitdiff
path: root/ext/interbase
diff options
context:
space:
mode:
authorJouni Ahto <jah@php.net>2000-06-24 16:24:29 +0000
committerJouni Ahto <jah@php.net>2000-06-24 16:24:29 +0000
commit8f1ff9e85e7b717ea896a7ad4220e11f8980cfe1 (patch)
treee973c40b5853f5b72ac5010afe1926b7227f3d11 /ext/interbase
parent303dc9e96a7b3a099bc9ea5b93ef6d6103ef3a7f (diff)
downloadphp-git-8f1ff9e85e7b717ea896a7ad4220e11f8980cfe1.tar.gz
- 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.
Diffstat (limited to 'ext/interbase')
-rw-r--r--ext/interbase/interbase.c28
-rw-r--r--ext/interbase/php_interbase.h1
2 files changed, 23 insertions, 6 deletions
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index 2c46cda538..a99211ab8e 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -356,10 +356,15 @@ static void _php_ibase_free_result(ibase_result *ib_result)
_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);
@@ -531,17 +536,17 @@ PHP_MINFO_FUNCTION(ibase)
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 @@ PHP_FUNCTION(ibase_prepare)
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 @@ PHP_FUNCTION(ibase_execute)
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_timefmt)
PHP_FUNCTION(ibase_num_fields)
{
pval **result;
- int type;
ibase_result *ib_result;
diff --git a/ext/interbase/php_interbase.h b/ext/interbase/php_interbase.h
index ba0a27c9c4..a534907e1d 100644
--- a/ext/interbase/php_interbase.h
+++ b/ext/interbase/php_interbase.h
@@ -122,6 +122,7 @@ typedef struct {
ibase_array *in_array, *out_array;
int in_array_cnt, out_array_cnt;
int dialect;
+ int cursor_open;
} ibase_query;
typedef struct {