From: Ilia Alshanetsky Date: Tue, 14 Feb 2006 14:26:11 +0000 (+0000) Subject: Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). X-Git-Tag: php-5.1.3RC1~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3608dd4c11827b8db5f610c95e4beab84cb8b0b7;p=php Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). --- diff --git a/NEWS b/NEWS index ba7b29cca3..d5bda2e745 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ PHP NEWS - Added ReflectionClass::newInstanceArgs($args). (Marcus) - Added imap_savebody() that allows message body to be written to a file. (Mike) +- Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). (Ilia) - Fixed bug #36382 (PDO/PgSQL's getColumnMeta() crashes). (Derick) - Fixed bug #36359 (splFileObject::fwrite() doesn't write when no data length specified). (Tony) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 6a5224d04c..500cf072ed 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -434,6 +434,8 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 0 TSRMLS_CC); + H->max_buffer_size = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_MAX_BUFFER_SIZE, 1024 * 1024 TSRMLS_CC); + if (mysql_options(H->server, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout)) { pdo_mysql_error(dbh); goto cleanup; diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index c3351e9c04..846acd1938 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -71,8 +71,6 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) return 1; } -#define PDO_MYSQL_MAX_BUFFER 1024*1024 /* 1 megabyte */ - static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) { pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; @@ -144,8 +142,8 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) S->fields[i].max_length? S->fields[i].max_length: S->fields[i].length; /* work-around for longtext and alike */ - if (S->bound_result[i].buffer_length > PDO_MYSQL_MAX_BUFFER) { - S->bound_result[i].buffer_length = PDO_MYSQL_MAX_BUFFER; + if (S->bound_result[i].buffer_length > H->max_buffer_size) { + S->bound_result[i].buffer_length = H->max_buffer_size; } } #if 0 diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index 4fb0670520..85af4731dd 100755 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -38,6 +38,7 @@ typedef struct { unsigned attached:1; unsigned buffered:1; unsigned _reserved:31; + unsigned long max_buffer_size; pdo_mysql_error_info einfo; } pdo_mysql_db_handle; @@ -82,5 +83,6 @@ enum { PDO_MYSQL_ATTR_INIT_COMMAND, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, + PDO_MYSQL_ATTR_MAX_BUFFER_SIZE, }; #endif