Skip to content

Commit aeffd3d

Browse files
committed
Restore ibase_free_result() behaviour
1 parent 5e99e47 commit aeffd3d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ibase_query.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,8 @@ PHP_FUNCTION(ibase_query)
11691169
goto _php_ibase_query_error;
11701170
}
11711171

1172+
ib_query->was_result_once = 1;
1173+
11721174
return;
11731175
}
11741176

@@ -1749,9 +1751,7 @@ PHP_FUNCTION(ibase_name_result)
17491751
Free the memory used by a result */
17501752
PHP_FUNCTION(ibase_free_result)
17511753
{
1752-
(void)execute_data;
1753-
RETVAL_TRUE;
1754-
// ibase_result was removed, nothing to be done here
1754+
_php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
17551755
}
17561756
/* }}} */
17571757

@@ -1840,7 +1840,7 @@ PHP_FUNCTION(ibase_execute)
18401840
Free memory used by a query */
18411841
PHP_FUNCTION(ibase_free_query)
18421842
{
1843-
_php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU);
1843+
_php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
18441844
}
18451845
/* }}} */
18461846

@@ -2236,7 +2236,7 @@ static void _php_ibase_alloc_ht_ind(ibase_query *ib_query)
22362236
}
22372237
}
22382238

2239-
static void _php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAMETERS)
2239+
static void _php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAMETERS, int as_result)
22402240
{
22412241
zval *query_arg;
22422242
ibase_query *ib_query;
@@ -2251,7 +2251,9 @@ static void _php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAMETERS)
22512251
return;
22522252
}
22532253

2254-
zend_list_close(Z_RES_P(query_arg));
2254+
if(!as_result || ib_query->was_result_once) {
2255+
zend_list_close(Z_RES_P(query_arg));
2256+
}
22552257

22562258
RETURN_TRUE;
22572259
}

php_ibase_includes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ typedef struct _ib_query {
161161
ISC_SHORT *in_nullind, *out_nullind;
162162
ISC_USHORT in_fields_count, out_fields_count;
163163
HashTable *ht_aliases, *ht_ind; // Precomputed for ibase_fetch_*()
164+
int was_result_once;
164165
} ibase_query;
165166

166167
enum php_interbase_option {
@@ -258,7 +259,7 @@ static int _php_ibase_get_vars_count(ibase_query *ib_query);
258259
static int _php_ibase_fetch_query_res(zval *from, ibase_query **ib_query);
259260
static int _php_ibase_alloc_ht_aliases(ibase_query *ib_query);
260261
static void _php_ibase_alloc_ht_ind(ibase_query *ib_query);
261-
static void _php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAMETERS);
262+
static void _php_ibase_free_query_impl(INTERNAL_FUNCTION_PARAMETERS, int as_result);
262263

263264
#ifdef __cplusplus
264265
}

0 commit comments

Comments
 (0)