]> granicus.if.org Git - php/commitdiff
Proper handling for databases that need to pre-calculate length of large
authorIlia Alshanetsky <iliaa@php.net>
Wed, 20 Jul 2005 03:38:33 +0000 (03:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 20 Jul 2005 03:38:33 +0000 (03:38 +0000)
columns, which is not normally done for performance reasons.

ext/pdo/pdo.c
ext/pdo/php_pdo_driver.h
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/mysql_statement.c

index 616612c87bca9bb4cdd575ba6e179a26283e793d..685af03ee11879553be617379fd5c678b72d5094 100755 (executable)
@@ -338,6 +338,7 @@ PHP_MINIT_FUNCTION(pdo)
        REGISTER_LONG_CONSTANT("PDO_ATTR_FETCH_CATALOG_NAMES",          (long)PDO_ATTR_FETCH_CATALOG_NAMES,                     CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PDO_ATTR_DRIVER_NAME",          (long)PDO_ATTR_DRIVER_NAME,     CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PDO_ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES,   CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("PDO_ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN, CONST_CS|CONST_PERSISTENT);
        
        REGISTER_LONG_CONSTANT("PDO_ERRMODE_SILENT",    (long)PDO_ERRMODE_SILENT,               CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PDO_ERRMODE_WARNING",   (long)PDO_ERRMODE_WARNING,              CONST_CS|CONST_PERSISTENT);
index 3f72f1dd0def25d0ba7df6a2cedb68781ef3167c..11650ac65efe7326b038e49193af0fcb3338a2ce 100755 (executable)
@@ -128,6 +128,7 @@ enum pdo_attribute_type {
        PDO_ATTR_FETCH_CATALOG_NAMES, /* include the catalog/db name names in the column names, where available */
        PDO_ATTR_DRIVER_NAME,             /* name of the driver (as used in the constructor) */
        PDO_ATTR_STRINGIFY_FETCHES,     /* converts integer/float types to strings during fetch */
+       PDO_ATTR_MAX_COLUMN_LEN,        /* make database calculate maximum length of data found in a column */
 
        /* this defines the start of the range for driver specific options.
         * Drivers should define their own attribute constants beginning with this
index 68563f3eb0bc3ebf37ce3022d83d6e5e4ccb5453..b7297800a7eab232aba67e076f989686886a4bff 100755 (executable)
@@ -208,6 +208,8 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
 
        dbh->alloc_own_columns = 1;
 
+       S->max_length = pdo_attr_lval(driver_options, PDO_ATTR_MAX_COLUMN_LEN, 0 TSRMLS_CC);
+
        return 1;
 
 #else
index 8947c27be484dcb7aee65d173f14a38f1a0b45aa..5680e0998110c2af0f8a22b1c133599783a04338 100755 (executable)
@@ -93,8 +93,7 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
 
                /* if buffered, pre-fetch all the data */
                if (H->buffered) {
-                       /* if we have bound the buffers don't set the attribute again */
-                       if (!S->result && stmt->column_count > 0) {
+                       if (S->max_length == 1 && !S->result) {
                                my_bool on = 1;
                                mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
                        }