diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt index 34f68f07a78..293eb71ca0a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt @@ -11,61 +11,52 @@ if (MySQLPDOTest::isPDOMySQLnd()) ?> --FILE-- $buffer_size, + /* buffer is only relevant with native PS */ + PDO::MYSQL_ATTR_DIRECT_QUERY => 0, + PDO::ATTR_EMULATE_PREPARES => 0, + ]); - /* unsigned overflow possible ? */ - $db = new PDO($dsn, $user, $pass, - array( - PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => $buffer_size, - /* buffer is only relevant with native PS */ - PDO::MYSQL_ATTR_DIRECT_QUERY => 0, - PDO::ATTR_EMULATE_PREPARES => 0, - )); + $db->exec(sprintf('CREATE TABLE test_attr_max_buffer_size(id INT, val LONGBLOB) ENGINE = %s', PDO_MYSQL_TEST_ENGINE)); - $db->exec(sprintf('CREATE TABLE test_attr_max_buffer_size(id INT, val LONGBLOB) ENGINE = %s', PDO_MYSQL_TEST_ENGINE)); + // 10 * (10 * 1024) = 10 * (10 * 1k) = 100k + $db->exec('INSERT INTO test_attr_max_buffer_size(id, val) VALUES (1, REPEAT("01234567890", 10240))'); - // 10 * (10 * 1024) = 10 * (10 * 1k) = 100k - $db->exec('INSERT INTO test_attr_max_buffer_size(id, val) VALUES (1, REPEAT("01234567890", 10240))'); + $stmt = $db->prepare('SELECT id, val FROM test_attr_max_buffer_size'); + $stmt->execute(); - $stmt = $db->prepare('SELECT id, val FROM test_attr_max_buffer_size'); - $stmt->execute(); - - $id = $val = NULL; - $stmt->bindColumn(1, $id); - $stmt->bindColumn(2, $val); - while ($row = $stmt->fetch(PDO::FETCH_BOUND)) { - printf("[%03d] id = %d, val = %s... (length: %d)\n", - $offset, $id, substr($val, 0, 10), strlen($val)); - } - - // This is necessary because we will be creating tables several times. - $db->query('DROP TABLE test_attr_max_buffer_size'); - - } catch (PDOException $e) { - printf("[%03d] %s, [%s] %s\n", - $offset, - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } + $stmt->bindColumn(1, $id); + $stmt->bindColumn(2, $val); + while ($stmt->fetch(PDO::FETCH_BOUND)) { + printf( + "[%03d] id = %d, val = %s... (length: %d)\n", + $offset, + $id, + substr($val, 0, 10), + strlen($val) + ); } - try_buffer_size(1, -1); - try_buffer_size(2, 1000); - try_buffer_size(4, 2000); - try { - try_buffer_size(3, NULL); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } + // This is necessary because we will be creating tables several times. + $db->query('DROP TABLE test_attr_max_buffer_size'); +} - print "done!"; +try_buffer_size(1, -1); +try_buffer_size(2, 1000); +try_buffer_size(4, 2000); +try { + try_buffer_size(3, null); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + +print "done!"; ?> --CLEAN--