diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2005-07-20 04:30:14 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2005-07-20 04:30:14 +0000 |
commit | 99d8090cb27d27f7b9d230dbaa68cdef8cb837a7 (patch) | |
tree | fc8a98bbbd6e9b7a7e03e0ac7ee00137855e3194 /ext/pdo_mysql/mysql_statement.c | |
parent | 97e8c6f4a98a2074aa2261f6e64f983277e3b2ac (diff) | |
download | php-git-99d8090cb27d27f7b9d230dbaa68cdef8cb837a7.tar.gz |
Fixed memory corruption (wrong order of operations of stored prep. stmt).
Optimize the max length calculation process.
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rwxr-xr-x | ext/pdo_mysql/mysql_statement.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 5680e09981..43587345a9 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -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); + } } } |