Proper handling for databases that need to pre-calculate length of large

columns, which is not normally done for performance reasons.
This commit is contained in:
Ilia Alshanetsky 2005-07-20 03:38:33 +00:00
parent 79f3cb9856
commit 97e8c6f4a9
4 changed files with 5 additions and 2 deletions

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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);
}