com php-src: Fixed bugs in pdo_mysql: ext/pdo/pdo_sql _parser.c ext/pdo/pdo_sql_parser.re ext/pdo/pdo _stmt.c ext/pdo_mysql/mysql_statement.c

From: Date: Thu, 08 May 2014 07:19:43 +0000
Subject: com php-src: Fixed bugs in pdo_mysql: ext/pdo/pdo_sql _parser.c ext/pdo/pdo_sql_parser.re ext/pdo/pdo _stmt.c ext/pdo_mysql/mysql_statement.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-78202@lists.php.net to get a copy of this message
Commit: 5f46c8fa31a8cfa0ad03b9aebd04243a09ac7be1 Author: Xinchen Hui <laruence@php.net> Thu, 8 May 2014 15:19:43 +0800 Parents: dfc940c5d95040ebc75c584e4104d760e181e2d1 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5f46c8fa31a8cfa0ad03b9aebd04243a09ac7be1 Log: Fixed bugs in pdo_mysql Changed paths: M ext/pdo/pdo_sql_parser.c M ext/pdo/pdo_sql_parser.re M ext/pdo/pdo_stmt.c M ext/pdo_mysql/mysql_statement.c Diff: diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 4420fcf..50b2b5d 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -434,6 +434,10 @@ struct placeholder { struct placeholder *next; }; +static void free_param_name(zval *el) { + efree(Z_PTR_P(el)); +} + PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery, int *outquery_len TSRMLS_DC) { @@ -670,7 +674,7 @@ rewrite: if (stmt->bound_param_map == NULL) { ALLOC_HASHTABLE(stmt->bound_param_map); - zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0); } for (plc = placeholders; plc; plc = plc->next) { @@ -711,12 +715,11 @@ rewrite: if (stmt->bound_param_map == NULL) { ALLOC_HASHTABLE(stmt->bound_param_map); - zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0); } for (plc = placeholders; plc; plc = plc->next) { char *name; - name = estrndup(plc->pos, plc->len); zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1); efree(name); diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 883a22c..4a206c7 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -76,6 +76,10 @@ struct placeholder { struct placeholder *next; }; +static void free_param_name(zval *el) { + efree(Z_PTR_P(el)); +} + PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery, int *outquery_len TSRMLS_DC) { @@ -312,7 +316,7 @@ rewrite: if (stmt->bound_param_map == NULL) { ALLOC_HASHTABLE(stmt->bound_param_map); - zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0); } for (plc = placeholders; plc; plc = plc->next) { @@ -353,12 +357,11 @@ rewrite: if (stmt->bound_param_map == NULL) { ALLOC_HASHTABLE(stmt->bound_param_map); - zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0); } for (plc = placeholders; plc; plc = plc->next) { char *name; - name = estrndup(plc->pos, plc->len); zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1); efree(name); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index bb8a95e..62db2c6 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -128,7 +128,7 @@ static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_pa * we will raise an error, as we can't be sure that it is safe * to bind multiple parameters onto the same zval in the underlying * driver */ - zval *name; + char *name; int position = 0; if (stmt->named_rewrite_template) { @@ -137,16 +137,16 @@ static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_pa } if (!param->name) { /* do the reverse; map the parameter number to the name */ - if ((name = zend_hash_index_find(stmt->bound_param_map, param->paramno)) != NULL) { - param->name = STR_COPY(Z_STR_P(name)); + if ((name = zend_hash_index_find_ptr(stmt->bound_param_map, param->paramno)) != NULL) { + param->name = STR_INIT(name, strlen(name), 0); return 1; } pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined" TSRMLS_CC); return 0; } - ZEND_HASH_FOREACH_VAL(stmt->bound_param_map, name) { - if (strncmp(Z_STRVAL_P(name), param->name->val, param->name->len + 1)) { + ZEND_HASH_FOREACH_PTR(stmt->bound_param_map, name) { + if (strncmp(name, param->name->val, param->name->len + 1)) { position++; continue; } @@ -460,7 +460,7 @@ static PHP_METHOD(PDOStatement, execute) if (key) { /* yes this is correct.. we don't want to count the null byte. ask wez */ - param.name = STR_COPY(key); + param.name = key; param.paramno = -1; } else { /* we're okay to be zero based here */ diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index df3a395..ac01102 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -404,7 +404,8 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ /* ensure that we free any previous unfetched results */ #ifndef PDO_USE_MYSQLND if (S->stmt) { - stmt->column_count = (int)mysql_num_fields(S->result); + //???? This line is very suspicious + //stmt->column_count = (int)mysql_num_fields(S->result); mysql_stmt_free_result(S->stmt); } #endif

« previous php.cvs (#78202) next »