diff options
author | Stanislav Malyshev <stas@php.net> | 2011-05-15 00:40:12 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2011-05-15 00:40:12 +0000 |
commit | 0f29950d9cde1170c168e5ab4537506fa4d1d29d (patch) | |
tree | f490bd54fb738507db485d47ec756fd2e3872966 /ext/pdo_mysql/mysql_statement.c | |
parent | 1ca8acda400a028ec59728d4d4609950a9a58155 (diff) | |
parent | 516c2f5920391239d4bfa2126ab772d5f712f8ba (diff) | |
download | php-git-0f29950d9cde1170c168e5ab4537506fa4d1d29d.tar.gz |
initiate 5.4 branch
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rwxr-xr-x | ext/pdo_mysql/mysql_statement.c | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 22b3474b0f..375e493930 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -59,12 +59,10 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ pefree(S->einfo.errmsg, stmt->dbh->is_persistent); S->einfo.errmsg = NULL; } -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (S->stmt) { pdo_mysql_stmt_close(S->stmt); S->stmt = NULL; } -#endif /* HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND */ #ifndef PDO_USE_MYSQLND if (S->params) { @@ -77,9 +75,6 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ efree(S->in_length); } -#endif /* PDO_USE_MYSQLND */ - -#ifdef HAVE_MYSQL_STMT_PREPARE if (S->bound_result) { int i; @@ -91,10 +86,9 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ efree(S->out_null); efree(S->out_length); } -#endif /* HAVE_MYSQL_STMT_PREPARE */ +#endif -#if HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND if (S->H->server) { while (mysql_more_results(S->H->server)) { MYSQL_RES *res; @@ -107,11 +101,11 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ mysql_free_result(res); } } - } -#endif /* HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND */ + } + #if PDO_USE_MYSQLND if (!S->stmt && S->current_data) { - free(S->current_data); + mnd_free(S->current_data); } #endif /* PDO_USE_MYSQLND */ @@ -131,7 +125,7 @@ static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ } /* }}} */ -#ifdef HAVE_MYSQL_STMT_PREPARE +#ifndef PDO_USE_MYSQLND static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ { pdo_mysql_stmt *S = stmt->driver_data; @@ -142,8 +136,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC) /* (re)bind the parameters */ if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { if (S->params) { - efree(S->params); - S->params = 0; + memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND)); } pdo_mysql_error_stmt(stmt); if (mysql_stmt_errno(S->stmt) == 2057) { @@ -294,11 +287,9 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ PDO_DBG_ENTER("pdo_mysql_stmt_execute"); PDO_DBG_INF_FMT("stmt=%p", S->stmt); -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (S->stmt) { PDO_DBG_RETURN(pdo_mysql_stmt_execute_prepared(stmt)); } -#endif /* ensure that we free any previous unfetched results */ if (S->result) { @@ -340,7 +331,6 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ { -#if HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_db_handle *H = S->H; long row_count; @@ -402,7 +392,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ #endif /* ensure that we free any previous unfetched results */ -#if HAVE_MYSQL_STMT_PREPARE +#ifndef PDO_USE_MYSQLND if (S->stmt) { stmt->column_count = (int)mysql_num_fields(S->result); mysql_stmt_free_result(S->stmt); @@ -442,10 +432,6 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ S->fields = mysql_fetch_fields(S->result); PDO_DBG_RETURN(1); } -#else - strcpy(stmt->error_code, "HYC00"); - PDO_DBG_RETURN(0); -#endif /* HAVE_MYSQL_STMT_PREPARE */ } /* }}} */ @@ -468,7 +454,6 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da #ifndef PDO_USE_MYSQLND PDO_MYSQL_PARAM_BIND *b; #endif -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; PDO_DBG_ENTER("pdo_mysql_stmt_param_hook"); @@ -600,7 +585,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da break; } } -#endif /* HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND */ + PDO_DBG_RETURN(1); } /* }}} */ @@ -622,7 +607,6 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, PDO_DBG_RETURN(1); } #else -# if HAVE_MYSQL_STMT_PREPARE int ret; if (S->stmt) { @@ -643,7 +627,6 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, PDO_DBG_RETURN(1); } -# endif /* HAVE_MYSQL_STMT_PREPARE */ #endif /* PDO_USE_MYSQLND */ if (!S->result) { @@ -652,7 +635,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, } #if PDO_USE_MYSQLND if (!S->stmt && S->current_data) { - free(S->current_data); + mnd_free(S->current_data); } #endif /* PDO_USE_MYSQLND */ @@ -730,15 +713,12 @@ static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsig } /* With mysqlnd data is stored inside mysqlnd, not S->current_data */ -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (!S->stmt) { -#endif if (S->current_data == NULL || !S->result) { PDO_DBG_RETURN(0); } -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND } -#endif + if (colno >= stmt->column_count) { /* error invalid column */ PDO_DBG_RETURN(0); @@ -750,7 +730,7 @@ static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsig *len = sizeof(zval); PDO_DBG_RETURN(1); } -#elif HAVE_MYSQL_STMT_PREPARE +#else if (S->stmt) { if (S->out_null[colno]) { *ptr = NULL; @@ -768,7 +748,7 @@ static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsig *len = S->out_length[colno]; PDO_DBG_RETURN(1); } -#endif /* PDO_USE_MYSQLND else HAVE_MYSQL_STMT_PREPARE */ +#endif *ptr = S->current_data[colno]; *len = S->current_lengths[colno]; PDO_DBG_RETURN(1); @@ -886,7 +866,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va #endif add_assoc_zval(return_value, "flags", flags); - add_assoc_string(return_value, "table",(F->table?F->table:""), 1); + add_assoc_string(return_value, "table", (char *) (F->table?F->table:""), 1); PDO_DBG_RETURN(SUCCESS); } /* }}} */ @@ -900,15 +880,12 @@ static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ mysql_free_result(S->result); S->result = NULL; } -#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (S->stmt) { int retval; retval = mysql_stmt_free_result(S->stmt); PDO_DBG_RETURN(retval ? 0 : 1); } -#endif -#if HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND while (mysql_more_results(S->H->server)) { MYSQL_RES *res; if (mysql_next_result(S->H->server) != 0) { @@ -919,7 +896,6 @@ static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ mysql_free_result(res); } } -#endif PDO_DBG_RETURN(1); } /* }}} */ |