[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
iliaa Sun Jan 11 23:52:48 2009 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: MFB: improved parameter handling http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.40r2=1.41diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.40 php-src/ext/interbase/ibase_query.c:1.41 --- php-src/ext/interbase/ibase_query.c:1.40Wed Dec 31 11:12:32 2008 +++ php-src/ext/interbase/ibase_query.c Sun Jan 11 23:52:48 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.40 2008/12/31 11:12:32 sebastian Exp $ */ +/* $Id: ibase_query.c,v 1.41 2009/01/11 23:52:48 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1210,7 +1210,7 @@ { ibase_trans *trans = NULL; ibase_db_link *ib_link; - zval *arg; + zval *arg = NULL; RESET_ERRMSG; @@ -1218,7 +1218,7 @@ return; } - if (ZEND_NUM_ARGS() == 0) { + if (!arg) { ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link), LE_LINK, le_link, le_plink); if (ib_link-tr_list == NULL || ib_link-tr_list-trans == NULL) { RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c interbase.c /ext/interbase/tests bug45373.phpt ibase_num_fields_001.phpt
felipe Sun Nov 23 20:00:51 2008 UTC Modified files: /php-src/ext/interbase ibase_query.c interbase.c /php-src/ext/interbase/testsbug45373.phpt ibase_num_fields_001.phpt Log: - New parameter parsing API http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.37r2=1.38diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.37 php-src/ext/interbase/ibase_query.c:1.38 --- php-src/ext/interbase/ibase_query.c:1.37Mon Oct 6 14:28:29 2008 +++ php-src/ext/interbase/ibase_query.c Sun Nov 23 20:00:51 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.37 2008/10/06 14:28:29 felipe Exp $ */ +/* $Id: ibase_query.c,v 1.38 2008/11/23 20:00:51 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1211,42 +1211,32 @@ PHP_FUNCTION(ibase_affected_rows) { ibase_trans *trans = NULL; - + ibase_db_link *ib_link; + zval *arg; + RESET_ERRMSG; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |r, arg) == FAILURE) { + return; + } - switch (ZEND_NUM_ARGS()) { - - ibase_db_link *ib_link; - zval **arg; + if (ZEND_NUM_ARGS() == 0) { + ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link), LE_LINK, le_link, le_plink); + if (ib_link-tr_list == NULL || ib_link-tr_list-trans == NULL) { + RETURN_FALSE; + } + trans = ib_link-tr_list-trans; + } else { + /* one id was passed, could be db or trans id */ + _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg, ib_link, trans); + if (trans == NULL) { + ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, arg, -1, LE_LINK, le_link, le_plink); - case 0: - ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link), LE_LINK, - le_link, le_plink); if (ib_link-tr_list == NULL || ib_link-tr_list-trans == NULL) { RETURN_FALSE; } trans = ib_link-tr_list-trans; - break; - - case 1: - if (zend_get_parameters_ex(1, arg) == FAILURE) { - RETURN_FALSE; - } - /* one id was passed, could be db or trans id */ - _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg, ib_link, trans); - if (trans == NULL) { - ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, arg, -1, LE_LINK, le_link, le_plink); - - if (ib_link-tr_list == NULL || ib_link-tr_list-trans == NULL) { - RETURN_FALSE; - } - trans = ib_link-tr_list-trans; - } - break; - - default: - WRONG_PARAM_COUNT; - break; + } } RETURN_LONG(trans-affected_rows); } @@ -1277,21 +1267,20 @@ * sets. */ - zval **result_arg; + zval *result_arg; ibase_result *ib_result; static char info_count[] = {isc_info_sql_records}; char result[64]; RESET_ERRMSG; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, result_arg) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, result_arg) == FAILURE) { + return; } - ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, LE_RESULT, le_result); + ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, LE_RESULT, le_result); - if (isc_dsql_sql_info(IB_STATUS, ib_result-stmt, sizeof(info_count), info_count, - sizeof(result), result)) { + if (isc_dsql_sql_info(IB_STATUS, ib_result-stmt, sizeof(info_count), info_count, sizeof(result), result)) { _php_ibase_error(TSRMLS_C); RETURN_FALSE; } @@ -1494,40 +1483,25 @@ static void _php_ibase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int fetch_type) /* {{{ */ { - zval **result_arg, **flag_arg; + zval *result_arg; + long flag_arg; long i, array_cnt = 0, flag = 0; ibase_result *ib_result; RESET_ERRMSG; - switch (ZEND_NUM_ARGS()) { - case 1: - if (FAILURE == zend_get_parameters_ex(1, result_arg)) { -
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c /ext/reflection php_reflection.c /main main.c TSRM tsrm_config_common.h tsrm_virtual_cwd.c ZendEngine2 zend.h zend_API.c zend_compile.h zend_exe
dmitry Thu Nov 22 13:33:54 2007 UTC Modified files: /TSRM tsrm_config_common.h tsrm_virtual_cwd.c /ZendEngine2zend.h zend_API.c zend_compile.h zend_execute.c zend_strtod.c zend_vm_execute.h zend_vm_execute.skl /ZendEngine2/tests bug43128.phpt /php-src/ext/interbase ibase_query.c /php-src/ext/reflection php_reflection.c /php-src/main main.c Log: Fixed bug #43128 (Very long class name causes segfault) http://cvs.php.net/viewvc.cgi/TSRM/tsrm_config_common.h?r1=1.19r2=1.20diff_format=u Index: TSRM/tsrm_config_common.h diff -u TSRM/tsrm_config_common.h:1.19 TSRM/tsrm_config_common.h:1.20 --- TSRM/tsrm_config_common.h:1.19 Thu Feb 15 19:11:29 2007 +++ TSRM/tsrm_config_common.h Thu Nov 22 13:33:53 2007 @@ -52,9 +52,17 @@ #endif #if (HAVE_ALLOCA || (defined (__GNUC__) __GNUC__ = 2)) -# define tsrm_do_alloca(p) alloca(p) -# define tsrm_free_alloca(p) +# define TSRM_ALLOCA_MAX_SIZE 4096 +# define TSRM_ALLOCA_FLAG(name) \ + int name; +# define tsrm_do_alloca_ex(size, limit, use_heap) \ + ((use_heap = ((size) (limit))) ? malloc(size) : alloca(size)) +# define tsrm_do_alloca(size, use_heap) \ + tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap) +# define tsrm_free_alloca(p, use_heap) \ + do { if (use_heap) free(p); } while (0) #else +# define TSRM_ALLOCA_FLAG(name) # define tsrm_do_alloca(p) malloc(p) # define tsrm_free_alloca(p) free(p) #endif http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.117r2=1.118diff_format=u Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.117 TSRM/tsrm_virtual_cwd.c:1.118 --- TSRM/tsrm_virtual_cwd.c:1.117 Tue Nov 13 09:47:19 2007 +++ TSRM/tsrm_virtual_cwd.c Thu Nov 22 13:33:53 2007 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: tsrm_virtual_cwd.c,v 1.117 2007/11/13 09:47:19 dmitry Exp $ */ +/* $Id: tsrm_virtual_cwd.c,v 1.118 2007/11/22 13:33:53 dmitry Exp $ */ #include sys/types.h #include sys/stat.h @@ -777,6 +777,7 @@ int length = strlen(path); char *temp; int retval; + TSRM_ALLOCA_FLAG(use_heap) if (length == 0) { return 1; /* Can't cd to empty string */ @@ -793,14 +794,14 @@ if (length == COPY_WHEN_ABSOLUTE(path) IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */ length++; } - temp = (char *) tsrm_do_alloca(length+1); + temp = (char *) tsrm_do_alloca(length+1, use_heap); memcpy(temp, path, length); temp[length] = 0; #if VIRTUAL_CWD_DEBUG fprintf (stderr, Changing directory to %s\n, temp); #endif retval = p_chdir(temp TSRMLS_CC); - tsrm_free_alloca(temp); + tsrm_free_alloca(temp, use_heap); return retval; } /* }}} */ http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.344r2=1.345diff_format=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.344 ZendEngine2/zend.h:1.345 --- ZendEngine2/zend.h:1.344Wed Nov 21 14:55:51 2007 +++ ZendEngine2/zend.h Thu Nov 22 13:33:53 2007 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend.h,v 1.344 2007/11/21 14:55:51 dmitry Exp $ */ +/* $Id: zend.h,v 1.345 2007/11/22 13:33:53 dmitry Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -178,11 +178,19 @@ #endif #if (HAVE_ALLOCA || (defined (__GNUC__) __GNUC__ = 2)) !(defined(ZTS) defined(ZEND_WIN32)) !(defined(ZTS) defined(NETWARE)) !(defined(ZTS) defined(HPUX)) !defined(DARWIN) -# define do_alloca(p) alloca(p) -# define free_alloca(p) +# define ZEND_ALLOCA_MAX_SIZE (32 * 1024) +# define ALLOCA_FLAG(name) \ + zend_bool name; +# define do_alloca_ex(size, limit, use_heap) \ + ((use_heap = (UNEXPECTED((size) (limit ? emalloc(size) : alloca(size)) +# define do_alloca(size, use_heap) \ + do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap) +# define free_alloca(p, use_heap) \ + do { if (UNEXPECTED(use_heap)) efree(p); } while (0) #else +# define ALLOCA_FLAG(name) # define do_alloca(p) emalloc(p) -# define free_alloca(p)efree(p) +# define free_alloca(p)efree(p) #endif #if ZEND_DEBUG http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.448r2=1.449diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.448 ZendEngine2/zend_API.c:1.449 --- ZendEngine2/zend_API.c:1.448Thu Nov 1 13:30:15 2007 +++ ZendEngine2/zend_API.c Thu Nov 22 13:33:53 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_API.c,v 1.448 2007/11/01 13:30:15 jani Exp $ */ +/* $Id: zend_API.c,v 1.449 2007/11/22 13:33:53 dmitry Exp $ */ #include zend.h #include zend_execute.h @@ -2195,11 +2195,10 @@ } }
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
lwe Thu Nov 8 19:41:57 2007 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: MFB - 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) - snprintf - slprintf http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.33r2=1.34diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.33 php-src/ext/interbase/ibase_query.c:1.34 --- php-src/ext/interbase/ibase_query.c:1.33Thu Jun 7 08:58:38 2007 +++ php-src/ext/interbase/ibase_query.c Thu Nov 8 19:41:57 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.33 2007/06/07 08:58:38 tony2001 Exp $ */ +/* $Id: ibase_query.c,v 1.34 2007/11/08 19:41:57 lwe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -49,6 +49,7 @@ typedef struct { ibase_db_link *link; ibase_trans *trans; + struct _ib_query *query; isc_stmt_handle stmt; unsigned short type; unsigned char has_more_rows, statement_type; @@ -56,9 +57,10 @@ ibase_array out_array[1]; /* last member */ } ibase_result; -typedef struct { +typedef struct _ib_query { ibase_db_link *link; ibase_trans *trans; + ibase_result *result; int result_res_id; isc_stmt_handle stmt; XSQLDA *in_sqlda, *out_sqlda; @@ -116,6 +118,22 @@ } /* }}} */ +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) /* {{{ */ { ibase_result *ib_result = (ibase_result *) rsrc-ptr; @@ -123,9 +141,11 @@ IBDEBUG(Freeing result by dtor...); if (ib_result) { _php_ibase_free_xsqlda(ib_result-out_sqlda); - if (ib_result-stmt ib_result-type != EXECUTE_RESULT) { - IBDEBUG(Dropping statement handle (free_result dtor)...); - isc_dsql_free_statement(IB_STATUS, ib_result-stmt, DSQL_drop); + if (ib_result-query != NULL) { + IBDEBUG(query still valid; don't drop statement handle); + 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); } @@ -142,11 +162,11 @@ if (ib_query-out_sqlda) { efree(ib_query-out_sqlda); } - if (ib_query-stmt) { - IBDEBUG(Dropping statement handle (free_query)...); - if (isc_dsql_free_statement(IB_STATUS, ib_query-stmt, DSQL_drop)) { - _php_ibase_error(TSRMLS_C); - } + if (ib_query-result != NULL) { + IBDEBUG(result still valid; don't drop statement handle); + ib_query-result-query = NULL; /* Indicate to result, that query is released */ + } else { + _php_ibase_free_stmt_handle(ib_query-link, ib_query-stmt TSRMLS_CC); } if (ib_query-in_array) { efree(ib_query-in_array); @@ -166,11 +186,7 @@ if (ib_query != NULL) { IBDEBUG(Preparing to free query by dtor...); - _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); } } @@ -302,9 +318,16 @@ static char info_type[] = {isc_info_sql_stmt_type}; char result[8]; + /* Return FAILURE, if querystring is empty */ + if (*query == '\0') { + php_error_docref(NULL
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
tony2001Fri Mar 16 09:30:19 2007 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: MFB: fix #40805 (Failure executing function ibase_execute()) http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.31r2=1.32diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.31 php-src/ext/interbase/ibase_query.c:1.32 --- php-src/ext/interbase/ibase_query.c:1.31Sat Feb 24 16:25:54 2007 +++ php-src/ext/interbase/ibase_query.c Fri Mar 16 09:30:18 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.31 2007/02/24 16:25:54 helly Exp $ */ +/* $Id: ibase_query.c,v 1.32 2007/03/16 09:30:18 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -669,13 +669,13 @@ var-sqldata = (void*)buf[i].val; switch (var-sqltype ~1) { - struct tm *t, tmbuf; + struct tm t, tmbuf; case SQL_TIMESTAMP: case SQL_TYPE_DATE: case SQL_TYPE_TIME: if (Z_TYPE_P(b_var) == IS_LONG) { - t = php_gmtime_r(Z_LVAL_P(b_var), tmbuf); + php_gmtime_r(Z_LVAL_P(b_var), t); } else { #ifdef HAVE_STRPTIME char *format = INI_STR(ibase.timestampformat); @@ -689,7 +689,7 @@ case SQL_TYPE_TIME: format = INI_STR(ibase.timeformat); } - if (!strptime(Z_STRVAL_P(b_var), format, t)) { + if (!strptime(Z_STRVAL_P(b_var), format, t)) { /* strptime() cannot handle it, so let IB have a try */ break; } @@ -700,13 +700,13 @@ switch (var-sqltype ~1) { default: /* == case SQL_TIMESTAMP */ - isc_encode_timestamp(t, buf[i].val.tsval); + isc_encode_timestamp(t, buf[i].val.tsval); break; case SQL_TYPE_DATE: - isc_encode_sql_date(t, buf[i].val.dtval); + isc_encode_sql_date(t, buf[i].val.dtval); break; case SQL_TYPE_TIME: - isc_encode_sql_time(t, buf[i].val.tmval); + isc_encode_sql_time(t, buf[i].val.tmval); break; } continue; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
tony2001Mon Jan 22 09:08:21 2007 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: fix wrong param definition http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.29r2=1.30diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.29 php-src/ext/interbase/ibase_query.c:1.30 --- php-src/ext/interbase/ibase_query.c:1.29Thu Jan 18 15:29:11 2007 +++ php-src/ext/interbase/ibase_query.c Mon Jan 22 09:08:21 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.29 2007/01/18 15:29:11 tony2001 Exp $ */ +/* $Id: ibase_query.c,v 1.30 2007/01/22 09:08:21 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1117,7 +1117,7 @@ } case 1: case 0: - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() ? 1 : 0 TSRMLS_CC, s|z, query, + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() ? 1 : 0 TSRMLS_CC, s, query, query_len)) { ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link), LE_LINK, le_link, le_plink); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
tony2001Thu Jan 18 15:29:11 2007 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: use snprintf() http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.28r2=1.29diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.28 php-src/ext/interbase/ibase_query.c:1.29 --- php-src/ext/interbase/ibase_query.c:1.28Mon Jan 1 09:29:24 2007 +++ php-src/ext/interbase/ibase_query.c Thu Jan 18 15:29:11 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.28 2007/01/01 09:29:24 sebastian Exp $ */ +/* $Id: ibase_query.c,v 1.29 2007/01/18 15:29:11 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1933,7 +1933,7 @@ add_index_stringl(return_value, 2, var-relname, var-relname_length, 1); add_assoc_stringl(return_value, relation, var-relname, var-relname_length, 1); - len = sprintf(buf, %d, var-sqllen); + len = snprintf(buf, 16, %d, var-sqllen); add_index_stringl(return_value, 3, buf, len, 1); add_assoc_stringl(return_value, length, buf, len, 1); @@ -1952,7 +1952,7 @@ precision = 18; break; } - len = sprintf(buf, NUMERIC(%d,%d), precision, -var-sqlscale); + len = snprintf(buf, 16, NUMERIC(%d,%d), precision, -var-sqlscale); add_index_stringl(return_value, 4, s, len, 1); add_assoc_stringl(return_value, type, s, len, 1); } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
iliaa Thu Nov 30 16:21:36 2006 UTC Modified files: /php-src/ext/interbase ibase_query.c Log: MFB: Thread safety fixes. http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.25r2=1.26diff_format=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.25 php-src/ext/interbase/ibase_query.c:1.26 --- php-src/ext/interbase/ibase_query.c:1.25Wed Mar 8 00:43:28 2006 +++ php-src/ext/interbase/ibase_query.c Thu Nov 30 16:21:36 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.25 2006/03/08 00:43:28 pajoye Exp $ */ +/* $Id: ibase_query.c,v 1.26 2006/11/30 16:21:36 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -669,14 +669,13 @@ var-sqldata = (void*)buf[i].val; switch (var-sqltype ~1) { - struct tm t; + struct tm *t, tmbuf; case SQL_TIMESTAMP: case SQL_TYPE_DATE: case SQL_TYPE_TIME: if (Z_TYPE_P(b_var) == IS_LONG) { - /* insert timestamp directly */ - t = *gmtime(Z_LVAL_P(b_var)); + t = php_gmtime_r(Z_LVAL_P(b_var), tmbuf); } else { #ifdef HAVE_STRPTIME char *format = INI_STR(ibase.timestampformat); @@ -690,7 +689,7 @@ case SQL_TYPE_TIME: format = INI_STR(ibase.timeformat); } - if (! strptime(Z_STRVAL_P(b_var), format, t)) { + if (!strptime(Z_STRVAL_P(b_var), format, t)) { /* strptime() cannot handle it, so let IB have a try */ break; } @@ -701,13 +700,13 @@ switch (var-sqltype ~1) { default: /* == case SQL_TIMESTAMP */ - isc_encode_timestamp(t, buf[i].val.tsval); + isc_encode_timestamp(t, buf[i].val.tsval); break; case SQL_TYPE_DATE: - isc_encode_sql_date(t, buf[i].val.dtval); + isc_encode_sql_date(t, buf[i].val.dtval); break; case SQL_TYPE_TIME: - isc_encode_sql_time(t, buf[i].val.tmval); + isc_encode_sql_time(t, buf[i].val.tmval); break; } continue; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Wed Nov 10 06:21:53 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fixed return value of ibase_execute() http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.21r2=1.22ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.21 php-src/ext/interbase/ibase_query.c:1.22 --- php-src/ext/interbase/ibase_query.c:1.21Tue Jul 6 09:46:18 2004 +++ php-src/ext/interbase/ibase_query.c Wed Nov 10 06:21:50 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.21 2004/07/06 13:46:18 abies Exp $ */ +/* $Id: ibase_query.c,v 1.22 2004/11/10 11:21:50 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -910,6 +910,9 @@ so we have to release it */ zend_list_delete(ib_query-trans_res_id); } + + RETVAL_TRUE; + return SUCCESS; default: @@ -1856,8 +1859,6 @@ } ib_query-result_res_id = zend_list_insert(result, le_result); RETVAL_RESOURCE(ib_query-result_res_id); - } else { - RETVAL_TRUE; } } while (0); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c interbase.c php_ibase_includes.h
abies Tue Jul 6 09:46:19 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c interbase.c php_ibase_includes.h Log: Don't copy ini items to module globals (fixed unregistered bug with mangled default_db setting) http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.20r2=1.21ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.20 php-src/ext/interbase/ibase_query.c:1.21 --- php-src/ext/interbase/ibase_query.c:1.20Sun Jul 4 13:13:58 2004 +++ php-src/ext/interbase/ibase_query.c Tue Jul 6 09:46:18 2004 @@ -16,13 +16,14 @@ +--+ */ -/* $Id: ibase_query.c,v 1.20 2004/07/04 17:13:58 iliaa Exp $ */ +/* $Id: ibase_query.c,v 1.21 2004/07/06 13:46:18 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h #endif #include php.h +#include php_ini.h #if HAVE_IBASE @@ -553,7 +554,7 @@ case SQL_TIMESTAMP: convert_to_string(val); #ifdef HAVE_STRPTIME - strptime(Z_STRVAL_P(val), IBG(timestampformat), t); + strptime(Z_STRVAL_P(val), INI_STR(ibase.timestampformat), t); #else n = sscanf(Z_STRVAL_P(val), %d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d, t.tm_mon, t.tm_mday, t.tm_year, t.tm_hour, t.tm_min, t.tm_sec); @@ -571,7 +572,7 @@ case SQL_TYPE_DATE: convert_to_string(val); #ifdef HAVE_STRPTIME - strptime(Z_STRVAL_P(val), IBG(dateformat), t); + strptime(Z_STRVAL_P(val), INI_STR(ibase.dateformat), t); #else n = sscanf(Z_STRVAL_P(val), %d%*[/]%d%*[/]%d, t.tm_mon, t.tm_mday, t.tm_year); @@ -588,7 +589,7 @@ case SQL_TYPE_TIME: convert_to_string(val); #ifdef HAVE_STRPTIME - strptime(Z_STRVAL_P(val), IBG(timeformat), t); + strptime(Z_STRVAL_P(val), INI_STR(ibase.timeformat), t); #else n = sscanf(Z_STRVAL_P(val), %d%*[:]%d%*[:]%d, t.tm_hour, t.tm_min, t.tm_sec); @@ -678,16 +679,16 @@ t = *gmtime(Z_LVAL_P(b_var)); } else { #ifdef HAVE_STRPTIME - char *format = IBG(timestampformat); + char *format = INI_STR(ibase.timestampformat); convert_to_string(b_var); switch (var-sqltype ~1) { case SQL_TYPE_DATE: - format = IBG(dateformat); + format = INI_STR(ibase.dateformat); break; case SQL_TYPE_TIME: - format = IBG(timeformat); + format = INI_STR(ibase.timeformat); } if (! strptime(Z_STRVAL_P(b_var), format, t)) { /* strptime() cannot handle it, so let IB have a try */ @@ -1083,9 +1084,9 @@ _php_ibase_module_error(CREATE DATABASE is not allowed in SQL safe mode TSRMLS_CC); - } else if ((IBG(max_links) != -1) (IBG(num_links) = IBG(max_links))) { + } else if (((l = INI_INT(ibase.max_links)) != -1) (IBG(num_links) = l)) { _php_ibase_module_error(CREATE DATABASE is not allowed: maximum link count - (%ld) reached TSRMLS_CC, IBG(max_links)); + (%ld) reached TSRMLS_CC, l); } else if (isc_dsql_execute_immediate(IB_STATUS, db, trans, (short)query_len, query, SQL_DIALECT_CURRENT, NULL)) { @@ -1355,15 +1356,15 @@ ZVAL_DOUBLE(val, *(double *) data); break; case SQL_DATE: /* == case SQL_TIMESTAMP: */ - format = IBG(timestampformat); + format = INI_STR(ibase.timestampformat);
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
iliaa Sun Jul 4 13:13:58 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Eliminate potentially dangerous alloca(). http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.19r2=1.20ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.19 php-src/ext/interbase/ibase_query.c:1.20 --- php-src/ext/interbase/ibase_query.c:1.19Mon Jun 28 07:27:05 2004 +++ php-src/ext/interbase/ibase_query.c Sun Jul 4 13:13:58 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.19 2004/06/28 11:27:05 abies Exp $ */ +/* $Id: ibase_query.c,v 1.20 2004/07/04 17:13:58 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1143,7 +1143,7 @@ break; } } else if (bind_n 0) { - bind_args = (zval ***) do_alloca(sizeof(zval **) * ZEND_NUM_ARGS()); + bind_args = (zval ***) emalloc(sizeof(zval **) * ZEND_NUM_ARGS()); if (FAILURE == zend_get_parameters_array_ex(ZEND_NUM_ARGS(), bind_args)) { break; @@ -1169,7 +1169,7 @@ _php_ibase_free_query(ib_query TSRMLS_CC); if (bind_args) { - free_alloca(bind_args); + efree(bind_args); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Mon Jun 28 07:27:06 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: MFB Fixed bug #28897 (-1 returned as -0.000 for 64-bit scaled int) http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.18r2=1.19ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.18 php-src/ext/interbase/ibase_query.c:1.19 --- php-src/ext/interbase/ibase_query.c:1.18Sat Jun 12 16:52:07 2004 +++ php-src/ext/interbase/ibase_query.c Mon Jun 28 07:27:05 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.18 2004/06/12 20:52:07 abies Exp $ */ +/* $Id: ibase_query.c,v 1.19 2004/06/28 11:27:05 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1321,7 +1321,7 @@ if (n = 0) { l = sprintf(string_data, % LL_MASK d.%0* LL_MASK d, n / f, -scale, n % f); - } else if (n -f) { + } else if (n = -f) { l = sprintf(string_data, % LL_MASK d.%0* LL_MASK d, n / f, -scale, -n % f); } else { l = sprintf(string_data, -0.%0* LL_MASK d, -scale, -n % f); @@ -1340,7 +1340,7 @@ if (n = 0) { l = sprintf(string_data, %ld.%0*ld, n / f, -scale, n % f); - } else if (n -f) { + } else if (n = -f) { l = sprintf(string_data, %ld.%0*ld, n / f, -scale, -n % f); } else { l = sprintf(string_data, -0.%0*ld, -scale, -n % f); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c php_interbase.h
abies Fri Jun 11 22:49:47 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c php_interbase.h Log: Added export macros http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.16r2=1.17ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.16 php-src/ext/interbase/ibase_query.c:1.17 --- php-src/ext/interbase/ibase_query.c:1.16Tue Jun 1 19:31:43 2004 +++ php-src/ext/interbase/ibase_query.c Fri Jun 11 22:49:47 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.16 2004/06/01 23:31:43 abies Exp $ */ +/* $Id: ibase_query.c,v 1.17 2004/06/12 02:49:47 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1279,7 +1279,7 @@ #endif /* }}} */ -static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ */ +FB_API int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ */ int scale, int flag TSRMLS_DC) { static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 1, 10, 100, 1, 10, http://cvs.php.net/diff.php/php-src/ext/interbase/php_interbase.h?r1=1.68r2=1.69ty=u Index: php-src/ext/interbase/php_interbase.h diff -u php-src/ext/interbase/php_interbase.h:1.68 php-src/ext/interbase/php_interbase.h:1.69 --- php-src/ext/interbase/php_interbase.h:1.68 Wed May 12 10:29:42 2004 +++ php-src/ext/interbase/php_interbase.h Fri Jun 11 22:49:47 2004 @@ -18,11 +18,23 @@ +--+ */ -/* $Id: php_interbase.h,v 1.68 2004/05/12 14:29:42 abies Exp $ */ +/* $Id: php_interbase.h,v 1.69 2004/06/12 02:49:47 abies Exp $ */ #ifndef PHP_INTERBASE_H #define PHP_INTERBASE_H +#ifdef PHP_WIN32 +# ifdef INTERBASE_EXPORTS +# define FB_API __declspec(dllexport) +# elif defined(COMPILE_DL_INTERBASE) +# define FB_API __declspec(dllimport) +# else +# define FB_API /* nothing special */ +# endif +#else +# define INTERBASE_API /* nothing special */ +#endif + extern zend_module_entry ibase_module_entry; #define phpext_interbase_ptr ibase_module_entry @@ -49,6 +61,7 @@ PHP_FUNCTION(ibase_timefmt); PHP_FUNCTION(ibase_gen_id); +PHP_FUNCTION(ibase_insert_id); PHP_FUNCTION(ibase_num_fields); PHP_FUNCTION(ibase_num_params); #if abies_0 @@ -92,6 +105,8 @@ PHP_FUNCTION(ibase_wait_event); PHP_FUNCTION(ibase_set_event_handler); PHP_FUNCTION(ibase_free_event_handler); + +FB_API int php_ibase_var_zval(zval *, void *, int, int, int, int TSRMLS_DC); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c interbase.c php_ibase_includes.h /ext/interbase/tests interbase.inc
abies Tue Jun 1 04:38:33 2004 EDT Modified files: /php-src/ext/interbase interbase.c ibase_query.c php_ibase_includes.h /php-src/ext/interbase/testsinterbase.inc Log: Use constant IBASE_CREATE instead of just 0 http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.220r2=1.221ty=u Index: php-src/ext/interbase/interbase.c diff -u php-src/ext/interbase/interbase.c:1.220 php-src/ext/interbase/interbase.c:1.221 --- php-src/ext/interbase/interbase.c:1.220 Sun May 30 16:24:46 2004 +++ php-src/ext/interbase/interbase.c Tue Jun 1 04:38:33 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: interbase.c,v 1.220 2004/05/30 20:24:46 abies Exp $ */ +/* $Id: interbase.c,v 1.221 2004/06/01 08:38:33 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -465,6 +465,7 @@ le_trans = zend_register_list_destructors_ex(_php_ibase_free_trans, NULL, interbase transaction, module_number); REGISTER_LONG_CONSTANT(IBASE_DEFAULT, PHP_IBASE_DEFAULT, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(IBASE_CREATE, PHP_IBASE_CREATE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IBASE_TEXT, PHP_IBASE_FETCH_BLOBS, CONST_PERSISTENT); /* deprecated, for BC only */ REGISTER_LONG_CONSTANT(IBASE_FETCH_BLOBS, PHP_IBASE_FETCH_BLOBS, CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IBASE_FETCH_ARRAYS, PHP_IBASE_FETCH_ARRAYS, CONST_PERSISTENT); http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.13r2=1.14ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.13 php-src/ext/interbase/ibase_query.c:1.14 --- php-src/ext/interbase/ibase_query.c:1.13Mon May 31 09:43:06 2004 +++ php-src/ext/interbase/ibase_query.c Tue Jun 1 04:38:33 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.13 2004/05/31 13:43:06 abies Exp $ */ +/* $Id: ibase_query.c,v 1.14 2004/06/01 08:38:33 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1049,6 +1049,7 @@ switch (ZEND_NUM_ARGS()) { long l; + zval *z; default: if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, 3 TSRMLS_CC, rrs, @@ -1073,9 +1074,9 @@ break; } - /* assume the statement is 'CREATE DATABASE ...' if the link argument is int(0) */ + /* the statement is 'CREATE DATABASE ...' if the link argument is IBASE_CREATE */ if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() - TSRMLS_CC, ls, l, query, query_len) l == 0) { + TSRMLS_CC, zs, z, query, query_len) ) {// l == PHP_IBASE_CREATE) { isc_db_handle db = NULL; isc_tr_handle trans = NULL; http://cvs.php.net/diff.php/php-src/ext/interbase/php_ibase_includes.h?r1=1.13r2=1.14ty=u Index: php-src/ext/interbase/php_ibase_includes.h diff -u php-src/ext/interbase/php_ibase_includes.h:1.13 php-src/ext/interbase/php_ibase_includes.h:1.14 --- php-src/ext/interbase/php_ibase_includes.h:1.13 Mon May 31 09:40:24 2004 +++ php-src/ext/interbase/php_ibase_includes.h Tue Jun 1 04:38:33 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: php_ibase_includes.h,v 1.13 2004/05/31 13:40:24 abies Exp $ */ +/* $Id: php_ibase_includes.h,v 1.14 2004/06/01 08:38:33 abies Exp $ */ #ifndef PHP_IBASE_INCLUDES_H #define PHP_IBASE_INCLUDES_H @@ -114,6 +114,7 @@ enum php_interbase_option { PHP_IBASE_DEFAULT = 0, + PHP_IBASE_CREATE= 0, /* fetch flags */ PHP_IBASE_FETCH_BLOBS = 1, PHP_IBASE_FETCH_ARRAYS = 2, http://cvs.php.net/diff.php/php-src/ext/interbase/tests/interbase.inc?r1=1.9r2=1.10ty=u Index: php-src/ext/interbase/tests/interbase.inc diff -u php-src/ext/interbase/tests/interbase.inc:1.9 php-src/ext/interbase/tests/interbase.inc:1.10 --- php-src/ext/interbase/tests/interbase.inc:1.9 Mon May 31 09:40:25 2004 +++ php-src/ext/interbase/tests/interbase.inc Tue Jun 1 04:38:33 2004 @@ -1,4 +1,4 @@ -?php /* $Id: interbase.inc,v 1.9 2004/05/31 13:40:25 abies Exp $ */ +?php /* $Id: interbase.inc,v 1.10 2004/06/01 08:38:33 abies Exp $ */ srand((double)microtime()*100); @@ -14,8 +14,9 @@ { global $test_base, $user, $password; - $test_db = ibase_query(0, sprintf( createSchema '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s, - $test_base, $user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE')); +
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Tue Jun 1 13:14:47 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Removed debugging code http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.14r2=1.15ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.14 php-src/ext/interbase/ibase_query.c:1.15 --- php-src/ext/interbase/ibase_query.c:1.14Tue Jun 1 04:38:33 2004 +++ php-src/ext/interbase/ibase_query.c Tue Jun 1 13:14:47 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.14 2004/06/01 08:38:33 abies Exp $ */ +/* $Id: ibase_query.c,v 1.15 2004/06/01 17:14:47 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1049,7 +1049,6 @@ switch (ZEND_NUM_ARGS()) { long l; - zval *z; default: if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, 3 TSRMLS_CC, rrs, @@ -1076,7 +1075,7 @@ /* the statement is 'CREATE DATABASE ...' if the link argument is IBASE_CREATE */ if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() - TSRMLS_CC, zs, z, query, query_len) ) {// l == PHP_IBASE_CREATE) { + TSRMLS_CC, ls, l, query, query_len) l == PHP_IBASE_CREATE) { isc_db_handle db = NULL; isc_tr_handle trans = NULL; @@ -1088,8 +1087,8 @@ _php_ibase_module_error(CREATE DATABASE is not allowed: maximum link count (%ld) reached TSRMLS_CC, IBG(max_links)); - } else if (isc_dsql_execute_immediate(IB_STATUS, db, trans, query_len, query, - SQL_DIALECT_CURRENT, NULL)) { + } else if (isc_dsql_execute_immediate(IB_STATUS, db, trans, (short)query_len, + query, SQL_DIALECT_CURRENT, NULL)) { _php_ibase_error(TSRMLS_C); } else if (!db) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Tue Jun 1 19:31:44 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Don't be too strict if the number of binding arguments provided exceeds the expected number http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.15r2=1.16ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.15 php-src/ext/interbase/ibase_query.c:1.16 --- php-src/ext/interbase/ibase_query.c:1.15Tue Jun 1 13:14:47 2004 +++ php-src/ext/interbase/ibase_query.c Tue Jun 1 19:31:43 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.15 2004/06/01 17:14:47 abies Exp $ */ +/* $Id: ibase_query.c,v 1.16 2004/06/01 23:31:43 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1137,10 +1137,11 @@ expected_n = ib_query.in_sqlda ? ib_query.in_sqlda-sqld : 0; if (bind_n != expected_n) { - _php_ibase_module_error(Statement expects %d arguments, %d given TSRMLS_CC, - expected_n, bind_n); - break; - + php_error_docref(NULL TSRMLS_CC, (bind_n expected_n) ? E_WARNING : E_NOTICE, + Statement expects %d arguments, %d given, expected_n, bind_n); + if (bind_n expected_n) { + break; + } } else if (bind_n 0) { bind_args = (zval ***) do_alloca(sizeof(zval **) * ZEND_NUM_ARGS()); @@ -1810,9 +1811,11 @@ expected_n = ib_query-in_sqlda ? ib_query-in_sqlda-sqld : 0; if (bind_n != expected_n) { - _php_ibase_module_error(Statement expects %d arguments, %d given TSRMLS_CC, - expected_n, bind_n); - break; + php_error_docref(NULL TSRMLS_CC, (bind_n expected_n) ? E_WARNING : E_NOTICE, + Statement expects %d arguments, %d given, expected_n, bind_n); + if (bind_n expected_n) { + break; + } } else if (bind_n 0) { /* have variables to bind */ args = (zval ***) do_alloca(ZEND_NUM_ARGS() * sizeof(zval **)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c php_ibase_includes.h /ext/interbase/tests interbase.inc
abies Mon May 31 09:40:25 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c php_ibase_includes.h /php-src/ext/interbase/testsinterbase.inc Log: Improved handling of 'CREATE DATABASE ...' by ibase_query() Improved param handling of ibase_query() and ibase_execute() http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.11r2=1.12ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.11 php-src/ext/interbase/ibase_query.c:1.12 --- php-src/ext/interbase/ibase_query.c:1.11Sun May 30 16:40:36 2004 +++ php-src/ext/interbase/ibase_query.c Mon May 31 09:40:24 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.11 2004/05/30 20:40:36 abies Exp $ */ +/* $Id: ibase_query.c,v 1.12 2004/05/31 13:40:24 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -92,6 +92,9 @@ static int le_result, le_query; +#define LE_RESULT Firebird/InterBase result +#define LE_QUERY Firebird/InterBase query + static void _php_ibase_free_xsqlda(XSQLDA *sqlda) /* {{{ */ { int i; @@ -838,7 +841,7 @@ /* }}} */ static int _php_ibase_exec(INTERNAL_FUNCTION_PARAMETERS, ibase_result **ib_resultp, /* {{{ */ - ibase_query *ib_query, int argc, zval ***args) + ibase_query *ib_query, zval ***args) { XSQLDA *in_sqlda = NULL, *out_sqlda = NULL; BIND_BUF *bind_buf = NULL; @@ -846,7 +849,8 @@ static char info_count[] = { isc_info_sql_records }; char result[64]; ISC_STATUS isc_result; - + int argc = ib_query-in_sqlda ? ib_query-in_sqlda-sqld : 0; + RESET_ERRMSG; for (i = 0; i argc; ++i) { @@ -935,11 +939,6 @@ if (ib_query-in_sqlda) { /* has placeholders */ IBDEBUG(Query wants XSQLDA for input); - if (ib_query-in_sqlda-sqld != argc) { - _php_ibase_module_error(Placeholders (%d) and variables (%d) mismatch - TSRMLS_CC, ib_query-in_sqlda-sqld, argc); - goto _php_ibase_exec_error; - } in_sqlda = emalloc(XSQLDA_LENGTH(ib_query-in_sqlda-sqld)); memcpy(in_sqlda, ib_query-in_sqlda, XSQLDA_LENGTH(ib_query-in_sqlda-sqld)); bind_buf = safe_emalloc(sizeof(BIND_BUF), ib_query-in_sqlda-sqld, 0); @@ -1035,141 +1034,123 @@ Execute a query */ PHP_FUNCTION(ibase_query) { - zval ***args, ***bind_args = NULL; - int i, bind_n = 0, trans_res_id = 0; + zval *zlink, *ztrans, ***bind_args = NULL; + char *query; + int bind_i, query_len; + long trans_res_id = 0; ibase_db_link *ib_link = NULL; ibase_trans *trans = NULL; ibase_query ib_query = { NULL, NULL, 0, 0 }; ibase_result *result = NULL; - char *query; RESET_ERRMSG; - - if (ZEND_NUM_ARGS() 1) { - WRONG_PARAM_COUNT; - } - - /* use stack to avoid leaks */ - args = (zval ***) do_alloca(sizeof(zval **) * ZEND_NUM_ARGS()); - + RETVAL_FALSE; - if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { - goto ibase_query_end; - - } - - i = 0; - while (Z_TYPE_PP(args[i++]) != IS_STRING) { - if (i = ZEND_NUM_ARGS()) { - _php_ibase_module_error(Query argument missing TSRMLS_CC); - goto ibase_query_end; - - } - } + switch (ZEND_NUM_ARGS()) { + long l; - convert_to_string_ex(args[i-1]); - query = Z_STRVAL_PP(args[i-1]); + default: + if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, 3 TSRMLS_CC, rrs, + zlink, ztrans, query, query_len)) { - /* find out if the first one or two arguments refer to either a link id, - a trans id or both */ - switch (i) { - case 1: + ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link*, zlink, -1, LE_LINK, le_link, le_plink); + ZEND_FETCH_RESOURCE(trans, ibase_trans*, ztrans, -1, LE_TRANS, le_trans); + + trans_res_id = Z_LVAL_P(ztrans); + bind_i = 3; + break; + } + case 2: + if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, 2 TSRMLS_CC, rs, + zlink, query, query_len)) { + _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, zlink, ib_link, trans); + + if (trans != NULL) { + trans_res_id = Z_LVAL_P(zlink); +
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Mon May 31 09:43:06 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fix typo in error message http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.12r2=1.13ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.12 php-src/ext/interbase/ibase_query.c:1.13 --- php-src/ext/interbase/ibase_query.c:1.12Mon May 31 09:40:24 2004 +++ php-src/ext/interbase/ibase_query.c Mon May 31 09:43:06 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.12 2004/05/31 13:40:24 abies Exp $ */ +/* $Id: ibase_query.c,v 1.13 2004/05/31 13:43:06 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1137,7 +1137,7 @@ expected_n = ib_query.in_sqlda ? ib_query.in_sqlda-sqld : 0; if (bind_n != expected_n) { - _php_ibase_module_error(Statements expect %d arguments, %d given TSRMLS_CC, + _php_ibase_module_error(Statement expects %d arguments, %d given TSRMLS_CC, expected_n, bind_n); break; @@ -1810,7 +1810,7 @@ expected_n = ib_query-in_sqlda ? ib_query-in_sqlda-sqld : 0; if (bind_n != expected_n) { - _php_ibase_module_error(Statements expect %d arguments, %d given TSRMLS_CC, + _php_ibase_module_error(Statement expects %d arguments, %d given TSRMLS_CC, expected_n, bind_n); break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Sun May 30 13:51:20 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fix unregistered bug (segfault on uninitialised pointer) Return string(0 ) from ibase_query() if query succeeded but did not affect any rows http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.8r2=1.9ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.8 php-src/ext/interbase/ibase_query.c:1.9 --- php-src/ext/interbase/ibase_query.c:1.8 Fri May 21 10:24:34 2004 +++ php-src/ext/interbase/ibase_query.c Sun May 30 13:51:19 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.8 2004/05/21 14:24:34 abies Exp $ */ +/* $Id: ibase_query.c,v 1.9 2004/05/30 17:51:19 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -307,6 +307,8 @@ ib_query-dialect = dialect; ib_query-query = estrdup(query); ib_query-trans_res_id = trans_res_id; + ib_query-out_sqlda = NULL; + ib_query-in_sqlda = NULL; if (isc_dsql_allocate_statement(IB_STATUS, link-handle, ib_query-stmt)) { _php_ibase_error(TSRMLS_C); @@ -989,10 +991,16 @@ i += len+3; } } - if (affected_rows 0) { - ib_query-trans-affected_rows = affected_rows; - RETVAL_LONG(affected_rows); - break; + + ib_query-trans-affected_rows = affected_rows; + + if (!ib_query-out_sqlda) { /* no result set is being returned */ + if (affected_rows) { + RETVAL_LONG(affected_rows); + } else { + /* this return value evaluates to bool(true) and to int(0) */ + RETVAL_STRINGL(0 ,2,1); + } } default: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c interbase.c
abies Sun May 30 16:24:46 2004 EDT Modified files: /php-src/ext/interbase interbase.c ibase_query.c Log: Fix Win32 build Added missing 'break' http://cvs.php.net/diff.php/php-src/ext/interbase/interbase.c?r1=1.219r2=1.220ty=u Index: php-src/ext/interbase/interbase.c diff -u php-src/ext/interbase/interbase.c:1.219 php-src/ext/interbase/interbase.c:1.220 --- php-src/ext/interbase/interbase.c:1.219 Sun May 30 12:41:28 2004 +++ php-src/ext/interbase/interbase.c Sun May 30 16:24:46 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: interbase.c,v 1.219 2004/05/30 16:41:28 abies Exp $ */ +/* $Id: interbase.c,v 1.220 2004/05/30 20:24:46 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -28,8 +28,6 @@ #include php.h -#define FILE_REVISION $Revision: 1.219 $ - #if HAVE_IBASE #include php_ini.h @@ -424,6 +422,8 @@ /* TODO this function should be part of either Zend or PHP API */ static PHP_INI_DISP(php_ibase_password_displayer_cb) { + TSRMLS_FETCH(); + if ((type == PHP_INI_DISPLAY_ORIG ini_entry-orig_value) || (type == PHP_INI_DISPLAY_ACTIVE ini_entry-value)) { PUTS(); http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.9r2=1.10ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.9 php-src/ext/interbase/ibase_query.c:1.10 --- php-src/ext/interbase/ibase_query.c:1.9 Sun May 30 13:51:19 2004 +++ php-src/ext/interbase/ibase_query.c Sun May 30 16:24:46 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.9 2004/05/30 17:51:19 abies Exp $ */ +/* $Id: ibase_query.c,v 1.10 2004/05/30 20:24:46 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1001,8 +1001,8 @@ /* this return value evaluates to bool(true) and to int(0) */ RETVAL_STRINGL(0 ,2,1); } + break; } - default: RETVAL_TRUE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Sun May 30 16:40:36 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Restrict 'CREATE DATABASE' in sql safe mode http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.10r2=1.11ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.10 php-src/ext/interbase/ibase_query.c:1.11 --- php-src/ext/interbase/ibase_query.c:1.10Sun May 30 16:24:46 2004 +++ php-src/ext/interbase/ibase_query.c Sun May 30 16:40:36 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.10 2004/05/30 20:24:46 abies Exp $ */ +/* $Id: ibase_query.c,v 1.11 2004/05/30 20:40:36 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1081,6 +1081,11 @@ if (IBG(default_link) == -1) { isc_db_handle db = NULL; isc_tr_handle trans = NULL; + + if (PG(sql_safe_mode)) { + _php_ibase_module_error(CREATE DATABASE not allowed in SQL safe mode TSRMLS_CC); + goto ibase_query_end; + } if (isc_dsql_execute_immediate(IB_STATUS, db, trans, 0, query, SQL_DIALECT_CURRENT, NULL)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Fri May 21 09:46:04 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Added test for duplicate field names when returning rows as hashes or objects # This change should be in 5.0.0, as it might break BC http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.6r2=1.7ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.6 php-src/ext/interbase/ibase_query.c:1.7 --- php-src/ext/interbase/ibase_query.c:1.6 Wed May 12 11:16:51 2004 +++ php-src/ext/interbase/ibase_query.c Fri May 21 09:46:04 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.6 2004/05/12 15:16:51 abies Exp $ */ +/* $Id: ibase_query.c,v 1.7 2004/05/21 13:46:04 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1504,7 +1504,31 @@ array_init(return_value); for (i = 0; i ib_result-out_sqlda-sqld; ++i) { + char alias[METADATALENGTH+4]; XSQLVAR *var = ib_result-out_sqlda-sqlvar[i]; + + if (! (fetch_type FETCH_ROW)) { + int i = 0; + char const *base = FIELD; /* use 'FIELD' if name is empty */ + + /** + * Ensure no two columns have identical names: + * keep generating new names until we find one that is unique. + */ + switch (*var-aliasname) { + void *p; + + default: + i = 1; + strcpy(alias, base = var-aliasname); + + while (SUCCESS == zend_symtable_find(Z_ARRVAL_P(return_value),alias,strlen(alias)+1,p)) { + + case '\0': + sprintf(alias, %s_%02d, base, i++); + } + } + } if (((var-sqltype 1) == 0) || *var-sqlind != -1) { zval *result; @@ -1614,13 +1638,13 @@ if (fetch_type FETCH_ROW) { add_index_zval(return_value, i, result); } else { - add_assoc_zval(return_value, var-aliasname, result); + add_assoc_zval(return_value, alias, result); } } else { if (fetch_type FETCH_ROW) { add_index_null(return_value, i); } else { - add_assoc_null(return_value, var-aliasname); + add_assoc_null(return_value, alias); } } } /* for field */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c /ext/interbase/tests 003.phpt
abies Fri May 21 10:24:34 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c /php-src/ext/interbase/tests003.phpt Log: Removed strcpy() call from most common case Added test for hash index generation http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.7r2=1.8ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.7 php-src/ext/interbase/ibase_query.c:1.8 --- php-src/ext/interbase/ibase_query.c:1.7 Fri May 21 09:46:04 2004 +++ php-src/ext/interbase/ibase_query.c Fri May 21 10:24:34 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.7 2004/05/21 13:46:04 abies Exp $ */ +/* $Id: ibase_query.c,v 1.8 2004/05/21 14:24:34 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1504,8 +1504,8 @@ array_init(return_value); for (i = 0; i ib_result-out_sqlda-sqld; ++i) { - char alias[METADATALENGTH+4]; XSQLVAR *var = ib_result-out_sqlda-sqlvar[i]; + char buf[METADATALENGTH+4], *alias = var-aliasname; if (! (fetch_type FETCH_ROW)) { int i = 0; @@ -1515,17 +1515,18 @@ * Ensure no two columns have identical names: * keep generating new names until we find one that is unique. */ - switch (*var-aliasname) { + switch (*alias) { void *p; default: i = 1; - strcpy(alias, base = var-aliasname); + base = alias; - while (SUCCESS == zend_symtable_find(Z_ARRVAL_P(return_value),alias,strlen(alias)+1,p)) { + while (SUCCESS == zend_symtable_find( + Z_ARRVAL_P(return_value),alias,strlen(alias)+1,p)) { case '\0': - sprintf(alias, %s_%02d, base, i++); + sprintf(alias = buf, %s_%02d, base, i++); } } } http://cvs.php.net/diff.php/php-src/ext/interbase/tests/003.phpt?r1=1.8r2=1.9ty=u Index: php-src/ext/interbase/tests/003.phpt diff -u php-src/ext/interbase/tests/003.phpt:1.8 php-src/ext/interbase/tests/003.phpt:1.9 --- php-src/ext/interbase/tests/003.phpt:1.8Wed May 19 04:54:52 2004 +++ php-src/ext/interbase/tests/003.phptFri May 21 10:24:34 2004 @@ -3,7 +3,7 @@ --SKIPIF-- ?php include(skipif.inc); ? --FILE-- -?php /* $Id: 003.phpt,v 1.8 2004/05/19 08:54:52 helly Exp $ */ +?php /* $Id: 003.phpt,v 1.9 2004/05/21 14:24:34 abies Exp $ */ require(interbase.inc); ibase_connect($test_base); @@ -125,8 +125,59 @@ ibase_free_result($sel); } /* for($iter) */ + /* check for correct handling of duplicate field names */ + $q = ibase_query('SELECT 1 AS id, 2 AS id, 3 AS id, 4 AS id, 5 AS id, 6 AS id, 7 AS id, 8 AS id, 9 AS id, + 10 AS id, 11 AS id, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 FROM rdb$database'); + var_dump(ibase_fetch_assoc($q)); + ibase_close(); echo end of test\n; ? --EXPECT-- +array(22) { + [ID]= + int(1) + [ID_01]= + int(2) + [ID_02]= + int(3) + [ID_03]= + int(4) + [ID_04]= + int(5) + [ID_05]= + int(6) + [ID_06]= + int(7) + [ID_07]= + int(8) + [ID_08]= + int(9) + [ID_09]= + int(10) + [ID_10]= + int(11) + [FIELD_00]= + int(12) + [FIELD_01]= + int(13) + [FIELD_02]= + int(14) + [FIELD_03]= + int(15) + [FIELD_04]= + int(16) + [FIELD_05]= + int(17) + [FIELD_06]= + int(18) + [FIELD_07]= + int(19) + [FIELD_08]= + int(20) + [FIELD_09]= + int(21) + [FIELD_10]= + int(22) +} end of test -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Wed May 12 11:16:51 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fixed a couple of inconsistencies in param binding # Previously, empty strings were either rejected (for scaled integers) # or silently converted to 0 (unscaled integers floats). Also, in some # cases, null zvals were converted to empty strings, which were # consequently rejected as unconvertible values. # In the new situation, empty strings will be handled as NULLs for # fields that cannot distinguish between the two (numeric/date/time). # Additionally, all range and value checking is now carried out by the # database, so there is a consistent interface for error handling. http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.5r2=1.6ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.5 php-src/ext/interbase/ibase_query.c:1.6 --- php-src/ext/interbase/ibase_query.c:1.5 Wed May 12 10:29:42 2004 +++ php-src/ext/interbase/ibase_query.c Wed May 12 11:16:51 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.5 2004/05/12 14:29:42 abies Exp $ */ +/* $Id: ibase_query.c,v 1.6 2004/05/12 15:16:51 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -618,182 +618,165 @@ var-sqlind = buf[i].sqlind; - if (Z_TYPE_P(b_var) != IS_NULL) { - buf[i].sqlind = 0; + /* check if a NULL should be inserted */ + switch (Z_TYPE_P(b_var)) { + int force_null; + + case IS_STRING: + + force_null = 0; + + /* for these types, an empty string can be handled like a NULL value */ + switch (var-sqltype ~1) { + case SQL_SHORT: + case SQL_LONG: + case SQL_INT64: + case SQL_FLOAT: + case SQL_DOUBLE: + case SQL_TIMESTAMP: + case SQL_TYPE_DATE: + case SQL_TYPE_TIME: + force_null = (Z_STRLEN_P(b_var) == 0); + } - if (var-sqlscale 0) { - /* - DECIMAL or NUMERIC field are stored internally as scaled integers. - Coerce it to string and let InterBase's internal routines handle it. - */ - goto php_ibase_bind_default; - } + if (! force_null) break; - var-sqldata = (void*)buf[i]; + case IS_NULL: - switch (var-sqltype ~1) { - struct tm t; + /* complain if this field doesn't allow NULL values */ + if (! (var-sqltype 1)) { + _php_ibase_module_error(Parameter %d: non-empty value required TSRMLS_CC, i+1); + rv = FAILURE; + } else { + buf[i].sqlind = -1; + } - case SQL_SHORT: - convert_to_long(b_var); - if (Z_LVAL_P(b_var) SHRT_MAX || Z_LVAL_P(b_var) SHRT_MIN) { - _php_ibase_module_error(Parameter %d exceeds field width TSRMLS_CC, i+1); - rv = FAILURE; - break; - } - buf[i].val.sval = (short) Z_LVAL_P(b_var); - break; - case SQL_LONG: - convert_to_long(b_var); -#if (SIZEOF_LONG 4) - /* ISC_LONG is always 32-bit */ - if (Z_LVAL_P(b_var) ISC_LONG_MAX || Z_LVAL_P(b_var) ISC_LONG_MIN) { - _php_ibase_module_error(Parameter %d exceeds field width TSRMLS_CC, i+1); - rv = FAILURE; - break; - } -#endif - buf[i].val.lval = (ISC_LONG) Z_LVAL_P(b_var); - break; -#if
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Fri May 7 11:11:07 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fix unregistered bug in zval pointer/array juggling # Thinko: element of a **zval[] is usually not a *zval[] # I can't believe this has gone undetected for 4+ years! http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.3r2=1.4ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.3 php-src/ext/interbase/ibase_query.c:1.4 --- php-src/ext/interbase/ibase_query.c:1.3 Wed May 5 18:18:35 2004 +++ php-src/ext/interbase/ibase_query.c Fri May 7 11:11:07 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.3 2004/05/05 22:18:35 abies Exp $ */ +/* $Id: ibase_query.c,v 1.4 2004/05/07 15:11:07 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -603,14 +603,14 @@ } /* }}} */ -static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ */ +static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{ */ ibase_query *ib_query TSRMLS_DC) { int i, array_cnt = 0, rv = SUCCESS; for (i = 0; i sqlda-sqld; ++i) { /* bound vars */ - zval *b_var = b_vars[i]; + zval *b_var = *b_vars[i]; XSQLVAR *var = sqlda-sqlvar[i]; var-sqlind = buf[i].sqlind; @@ -881,19 +881,19 @@ /* }}} */ static int _php_ibase_exec(INTERNAL_FUNCTION_PARAMETERS, ibase_result **ib_resultp, /* {{{ */ - ibase_query *ib_query, int argc, zval **args) + ibase_query *ib_query, int argc, zval ***args) { XSQLDA *in_sqlda = NULL, *out_sqlda = NULL; BIND_BUF *bind_buf = NULL; - int rv = FAILURE; + int i, rv = FAILURE; static char info_count[] = { isc_info_sql_records }; char result[64]; ISC_STATUS isc_result; RESET_ERRMSG; - if (argc 0 args != NULL) { - SEPARATE_ZVAL(args); + for (i = 0; i argc; ++i) { + SEPARATE_ZVAL(args[i]); } switch (ib_query-statement_type) { @@ -1072,7 +1072,7 @@ Execute a query */ PHP_FUNCTION(ibase_query) { - zval ***args, **bind_args = NULL; + zval ***args, ***bind_args = NULL; int i, bind_n = 0, trans_res_id = 0; ibase_db_link *ib_link = NULL; ibase_trans *trans = NULL; @@ -1186,7 +1186,7 @@ if (ZEND_NUM_ARGS() i) { /* have variables to bind */ bind_n = ZEND_NUM_ARGS() - i; - bind_args = args[i]; + bind_args = args[i]; } /* open default transaction */ @@ -1830,7 +1830,7 @@ Execute a previously prepared query */ PHP_FUNCTION(ibase_execute) { - zval ***args, **bind_args = NULL; + zval ***args, ***bind_args = NULL; ibase_query *ib_query; ibase_result *result = NULL; @@ -1850,7 +1850,7 @@ ZEND_FETCH_RESOURCE(ib_query, ibase_query *, args[0], -1, InterBase query, le_query); if (ZEND_NUM_ARGS() 1) { /* have variables to bind */ - bind_args = args[1]; + bind_args = args[1]; } /* Have we used this cursor before and it's still open (exec proc has no cursor) ? */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Wed May 5 18:18:35 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: Fixed unregistered bug: array count is incorrect when binding array ids Fixed unregistered bug: empty numeric/datetime param argument is coerced to a string that cannot be handled by the IB API layer http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.2r2=1.3ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.2 php-src/ext/interbase/ibase_query.c:1.3 --- php-src/ext/interbase/ibase_query.c:1.2 Tue May 4 08:42:54 2004 +++ php-src/ext/interbase/ibase_query.c Wed May 5 18:18:35 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.2 2004/05/04 12:42:54 abies Exp $ */ +/* $Id: ibase_query.c,v 1.3 2004/05/05 22:18:35 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -615,14 +615,7 @@ var-sqlind = buf[i].sqlind; - if (Z_TYPE_P(b_var) == IS_NULL) { - if ((var-sqltype 1) != 1) { - _php_ibase_module_error(Parameter %d must have a value TSRMLS_CC, i+1); - rv = FAILURE; - } - buf[i].sqlind = -1; - if ((var-sqltype ~1) == SQL_ARRAY) ++array_cnt; - } else { + if (Z_TYPE_P(b_var) != IS_NULL) { buf[i].sqlind = 0; if (var-sqlscale 0) { @@ -630,7 +623,7 @@ DECIMAL or NUMERIC field are stored internally as scaled integers. Coerce it to string and let InterBase's internal routines handle it. */ - var-sqltype = SQL_TEXT; + goto php_ibase_bind_default; } var-sqldata = (void*)buf[i]; @@ -775,7 +768,7 @@ } } else { /* convert the array data into something IB can understand */ - ibase_array *ar = ib_query-in_array[array_cnt++]; + ibase_array *ar = ib_query-in_array[array_cnt]; void *array_data = emalloc(ar-ar_size); ISC_QUAD array_id = { 0, 0 }; @@ -797,15 +790,32 @@ buf[i].val.qval = array_id; efree(array_data); } + ++array_cnt; break; - default: php_ibase_bind_default: + /* empty strings should be coerced to NULL for non-text types */ + if (Z_TYPE_P(b_var) == IS_STRING Z_STRLEN_P(b_var) == 0) { + ZVAL_NULL(b_var); + break; + } + + default: convert_to_string(b_var); var-sqldata = Z_STRVAL_P(b_var); var-sqllen = Z_STRLEN_P(b_var); var-sqltype = SQL_TEXT; } /* switch */ } /* if */ + + if (Z_TYPE_P(b_var) == IS_NULL) { + if (! (var-sqltype 1)) { + _php_ibase_module_error(Parameter %d must have a value TSRMLS_CC, i+1); + rv = FAILURE; + } + buf[i].sqlind = -1; + + if (var-sqltype SQL_ARRAY) ++array_cnt; + } } /* for */ return rv; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/interbase ibase_query.c
abies Tue May 4 08:42:54 2004 EDT Modified files: /php-src/ext/interbase ibase_query.c Log: ibase_query(): Be careful not to return true on error conditions http://cvs.php.net/diff.php/php-src/ext/interbase/ibase_query.c?r1=1.1r2=1.2ty=u Index: php-src/ext/interbase/ibase_query.c diff -u php-src/ext/interbase/ibase_query.c:1.1 php-src/ext/interbase/ibase_query.c:1.2 --- php-src/ext/interbase/ibase_query.c:1.1 Mon Apr 5 09:22:33 2004 +++ php-src/ext/interbase/ibase_query.c Tue May 4 08:42:54 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: ibase_query.c,v 1.1 2004/04/05 13:22:33 abies Exp $ */ +/* $Id: ibase_query.c,v 1.2 2004/05/04 12:42:54 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -941,7 +941,7 @@ return SUCCESS; default: - RETVAL_TRUE; + RETVAL_FALSE; } /* allocate sqlda and output buffers */ @@ -1027,7 +1027,11 @@ if (affected_rows 0) { ib_query-trans-affected_rows = affected_rows; RETVAL_LONG(affected_rows); + break; } + + default: + RETVAL_TRUE; } rv = SUCCESS; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php