]> granicus.if.org Git - php/commitdiff
Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB).
authorIlia Alshanetsky <iliaa@php.net>
Tue, 14 Feb 2006 14:26:11 +0000 (14:26 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 14 Feb 2006 14:26:11 +0000 (14:26 +0000)
NEWS
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/mysql_statement.c
ext/pdo_mysql/php_pdo_mysql_int.h

diff --git a/NEWS b/NEWS
index ba7b29cca3aafa4145eeaf75097d39c0c3f54224..d5bda2e74539c805ec3a40a9cfa52f8c37a2a6d4 100644 (file)
--- 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)
index 6a5224d04c5a600a435f5511a4a0565f83235b17..500cf072ede153d37ae71a141e10936c3a72e718 100755 (executable)
@@ -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;
index c3351e9c04b342e51cae07554ffcb1509e75f8c9..846acd1938e171c0dc7ead22d3a1aa77c9ddc712 100755 (executable)
@@ -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
index 4fb06705203993633874c0caa1deb3b313c4ee13..85af4731dd4f5a42b1b84b4e7b4b55a35c6af747 100755 (executable)
@@ -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