mirror of
https://github.com/php/php-src.git
synced 2024-09-23 02:47:26 +00:00
Fixed memory corruption (wrong order of operations of stored prep. stmt).
Optimize the max length calculation process.
This commit is contained in:
parent
97e8c6f4a9
commit
99d8090cb2
@ -91,19 +91,12 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if buffered, pre-fetch all the data */
|
||||
if (H->buffered) {
|
||||
if (S->max_length == 1 && !S->result) {
|
||||
my_bool on = 1;
|
||||
mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
|
||||
}
|
||||
mysql_stmt_store_result(S->stmt);
|
||||
}
|
||||
|
||||
if (!S->result) {
|
||||
/* figure out the result set format, if any */
|
||||
S->result = mysql_stmt_result_metadata(S->stmt);
|
||||
if (S->result) {
|
||||
int calc_max_length = H->buffered && S->max_length == 1;
|
||||
|
||||
S->fields = mysql_fetch_fields(S->result);
|
||||
|
||||
if (S->bound_result) {
|
||||
@ -123,6 +116,11 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
|
||||
|
||||
/* summon memory to hold the row */
|
||||
for (i = 0; i < stmt->column_count; i++) {
|
||||
if (calc_max_length && S->fields[i].type == FIELD_TYPE_BLOB) {
|
||||
my_bool on = 1;
|
||||
mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
|
||||
calc_max_length = 0;
|
||||
}
|
||||
S->bound_result[i].buffer_length =
|
||||
S->fields[i].max_length? S->fields[i].max_length:
|
||||
S->fields[i].length;
|
||||
@ -136,6 +134,11 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
|
||||
pdo_mysql_error_stmt(stmt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if buffered, pre-fetch all the data */
|
||||
if (H->buffered) {
|
||||
mysql_stmt_store_result(S->stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user