From: Andrey Hristov Date: Sun, 10 Jul 2005 02:49:14 +0000 (+0000) Subject: ok, calculate max_length only in case of a blob (normal, medium, long). X-Git-Tag: php-5.1.0b3~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55ab9b75a689d26f5c8d9c628ec390921a0754ef;p=php ok, calculate max_length only in case of a blob (normal, medium, long). in case of a varchar lets allocate 255 bytes and be quick without asking libmysql to update max_length --- diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index c778fe874f..bfade370fb 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -94,7 +94,25 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* if buffered, pre-fetch all the data */ if (H->buffered) { my_bool on = 1; - mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); + /* if we have bound the buffers don't set the attribute again */ + if (!S->result) { + for (i= 0; i < stmt->column_count; i++) { + /* + FIXME: using directly internal structs - but for now cleaner + then calling 2 times result_metadata. + */ + switch (S->fields[i].type) { + case MYSQL_TYPE_MEDIUM_BLOB: + case MYSQL_TYPE_LONG_BLOB: + case MYSQL_TYPE_BLOB: + mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); + i= stmt->column_count; + break; + default: + break; + } + } + } mysql_stmt_store_result(S->stmt); }