iliaa Wed Jul 20 00:30:15 2005 EDT
Modified files:
/php-src/ext/pdo_mysql mysql_statement.c
Log:
Fixed memory corruption (wrong order of operations of stored prep. stmt).
Optimize the max length calculation process.
http://cvs.php.net/diff.php/php-src/ext/pdo_mysql/mysql_statement.c?r1=1.47&r2=1.48&ty=u
Index: php-src/ext/pdo_mysql/mysql_statement.c
diff -u php-src/ext/pdo_mysql/mysql_statement.c:1.47
php-src/ext/pdo_mysql/mysql_statement.c:1.48
--- php-src/ext/pdo_mysql/mysql_statement.c:1.47 Tue Jul 19 23:38:32 2005
+++ php-src/ext/pdo_mysql/mysql_statement.c Wed Jul 20 00:30:14 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysql_statement.c,v 1.47 2005/07/20 03:38:32 iliaa Exp $ */
+/* $Id: mysql_statement.c,v 1.48 2005/07/20 04:30:14 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -91,19 +91,12 @@
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 @@
/* 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 @@
pdo_mysql_error_stmt(stmt);
return 0;
}
+
+ /* if buffered, pre-fetch all the data */
+ if (H->buffered) {
+ mysql_stmt_store_result(S->stmt);
+ }
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php