[DOC] prototype for ibase_query() should be changed to:

PHP4:
  resource ibase_query ( [resource $link_identifier,] string $query [, mixed $bind_arg [, ...]] )
PHP5:
  resource ibase_query ( [resource $link_identifier,] [resource $transaction_identifier,] string $query [, mixed $bind_arg [, ...]] )

prototype for ibase_prepare() should be changed to:
PHP4:
  resource ibase_prepare ( [resource $link_identifier,] string $query )
PHP5:
  resource ibase_prepare ( [resource $link_identifier,] [resource $transaction_identifier,] string $query )

prototype for ibase_execute() should be changed to:
  mixed ibase_execute ( resource $query, [, mixed $bind_arg [, ...]] )

- Fixed bug #30690: (Resource handle from ibase_execute becomes invalid after return)
- Fixed bug #30907: (ibase_query() crashes (in fact the same bug as #32143)
- Fixed bug #32143: (ibase_query() causing IBserver 7 crash with NULL param as link-id)
- Fixed bug #39056: (Interbase NUMERIC data type error)
- Fixed bug #39397: (invalid statement handle in Unknown on line 0)
- Fixed bug #39700: (NUMERIC error when result precision are 7,8 or 12-14)
- Fixed bug #42284: (duplicate of #39700)
This commit is contained in:
Lars Westermann 2007-11-08 19:16:27 +00:00
parent 6d2bcdacc1
commit b599957076

View file

@ -49,6 +49,7 @@ typedef struct {
typedef struct { typedef struct {
ibase_db_link *link; ibase_db_link *link;
ibase_trans *trans; ibase_trans *trans;
struct _ib_query *query;
isc_stmt_handle stmt; isc_stmt_handle stmt;
unsigned short type; unsigned short type;
unsigned char has_more_rows, statement_type; unsigned char has_more_rows, statement_type;
@ -56,9 +57,10 @@ typedef struct {
ibase_array out_array[1]; /* last member */ ibase_array out_array[1]; /* last member */
} ibase_result; } ibase_result;
typedef struct { typedef struct _ib_query {
ibase_db_link *link; ibase_db_link *link;
ibase_trans *trans; ibase_trans *trans;
ibase_result *result;
int result_res_id; int result_res_id;
isc_stmt_handle stmt; isc_stmt_handle stmt;
XSQLDA *in_sqlda, *out_sqlda; XSQLDA *in_sqlda, *out_sqlda;
@ -116,6 +118,22 @@ static void _php_ibase_free_xsqlda(XSQLDA *sqlda) /* {{{ */
} }
/* }}} */ /* }}} */
static void _php_ibase_free_stmt_handle(ibase_db_link *link, isc_stmt_handle stmt TSRMLS_DC) /* {{{ */
{
if (stmt) {
IBDEBUG("Dropping statement handle (free_stmt_handle)...");
/* Only free statement if db-connection is still open */
char db_items[] = {isc_info_page_size}, res_buf[40];
if (SUCCESS == isc_database_info(IB_STATUS, &link->handle,
sizeof(db_items), db_items, sizeof(res_buf), res_buf)) {
if (isc_dsql_free_statement(IB_STATUS, &stmt, DSQL_drop)) {
_php_ibase_error(TSRMLS_C);
}
}
}
}
/* }}} */
static void _php_ibase_free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ static void _php_ibase_free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
{ {
ibase_result *ib_result = (ibase_result *) rsrc->ptr; ibase_result *ib_result = (ibase_result *) rsrc->ptr;
@ -123,9 +141,11 @@ static void _php_ibase_free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{
IBDEBUG("Freeing result by dtor..."); IBDEBUG("Freeing result by dtor...");
if (ib_result) { if (ib_result) {
_php_ibase_free_xsqlda(ib_result->out_sqlda); _php_ibase_free_xsqlda(ib_result->out_sqlda);
if (ib_result->stmt && ib_result->type != EXECUTE_RESULT) { if (ib_result->query != NULL) {
IBDEBUG("Dropping statement handle (free_result dtor)..."); IBDEBUG("query still valid; don't drop statement handle");
isc_dsql_free_statement(IB_STATUS, &ib_result->stmt, DSQL_drop); ib_result->query->result = NULL; /* Indicate to query, that result is released */
} else {
_php_ibase_free_stmt_handle(ib_result->link, ib_result->stmt TSRMLS_CC);
} }
efree(ib_result); efree(ib_result);
} }
@ -142,11 +162,11 @@ static void _php_ibase_free_query(ibase_query *ib_query TSRMLS_DC) /* {{{ */
if (ib_query->out_sqlda) { if (ib_query->out_sqlda) {
efree(ib_query->out_sqlda); efree(ib_query->out_sqlda);
} }
if (ib_query->stmt) { if (ib_query->result != NULL) {
IBDEBUG("Dropping statement handle (free_query)..."); IBDEBUG("result still valid; don't drop statement handle");
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)) { ib_query->result->query = NULL; /* Indicate to result, that query is released */
_php_ibase_error(TSRMLS_C); } else {
} _php_ibase_free_stmt_handle(ib_query->link, ib_query->stmt TSRMLS_CC);
} }
if (ib_query->in_array) { if (ib_query->in_array) {
efree(ib_query->in_array); efree(ib_query->in_array);
@ -166,11 +186,7 @@ static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {
if (ib_query != NULL) { if (ib_query != NULL) {
IBDEBUG("Preparing to free query by dtor..."); IBDEBUG("Preparing to free query by dtor...");
_php_ibase_free_query(ib_query TSRMLS_CC); _php_ibase_free_query(ib_query TSRMLS_CC);
if (ib_query->statement_type != isc_info_sql_stmt_exec_procedure) {
zend_list_delete(ib_query->result_res_id);
}
efree(ib_query); efree(ib_query);
} }
} }
@ -302,9 +318,16 @@ static int _php_ibase_alloc_query(ibase_query *ib_query, ibase_db_link *link, /*
static char info_type[] = {isc_info_sql_stmt_type}; static char info_type[] = {isc_info_sql_stmt_type};
char result[8]; char result[8];
/* Return FAILURE, if querystring is empty */
if (*query == '\0') {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Querystring empty.");
return FAILURE;
}
ib_query->link = link; ib_query->link = link;
ib_query->trans = trans; ib_query->trans = trans;
ib_query->result_res_id = 0; ib_query->result_res_id = 0;
ib_query->result = NULL;
ib_query->stmt = NULL; ib_query->stmt = NULL;
ib_query->in_array = NULL; ib_query->in_array = NULL;
ib_query->out_array = NULL; ib_query->out_array = NULL;
@ -930,6 +953,9 @@ static int _php_ibase_exec(INTERNAL_FUNCTION_PARAMETERS, ibase_result **ib_resul
res->link = ib_query->link; res->link = ib_query->link;
res->trans = ib_query->trans; res->trans = ib_query->trans;
res->stmt = ib_query->stmt; res->stmt = ib_query->stmt;
/* ib_result and ib_query point at each other to handle release of statement handle properly */
res->query = ib_query;
ib_query->result = res;
res->statement_type = ib_query->statement_type; res->statement_type = ib_query->statement_type;
res->has_more_rows = 1; res->has_more_rows = 1;
@ -1288,9 +1314,23 @@ PHP_FUNCTION(ibase_num_rows)
static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ */ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ */
int scale, int flag TSRMLS_DC) int scale, int flag TSRMLS_DC)
{ {
static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 100000000, 1000000000, static ISC_INT64 const scales[] = { 1, 10, 100, 1000,
1000000000, LL_LIT(10000000000),LL_LIT(100000000000),LL_LIT(10000000000000),LL_LIT(100000000000000), 10000,
LL_LIT(1000000000000000),LL_LIT(1000000000000000),LL_LIT(1000000000000000000) }; 100000,
1000000,
10000000,
100000000,
1000000000,
LL_LIT(10000000000),
LL_LIT(100000000000),
LL_LIT(1000000000000),
LL_LIT(10000000000000),
LL_LIT(100000000000000),
LL_LIT(1000000000000000),
LL_LIT(10000000000000000),
LL_LIT(100000000000000000),
LL_LIT(1000000000000000000)
};
switch (type & ~1) { switch (type & ~1) {
unsigned short l; unsigned short l;