From: Ilia Alshanetsky Date: Wed, 20 Jul 2005 03:38:33 +0000 (+0000) Subject: Proper handling for databases that need to pre-calculate length of large X-Git-Tag: RELEASE_0_9~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97e8c6f4a98a2074aa2261f6e64f983277e3b2ac;p=php Proper handling for databases that need to pre-calculate length of large columns, which is not normally done for performance reasons. --- diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index 616612c87b..685af03ee1 100755 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -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); diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index 3f72f1dd0d..11650ac65e 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -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 diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 68563f3eb0..b7297800a7 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -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 diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 8947c27be4..5680e09981 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -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); }