From c7dd0405226cf9a79127d3978ba29db9a95a21ac Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Thu, 23 Nov 2023 17:54:10 +0900 Subject: [PATCH 1/3] Optimized pdo_mysql tests --- ext/pdo/tests/pdo_017.phpt | 4 +- ext/pdo_mysql/tests/bug41125.phpt | 9 +- ext/pdo_mysql/tests/bug44327.phpt | 8 +- ext/pdo_mysql/tests/bug46292.phpt | 8 +- ext/pdo_mysql/tests/bug53551.phpt | 20 ++- ext/pdo_mysql/tests/bug53782.phpt | 16 +-- ext/pdo_mysql/tests/bug54929.phpt | 26 ++-- ext/pdo_mysql/tests/bug63176.phpt | 10 +- ext/pdo_mysql/tests/bug63185.phpt | 26 ++-- ext/pdo_mysql/tests/bug66141.phpt | 4 +- ext/pdo_mysql/tests/bug66528.phpt | 14 +- ext/pdo_mysql/tests/bug66878.phpt | 5 +- ext/pdo_mysql/tests/bug67004.phpt | 6 +- ext/pdo_mysql/tests/bug68371.phpt | 48 +++---- ext/pdo_mysql/tests/bug70066.phpt | 9 +- ext/pdo_mysql/tests/bug70272.phpt | 14 +- ext/pdo_mysql/tests/bug70389.phpt | 7 +- ext/pdo_mysql/tests/bug70862.phpt | 6 +- ext/pdo_mysql/tests/bug71145.phpt | 13 +- ext/pdo_mysql/tests/bug71569.phpt | 5 +- ext/pdo_mysql/tests/bug75177.phpt | 14 +- ext/pdo_mysql/tests/bug76815.phpt | 26 ++-- ext/pdo_mysql/tests/bug77289.phpt | 5 +- ext/pdo_mysql/tests/bug78152.phpt | 23 ++-- ext/pdo_mysql/tests/bug79132.phpt | 6 +- ext/pdo_mysql/tests/bug79375.phpt | 9 +- ext/pdo_mysql/tests/bug79596.phpt | 9 +- ext/pdo_mysql/tests/bug79872.phpt | 5 +- ext/pdo_mysql/tests/bug80458.phpt | 42 +++--- ext/pdo_mysql/tests/bug80808.phpt | 8 +- ext/pdo_mysql/tests/bug80908.phpt | 12 +- ext/pdo_mysql/tests/bug81037.phpt | 17 +-- ext/pdo_mysql/tests/bug_33689.phpt | 21 ++- ext/pdo_mysql/tests/bug_37445.phpt | 10 +- ext/pdo_mysql/tests/bug_38546.phpt | 26 ++-- ext/pdo_mysql/tests/bug_39483.phpt | 14 +- ext/pdo_mysql/tests/bug_39858.phpt | 31 ++--- ext/pdo_mysql/tests/bug_41125.phpt | 26 ++-- ext/pdo_mysql/tests/bug_41698.phpt | 13 +- ext/pdo_mysql/tests/bug_41997.phpt | 28 ++-- ext/pdo_mysql/tests/bug_42499.phpt | 23 +--- ext/pdo_mysql/tests/bug_43371.phpt | 4 +- ext/pdo_mysql/tests/bug_44454.phpt | 16 +-- ext/pdo_mysql/tests/bug_44707.phpt | 27 +--- ext/pdo_mysql/tests/bug_45120.phpt | 13 +- ext/pdo_mysql/tests/bug_50323.phpt | 28 ++-- ext/pdo_mysql/tests/bug_51670.phpt | 10 +- ext/pdo_mysql/tests/bug_61207.phpt | 29 ++-- ext/pdo_mysql/tests/bug_61411.phpt | 22 +-- ext/pdo_mysql/tests/bug_61755.phpt | 10 +- ext/pdo_mysql/tests/bug_74376.phpt | 13 +- ext/pdo_mysql/tests/bug_pecl_12925.phpt | 10 +- ext/pdo_mysql/tests/bug_pecl_7976.phpt | 32 ++--- ext/pdo_mysql/tests/change_column_count.phpt | 8 +- ext/pdo_mysql/tests/config.inc | 52 -------- ext/pdo_mysql/tests/gh11550.phpt | 15 +-- .../tests/{gh-11587.phpt => gh11587.phpt} | 8 +- ext/pdo_mysql/tests/inc/config.inc | 14 ++ .../tests/{ => inc}/mysql_pdo_test.inc | 126 +++++++++++------- ext/pdo_mysql/tests/last_insert_id.phpt | 19 ++- ext/pdo_mysql/tests/native_types.phpt | 8 +- .../tests/pdo_mysql___construct.phpt | 14 +- .../tests/pdo_mysql___construct_ini.phpt | 4 +- .../tests/pdo_mysql___construct_options.phpt | 51 ++++--- ...do_mysql___construct_options_libmysql.phpt | 7 +- .../tests/pdo_mysql___construct_uri.phpt | 7 +- .../tests/pdo_mysql_attr_autocommit.phpt | 30 ++--- ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt | 30 +++-- .../tests/pdo_mysql_attr_client_version.phpt | 5 +- .../pdo_mysql_attr_connection_status.phpt | 9 +- .../tests/pdo_mysql_attr_driver_name.phpt | 5 +- .../tests/pdo_mysql_attr_errmode.phpt | 7 +- .../pdo_mysql_attr_fetch_table_names.phpt | 20 ++- .../tests/pdo_mysql_attr_init_command.phpt | 17 ++- .../tests/pdo_mysql_attr_max_buffer_size.phpt | 11 +- .../pdo_mysql_attr_multi_statements.phpt | 15 ++- .../tests/pdo_mysql_attr_oracle_nulls.phpt | 5 +- .../tests/pdo_mysql_attr_prefetch.phpt | 5 +- .../tests/pdo_mysql_attr_server_info.phpt | 5 +- .../tests/pdo_mysql_attr_server_version.phpt | 5 +- .../tests/pdo_mysql_attr_statement_class.phpt | 25 ++-- .../tests/pdo_mysql_begintransaction.phpt | 44 +++--- ext/pdo_mysql/tests/pdo_mysql_bit.phpt | 7 +- .../tests/pdo_mysql_class_constants.phpt | 16 +-- .../tests/pdo_mysql_closecursor_error.phpt | 4 +- ext/pdo_mysql/tests/pdo_mysql_commit.phpt | 34 ++--- .../tests/pdo_mysql_connect_attr.phpt | 17 ++- .../tests/pdo_mysql_connect_charset.phpt | 6 +- ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt | 31 +++-- ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt | 29 ++-- ext/pdo_mysql/tests/pdo_mysql_exec.phpt | 18 +-- ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt | 50 ++++--- .../tests/pdo_mysql_exec_load_data.phpt | 113 ++++++++-------- .../tests/pdo_mysql_exec_select.phpt | 12 +- ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt | 12 +- .../tests/pdo_mysql_get_attribute.phpt | 45 +++---- .../tests/pdo_mysql_inTransaction.phpt | 6 +- ext/pdo_mysql/tests/pdo_mysql_interface.phpt | 27 ++-- .../tests/pdo_mysql_last_insert_id.phpt | 14 +- .../pdo_mysql_local_infile_default_off.phpt | 5 +- ..._mysql_local_infile_directory_allowed.phpt | 16 +-- ...o_mysql_local_infile_directory_denied.phpt | 19 ++- ...file_overrides_local_infile_directory.phpt | 16 +-- .../tests/pdo_mysql_local_infile_set_on.phpt | 7 +- .../pdo_mysql_multi_stmt_nextrowset.phpt | 41 +++--- .../tests/pdo_mysql_param_str_natl.phpt | 16 +-- ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt | 25 ++-- ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt | 5 +- .../tests/pdo_mysql_prepare_emulated.phpt | 15 +-- .../pdo_mysql_prepare_emulated_anonymous.phpt | 7 +- ...epare_emulated_anonymous_placeholders.phpt | 14 +- .../pdo_mysql_prepare_emulated_myisam.phpt | 15 +-- ...o_mysql_prepare_emulated_myisam_index.phpt | 12 +- ...epare_emulated_placeholder_everywhere.phpt | 6 +- .../pdo_mysql_prepare_match_against.phpt | 10 +- .../tests/pdo_mysql_prepare_native.phpt | 14 +- ..._prepare_native_anonymous_placeholder.phpt | 14 +- .../pdo_mysql_prepare_native_clear_error.phpt | 10 +- .../pdo_mysql_prepare_native_column.phpt | 17 +-- ..._prepare_native_dup_named_placeholder.phpt | 10 +- .../pdo_mysql_prepare_native_mixed_style.phpt | 20 +-- .../pdo_mysql_prepare_native_myisam.phpt | 14 +- ...pdo_mysql_prepare_native_myisam_index.phpt | 14 +- ...ysql_prepare_native_named_placeholder.phpt | 7 +- ...prepare_native_placeholder_everywhere.phpt | 7 +- ext/pdo_mysql/tests/pdo_mysql_quote.phpt | 4 +- ext/pdo_mysql/tests/pdo_mysql_rollback.phpt | 53 ++++---- .../tests/pdo_mysql_stmt_bindcolumn.phpt | 21 +-- .../tests/pdo_mysql_stmt_bindparam.phpt | 25 ++-- .../tests/pdo_mysql_stmt_bindparam_types.phpt | 13 +- .../tests/pdo_mysql_stmt_bindvalue.phpt | 26 ++-- .../tests/pdo_mysql_stmt_blobfromstream.phpt | 9 +- ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt | 6 +- .../tests/pdo_mysql_stmt_closecursor.phpt | 41 +++--- .../pdo_mysql_stmt_closecursor_empty.phpt | 16 +-- .../tests/pdo_mysql_stmt_columncount.phpt | 24 ++-- .../tests/pdo_mysql_stmt_errorcode.phpt | 15 +-- .../tests/pdo_mysql_stmt_errorinfo.phpt | 44 +++--- .../tests/pdo_mysql_stmt_fetch_class.phpt | 9 +- .../pdo_mysql_stmt_fetch_non_select.phpt | 25 ++-- .../tests/pdo_mysql_stmt_fetch_serialize.phpt | 9 +- ...ysql_stmt_fetch_serialize_fetch_class.phpt | 9 +- ...pdo_mysql_stmt_fetch_serialize_simple.phpt | 6 +- .../tests/pdo_mysql_stmt_fetchobject.phpt | 15 ++- .../pdo_mysql_stmt_fetchobject_ctor_args.phpt | 15 ++- .../tests/pdo_mysql_stmt_getcolumnmeta.phpt | 14 +- .../tests/pdo_mysql_stmt_multiquery.phpt | 25 ++-- .../tests/pdo_mysql_stmt_nextrowset.phpt | 54 ++++---- .../tests/pdo_mysql_stmt_rowcount.phpt | 17 ++- .../tests/pdo_mysql_stmt_unbuffered_2050.phpt | 33 ++--- .../pdo_mysql_stmt_variable_columncount.phpt | 39 +++--- ext/pdo_mysql/tests/pdo_mysql_subclass.phpt | 6 +- ext/pdo_mysql/tests/pdo_mysql_types.phpt | 6 +- .../tests/pdo_mysql_types_zerofill.phpt | 6 +- ext/pdo_mysql/tests/pecl_bug_5200.phpt | 15 +-- ext/pdo_mysql/tests/pecl_bug_5780.phpt | 17 ++- ext/pdo_mysql/tests/pecl_bug_5802.phpt | 12 +- ext/pdo_mysql/tests/show_tables.phpt | 10 +- .../tests/skipifinfilenotallowed.inc | 6 - ext/pdo_mysql/tests/table.inc | 9 -- ext/pdo_mysql/tests/unsigned_bigint.phpt | 14 +- 161 files changed, 1299 insertions(+), 1577 deletions(-) delete mode 100644 ext/pdo_mysql/tests/config.inc rename ext/pdo_mysql/tests/{gh-11587.phpt => gh11587.phpt} (92%) create mode 100644 ext/pdo_mysql/tests/inc/config.inc rename ext/pdo_mysql/tests/{ => inc}/mysql_pdo_test.inc (51%) delete mode 100644 ext/pdo_mysql/tests/skipifinfilenotallowed.inc delete mode 100644 ext/pdo_mysql/tests/table.inc diff --git a/ext/pdo/tests/pdo_017.phpt b/ext/pdo/tests/pdo_017.phpt index bc514bff2c32b..e1471bb36308a 100644 --- a/ext/pdo/tests/pdo_017.phpt +++ b/ext/pdo/tests/pdo_017.phpt @@ -19,7 +19,7 @@ try { } if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc'); + require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc'); if (false === MySQLPDOTest::detect_transactional_mysql_engine($db)) { die('skip your mysql configuration does not support working transactions'); } @@ -32,7 +32,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc'); + require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc'); $suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db); } else { $suf = ''; diff --git a/ext/pdo_mysql/tests/bug41125.phpt b/ext/pdo_mysql/tests/bug41125.phpt index fd854b5e9c558..aa488c1310984 100644 --- a/ext/pdo_mysql/tests/bug41125.phpt +++ b/ext/pdo_mysql/tests/bug41125.phpt @@ -4,16 +4,13 @@ Bug #41125 (PDO mysql + quote() + prepare() can result in seg fault) pdo_mysql --SKIPIF-- --FILE-- quote('%' . $search . '%'); diff --git a/ext/pdo_mysql/tests/bug44327.phpt b/ext/pdo_mysql/tests/bug44327.phpt index aa53713843839..e5ad02e8db46c 100644 --- a/ext/pdo_mysql/tests/bug44327.phpt +++ b/ext/pdo_mysql/tests/bug44327.phpt @@ -4,13 +4,12 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash) pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); @@ -38,11 +37,10 @@ $db = MySQLPDOTest::factory(); @$stmt->execute(); $row = $stmt->fetch(); var_dump($row->queryString); - ?> --CLEAN-- exec("DROP TABLE test_44327"); ?> diff --git a/ext/pdo_mysql/tests/bug46292.phpt b/ext/pdo_mysql/tests/bug46292.phpt index 38c79bc55e6bc..5ebf9aef51ccb 100644 --- a/ext/pdo_mysql/tests/bug46292.phpt +++ b/ext/pdo_mysql/tests/bug46292.phpt @@ -4,16 +4,14 @@ Bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_ pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_46292'); ?> diff --git a/ext/pdo_mysql/tests/bug53551.phpt b/ext/pdo_mysql/tests/bug53551.phpt index ab394e557a76c..2e4fb62d9e957 100644 --- a/ext/pdo_mysql/tests/bug53551.phpt +++ b/ext/pdo_mysql/tests/bug53551.phpt @@ -4,31 +4,30 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash) pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $createSql = "CREATE TABLE `bug53551` ( - `count` bigint(20) unsigned NOT NULL DEFAULT '0' + `count` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' )"; -$db->exec('drop table if exists bug53551'); +$db->exec('DROP TABLE IF EXISTS bug53551'); $db->exec($createSql); -$db->exec("insert into bug53551 set `count` = 1 "); +$db->exec("INSERT INTO bug53551 SET `count` = 1 "); $db->exec("SET sql_mode = 'Traditional'"); $sql = 'UPDATE bug53551 SET `count` = :count'; $stmt = $db->prepare($sql); -$values = array ( - 'count' => NULL, -); +$values = [ + 'count' => null, +]; echo "1\n"; $stmt->execute($values); @@ -39,11 +38,10 @@ $stmt->execute($values); var_dump($stmt->errorInfo()); echo "\ndone\n"; - ?> --CLEAN-- exec('DROP TABLE IF EXISTS bug53551'); ?> diff --git a/ext/pdo_mysql/tests/bug53782.phpt b/ext/pdo_mysql/tests/bug53782.phpt index e520b15fc100b..5eb8384b58099 100644 --- a/ext/pdo_mysql/tests/bug53782.phpt +++ b/ext/pdo_mysql/tests/bug53782.phpt @@ -1,19 +1,16 @@ --TEST-- PDO MySQL Bug #53782 (foreach throws irrelevant exception) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -31,11 +28,6 @@ foreach ($res as $k => $v) { echo "DONE"; ?> ---CLEAN-- - --EXPECTF-- Caught: SQLSTATE[42000]: %s Value: 0 diff --git a/ext/pdo_mysql/tests/bug54929.phpt b/ext/pdo_mysql/tests/bug54929.phpt index 27e228b25af60..e1e730dcafccd 100644 --- a/ext/pdo_mysql/tests/bug54929.phpt +++ b/ext/pdo_mysql/tests/bug54929.phpt @@ -4,38 +4,34 @@ Bug #54929 (Parse error with single quote in sql comment (pdo-mysql)) pdo_mysql --SKIPIF-- --FILE-- prepare($query); - if (!$stmt->execute(array("foo"))) { + if (!$stmt->execute(["foo"])) { var_dump($stmt->errorInfo()); } else{ var_dump($stmt->fetch(PDO::FETCH_ASSOC)); } } -testQuery("/* ' */ select ? as f1 /* ' */"); -testQuery("/* '-- */ select ? as f1 /* *' */"); -testQuery("/* ' */ select ? as f1 --';"); -testQuery("/* ' */ select ? as f1 -- 'a;"); -testQuery("/*'**/ select ? as f1 /* ' */"); -testQuery("/*'***/ select ? as f1 /* ' */"); +testQuery("/* ' */ SELECT ? AS f1 /* ' */"); +testQuery("/* '-- */ SELECT ? AS f1 /* *' */"); +testQuery("/* ' */ SELECT ? AS f1 --';"); +testQuery("/* ' */ SELECT ? AS f1 -- 'a;"); +testQuery("/*'**/ SELECT ? AS f1 /* ' */"); +testQuery("/*'***/ SELECT ? AS f1 /* ' */"); testQuery("/*'**a ***b / **** ****** -**/ select ? as f1 /* ' */"); +**/ SELECT ? AS f1 /* ' */"); ?> --EXPECTF-- diff --git a/ext/pdo_mysql/tests/bug63176.phpt b/ext/pdo_mysql/tests/bug63176.phpt index 599aaaa67c091..2210709dfc40e 100644 --- a/ext/pdo_mysql/tests/bug63176.phpt +++ b/ext/pdo_mysql/tests/bug63176.phpt @@ -4,12 +4,13 @@ Bug #63176 (Segmentation fault when instantiate 2 persistent PDO to the same db pdo_mysql --SKIPIF-- --FILE-- db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); + $this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]); } else { - $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); + $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]); } $this->db->query('SELECT 1')->fetchAll(); } diff --git a/ext/pdo_mysql/tests/bug63185.phpt b/ext/pdo_mysql/tests/bug63185.phpt index 37a23340bdb7c..948a626e17ca2 100644 --- a/ext/pdo_mysql/tests/bug63185.phpt +++ b/ext/pdo_mysql/tests/bug63185.phpt @@ -1,29 +1,30 @@ --TEST-- Bug #63185: nextRowset() ignores MySQL errors with native prepared statements --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second'); -$pdo->exec('CREATE PROCEDURE test_procedure_error_at_second () +$procedure = 'test_procedure_error_at_second_63185'; + +$pdo->exec("DROP PROCEDURE IF EXISTS {$procedure}"); +$pdo->exec("CREATE PROCEDURE {$procedure} () BEGIN - SELECT "x" as foo; + SELECT 'x' AS foo; SELECT * FROM no_such_table; - END'); + END"); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); -$st = $pdo->query('CALL test_procedure_error_at_second()'); +$st = $pdo->query("CALL {$procedure}()"); var_dump($st->fetchAll()); try { var_dump($st->nextRowset()); @@ -33,7 +34,7 @@ try { unset($st); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); -$st = $pdo->query('CALL test_procedure_error_at_second()'); +$st = $pdo->query("CALL {$procedure}()"); var_dump($st->fetchAll()); try { var_dump($st->nextRowset()); @@ -41,13 +42,12 @@ try { echo $e->getMessage(), "\n"; } var_dump($st->fetchAll()); - ?> --CLEAN-- query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second'); +$pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second_63185'); ?> --EXPECTF-- array(1) { diff --git a/ext/pdo_mysql/tests/bug66141.phpt b/ext/pdo_mysql/tests/bug66141.phpt index 4accc673dcdc0..a81501b6f9c35 100644 --- a/ext/pdo_mysql/tests/bug66141.phpt +++ b/ext/pdo_mysql/tests/bug66141.phpt @@ -4,12 +4,12 @@ Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after fail pdo_mysql --SKIPIF-- --FILE-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); -$dbh->exec('CREATE TABLE test_66528 (a int) engine=innodb'); +$dbh->exec('CREATE TABLE test_66528 (a INT) ENGINE=InnoDB'); $dbh->beginTransaction(); $dbh->exec('INSERT INTO test_66528 (a) VALUES (1), (2)'); $stmt = $dbh->query('SELECT * FROM test_66528'); @@ -42,8 +41,9 @@ try { ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_66528'); ?> --EXPECT-- SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. diff --git a/ext/pdo_mysql/tests/bug66878.phpt b/ext/pdo_mysql/tests/bug66878.phpt index 44c640ba0c2c6..769ba4e1d9e7a 100644 --- a/ext/pdo_mysql/tests/bug66878.phpt +++ b/ext/pdo_mysql/tests/bug66878.phpt @@ -4,13 +4,12 @@ Bug #66878: Multiple rowsets not returned unless PDO statement object is unset() pdo_mysql --SKIPIF-- --FILE-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); diff --git a/ext/pdo_mysql/tests/bug68371.phpt b/ext/pdo_mysql/tests/bug68371.phpt index 375011af33ea7..b59c60120210b 100644 --- a/ext/pdo_mysql/tests/bug68371.phpt +++ b/ext/pdo_mysql/tests/bug68371.phpt @@ -4,43 +4,43 @@ PDO MySQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific pdo_mysql --SKIPIF-- --FILE-- setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); -$attrs = array( +$attrs = [ // Extensive test: default value and set+get values PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0), PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1), PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, false, true), // Just test the default - PDO::ATTR_AUTOCOMMIT => array(null), - PDO::ATTR_PREFETCH => array(null), - PDO::ATTR_TIMEOUT => array(null), - PDO::ATTR_ERRMODE => array(null), - PDO::ATTR_SERVER_VERSION => array(null), - PDO::ATTR_CLIENT_VERSION => array(null), - PDO::ATTR_SERVER_INFO => array(null), - PDO::ATTR_CONNECTION_STATUS => array(null), - PDO::ATTR_CASE => array(null), - PDO::ATTR_CURSOR_NAME => array(null), - PDO::ATTR_CURSOR => array(null), - PDO::ATTR_ORACLE_NULLS => array(null), - PDO::ATTR_PERSISTENT => array(null), - PDO::ATTR_STATEMENT_CLASS => array(null), - PDO::ATTR_FETCH_TABLE_NAMES => array(null), - PDO::ATTR_FETCH_CATALOG_NAMES => array(null), - PDO::ATTR_DRIVER_NAME => array(null), - PDO::ATTR_STRINGIFY_FETCHES => array(null), - PDO::ATTR_MAX_COLUMN_LEN => array(null), - PDO::ATTR_DEFAULT_FETCH_MODE => array(null), -); + PDO::ATTR_AUTOCOMMIT => [null], + PDO::ATTR_PREFETCH => [null], + PDO::ATTR_TIMEOUT => [null], + PDO::ATTR_ERRMODE => [null], + PDO::ATTR_SERVER_VERSION => [null], + PDO::ATTR_CLIENT_VERSION => [null], + PDO::ATTR_SERVER_INFO => [null], + PDO::ATTR_CONNECTION_STATUS => [null], + PDO::ATTR_CASE => [null], + PDO::ATTR_CURSOR_NAME => [null], + PDO::ATTR_CURSOR => [null], + PDO::ATTR_ORACLE_NULLS => [null], + PDO::ATTR_PERSISTENT => [null], + PDO::ATTR_STATEMENT_CLASS => [null], + PDO::ATTR_FETCH_TABLE_NAMES => [null], + PDO::ATTR_FETCH_CATALOG_NAMES => [null], + PDO::ATTR_DRIVER_NAME => [null], + PDO::ATTR_STRINGIFY_FETCHES => [null], + PDO::ATTR_MAX_COLUMN_LEN => [null], + PDO::ATTR_DEFAULT_FETCH_MODE => [null], +]; foreach ($attrs as $a => $vals) { foreach ($vals as $v) { diff --git a/ext/pdo_mysql/tests/bug70066.phpt b/ext/pdo_mysql/tests/bug70066.phpt index fefec5ec56da1..b8245d6af8a6c 100644 --- a/ext/pdo_mysql/tests/bug70066.phpt +++ b/ext/pdo_mysql/tests/bug70066.phpt @@ -1,19 +1,17 @@ --TEST-- Bug #70066: Unexpected "Cannot execute queries while other unbuffered queries" --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); @@ -21,7 +19,6 @@ $db = $pdo->query('SELECT DATABASE()')->fetchColumn(0); // USE is not supported in the prepared statement protocol, // so this will fall back to emulation. $pdo->query('USE ' . $db); - ?> ===DONE=== --EXPECT-- diff --git a/ext/pdo_mysql/tests/bug70272.phpt b/ext/pdo_mysql/tests/bug70272.phpt index b3f4a485bc8de..b298df9190b0f 100644 --- a/ext/pdo_mysql/tests/bug70272.phpt +++ b/ext/pdo_mysql/tests/bug70272.phpt @@ -4,21 +4,19 @@ Bug #70272 (Segfault in pdo_mysql) pdo_mysql --SKIPIF-- ---INI-- -report_memleaks=off --FILE-- a = &$a; -require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +require_once __DIR__ . '/inc/mysql_pdo_test.inc'; -$dummy = new StdClass(); +$dummy = new stdClass(); -$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); -$dummy = NULL; +$db = MySQLPDOTest::factory(); +$dummy = null; $a->c = $db; $a->b = $db->prepare("select 1"); diff --git a/ext/pdo_mysql/tests/bug70389.phpt b/ext/pdo_mysql/tests/bug70389.phpt index 1a50f2b8d8cd0..b4f6bf1afeb48 100644 --- a/ext/pdo_mysql/tests/bug70389.phpt +++ b/ext/pdo_mysql/tests/bug70389.phpt @@ -4,24 +4,23 @@ Bug #70389 (PDO constructor changes unrelated variables) pdo_mysql --SKIPIF-- --FILE-- true, PDO::MYSQL_ATTR_LOCAL_INFILE => true, PDO::ATTR_PERSISTENT => true, ]; -$std = new StdClass(); +$std = new stdClass(); $std->flags = $flags; new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, $flags); var_dump($flags); - ?> --EXPECTF-- array(3) { diff --git a/ext/pdo_mysql/tests/bug70862.phpt b/ext/pdo_mysql/tests/bug70862.phpt index c9a37285dee66..023125b2fc4b4 100644 --- a/ext/pdo_mysql/tests/bug70862.phpt +++ b/ext/pdo_mysql/tests/bug70862.phpt @@ -4,12 +4,12 @@ MySQL Prepared Statements and BLOBs pdo_mysql --SKIPIF-- --FILE-- exec(sprintf('CREATE TABLE test_70862(id INT, label BLOB)')); @@ -38,7 +38,7 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_70862'); ?> diff --git a/ext/pdo_mysql/tests/bug71145.phpt b/ext/pdo_mysql/tests/bug71145.phpt index 97883072ea3a1..0c6f1a549dfb9 100644 --- a/ext/pdo_mysql/tests/bug71145.phpt +++ b/ext/pdo_mysql/tests/bug71145.phpt @@ -4,24 +4,21 @@ Bug #71145: Multiple statements in init command triggers unbuffered query error pdo_mysql --SKIPIF-- --FILE-- PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; SET SESSION sql_mode=traditional', PDO::ATTR_STRINGIFY_FETCHES => true, -); -putenv('PDOTEST_ATTR=' . serialize($attr)); +]; -$pdo = MySQLPDOTest::factory(); +$pdo = MySQLPDOTest::factoryWithAttr($attr); var_dump($pdo->query('SELECT 42')->fetchColumn(0)); - ?> --EXPECT-- string(2) "42" diff --git a/ext/pdo_mysql/tests/bug71569.phpt b/ext/pdo_mysql/tests/bug71569.phpt index aade487ed033d..fe50b669d845b 100644 --- a/ext/pdo_mysql/tests/bug71569.phpt +++ b/ext/pdo_mysql/tests/bug71569.phpt @@ -4,12 +4,12 @@ Bug #71569 (#70389 fix causes segmentation fault) pdo_mysql --SKIPIF-- --FILE-- getMessage(); } - ?> --EXPECT-- SQLSTATE[42000] [1065] Query was empty diff --git a/ext/pdo_mysql/tests/bug75177.phpt b/ext/pdo_mysql/tests/bug75177.phpt index 2238a013c312a..21c6b34fdcb6e 100644 --- a/ext/pdo_mysql/tests/bug75177.phpt +++ b/ext/pdo_mysql/tests/bug75177.phpt @@ -4,16 +4,16 @@ PDO MySQL Bug #75177 Type 'bit' is fetched as unexpected string pdo_mysql --SKIPIF-- --FILE-- query("CREATE TABLE test_75177 (`bit` bit(8)) ENGINE=InnoDB"); +$pdo->query("CREATE TABLE test_75177 (`bit` BIT(8)) ENGINE=InnoDB"); $pdo->query("INSERT INTO test_75177 (`bit`) VALUES (1), (0b011), (0b01100)"); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); @@ -27,12 +27,12 @@ $ret = $pdo->query("SELECT * FROM test_75177")->fetchAll(); foreach ($ret as $i) { var_dump($i["bit"]); } - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_75177'); ?> --EXPECT-- int(1) diff --git a/ext/pdo_mysql/tests/bug76815.phpt b/ext/pdo_mysql/tests/bug76815.phpt index e991e7aec0be4..ed9f422adc106 100644 --- a/ext/pdo_mysql/tests/bug76815.phpt +++ b/ext/pdo_mysql/tests/bug76815.phpt @@ -4,22 +4,25 @@ Bug #76815: PDOStatement cannot be GCed/closeCursor-ed when a PROCEDURE resultse pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->query('DROP FUNCTION IF EXISTS tst'); -$pdo->query('DROP PROCEDURE IF EXISTS tst2'); -$pdo->query('CREATE FUNCTION tst() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN \'x12345\'; END'); -$pdo->query('CREATE PROCEDURE tst2() BEGIN SELECT tst(); END'); +$func = 'bug76815_pdo_mysql_f'; +$procedure = 'bug76815_pdo_mysql_p'; -$st = $pdo->prepare('CALL tst2()'); +$pdo->query("DROP FUNCTION IF EXISTS {$func}"); +$pdo->query("DROP PROCEDURE IF EXISTS {$procedure}"); +$pdo->query("CREATE FUNCTION {$func}() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN 'x12345'; END"); +$pdo->query("CREATE PROCEDURE {$procedure}() BEGIN SELECT {$func}(); END"); + +$st = $pdo->prepare("CALL {$procedure}()"); try { $st->execute(); } catch (PDOException $ex) { @@ -27,15 +30,14 @@ try { } unset($st); echo "Ok.\n"; - ?> --CLEAN-- query('DROP FUNCTION IF EXISTS tst'); -$pdo->query('DROP PROCEDURE IF EXISTS tst2'); +$pdo->query('DROP FUNCTION IF EXISTS bug76815_pdo_mysql_f'); +$pdo->query('DROP PROCEDURE IF EXISTS bug76815_pdo_mysql_p'); ?> --EXPECT-- -SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'tst()' at row 1 +SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'bug76815_pdo_mysql_f()' at row 1 Ok. diff --git a/ext/pdo_mysql/tests/bug77289.phpt b/ext/pdo_mysql/tests/bug77289.phpt index 8c847a59c8f3e..b5786bc949b7d 100644 --- a/ext/pdo_mysql/tests/bug77289.phpt +++ b/ext/pdo_mysql/tests/bug77289.phpt @@ -4,12 +4,12 @@ Bug #77289: PDO MySQL segfaults with persistent connection pdo_mysql --SKIPIF-- --FILE-- true]); $pdo->exec("DROP TABLE IF EXISTS bug77289"); $pdo->exec("CREATE TEMPORARY TABLE bug77289 (x INT)"); $pdo->exec("UPDATE bug77289 SET x = x"); - ?> ===DONE=== --EXPECT-- diff --git a/ext/pdo_mysql/tests/bug78152.phpt b/ext/pdo_mysql/tests/bug78152.phpt index c3734c41e5fc8..b8a347703f60a 100644 --- a/ext/pdo_mysql/tests/bug78152.phpt +++ b/ext/pdo_mysql/tests/bug78152.phpt @@ -4,31 +4,32 @@ Bug #78152: PDO::exec() - Bad error handling with multiple commands pdo_mysql --SKIPIF-- --FILE-- exec("INSERT INTO test(id, label) VALUES (41, 'x'); INSERT INTO test_bad(id, label) VALUES (42, 'y')")); +$table = 'bug78152_pdo_mysql'; +MySQLPDOTest::createTestTable($table, $db); + +var_dump($db->exec("INSERT INTO {$table} (id, label) VALUES (41, 'x'); INSERT INTO {$table}_bad (id, label) VALUES (42, 'y')")); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try { - var_dump($db->exec("INSERT INTO test(id, label) VALUES (42, 'x'); INSERT INTO test_bad(id, label) VALUES (43, 'y')")); + var_dump($db->exec("INSERT INTO {$table} (id, label) VALUES (42, 'x'); INSERT INTO {$table}_bad (id, label) VALUES (43, 'y')")); } catch (PDOException $e) { echo $e->getMessage(), "\n"; } - ?> --CLEAN-- exec('DROP TABLE IF EXISTS bug78152_pdo_mysql'); ?> --EXPECTF-- -Warning: PDO::exec(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist in %s on line %d +Warning: PDO::exec(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.bug78152_pdo_mysql_bad' doesn't exist in %s on line %d bool(false) -SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist +SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.bug78152_pdo_mysql_bad' doesn't exist diff --git a/ext/pdo_mysql/tests/bug79132.phpt b/ext/pdo_mysql/tests/bug79132.phpt index 0761c23a02fc3..3e1c7f8eb856c 100644 --- a/ext/pdo_mysql/tests/bug79132.phpt +++ b/ext/pdo_mysql/tests/bug79132.phpt @@ -4,12 +4,12 @@ Bug #79132: PDO re-uses parameter values from earlier calls to execute() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -21,7 +21,7 @@ $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); test($pdo); function test($pdo) { - $stmt = $pdo->prepare('select ? a, ? b'); + $stmt = $pdo->prepare('SELECT ? a, ? b'); $set = [ ['a', 'b'], diff --git a/ext/pdo_mysql/tests/bug79375.phpt b/ext/pdo_mysql/tests/bug79375.phpt index 8478a5a2cbdbe..fb118f1db2d53 100644 --- a/ext/pdo_mysql/tests/bug79375.phpt +++ b/ext/pdo_mysql/tests/bug79375.phpt @@ -1,17 +1,16 @@ --TEST-- Bug #79375: mysqli_store_result does not report error from lock wait timeout --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- query('CREATE TABLE test_79375 (first int) ENGINE = InnoDB'); +$db->query('CREATE TABLE test_79375 (first INT) ENGINE = InnoDB'); $db->query('INSERT INTO test_79375 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9)'); function testNormalQuery(PDO $db, string $name) { @@ -94,7 +93,7 @@ echo "\n"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_79375'); ?> diff --git a/ext/pdo_mysql/tests/bug79596.phpt b/ext/pdo_mysql/tests/bug79596.phpt index 5b0d62d3f278f..69fc6d473ad85 100644 --- a/ext/pdo_mysql/tests/bug79596.phpt +++ b/ext/pdo_mysql/tests/bug79596.phpt @@ -4,14 +4,14 @@ Bug #79596 (MySQL FLOAT truncates to int some locales) pdo_mysql --SKIPIF-- --FILE-- query('SELECT broken FROM bug79596')->fetchColumn(0)); ?> --CLEAN-- exec("DROP TABLE IF EXISTS bug79596"); ?> diff --git a/ext/pdo_mysql/tests/bug79872.phpt b/ext/pdo_mysql/tests/bug79872.phpt index 7713370dee3be..48241ece5dabf 100644 --- a/ext/pdo_mysql/tests/bug79872.phpt +++ b/ext/pdo_mysql/tests/bug79872.phpt @@ -4,12 +4,12 @@ Bug #79872: Can't execute query with pending result sets pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -21,7 +21,6 @@ try { } catch (PDOException $e) { echo $e->getMessage(), "\n"; } - ?> --EXPECT-- SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor() diff --git a/ext/pdo_mysql/tests/bug80458.phpt b/ext/pdo_mysql/tests/bug80458.phpt index 0f96e816da960..aecdca6674ccb 100644 --- a/ext/pdo_mysql/tests/bug80458.phpt +++ b/ext/pdo_mysql/tests/bug80458.phpt @@ -1,23 +1,22 @@ --TEST-- Bug #80458 PDOStatement::fetchAll() throws for upsert queries --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); -$db->query('CREATE TABLE test_80458 (first int) ENGINE = InnoDB'); +$db->query('CREATE TABLE test_80458 (first INT) ENGINE = InnoDB'); $res = $db->query('INSERT INTO test_80458(first) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16)'); var_dump($res->fetchAll()); @@ -42,19 +41,23 @@ $stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=5'); $stmt->execute(); var_dump($stmt->fetchAll()); -$db->exec('CREATE PROCEDURE nores() BEGIN DELETE FROM test_80458 WHERE first=6; END;'); -$stmt4 = $db->prepare('CALL nores()'); +$procedure_nores = 'nores_bug80458_pdo_mysql_p'; + +$db->exec("CREATE PROCEDURE {$procedure_nores}() BEGIN DELETE FROM test_80458 WHERE first=6; END;"); +$stmt4 = $db->prepare("CALL {$procedure_nores}()"); $stmt4->execute(); var_dump($stmt4->fetchAll()); -$db->exec('DROP PROCEDURE IF EXISTS nores'); +$db->exec("DROP PROCEDURE IF EXISTS {$procedure_nores}"); + +$procedure_ret = 'ret_bug80458_pdo_mysql_p'; -$db->exec('CREATE PROCEDURE ret() BEGIN SELECT first FROM test_80458 WHERE first=7; END;'); -$stmt5 = $db->prepare('CALL ret()'); +$db->exec("CREATE PROCEDURE {$procedure_ret}() BEGIN SELECT first FROM test_80458 WHERE first=7; END;"); +$stmt5 = $db->prepare("CALL {$procedure_ret}()"); $stmt5->execute(); var_dump($stmt5->fetchAll()); $stmt5->nextRowset(); // needed to fetch the empty result set of CALL var_dump($stmt5->fetchAll()); -$db->exec('DROP PROCEDURE IF EXISTS ret'); +$db->exec("DROP PROCEDURE IF EXISTS {$procedure_ret}"); /* With emulated prepares */ print("Emulated prepares\n"); @@ -81,17 +84,17 @@ $stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=12'); $stmt->execute(); var_dump($stmt->fetchAll()); -$db->exec('CREATE PROCEDURE nores() BEGIN DELETE FROM test_80458 WHERE first=13; END;'); -$stmt4 = $db->prepare('CALL nores()'); +$db->exec("CREATE PROCEDURE {$procedure_nores}() BEGIN DELETE FROM test_80458 WHERE first=13; END;"); +$stmt4 = $db->prepare("CALL {$procedure_nores}()"); $stmt4->execute(); var_dump($stmt4->fetchAll()); -$db->exec('CREATE PROCEDURE ret() BEGIN SELECT first FROM test_80458 WHERE first=14; END;'); -$stmt5 = $db->prepare('CALL ret()'); +$db->exec("CREATE PROCEDURE {$procedure_ret}() BEGIN SELECT first FROM test_80458 WHERE first=14; END;"); +$stmt5 = $db->prepare("CALL {$procedure_ret}()"); $stmt5->execute(); var_dump($stmt5->fetchAll()); $stmt5->nextRowset(); // needed to fetch the empty result set of CALL var_dump($stmt5->fetchAll()); -$db->exec('DROP PROCEDURE IF EXISTS ret'); +$db->exec("DROP PROCEDURE IF EXISTS {$procedure_ret}"); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); @@ -103,15 +106,14 @@ var_dump($stmt->fetchAll()); $stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=16'); $stmt->execute(); var_dump($stmt->fetchAll()); - ?> --CLEAN-- exec('DROP PROCEDURE IF EXISTS nores'); -$db->exec('DROP PROCEDURE IF EXISTS ret'); +$db->exec('DROP TABLE IF EXISTS test_80458'); +$db->exec('DROP PROCEDURE IF EXISTS nores_bug80458_pdo_mysql_p'); +$db->exec('DROP PROCEDURE IF EXISTS ret_bug80458_pdo_mysql_p'); ?> --EXPECT-- array(0) { diff --git a/ext/pdo_mysql/tests/bug80808.phpt b/ext/pdo_mysql/tests/bug80808.phpt index 11034459fe456..779a8c5a84407 100644 --- a/ext/pdo_mysql/tests/bug80808.phpt +++ b/ext/pdo_mysql/tests/bug80808.phpt @@ -4,13 +4,12 @@ Bug #80808: PDO returns ZEROFILL integers without leading zeros pdo_mysql --SKIPIF-- --FILE-- exec('CREATE TABLE test_80808 (postcode INT(4) UNSIGNED ZEROFILL)'); @@ -20,11 +19,10 @@ $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); var_dump($pdo->query('SELECT * FROM test_80808')->fetchColumn(0)); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); var_dump($pdo->query('SELECT * FROM test_80808')->fetchColumn(0)); - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_80808'); ?> diff --git a/ext/pdo_mysql/tests/bug80908.phpt b/ext/pdo_mysql/tests/bug80908.phpt index 7896246eb6877..52b7a40dbb3cc 100644 --- a/ext/pdo_mysql/tests/bug80908.phpt +++ b/ext/pdo_mysql/tests/bug80908.phpt @@ -1,16 +1,15 @@ --TEST-- Bug #80908: pdo_mysql lastInsertId() return wrong, when table id bigger than the maximum value of int64 --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('CREATE TABLE test_80908 (`id` bigint(20) unsigned AUTO_INCREMENT, `name` varchar(5), primary key (`id`)) ENGINE = InnoDB AUTO_INCREMENT=10376293541461622799'); +$db->exec('CREATE TABLE test_80908 (`id` BIGINT(20) UNSIGNED AUTO_INCREMENT, `name` VARCHAR(5), PRIMARY KEY (`id`)) ENGINE = InnoDB AUTO_INCREMENT=10376293541461622799'); function testLastInsertId(PDO $db) { echo "Running test lastInsertId\n"; $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); try { - $db->exec("insert into test_80908 (`name`) values ('bar')"); + $db->exec("INSERT INTO test_80908 (`name`) VALUES ('bar')"); $id = $db->lastInsertId(); echo "Last insert id is " . $id . "\n"; } catch (PDOException $e) { @@ -37,11 +36,10 @@ function testLastInsertId(PDO $db) { testLastInsertId($db); unset($db); echo "\n"; - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_80908'); ?> diff --git a/ext/pdo_mysql/tests/bug81037.phpt b/ext/pdo_mysql/tests/bug81037.phpt index 73cc757a4cfbd..4a77b11c9fba8 100644 --- a/ext/pdo_mysql/tests/bug81037.phpt +++ b/ext/pdo_mysql/tests/bug81037.phpt @@ -1,23 +1,24 @@ --TEST-- Bug #81037 PDO discards error message text from prepared statement --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); -MySQLPDOTest::createTestTable($pdo); -$sql = "SELECT id FROM test WHERE label = :par"; +$table = 'bug81037_pdo_mysql'; +MySQLPDOTest::createTestTable($table, $pdo); + +$sql = "SELECT id FROM {$table} WHERE label = :par"; $stmt = $pdo->prepare($sql); try { $stmt->execute(); @@ -25,12 +26,12 @@ try { echo $e->getMessage(), "\n"; } $data = $stmt->fetchAll(PDO::FETCH_ASSOC); - ?> --CLEAN-- exec('DROP TABLE IF EXISTS bug81037_pdo_mysql'); ?> --EXPECT-- SQLSTATE[HY093]: Invalid parameter number diff --git a/ext/pdo_mysql/tests/bug_33689.phpt b/ext/pdo_mysql/tests/bug_33689.phpt index d3f90baf534b5..1041eb82c8fc1 100644 --- a/ext/pdo_mysql/tests/bug_33689.phpt +++ b/ext/pdo_mysql/tests/bug_33689.phpt @@ -1,29 +1,26 @@ --TEST-- PDO MySQL Bug #33689 (query() execute() and fetch() return false on valid select queries) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('CREATE TABLE test_33689 (bar INT NOT NULL)'); $db->exec('INSERT INTO test_33689 VALUES(1)'); -var_dump($db->query('SELECT * from test_33689')); -foreach ($db->query('SELECT * from test_33689') as $row) { +var_dump($db->query('SELECT * FROM test_33689')); +foreach ($db->query('SELECT * FROM test_33689') as $row) { print_r($row); } -$stmt = $db->prepare('SELECT * from test_33689'); +$stmt = $db->prepare('SELECT * FROM test_33689'); print_r($stmt->getColumnMeta(0)); $stmt->execute(); $tmp = $stmt->getColumnMeta(0); @@ -39,14 +36,14 @@ print_r($tmp); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_33689'); ?> --EXPECTF-- object(PDOStatement)#%d (1) { ["queryString"]=> - string(24) "SELECT * from test_33689" + string(24) "SELECT * FROM test_33689" } Array ( diff --git a/ext/pdo_mysql/tests/bug_37445.phpt b/ext/pdo_mysql/tests/bug_37445.phpt index 6bf75999c683d..842e2e37bc2e1 100644 --- a/ext/pdo_mysql/tests/bug_37445.phpt +++ b/ext/pdo_mysql/tests/bug_37445.phpt @@ -1,18 +1,16 @@ --TEST-- PDO MySQL Bug #37445 (Premature stmt object destruction) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO :: ATTR_EMULATE_PREPARES, true); $stmt = $db->prepare("SELECT 1"); diff --git a/ext/pdo_mysql/tests/bug_38546.phpt b/ext/pdo_mysql/tests/bug_38546.phpt index f662e9278c31a..3db800a8a1c25 100644 --- a/ext/pdo_mysql/tests/bug_38546.phpt +++ b/ext/pdo_mysql/tests/bug_38546.phpt @@ -1,19 +1,16 @@ --TEST-- PDO MySQL Bug #38546 (bindParam incorrect processing of bool types) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_EMULATE_PREPARES, false); @@ -49,7 +46,7 @@ if ($result === false) { print("ok insert\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } @@ -75,7 +72,7 @@ if ($result === false) { print("ok prepare 1\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } @@ -101,7 +98,7 @@ if ($result === false) { print("ok prepare 2\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } @@ -128,7 +125,7 @@ if ($result === false) { print("ok prepare 3\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } @@ -155,7 +152,7 @@ if ($result === false) { print("ok prepare 4\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } @@ -182,14 +179,13 @@ if ($result === false) { print("ok prepare 5\n"); } -foreach ($db->query('SELECT * from test_38546') as $row) { +foreach ($db->query('SELECT * FROM test_38546') as $row) { print_r($row); } - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_38546'); ?> diff --git a/ext/pdo_mysql/tests/bug_39483.phpt b/ext/pdo_mysql/tests/bug_39483.phpt index 810251e96cba7..c15d775b93d38 100644 --- a/ext/pdo_mysql/tests/bug_39483.phpt +++ b/ext/pdo_mysql/tests/bug_39483.phpt @@ -1,22 +1,20 @@ --TEST-- PDO MySQL Bug #39483 (Problem with handling of \ char in prepared statements) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE); +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $stmt = $db->prepare('SELECT UPPER(\'\0:D\0\'),?'); -$stmt->execute(array(1)); +$stmt->execute([1]); var_dump($stmt->fetchAll(PDO::FETCH_NUM)); ?> --EXPECTF-- diff --git a/ext/pdo_mysql/tests/bug_39858.phpt b/ext/pdo_mysql/tests/bug_39858.phpt index c56fbf72fe28d..66cb6d068de8a 100644 --- a/ext/pdo_mysql/tests/bug_39858.phpt +++ b/ext/pdo_mysql/tests/bug_39858.phpt @@ -1,35 +1,25 @@ --TEST-- Bug #39858 (Lost connection to MySQL server during query by a repeated call stored proced) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(50000); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function bug_39858($db) { + $procedure = 'bug_39858_pdo_mysql_p'; - $db->exec("DROP PROCEDURE IF EXISTS p"); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); $db->exec(" - CREATE PROCEDURE p() + CREATE PROCEDURE {$procedure}() NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER @@ -38,19 +28,18 @@ function bug_39858($db) { SELECT 2 * 2; END;"); - $stmt = $db->prepare("CALL p()"); + $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset()); - $stmt = $db->prepare("CALL p()"); + $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset()); $stmt->closeCursor(); - } printf("Emulated Prepared Statements...\n"); @@ -65,9 +54,9 @@ print "done!"; ?> --CLEAN-- exec("DROP PROCEDURE IF EXISTS p"); +$db->exec("DROP PROCEDURE IF EXISTS bug_39858_pdo_mysql_p"); ?> --EXPECT-- Emulated Prepared Statements... diff --git a/ext/pdo_mysql/tests/bug_41125.phpt b/ext/pdo_mysql/tests/bug_41125.phpt index 106d76e888cbc..45749b7d712be 100644 --- a/ext/pdo_mysql/tests/bug_41125.phpt +++ b/ext/pdo_mysql/tests/bug_41125.phpt @@ -4,29 +4,25 @@ Bug #41125 (PDO mysql + quote() + prepare() can result in segfault) pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 40100) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(40100); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); // And now allow the evil to do his work $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); -$sql = "CREATE TABLE IF NOT EXISTS test_41125(id INT); INSERT INTO test_41125(id) VALUES (1); SELECT * FROM test_41125; INSERT INTO test_41125(id) VALUES (2); SELECT * FROM test_41125;"; +$sql = <<query($sql); do { var_dump($stmt->fetchAll()); @@ -36,7 +32,7 @@ print "done!"; ?> --CLEAN-- exec("DROP TABLE IF EXISTS test_41125"); ?> diff --git a/ext/pdo_mysql/tests/bug_41698.phpt b/ext/pdo_mysql/tests/bug_41698.phpt index 5c22f9569ce71..d202daadacd4f 100644 --- a/ext/pdo_mysql/tests/bug_41698.phpt +++ b/ext/pdo_mysql/tests/bug_41698.phpt @@ -1,19 +1,16 @@ --TEST-- PDO MySQL Bug #41698 (float parameters truncated to integer in prepared statements) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- query('SELECT * FROM test_41698')->fetchAll(PDO::FETCH_ASSOC)); ?> --CLEAN-- exec("DROP TABLE IF EXISTS test_41698"); ?> diff --git a/ext/pdo_mysql/tests/bug_41997.phpt b/ext/pdo_mysql/tests/bug_41997.phpt index 51f41eb6d8c26..6a5aa3f148dae 100644 --- a/ext/pdo_mysql/tests/bug_41997.phpt +++ b/ext/pdo_mysql/tests/bug_41997.phpt @@ -4,30 +4,22 @@ PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks futur pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(50000); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); -$db->exec('DROP PROCEDURE IF EXISTS p'); -$db->exec('CREATE PROCEDURE p() BEGIN SELECT 1 AS "one"; END'); +$procedure = 'bug_41997_pdo_mysql_p'; + +$db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); +$db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT 1 AS 'one'; END"); -$stmt = $db->query("CALL p()"); +$stmt = $db->query("CALL {$procedure}()"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset()); @@ -40,9 +32,9 @@ print "done!"; ?> --CLEAN-- exec("DROP PROCEDURE IF EXISTS p"); +$db->exec("DROP PROCEDURE IF EXISTS bug_41997_pdo_mysql_p"); ?> --EXPECT-- array(1) { diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt index 9daae9c3aa193..721f1b2834e09 100644 --- a/ext/pdo_mysql/tests/bug_42499.phpt +++ b/ext/pdo_mysql/tests/bug_42499.phpt @@ -1,33 +1,19 @@ --TEST-- Bug #42499 (Multi-statement execution via PDO::exec() makes connection unusable) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version'); -$row = $stmt->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 41000) - die(sprintf("skip Need MySQL Server 4.1.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(40100); ?> --FILE-- exec("DROP TABLE IF EXISTS test_42499"); $db->exec("CREATE TABLE test_42499(id CHAR(1)); INSERT INTO test_42499(id) VALUES ('a')"); @@ -38,7 +24,6 @@ function bug_42499($db) { $db->exec('SELECT id FROM test_42499'); // This will bail at you because you have not fetched the SELECT results: this is not a bug! $db->exec("INSERT INTO test_42499(id) VALUES ('b')"); - } print "Emulated Prepared Statements...\n"; @@ -57,7 +42,7 @@ print "done!"; ?> --CLEAN-- exec("DROP TABLE IF EXISTS test_42499"); ?> diff --git a/ext/pdo_mysql/tests/bug_43371.phpt b/ext/pdo_mysql/tests/bug_43371.phpt index f8b98c237a2c4..b773ca3ec89d2 100644 --- a/ext/pdo_mysql/tests/bug_43371.phpt +++ b/ext/pdo_mysql/tests/bug_43371.phpt @@ -4,12 +4,12 @@ Bug #43371 (Memory errors in PDO constructor) pdo_mysql --SKIPIF-- --FILE-- true)); diff --git a/ext/pdo_mysql/tests/bug_44454.phpt b/ext/pdo_mysql/tests/bug_44454.phpt index 9c684978987c5..0e258fa24e65f 100644 --- a/ext/pdo_mysql/tests/bug_44454.phpt +++ b/ext/pdo_mysql/tests/bug_44454.phpt @@ -1,24 +1,19 @@ --TEST-- Bug #44454 (Unexpected exception thrown in foreach() statement) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('DROP TABLE IF EXISTS test_44454'); $db->exec('CREATE TABLE test_44454(a INT, b INT, UNIQUE KEY idx_ab (a, b))'); $db->exec('INSERT INTO test_44454(a, b) VALUES (1, 1)'); @@ -54,7 +49,6 @@ function bug_44454($db) { printf("... PDO - %s\n", var_export($db->errorInfo(), true)); } } - } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -71,7 +65,7 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_44454'); ?> diff --git a/ext/pdo_mysql/tests/bug_44707.phpt b/ext/pdo_mysql/tests/bug_44707.phpt index cb9c3564d9f07..d7005a9e8fb09 100644 --- a/ext/pdo_mysql/tests/bug_44707.phpt +++ b/ext/pdo_mysql/tests/bug_44707.phpt @@ -1,34 +1,20 @@ --TEST-- Bug #44707 (The MySQL PDO driver resets variable content after bindParam on tinyint field) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version'); -$row = $stmt->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 41000) - die(sprintf("skip Will work different with MySQL Server < 4.1.0, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(40100); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function bug_44707($db) { - $db->exec('CREATE TABLE test_44707(id INT, mybool TINYINT)'); $id = 1; @@ -54,7 +40,6 @@ function bug_44707($db) { $stmt = $db->query('SELECT * FROM test_44707'); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } @@ -73,7 +58,7 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_44707'); ?> diff --git a/ext/pdo_mysql/tests/bug_45120.phpt b/ext/pdo_mysql/tests/bug_45120.phpt index 01654e4a3f86a..98647ad98d3b6 100644 --- a/ext/pdo_mysql/tests/bug_45120.phpt +++ b/ext/pdo_mysql/tests/bug_45120.phpt @@ -1,22 +1,18 @@ --TEST-- Bug #45120 (PDOStatement->execute() returns true then false for same statement) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- prepare("SELECT 1 AS 'one'"); if (true !== $stmt->execute()) printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true)); @@ -31,7 +27,6 @@ function bug_45120($db) { $res = $stmt->fetch(PDO::FETCH_ASSOC); if ($res['one'] != 1) printf("[004] Wrong results: %s\n", var_export($res, true)); - } print "Emulated Prepared Statements\n"; diff --git a/ext/pdo_mysql/tests/bug_50323.phpt b/ext/pdo_mysql/tests/bug_50323.phpt index f33b847c2aaea..ea925d1606e92 100644 --- a/ext/pdo_mysql/tests/bug_50323.phpt +++ b/ext/pdo_mysql/tests/bug_50323.phpt @@ -1,18 +1,16 @@ --TEST-- Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('CREATE DATABASE `crazy;dbname`')) { - $dsn = changeDSN(getenv('PDOTEST_DSN'), array('dbname' => 'crazy;;dbname')); - $user = getenv('PDOTEST_USER'); - $pass = getenv('PDOTEST_PASS'); + if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) { + $dsn = changeDSN(PDO_MYSQL_TEST_DSN, array('dbname' => 'crazy;;dbname')); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; - new PDO($dsn, $user, $pass); -} -echo 'done!'; + new PDO($dsn, $user, $pass); + } + echo 'done!'; ?> --CLEAN-- exec('DROP DATABASE IF EXISTS `crazy;dbname`'); ?> diff --git a/ext/pdo_mysql/tests/bug_51670.phpt b/ext/pdo_mysql/tests/bug_51670.phpt index f3fc7277deeb0..80176080bb10f 100644 --- a/ext/pdo_mysql/tests/bug_51670.phpt +++ b/ext/pdo_mysql/tests/bug_51670.phpt @@ -1,18 +1,16 @@ --TEST-- Bug #51670 (getColumnMeta causes segfault when re-executing query after calling nextRowset) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- prepare('SELECT 1 AS num'); $query->execute(); if(!is_array($query->getColumnMeta(0))) die('FAIL!'); diff --git a/ext/pdo_mysql/tests/bug_61207.phpt b/ext/pdo_mysql/tests/bug_61207.phpt index af9387c9ea33b..7934db83cd6a8 100644 --- a/ext/pdo_mysql/tests/bug_61207.phpt +++ b/ext/pdo_mysql/tests/bug_61207.phpt @@ -4,21 +4,20 @@ PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't al pdo_mysql --SKIPIF-- --FILE-- query('create table `test_61207`( `id` int )'); +$db->query('CREATE TABLE `test_61207`(`id` INT)'); -$handle1 = $db->prepare('insert into test_61207(id) values(1); - select * from test_61207 where id = ?; - update test_61207 set id = 2 where id = ?;'); +$handle1 = $db->prepare('INSERT INTO test_61207(id) VALUES (1); + SELECT * FROM test_61207 WHERE id = ?; + UPDATE test_61207 SET id = 2 WHERE id = ?;'); $handle1->bindValue(1, '1'); $handle1->bindValue(2, '1'); @@ -32,8 +31,8 @@ do { print("Results detected\n"); } while($handle1->nextRowset()); -$handle2 = $db->prepare('select * from test_61207 where id = ?; - update test_61207 set id = 1 where id = ?;'); +$handle2 = $db->prepare('SELECT * FROM test_61207 WHERE id = ?; + UPDATE test_61207 SET id = 1 WHERE id = ?;'); $handle2->bindValue(1, '2'); $handle2->bindValue(2, '2'); @@ -48,8 +47,8 @@ do { print("Results detected\n"); } while($handle2->nextRowset()); -$handle3 = $db->prepare('update test_61207 set id = 2 where id = ?; - select * from test_61207 where id = ?;'); +$handle3 = $db->prepare('UPDATE test_61207 SET id = 2 WHERE id = ?; + SELECT * FROM test_61207 WHERE id = ?;'); $handle3->bindValue(1, '1'); $handle3->bindValue(2, '2'); @@ -64,9 +63,9 @@ do { print("Results detected\n"); } while($handle3->nextRowset()); -$handle4 = $db->prepare('insert into test_61207(id) values(3); - update test_61207 set id = 2 where id = ?; - select * from test_61207 where id = ?;'); +$handle4 = $db->prepare('INSERT INTO test_61207(id) VALUES (3); + UPDATE test_61207 SET id = 2 WHERE id = ?; + SELECT * FROM test_61207 WHERE id = ?;'); $handle4->bindValue(1, '3'); $handle4->bindValue(2, '2'); @@ -83,7 +82,7 @@ do { ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_61207'); ?> diff --git a/ext/pdo_mysql/tests/bug_61411.phpt b/ext/pdo_mysql/tests/bug_61411.phpt index 4993820c1a609..60582f8828dd9 100644 --- a/ext/pdo_mysql/tests/bug_61411.phpt +++ b/ext/pdo_mysql/tests/bug_61411.phpt @@ -1,29 +1,18 @@ --TEST-- Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 40106) - die(sprintf("skip Need MySQL Server 4.1.6+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(40106); ?> --FILE-- prepare("SELECT 1"); $stmt->execute(); diff --git a/ext/pdo_mysql/tests/bug_61755.phpt b/ext/pdo_mysql/tests/bug_61755.phpt index c75eb15e01bad..a9c2e86699b62 100644 --- a/ext/pdo_mysql/tests/bug_61755.phpt +++ b/ext/pdo_mysql/tests/bug_61755.phpt @@ -1,18 +1,16 @@ --TEST-- Bug #61755 (A parsing bug in the prepared statements can lead to access violations) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/ext/pdo_mysql/tests/bug_74376.phpt b/ext/pdo_mysql/tests/bug_74376.phpt index 80abdc1251416..b145a6af87704 100644 --- a/ext/pdo_mysql/tests/bug_74376.phpt +++ b/ext/pdo_mysql/tests/bug_74376.phpt @@ -1,26 +1,23 @@ --TEST-- Bug #74376 (Invalid free of persistent results on error/connection loss) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- query("select (select 1 union select 2)"); +$db = MySQLPDOTest::factoryWithAttr($attr); +$stmt = $db->query("SELECT (SELECT 1 UNION SELECT 2)"); print "ok"; ?> diff --git a/ext/pdo_mysql/tests/bug_pecl_12925.phpt b/ext/pdo_mysql/tests/bug_pecl_12925.phpt index bced0dc4080ec..f925ec1418795 100644 --- a/ext/pdo_mysql/tests/bug_pecl_12925.phpt +++ b/ext/pdo_mysql/tests/bug_pecl_12925.phpt @@ -1,21 +1,18 @@ --TEST-- PDO MySQL PECL bug #1295 (http://pecl.php.net/bugs/bug.php?id=12925) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('DROP TABLE IF EXISTS test_12925'); $db->exec('CREATE TABLE test_12925(id CHAR(1))'); $db->exec("INSERT INTO test_12925(id) VALUES ('a')"); @@ -27,7 +24,6 @@ function bug_pecl_1295($db) { $stmt->execute(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); - } printf("Emulated...\n"); @@ -44,7 +40,7 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_12925'); ?> diff --git a/ext/pdo_mysql/tests/bug_pecl_7976.phpt b/ext/pdo_mysql/tests/bug_pecl_7976.phpt index 62dfaec947770..42c4387b69e8e 100644 --- a/ext/pdo_mysql/tests/bug_pecl_7976.phpt +++ b/ext/pdo_mysql/tests/bug_pecl_7976.phpt @@ -1,42 +1,30 @@ --TEST-- PECL Bug #7976 (Calling stored procedure several times) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(50000); ?> --FILE-- exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT '1' AS _one; END;"); - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;'); - - $stmt = $db->query('CALL p()'); + $stmt = $db->query("CALL {$procedure}()"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); - $stmt = $db->query('CALL p()'); + $stmt = $db->query("CALL {$procedure}()"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); - } printf("Emulated...\n"); @@ -53,9 +41,9 @@ print "done!"; ?> --CLEAN-- exec('DROP PROCEDURE IF EXISTS p'); +$db->exec('DROP PROCEDURE IF EXISTS bug_pecl_7976_pdo_mysql_p'); ?> --EXPECT-- Emulated... diff --git a/ext/pdo_mysql/tests/change_column_count.phpt b/ext/pdo_mysql/tests/change_column_count.phpt index 5aeba12561608..dd1ed62084efc 100644 --- a/ext/pdo_mysql/tests/change_column_count.phpt +++ b/ext/pdo_mysql/tests/change_column_count.phpt @@ -1,16 +1,15 @@ --TEST-- Change column count after statement has been prepared --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -31,11 +30,10 @@ var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); $db->exec('ALTER TABLE test_change_column_count ADD new_col VARCHAR(255)'); $stmt->execute(['id' => 10]); var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_change_column_count'); ?> diff --git a/ext/pdo_mysql/tests/config.inc b/ext/pdo_mysql/tests/config.inc deleted file mode 100644 index 8bcc1ee65968f..0000000000000 --- a/ext/pdo_mysql/tests/config.inc +++ /dev/null @@ -1,52 +0,0 @@ - $v) { - putenv("$k=$v"); -} - -/* MySQL specific settings */ -define('PDO_MYSQL_TEST_ENGINE', (false !== getenv('PDO_MYSQL_TEST_ENGINE')) ? getenv('PDO_MYSQL_TEST_ENGINE') : 'InnoDB'); -define('PDO_MYSQL_TEST_HOST', (false !== getenv('PDO_MYSQL_TEST_HOST')) ? getenv('PDO_MYSQL_TEST_HOST') : 'localhost'); -define('PDO_MYSQL_TEST_PORT', (false !== getenv('PDO_MYSQL_TEST_PORT')) ? getenv('PDO_MYSQL_TEST_PORT') : NULL); -define('PDO_MYSQL_TEST_DB', (false !== getenv('PDO_MYSQL_TEST_DB')) ? getenv('PDO_MYSQL_TEST_DB') : 'test'); -define('PDO_MYSQL_TEST_SOCKET', (false !== getenv('PDO_MYSQL_TEST_SOCKET')) ? getenv('PDO_MYSQL_TEST_SOCKET') : NULL); -define('PDO_MYSQL_TEST_DSN', (false !== getenv('PDO_MYSQL_TEST_DSN')) ? getenv('PDO_MYSQL_TEST_DSN') : $config['ENV']['PDOTEST_DSN']); -define('PDO_MYSQL_TEST_USER', (false !== getenv('PDO_MYSQL_TEST_USER')) ? getenv('PDO_MYSQL_TEST_USER') : $config['ENV']['PDOTEST_USER']); -define('PDO_MYSQL_TEST_PASS', (false !== getenv('PDO_MYSQL_TEST_PASS')) ? getenv('PDO_MYSQL_TEST_PASS') : $config['ENV']['PDOTEST_PASS']); -define('PDO_MYSQL_TEST_CHARSET', (false !== getenv('PDO_MYSQL_TEST_CHARSET')) ? getenv('PDO_MYSQL_TEST_CHARSET') : NULL); - -if (!function_exists('sys_get_temp_dir')) { - function sys_get_temp_dir() { - - if (!empty($_ENV['TMP'])) - return realpath( $_ENV['TMP'] ); - if (!empty($_ENV['TMPDIR'])) - return realpath( $_ENV['TMPDIR'] ); - if (!empty($_ENV['TEMP'])) - return realpath( $_ENV['TEMP'] ); - - $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($temp_file) { - $temp_dir = realpath(dirname($temp_file)); - unlink($temp_file); - return $temp_dir; - } - return FALSE; - } -} -?> diff --git a/ext/pdo_mysql/tests/gh11550.phpt b/ext/pdo_mysql/tests/gh11550.phpt index 5bf0b26497ca0..28f3049e33031 100644 --- a/ext/pdo_mysql/tests/gh11550.phpt +++ b/ext/pdo_mysql/tests/gh11550.phpt @@ -1,22 +1,21 @@ --TEST-- Bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec(<<<'SQL' CREATE TABLE `test_gh11550` ( - `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `name`(`name`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; @@ -25,14 +24,14 @@ $pdo->exec(<<<'SQL' INSERT INTO `test_gh11550` (`name`) VALUES ('test1'); SQL); -$stmt = $pdo->prepare('select * from test_gh11550'); +$stmt = $pdo->prepare('SELECT * FROM test_gh11550'); var_dump('PDO-1:', $stmt->execute(), $stmt->fetchAll()); $stmt->closeCursor(); // Optional. Segmentation fault (core dumped) $pdo->exec(<<<'SQL' ALTER TABLE `test_gh11550` -ADD COLUMN `a` varchar(255) NOT NULL DEFAULT ''; +ADD COLUMN `a` VARCHAR(255) NOT NULL DEFAULT ''; SQL); var_dump('PDO-2:', $stmt->execute(), $stmt->fetchAll()); @@ -40,7 +39,7 @@ echo 'Done'; ?> --CLEAN-- query('DROP TABLE IF EXISTS test_gh11550'); ?> diff --git a/ext/pdo_mysql/tests/gh-11587.phpt b/ext/pdo_mysql/tests/gh11587.phpt similarity index 92% rename from ext/pdo_mysql/tests/gh-11587.phpt rename to ext/pdo_mysql/tests/gh11587.phpt index 4c4a63158efa5..2e56a2e5f0568 100644 --- a/ext/pdo_mysql/tests/gh-11587.phpt +++ b/ext/pdo_mysql/tests/gh11587.phpt @@ -4,13 +4,13 @@ GH-11587 PHP8.1: Fixed the condition for result set values to be of native type, pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_11587'); ?> diff --git a/ext/pdo_mysql/tests/inc/config.inc b/ext/pdo_mysql/tests/inc/config.inc new file mode 100644 index 0000000000000..67ef14bee2ef3 --- /dev/null +++ b/ext/pdo_mysql/tests/inc/config.inc @@ -0,0 +1,14 @@ + false !== getenv('PDO_MYSQL_TEST_DSN') ? getenv('PDO_MYSQL_TEST_DSN') : 'mysql:host=localhost;dbname=test', + 'PDO_MYSQL_TEST_USER' => false !== getenv('PDO_MYSQL_TEST_USER') ? getenv('PDO_MYSQL_TEST_USER') : 'root', + 'PDO_MYSQL_TEST_PASS' => false !== getenv('PDO_MYSQL_TEST_PASS') ? getenv('PDO_MYSQL_TEST_PASS') : '', + 'PDO_MYSQL_TEST_ENGINE' => false !== getenv('PDO_MYSQL_TEST_ENGINE') ? getenv('PDO_MYSQL_TEST_ENGINE') : 'InnoDB', + 'PDO_MYSQL_TEST_HOST' => false !== getenv('PDO_MYSQL_TEST_HOST') ? getenv('PDO_MYSQL_TEST_HOST') : 'localhost', + 'PDO_MYSQL_TEST_PORT' => false !== getenv('PDO_MYSQL_TEST_PORT') ? getenv('PDO_MYSQL_TEST_PORT') : null, + 'PDO_MYSQL_TEST_DB' => false !== getenv('PDO_MYSQL_TEST_DB') ? getenv('PDO_MYSQL_TEST_DB') : 'test', + 'PDO_MYSQL_TEST_SOCKET' => false !== getenv('PDO_MYSQL_TEST_SOCKET') ? getenv('PDO_MYSQL_TEST_SOCKET') : null, + 'PDO_MYSQL_TEST_CHARSET' => false !== getenv('PDO_MYSQL_TEST_CHARSET') ? getenv('PDO_MYSQL_TEST_CHARSET') : null, + 'PDO_MYSQL_TEST_ATTR' => false !== getenv('PDO_MYSQL_TEST_ATTR') ? getenv('PDO_MYSQL_TEST_ATTR') : null, +]; +?> diff --git a/ext/pdo_mysql/tests/mysql_pdo_test.inc b/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc similarity index 51% rename from ext/pdo_mysql/tests/mysql_pdo_test.inc rename to ext/pdo_mysql/tests/inc/mysql_pdo_test.inc index 0fcb21668b9e6..64f8a5552f481 100644 --- a/ext/pdo_mysql/tests/mysql_pdo_test.inc +++ b/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc @@ -1,25 +1,24 @@ $v) { + define($k, $v); +} - static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null, $mydsn = null) { +class MySQLPDOTest extends PDOTest { + static function factory($classname = 'PDO', $mydsn = null, $myAttr = null) { $dsn = self::getDSN($mydsn); $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; - $attr = getenv('PDOTEST_ATTR'); + $attr = PDO_MYSQL_TEST_ATTR; - if (is_string($attr) && strlen($attr)) { - $attr = unserialize($attr); + if ($myAttr) { + $attr = $myAttr; } else { - $attr = null; + $attr = is_string($attr) && strlen($attr) ? unserialize($attr) : null; } - if ($user === false) - $user = NULL; - if ($pass === false) - $pass = NULL; $db = new $classname($dsn, $user, $pass, $attr); if (!$db) { @@ -32,20 +31,23 @@ class MySQLPDOTest extends PDOTest { return $db; } - static function createTestTable($db, $engine = null) { + static function factoryWithAttr($attr) { + return self::factory('PDO', null, $attr); + } + + static function createTestTable($table, $db, $engine = null) { if (!$engine) $engine = PDO_MYSQL_TEST_ENGINE; - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine); - $db->exec("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')"); + $db->exec("DROP TABLE IF EXISTS {$table}"); + $db->exec("CREATE TABLE {$table} (id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE={$engine}"); + $db->exec("INSERT INTO {$table} (id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')"); } static function getTableEngine() { return PDO_MYSQL_TEST_ENGINE; } - static function getDSN($new_options = null, $addition = '') { if (!$new_options) return PDO_MYSQL_TEST_DSN . $addition; @@ -118,27 +120,20 @@ class MySQLPDOTest extends PDOTest { } static function getTempDir() { - - if (!function_exists('sys_get_temp_dir')) { - - if (!empty($_ENV['TMP'])) - return realpath( $_ENV['TMP'] ); - if (!empty($_ENV['TMPDIR'])) - return realpath( $_ENV['TMPDIR'] ); - if (!empty($_ENV['TEMP'])) - return realpath( $_ENV['TEMP'] ); - - $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($temp_file) { - $temp_dir = realpath(dirname($temp_file)); - unlink($temp_file); - return $temp_dir; - } - return FALSE; - } else { - return sys_get_temp_dir(); + if (!empty($_ENV['TMP'])) + return realpath( $_ENV['TMP'] ); + if (!empty($_ENV['TMPDIR'])) + return realpath( $_ENV['TMPDIR'] ); + if (!empty($_ENV['TEMP'])) + return realpath( $_ENV['TEMP'] ); + + $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); + if ($temp_file) { + $temp_dir = realpath(dirname($temp_file)); + unlink($temp_file); + return $temp_dir; } - + return false; } static function detect_transactional_mysql_engine($db) { @@ -158,20 +153,59 @@ class MySQLPDOTest extends PDOTest { } static function isPDOMySQLnd() { - ob_start(); - phpinfo(); - $tmp = ob_get_contents(); - ob_end_clean(); - return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) && - preg_match('/Client API version.*mysqlnd/', $tmp)); + ob_start(); + phpinfo(); + $tmp = ob_get_contents(); + ob_end_clean(); + return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) && + preg_match('/Client API version.*mysqlnd/', $tmp)); } - static function dropTestTable($db = NULL, $tableName = 'test') { - if (is_null($db)) + static function skip() { + try { $db = self::factory(); + } catch (PDOException $e) { + die('skip could not connect'); + } + } - $db->exec('DROP TABLE IF EXISTS '.$tableName); + static function skipInfileNotAllowed() { + $db = self::factory(); + $stmt = $db->query("SHOW VARIABLES LIKE 'local_infile'"); + if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != 'ON')) + die("skip Server variable 'local_infile' seems not set to 'ON', found '". $row['value'] ."'"); } + static function skipVersionThanLess ($expected_version) { + $nums = [ + (int) substr($expected_version, 0, 1), + (int) substr($expected_version, 1, 2), + (int) substr($expected_version, 3, 2), + ]; + $expected_version_str = implode('.', $nums); + + $db = self::factory(); + $stmt = $db->query('SELECT VERSION() as _version'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $matches = array(); + if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) + die(sprintf("skip Cannot determine MySQL Server version\n")); + + $version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; + if ($version < $expected_version) + die(sprintf("skip Need MySQL Server %s+, found %d.%02d.%02d (%d)\n", + $expected_version_str, $matches[1], $matches[2], $matches[3], $version)); + } + + static function skipNotMySQLnd(?string $message = null) { + $message = $message ?? 'skip only for mysqlnd'; + if (!self::isPDOMySQLnd()) die($message); + } + + static function skipNotTransactionalEngine(?string $message = null) { + $db = self::factory(); + $message = $message ?? 'skip Transactional engine not found'; + if (false == self::detect_transactional_mysql_engine($db)) die($message); + } } ?> diff --git a/ext/pdo_mysql/tests/last_insert_id.phpt b/ext/pdo_mysql/tests/last_insert_id.phpt index 36ffb41d8a3f8..4a565cef6f78e 100644 --- a/ext/pdo_mysql/tests/last_insert_id.phpt +++ b/ext/pdo_mysql/tests/last_insert_id.phpt @@ -1,20 +1,18 @@ --TEST-- PDO MySQL auto_increment / last insert id --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- query("CREATE TABLE test_last_insert_id (id int auto_increment primary key, num int)")); +print_r($db->query("CREATE TABLE test_last_insert_id (id INT AUTO_INCREMENT PRIMARY KEY, num INT)")); print_r($db->query("INSERT INTO test_last_insert_id (id, num) VALUES (23, 42)")); @@ -24,13 +22,14 @@ print_r($db->lastInsertId()); ?> --CLEAN-- query('DROP TABLE IF EXISTS test_last_insert_id'); ?> --EXPECT-- PDOStatement Object ( - [queryString] => CREATE TABLE test_last_insert_id (id int auto_increment primary key, num int) + [queryString] => CREATE TABLE test_last_insert_id (id INT AUTO_INCREMENT PRIMARY KEY, num INT) ) PDOStatement Object ( diff --git a/ext/pdo_mysql/tests/native_types.phpt b/ext/pdo_mysql/tests/native_types.phpt index 6b5a9a9329a7d..05e1d2ac7a3f9 100644 --- a/ext/pdo_mysql/tests/native_types.phpt +++ b/ext/pdo_mysql/tests/native_types.phpt @@ -4,13 +4,13 @@ PDO MySQL should use native types if ATTR_STRINGIFY_FETCHES is not enabled pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -26,7 +26,7 @@ var_dump($db->query('SELECT * FROM test_native_types')->fetchAll(PDO::FETCH_ASSO ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_native_types'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt index aa52764dea2c7..7d744cbd34490 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt @@ -4,16 +4,15 @@ MySQL PDO->__construct() - Generic + DSN pdo_mysql --SKIPIF-- --FILE-- getMessage()); } - } // what about long values for a valid option ... @@ -142,7 +139,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI'); // atoi('abc') = 0, 0 -> fallback to default 3306 -> may or may not fail! } catch (PDOException $e) { } - } if (PDO_MYSQL_TEST_DB) { @@ -161,7 +157,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI'); try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { printf("[023] DSN=%s, %s\n", $dsn, $e->getMessage()); } - } if (PDO_MYSQL_TEST_SOCKET && (stristr(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_SOCKET) !== false)) { @@ -179,7 +174,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI'); try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { printf("[025] DSN=%s, %s\n", $dsn, $e->getMessage()); } - } $have_charset_support = false; @@ -238,9 +232,7 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI'); } else { printf("[030] You're trying to run the tests with charset '%s' which seems not supported by the server!", $charset); } - } - } if ($have_charset_support) { @@ -282,10 +274,8 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI'); } catch (PDOException $e) { printf("[034] %s\n", $e->getMessage()); } - } } - } catch (PDOException $e) { printf("[001] %s, [%s] %s\n", $e->getMessage(), diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt index 1e3f05b3c8f47..11c2f183245ab 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt @@ -4,7 +4,7 @@ MySQL PDO->__construct() - URI pdo_mysql --SKIPIF-- __construct(), options pdo_mysql --SKIPIF-- --FILE-- $value)); + $db = new PDO($dsn, $user, $pass, [$option => $value]); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); if (!is_object($db) || ($value !== ($tmp = @$db->getAttribute($option)))) printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n", @@ -29,45 +28,43 @@ MySQLPDOTest::skip(); } catch (PDOException $e) { printf("[%03d] %s\n", $offset, $e->getMessage()); } - } try { - $dsn = MySQLPDOTest::getDSN(); $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; - $valid_options = array( + $valid_options = [ /* pdo_dbh.c */ - PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT', - PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT', + PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT', + PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT', /* mysql_driver.c */ /* TODO Possible bug PDO::ATTR_TIMEOUT != MYSQLI_OPT_CONNECT_TIMEOUT*/ - PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT', - PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', + PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT', + PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY', - PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE', - PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY', + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY', + PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE', + PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY', - PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND', - PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', - ); + PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND', + PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', + ]; - $defaults = array( - PDO::ATTR_PERSISTENT => false, - PDO::ATTR_AUTOCOMMIT => 1, + $defaults = [ + PDO::ATTR_PERSISTENT => false, + PDO::ATTR_AUTOCOMMIT => 1, /* TODO - why is this a valid option if getAttribute() does not support it?! */ - PDO::ATTR_TIMEOUT => false, - PDO::ATTR_EMULATE_PREPARES => 1, - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, + PDO::ATTR_TIMEOUT => false, + PDO::ATTR_EMULATE_PREPARES => 1, + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_LOCAL_INFILE => false, + PDO::MYSQL_ATTR_LOCAL_INFILE => false, /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_DIRECT_QUERY => 1, - PDO::MYSQL_ATTR_INIT_COMMAND => '', - ); + PDO::MYSQL_ATTR_DIRECT_QUERY => 1, + PDO::MYSQL_ATTR_INIT_COMMAND => '', + ]; try { if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type'))) diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt index 9fcbf3b2b7949..e3d8ee2db6583 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt @@ -4,17 +4,16 @@ MySQL PDO->__construct(), libmysql only options pdo_mysql --SKIPIF-- --FILE-- __construct() - URI pdo_mysql --SKIPIF-- --FILE-- ---EXPECTF-- +--EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt index 928e620546f16..0af28e9e8ba25 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt @@ -4,13 +4,12 @@ PDO::ATTR_AUTOCOMMIT pdo_mysql --SKIPIF-- --FILE-- getAttribute(PDO::ATTR_AUTOCOMMIT))) printf("[010] Expecting int/1 got %s\n", var_export($tmp, true)); + $table = 'pdo_mysql_attr_autocommit'; if (MySQLPDOTest::detect_transactional_mysql_engine($db)) { // nice, we have a transactional engine to play with - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + MySQLPDOTest::createTestTable($table, $db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); $num = $row['_num']; - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->query("INSERT INTO {$table} (id, label) VALUES (100, 'z')"); $num++; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[011] Insert has failed, test will fail\n"); // autocommit is on, no rollback possible $db->query('ROLLBACK'); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[012] ROLLBACK should not have undone anything\n"); if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0)) printf("[013] Cannot turn off autocommit\n"); - $db->query('DELETE FROM test WHERE id = 100'); + $db->query("DELETE FROM {$table} WHERE id = 100"); $db->query('ROLLBACK'); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[014] ROLLBACK should have undone the DELETE\n"); - $db->query('DELETE FROM test WHERE id = 100'); + $db->query("DELETE FROM {$table} WHERE id = 100"); $db->query('COMMIT'); $num--; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[015] DELETE should have been committed\n"); - } print "done!"; ?> --CLEAN-- query('DROP TABLE IF EXISTS pdo_mysql_attr_autocommit'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt index 1c629a3f01397..f2cc2a5fd60c4 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt @@ -4,23 +4,24 @@ PDO::ATTR_CASE pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + + $table = 'pdo_mysql_attr_case'; + MySQLPDOTest::createTestTable($table, $db); $default = $db->getAttribute(PDO::ATTR_CASE); - $known = array( + $known = [ PDO::CASE_LOWER => 'PDO::CASE_LOWER', PDO::CASE_UPPER => 'PDO::CASE_UPPER', PDO::CASE_NATURAL => 'PDO::CASE_NATURAL' - ); + ]; if (!isset($known[$default])) printf("[001] getAttribute(PDO::ATTR_CASE) returns unknown value '%s'\n", var_export($default, true)); @@ -28,7 +29,7 @@ $db = MySQLPDOTest::factory(); var_dump($known[$default]); // lets see what the default is... - if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2"))) + if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM {$table} ORDER BY id ASC LIMIT 2"))) printf("[002] %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); @@ -42,15 +43,15 @@ $db = MySQLPDOTest::factory(); printf("[004] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", var_export($tmp, true)); - if (true === $db->exec('ALTER TABLE test ADD MiXeD CHAR(1)')) + if (true === $db->exec("ALTER TABLE {$table} ADD MiXeD CHAR(1)")) printf("[005] Cannot add column %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (false === $db->exec('ALTER TABLE test ADD MYUPPER CHAR(1)')) + if (false === $db->exec("ALTER TABLE {$table} ADD MYUPPER CHAR(1)")) printf("[006] Cannot add column %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2"))) + if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM {$table} ORDER BY id ASC LIMIT 2"))) printf("[007] %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); @@ -64,7 +65,7 @@ $db = MySQLPDOTest::factory(); printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", var_export($tmp, true)); - if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1"))) + if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM {$table} ORDER BY id ASC LIMIT 1"))) printf("[010] %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); @@ -78,7 +79,7 @@ $db = MySQLPDOTest::factory(); printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", var_export($tmp, true)); - if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1"))) + if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM {$table} ORDER BY id ASC LIMIT 1"))) printf("[013] %s - %s\n", var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); @@ -88,8 +89,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- query('DROP TABLE IF EXISTS pdo_mysql_attr_case'); ?> --EXPECT-- string(15) "PDO::CASE_LOWER" diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt index 396624e04546b..da3f23830f365 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_client_version.phpt @@ -4,13 +4,12 @@ PDO::ATTR_CLIENT_VERSION pdo_mysql --SKIPIF-- --FILE-- errorCode()) || ('00000' == $db->errorCode())); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt index b1896e53ee722..38c1ffcb4ffa5 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt @@ -4,13 +4,12 @@ PDO::ATTR_CONNECTION_STATUS pdo_mysql --SKIPIF-- --FILE-- -getAttribute(PDO::ATTR_CONNECTION_STATUS); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt index fadf5e979f977..3be2e5aacf719 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt @@ -4,13 +4,12 @@ PDO::ATTR_DRIVER_NAME pdo_mysql --SKIPIF-- --FILE-- errorCode()) || ('00000' == $db->errorCode())); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt index 40c985b4c3fdb..df5f6c99d3483 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt @@ -4,15 +4,14 @@ PDO::ATTR_ERRMODE pdo_mysql --SKIPIF-- --INI-- error_reporting=E_ALL --FILE-- query('THIS IS NOT VALID SQL'); } catch (PDOException $e) { - $code = $db->errorCode(); $info = $db->errorInfo(); @@ -107,7 +105,6 @@ error_reporting=E_ALL if ($e->getFile() !== __FILE__) printf("[020] Exception has been thrown in file '%s', exception object reports file '%s'\n", __FILE__, $e->getFile()); - } function my_handler($e) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt index 8e7d781f2f880..a4670017eec5a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt @@ -4,32 +4,40 @@ PDO::ATTR_FETCH_TABLE_NAMES pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 1); - $stmt = $db->query('SELECT label FROM test LIMIT 1'); + $stmt = $db->query("SELECT label FROM {$table} LIMIT 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); $db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 0); - $stmt = $db->query('SELECT label FROM test LIMIT 1'); + $stmt = $db->query("SELECT label FROM {$table} LIMIT 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); print "done!"; ?> +--CLEAN-- +query('DROP TABLE IF EXISTS pdo_mysql_attr_fetch_table_names'); +?> --EXPECT-- array(1) { [0]=> array(1) { - ["test.label"]=> + ["pdo_mysql_attr_fetch_table_names.label"]=> string(1) "a" } } diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt index a6921b092895a..ff38ea86c1cf0 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt @@ -4,21 +4,20 @@ PDO::MYSQL_ATTR_INIT_COMMAND pdo_mysql --SKIPIF-- --INI-- error_reporting=E_ALL --FILE-- exec(sprintf('DROP TABLE IF EXISTS %s', $table)); @@ -37,8 +36,14 @@ error_reporting=E_ALL $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); print "done!"; ?> ---EXPECTF-- -string(58) "CREATE TABLE test_%s(id INT)" +--CLEAN-- +query('DROP TABLE IF EXISTS pdo_mysql_attr_init_command'); +?> +--EXPECT-- +string(48) "CREATE TABLE pdo_mysql_attr_init_command(id INT)" string(5) "00000" array(1) { [0]=> 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 9dcb7612320be..6491bb7bca2e0 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 @@ -4,19 +4,17 @@ MySQL PDO->__construct(), PDO::MYSQL_ATTR_MAX_BUFFER_SIZE pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- query('DROP TABLE IF EXISTS test_attr_max_buffer_size'); ?> --EXPECTF-- [001] id = 1, val = 0123456789... (length: %d) diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt index 9c97729ccc82c..b97c858530d51 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt @@ -4,21 +4,21 @@ PDO::MYSQL_ATTR_MULTI_STATEMENTS pdo_mysql --SKIPIF-- --INI-- error_reporting=E_ALL --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); @@ -51,9 +51,14 @@ error_reporting=E_ALL $stmt = $db->query('SELECT 1 AS value;'); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); print "done!"; ?> +--CLEAN-- +query('DROP TABLE IF EXISTS pdo_mysql_attr_multi_statements'); +?> --EXPECTF-- string(5) "00000" array(2) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index 6fa3ce055240c..f2121de6d3682 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -4,14 +4,13 @@ PDO::ATTR_ORACLE_NULLS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ORACLE_NULLS, []); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt index f24de5a390a4c..ac11b556a4bcf 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt @@ -4,13 +4,12 @@ PDO::ATTR_PREFETCH pdo_mysql --SKIPIF-- --FILE-- getAttribute(PDO::ATTR_PREFETCH)); var_dump($db->setAttribute(PDO::ATTR_PREFETCH, true)); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt index c672acd2eb635..9da3b83c9ce6a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt @@ -4,13 +4,12 @@ PDO::ATTR_SERVER_INFO pdo_mysql --SKIPIF-- --FILE-- errorCode()) || ('00000' == $db->errorCode())); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt index e193ae3fca5bf..edbcbe251798d 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt @@ -4,13 +4,12 @@ PDO::ATTR_SERVER_VERSION pdo_mysql --SKIPIF-- --FILE-- errorCode()) || ('00000' == $db->errorCode())); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt index 317e3ec3a22f0..a22af1cbdefb1 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt @@ -4,16 +4,18 @@ PDO::ATTR_STATEMENT_CLASS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + + $table = 'pdo_mysql_attr_statement_class'; + + MySQLPDOTest::createTestTable($table, $db); $default = $db->getAttribute(PDO::ATTR_STATEMENT_CLASS); var_dump($default); @@ -94,7 +96,7 @@ $db = MySQLPDOTest::factory(); printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true)); var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2"); class mystatement5 extends mystatement4 { public function fetchAll($fetch_style = 1, ...$fetch_args): array { @@ -104,13 +106,13 @@ $db = MySQLPDOTest::factory(); if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement5', array('mystatement5'))))) printf("[009] Expecting boolean/true got %s\n", var_export($tmp, true)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2"); var_dump($stmt->fetchAll()); if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement')))) printf("[010] Expecting boolean/true got %s\n", var_export($tmp, true)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 1"); var_dump($stmt->fetchAll()); // Yes, this is a fatal error and I want it to fail. @@ -118,11 +120,16 @@ $db = MySQLPDOTest::factory(); } try { $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['mystatement6', ['mystatement6']]); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 1"); } catch (\Error $e) { echo get_class($e), ': ', $e->getMessage(), \PHP_EOL; } - +?> +--CLEAN-- +query('DROP TABLE IF EXISTS pdo_mysql_attr_statement_class'); ?> --EXPECT-- array(1) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt index 7c78d691eaf0c..966b379f9d421 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt @@ -4,18 +4,17 @@ PDO->beginTransaction() pdo_mysql --SKIPIF-- +MySQLPDOTest::skipNotTransactionalEngine(); --FILE-- getAttribute(PDO::ATTR_AUTOCOMMIT)) printf("[001] Autocommit should be on by default\n"); @@ -27,7 +26,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) printf("[003] Autocommit should be on by default, beginTransaction() shall not impact it\n"); - if (0 == $db->exec('DELETE FROM test')) + if (0 == $db->exec("DELETE FROM {$table}")) printf("[004] No rows deleted, can't be true.\n"); /* This is the PDO way to close a connection */ @@ -36,7 +35,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); /* Autocommit was off - by definition. Commit was not issued. DELETE should have been rolled back. */ - if (!($stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC'))) + if (!($stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"))) printf("[005] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); $row = $stmt->fetch(PDO::FETCH_ASSOC); @@ -45,7 +44,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (!$db->beginTransaction()) printf("[006] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) + if (1 !== $db->exec(sprintf('DELETE FROM %s WHERE id = %d', $table, $row['id']))) printf("[007] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); if (!$db->commit()) @@ -54,7 +53,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) printf("[009] Autocommit should be on after commit()\n"); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id'])))) printf("[010] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); @@ -62,9 +61,9 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (!$db->beginTransaction()) printf("[011] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $db->exec(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z')", $row['id'])); + $db->exec(sprintf("INSERT INTO %s (id, label) VALUES (%d, 'z')", $table, $row['id'])); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id'])))) printf("[012] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); $new_row1 = $stmt->fetch(PDO::FETCH_ASSOC); @@ -73,7 +72,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (!$db->commit()) printf("[013] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id'])))) printf("[014] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); @@ -86,7 +85,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (!$db->beginTransaction()) printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) + if (1 !== $db->exec(sprintf('DELETE FROM %s WHERE id = %d', $table, $row['id']))) printf("[017] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); if (!$db->rollback()) @@ -95,7 +94,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) printf("[019] Autocommit should be on after rollback\n"); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id'])))) printf("[020] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); @@ -150,7 +149,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) // TODO: What about an engine that does not support transactions? $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, 'MyISAM'); + MySQLPDOTest::createTestTable($table, $db, 'MyISAM'); if (false == $db->beginTransaction()) printf("[031] Cannot start a transaction, [%s] [%s]\n", @@ -159,7 +158,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) printf("[032] Autocommit should be on my default, beginTransaction() should not change that\n"); - if (0 == $db->exec('DELETE FROM test')) + if (0 == $db->exec("DELETE FROM {$table}")) printf("[033] No rows deleted, can't be true.\n"); if (!$db->commit()) @@ -169,7 +168,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) printf("[035] Cannot start a transaction, [%s] [%s]\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (0 == $db->exec("INSERT INTO test(id, label) VALUES (1, 'a')")) + if (0 == $db->exec("INSERT INTO {$table} (id, label) VALUES (1, 'a')")) printf("[036] Cannot insert data, [%s] [%s]\n", $db->errorCode(), implode(' ', $db->errorInfo())); @@ -179,15 +178,16 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) var_dump($db->errorCode()); - if (1 != $db->exec('DELETE FROM test')) + if (1 != $db->exec("DELETE FROM {$table}")) printf("[038] No rows deleted, can't be true.\n"); print "done!"; ?> --CLEAN-- query('DROP TABLE IF EXISTS pdo_mysql_begintransaction'); ?> --EXPECT-- array(2) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_bit.phpt b/ext/pdo_mysql/tests/pdo_mysql_bit.phpt index fdba14d179891..eeb96f6ba480c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_bit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_bit.phpt @@ -4,7 +4,7 @@ MySQL PDO->exec(), BIT columns - remove after fix! pdo_mysql --SKIPIF-- exec($sql); if ($db->errorCode() != 0) { @@ -49,7 +48,7 @@ if (MySQLPDOTest::isPDOMySQLnd()) ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_mysql_bit'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt index a79e219fd076a..6413675aeb9bc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt @@ -6,13 +6,13 @@ pdo_mysql --FILE-- true, + $expected = [ + 'MYSQL_ATTR_USE_BUFFERED_QUERY' => true, 'MYSQL_ATTR_LOCAL_INFILE' => true, 'MYSQL_ATTR_DIRECT_QUERY' => true, 'MYSQL_ATTR_FOUND_ROWS' => true, @@ -37,8 +37,8 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) { "MYSQL_ATTR_SSL_CAPATH" => true, "MYSQL_ATTR_SSL_CIPHER" => true, "MYSQL_ATTR_COMPRESS" => true, - "MYSQL_ATTR_MULTI_STATEMENTS" => true, - ); + "MYSQL_ATTR_MULTI_STATEMENTS" => true, + ]; if (!MySQLPDOTest::isPDOMySQLnd()) { $expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true; @@ -71,12 +71,12 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) { */ $ref = new ReflectionClass('PDO'); $constants = $ref->getConstants(); - $values = array(); + $values = []; foreach ($constants as $name => $value) if (substr($name, 0, 11) == 'MYSQL_ATTR_') { if (!isset($values[$value])) - $values[$value] = array($name); + $values[$value] = [$name]; else $values[$value][] = $name; diff --git a/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt b/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt index 344332b40ab3d..a33ab7f03cd23 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_closecursor_error.phpt @@ -4,12 +4,12 @@ Error during closeCursor() of multi query pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); diff --git a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt index 58d1956edde78..b32f40c7bed55 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt @@ -4,26 +4,26 @@ MySQL PDO->commit() pdo_mysql --SKIPIF-- +MySQLPDOTest::skipNotTransactionalEngine(); --FILE-- beginTransaction())) { printf("[001] Expecting true, got %s/%s\n", gettype($tmp), $tmp); } // DDL will issue an implicit commit - $db->exec(sprintf('DROP TABLE IF EXISTS test_commit')); - $db->exec(sprintf('CREATE TABLE test_commit(id INT) ENGINE=%s', MySQLPDOTest::detect_transactional_mysql_engine($db))); + $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table2)); + $db->exec(sprintf('CREATE TABLE %s (id INT) ENGINE=%s', $table2, MySQLPDOTest::detect_transactional_mysql_engine($db))); try { $db->commit(); $failed = false; @@ -43,14 +43,14 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) if (true !== ($tmp = $db->beginTransaction())) printf("[004] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->exec("INSERT INTO {$table} (id, label) VALUES (100, 'z')"); if (true !== ($tmp = $db->commit())) printf("[005] No commit allowed? [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); // a weak test without unicode etc. - lets leave that to dedicated tests - $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 100"); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { printf("[006] Record data is strange, dumping rows\n"); @@ -60,18 +60,18 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) // Ok, lets check MyISAM resp. any other non-transactional engine // pdo_mysql_begin_transaction has more on this, quick check only $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, 'MyISAM'); + MySQLPDOTest::createTestTable($table, $db, 'MyISAM'); if (true !== ($tmp = $db->beginTransaction())) printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->exec("INSERT INTO {$table} (id, label) VALUES (100, 'z')"); if (true !== ($tmp = $db->commit())) printf("[008] No commit allowed? [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); // a weak test without unicode etc. - lets leave that to dedicated tests - $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 100"); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { printf("[009] Record data is strange, dumping rows\n"); @@ -88,10 +88,10 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_commit'); -MySQLPDOTest::dropTestTable($db); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_commit'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_commit_2'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_connect_attr.phpt b/ext/pdo_mysql/tests/pdo_mysql_connect_attr.phpt index 810f96012665c..d62664d03958f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_connect_attr.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_connect_attr.phpt @@ -4,27 +4,26 @@ PDO_MYSQL: check the session_connect_attrs table for connection attributes pdo_mysql --SKIPIF-- query("select count(*) from information_schema.tables where table_schema='performance_schema' and table_name='session_connect_attrs'"); +$stmt = $pdo->query("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='performance_schema' AND table_name='session_connect_attrs'"); if (!$stmt || !$stmt->fetchColumn()) { die("skip mysql does not support session_connect_attrs table yet"); } -$stmt = $pdo->query("show variables like 'performance_schema'"); +$stmt = $pdo->query("SHOW VARIABLES LIKE 'performance_schema'"); if (!$stmt || $stmt->fetchColumn(1) !== 'ON') { die("skip performance_schema is OFF"); } - ?> --FILE-- query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_server_host' and processlist_id = connection_id()"); + $stmt = $pdo->query("SELECT * FROM performance_schema.session_connect_attrs WHERE ATTR_NAME='_server_host' AND processlist_id = connection_id()"); $row = $stmt->fetch(PDO::FETCH_ASSOC); @@ -44,7 +43,7 @@ if (isset($host) && $host !== '') { } } -$stmt = $pdo->query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_client_name' and processlist_id = connection_id()"); +$stmt = $pdo->query("SELECT * FROM performance_schema.session_connect_attrs WHERE ATTR_NAME='_client_name' AND processlist_id = connection_id()"); $row = $stmt->fetch(PDO::FETCH_ASSOC); if (!$row || !isset($row['attr_name'])) { @@ -56,4 +55,4 @@ if (!$row || !isset($row['attr_name'])) { printf("done!"); ?> --EXPECT-- -done! \ No newline at end of file +done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt b/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt index 1c57b0a4593b3..1fe1170e3f23c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt @@ -4,12 +4,12 @@ PDO_MYSQL: Defining a connection charset in the DSN pdo_mysql --SKIPIF-- --FILE-- $new_charset)); + $link = MySQLPDOTest::factory('PDO', ['charset' => $new_charset]); $conn_charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value; if ($charset !== $conn_charset) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt index 1e405d3ffdf24..5cf645d355794 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt @@ -4,28 +4,26 @@ MySQL PDO->errorCode() pdo_mysql --SKIPIF-- --FILE-- errorCode(); if (($code != $expected) && (($expected != '00000') && ($code != ''))) { printf("[%03d] Expecting error code '%s' got code '%s'\n", $offset, $expected, $code); } - } try { - /* If you create a PDOStatement object through PDO->prepare() or PDO->query() and invoke an error on the statement handle, @@ -36,28 +34,28 @@ $db = MySQLPDOTest::factory(); $code = $db->errorCode(); check_error(2, $db); - $stmt = $db->query('SELECT id, label FROM test'); + $stmt = $db->query("SELECT id, label FROM {$table}"); $stmt2 = &$stmt; check_error(3, $db); check_error(4, $stmt); - $db->exec('DROP TABLE IF EXISTS test'); + $db->exec("DROP TABLE IF EXISTS {$table}"); @$stmt->execute(); check_error(4, $db); check_error(5, $stmt, '42S02'); check_error(6, $stmt2, '42S02'); - $db->exec('DROP TABLE IF EXISTS unknown'); - @$stmt = $db->query('SELECT id, label FROM unknown'); + $db->exec('DROP TABLE IF EXISTS pdo_mysql_errorcode_unknown'); + @$stmt = $db->query('SELECT id, label FROM pdo_mysql_errorcode_unknown'); check_error(7, $db, '42S02'); - MySQLPDOTest::createTestTable($db); - $stmt = $db->query('SELECT id, label FROM test'); + MySQLPDOTest::createTestTable($table, $db); + $stmt = $db->query("SELECT id, label FROM {$table}"); check_error(8, $db); check_error(9, $stmt); $db2 = &$db; - @$db->query('SELECT id, label FROM unknown'); + @$db->query('SELECT id, label FROM pdo_mysql_errorcode_unknown'); check_error(10, $db, '42S02'); check_error(11, $db2, '42S02'); check_error(12, $stmt); @@ -80,8 +78,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- query('DROP TABLE IF EXISTS pdo_mysql_errorcode'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt index ef24fb1135f75..e286ee6fbcce6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_errorinfo.phpt @@ -4,15 +4,16 @@ MySQL PDO->errorInfo() pdo_mysql --SKIPIF-- --FILE-- errorInfo(); @@ -29,13 +30,12 @@ $db = MySQLPDOTest::factory(); if (!isset($info[2]) || $info[2] == '') printf("[%03d] Driver-specific error message.not set\n", $offset); } - } function pdo_mysql_errorinfo($db, $offset) { + global $table; try { - /* If you create a PDOStatement object through PDO->prepare() or PDO->query() and invoke an error on the statement handle, @@ -46,12 +46,12 @@ $db = MySQLPDOTest::factory(); $code = $db->errorCode(); check_error($offset + 2, $db); - $stmt = $db->query('SELECT id, label FROM test'); + $stmt = $db->query("SELECT id, label FROM {$table}"); $stmt2 = &$stmt; check_error($offset + 3, $db); check_error($offset + 4, $stmt); - $db->exec('DROP TABLE IF EXISTS test'); + $db->exec("DROP TABLE IF EXISTS {$table}"); @$stmt->execute(); check_error($offset + 5, $db); check_error($offset + 6, $stmt, '42S02'); @@ -60,14 +60,14 @@ $db = MySQLPDOTest::factory(); @$stmt = $db->query('SELECT id, label FROM unknown'); check_error($offset + 8, $db, '42S02'); - MySQLPDOTest::createTestTable($db); - $stmt = $db->query('SELECT id, label FROM test'); + MySQLPDOTest::createTestTable($table, $db); + $stmt = $db->query("SELECT id, label FROM {$table}"); check_error($offset + 9, $db); check_error($offset + 10, $stmt); $db2 = &$db; - $db->exec('DROP TABLE IF EXISTS unknown'); - @$db->query('SELECT id, label FROM unknown'); + $db->exec('DROP TABLE IF EXISTS pdo_mysql_errorinfo_unknown'); + @$db->query('SELECT id, label FROM pdo_mysql_errorinfo_unknown'); check_error($offset + 11, $db, '42S02'); check_error($offset + 12, $db2, '42S02'); check_error($offset + 13, $stmt); @@ -99,8 +99,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- query('DROP TABLE IF EXISTS pdo_mysql_errorinfo'); ?> --EXPECT-- Emulated Prepared Statements... diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt index 9fa840b4c30d8..35a3fd908a178 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt @@ -4,15 +4,13 @@ MySQL PDO->exec(), affected rows pdo_mysql --SKIPIF-- --FILE-- exec($sql); if (!is_null($exp) && ($ret !== $exp)) { printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", @@ -20,7 +18,6 @@ MySQLPDOTest::skip(); $db->errorCode(), implode(' ', $db->errorInfo())); return false; } - } catch (PDOException $e) { printf("[%03d] '%s' has failed, [%s] %s\n", $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); @@ -30,13 +27,11 @@ MySQLPDOTest::skip(); return true; } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); /* affected rows related */ try { - exec_and_count(2, $db, 'DROP TABLE IF EXISTS test_mysql_exec', 0); exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); exec_and_count(4, $db, "INSERT INTO test_mysql_exec(id, col1) VALUES (1, 'a')", 1); @@ -59,7 +54,6 @@ MySQLPDOTest::skip(); // Results may vary. Typically you will get 1. But the MySQL 5.1 manual states: Truncation operations do not return the number of deleted rows. // Don't rely on any return value! exec_and_count(38, $db, 'TRUNCATE TABLE test_mysql_exec', NULL); - } catch (PDOException $e) { printf("[001] %s, [%s] %s\n", $e->getMessage(), @@ -148,7 +142,6 @@ MySQLPDOTest::skip(); // multi query try { - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $exp = 0; @@ -162,8 +155,6 @@ MySQLPDOTest::skip(); // this is interesting: if we get sort of affected rows, what will happen now? $tmp = @$db->exec('INSERT INTO test_mysql_exec(id) VALUES (1); INSERT INTO test_mysql_exec(id) VALUES (2)'); printf("[035] With emulated PS it works but makes no sense given that exec() returns sort of affected rows...\n"); - - } catch (PDOException $e) { printf("[033] %s, [%s] %s\n", $e->getMessage(), @@ -175,8 +166,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- query('DROP TABLE IF EXISTS test_mysql_exec'); ?> --EXPECTF-- Warning: PDO::exec(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'THIS IS NOT VALID SQL, I HOPE' at line 1 in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt index 834706a2bad03..89586525b748b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt @@ -4,15 +4,13 @@ MySQL PDO->exec(), affected rows pdo_mysql --SKIPIF-- --FILE-- exec($sql); else @@ -34,29 +32,31 @@ MySQLPDOTest::skip(); return true; } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + $db_name = 'pdo_mysql_exec_ddl_db'; + $db_name_2 = 'pdo_mysql_exec_ddl_db_2'; + $table = 'pdo_mysql_exec_ddl'; + $table2 = 'pdo_mysql_exec_ddl_2'; /* affected rows related */ try { - - @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); - @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); - if (1 === @$db->exec('CREATE DATABASE pdo_exec_ddl')) { + @$db->exec("DROP DATABASE IF EXISTS {$db_name}"); + @$db->exec("DROP DATABASE IF EXISTS {$db_name_2}"); + if (1 === @$db->exec("CREATE DATABASE {$db_name}")) { // yippie - we can create databases etc. - exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1); + exec_and_count(3, $db, "ALTER DATABASE {$db_name} CHARACTER SET latin1", 1); } - exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0); - exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0); - if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) { - exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0); - exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0); - exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0); - exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0); - exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0); - exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0); + exec_and_count(4, $db, "DROP TABLE IF EXISTS {$table}", 0); + exec_and_count(5, $db, "DROP TABLE IF EXISTS {$table2}", 0); + if (0 === $db->exec("CREATE TABLE {$table} (id INT, col1 CHAR(2))")) { + exec_and_count(5, $db, "CREATE INDEX idx1 ON {$table} (id)", 0); + exec_and_count(6, $db, "DROP INDEX idx1 ON {$table}", 0); + exec_and_count(7, $db, "ALTER TABLE {$table} DROP id", 0); + exec_and_count(8, $db, "ALTER TABLE {$table} ADD id INT", 0); + exec_and_count(9, $db, "ALTER TABLE {$table} ALTER id SET DEFAULT 1", 0); + exec_and_count(10, $db, "RENAME TABLE {$table} TO {$table2}", 0); } /* @@ -81,14 +81,12 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_exec_ddl'); -@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl2'); -@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); -@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_exec_ddl'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_exec_ddl_2'); +$db->exec('DROP DATABASE IF EXISTS pdo_mysql_exec_ddl_db'); +$db->exec('DROP DATABASE IF EXISTS pdo_mysql_exec_ddl_db_2'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt index 25850040085b5..9876ae0759f33 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt @@ -4,7 +4,7 @@ MySQL PDO->exec(), affected rows pdo_mysql --SKIPIF-- fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { if (file_exists($filename) && !is_writable($filename)) die("skip {$filename} not writable"); } - ?> --FILE-- exec($sql); - if ($ret !== $exp) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - } catch (PDOException $e) { - - if (42000 == $db->errorCode()) { - // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) - // Load data infile not allowed - return false; - } - - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); +function exec_and_count($offset, &$db, $sql, $exp) { + try { + $ret = $db->exec($sql); + if ($ret !== $exp) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + } catch (PDOException $e) { + if (42000 == $db->errorCode()) { + // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) + // Load data infile not allowed return false; } - return true; + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - putenv('PDOTEST_ATTR='.serialize([PDO::MYSQL_ATTR_LOCAL_INFILE=>true])); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - - /* affected rows related */ + return true; +} - exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec_load_data(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); +require_once __DIR__ . '/inc/mysql_pdo_test.inc'; +$db = MySQLPDOTest::factoryWithAttr([PDO::MYSQL_ATTR_LOCAL_INFILE=>true]); - $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); - if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { - $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } else { - $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } +/* affected rows related */ - $fp = fopen($filename, "w"); - fwrite($fp, "1;foo\n"); - fwrite($fp, "2;bar"); - fclose($fp); +exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec_load_data(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - $sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test_mysql_exec_load_data FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename)); - - if (exec_and_count(4, $db, $sql, 2)) { +$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); +if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { + $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; +} else { + $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; +} - $stmt = $db->query('SELECT id, col1 FROM test_mysql_exec_load_data ORDER BY id ASC'); - $expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar")); - $ret = $stmt->fetchAll(PDO::FETCH_ASSOC); - foreach ($expected as $offset => $exp) { - foreach ($exp as $key => $value) { - if ($ret[$offset][$key] != $value) { - printf("Results seem wrong, check manually\n"); - var_dump($ret); - var_dump($expected); - break 2; - } +$fp = fopen($filename, "w"); +fwrite($fp, "1;foo\n"); +fwrite($fp, "2;bar"); +fclose($fp); + +$sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test_mysql_exec_load_data FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename)); + +if (exec_and_count(4, $db, $sql, 2)) { + $stmt = $db->query('SELECT id, col1 FROM test_mysql_exec_load_data ORDER BY id ASC'); + $expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar")); + $ret = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($expected as $offset => $exp) { + foreach ($exp as $key => $value) { + if ($ret[$offset][$key] != $value) { + printf("Results seem wrong, check manually\n"); + var_dump($ret); + var_dump($expected); + break 2; } } } +} - unlink($filename); +unlink($filename); - print "done!"; +print "done!"; ?> --CLEAN-- query('DROP TABLE IF EXISTS test_mysql_exec_load_data'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt index d9024b61f0057..fe1550776dc55 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt @@ -4,15 +4,13 @@ MySQL PDO->exec(), SELECT pdo_mysql --SKIPIF-- --FILE-- exec($sql); if ($ret !== $exp) { printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", @@ -30,9 +28,8 @@ MySQLPDOTest::skip(); return true; } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); /* affected rows related */ try { @@ -55,8 +52,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- query('DROP TABLE IF EXISTS test_mysql_exec_select'); ?> --EXPECTF-- Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt b/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt index a01c49bc41e89..49792d3bb021b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_fetch_both.phpt @@ -4,17 +4,15 @@ MySQL PDOStatement->fetch() pdo_mysql --SKIPIF-- --FILE-- query('SELECT 1'); $num = $stmt->fetch(PDO::FETCH_NUM); @@ -37,21 +35,15 @@ $db = MySQLPDOTest::factory(); var_dump($expect); var_dump($both); } - } catch (PDOException $e) { - printf("[%03d] %s, [%s] %s\n", $offset, $e->getMessage(), $db->errroCode(), implode(' ', $db->errorInfo())); - } - } try { - fetch(2, $db, 'SELECT 1', array(0 => '1', '1' => '1')); - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); diff --git a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt index 8be56a1f3a06b..552a60e57bcdc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt @@ -4,23 +4,17 @@ MySQL PDO->getAttribute() pdo_mysql --SKIPIF-- +MySQLPDOTest::skipNotTransactionalEngine(); --FILE-- setAttribute($attribute, $value)) { printf("[%03d] Cannot set attribute '%s' to value '%s'\n", $offset, $attribute, var_export($tmp, true)); @@ -39,7 +33,6 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) $offset, $attribute, var_export($value, true), gettype($value), var_export($tmp, true), gettype($tmp)); return false; } - } catch (PDOException $e) { printf("[%03d] %s, [%s] %s\n", $offset, $e->getMessage(), @@ -51,7 +44,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) } set_and_get(1, $db, PDO::ATTR_AUTOCOMMIT, 1); -/* + /* set_and_get(2, $db, PDO::ATTR_AUTOCOMMIT, 0); set_and_get(3, $db, PDO::ATTR_AUTOCOMMIT, -1); $obj = new stdClass(); @@ -66,34 +59,28 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) set_and_get(9, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, ''); set_and_get(10, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, 'SOME SQL'); set_and_get(11, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, -1); - -*/ -/* -PDO::MYSQL_ATTR_READ_DEFAULT_FILE (integer) + */ + /* + PDO::MYSQL_ATTR_READ_DEFAULT_FILE (integer) Read options from the named option file instead of from my.cnf. -PDO::MYSQL_ATTR_READ_DEFAULT_GROUP (integer) + PDO::MYSQL_ATTR_READ_DEFAULT_GROUP (integer) Read options from the named group from my.cnf or the file specified with MYSQL_READ_DEFAULT_FILE. -PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer) + PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer) Maximum buffer size. Defaults to 1 MiB. -PDO::MYSQL_ATTR_DIRECT_QUERY (integer) + PDO::MYSQL_ATTR_DIRECT_QUERY (integer) Perform direct queries, don't use prepared statements. -*/ -/* -TODO - read only -PDO::ATTR_CONNECTION_STATUS -PDO::ATTR_SERVER_INFO -*/ + */ + /* + TODO - read only + PDO::ATTR_CONNECTION_STATUS + PDO::ATTR_SERVER_INFO + */ print "done!"; ?> ---CLEAN-- - --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_inTransaction.phpt b/ext/pdo_mysql/tests/pdo_mysql_inTransaction.phpt index d6fe59a6c1b63..af0f7648410ca 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_inTransaction.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_inTransaction.phpt @@ -4,12 +4,12 @@ MySQL PDO class inTransaction pdo_mysql --SKIPIF-- --FILE-- beginTransaction(); var_dump($db->inTransaction()); -$db->exec('DROP TABLE IF EXISTS test'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_inTransaction'); var_dump($db->inTransaction()); // We should be able to start a new transaction after the implicit commit. diff --git a/ext/pdo_mysql/tests/pdo_mysql_interface.phpt b/ext/pdo_mysql/tests/pdo_mysql_interface.phpt index aeb441bc0363a..4f7a2316a1482 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_interface.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_interface.phpt @@ -4,34 +4,31 @@ MySQL PDO class interface pdo_mysql --SKIPIF-- +MySQLPDOTest::skipNotTransactionalEngine(); --FILE-- true, + $expected = [ + '__construct' => true, 'prepare' => true, - 'beginTransaction' => true, + 'beginTransaction' => true, 'commit' => true, 'rollBack' => true, - 'setAttribute' => true, + 'setAttribute' => true, 'exec' => true, 'query' => true, - 'lastInsertId' => true, + 'lastInsertId' => true, 'errorCode' => true, 'errorInfo' => true, - 'getAttribute' => true, + 'getAttribute' => true, 'quote' => true, - 'inTransaction' => true, - 'getAvailableDrivers' => true, - ); + 'inTransaction' => true, + 'getAvailableDrivers' => true, + ]; $classname = get_class($db); $methods = get_class_methods($classname); diff --git a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt index 4d9d7864c8e0f..e7d6f8400376c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt @@ -4,13 +4,12 @@ MySQL PDO->lastInsertId() pdo_mysql --SKIPIF-- --FILE-- query('SELECT LAST_INSERT_ID() as _last_id'); + $stmt = $db->query('SELECT LAST_INSERT_ID() AS _last_id'); $row = $stmt->fetch(PDO::FETCH_ASSOC); $last_id = $row['_last_id']; if ($next_id != $last_id) { @@ -87,7 +86,7 @@ $db = MySQLPDOTest::factory(); $inc = 1; } - $stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id'); + $stmt = $db->query('SELECT LAST_INSERT_ID() AS _last_id'); $row = $stmt->fetch(PDO::FETCH_ASSOC); $last_id = $row['_last_id']; @@ -112,8 +111,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_pdo_mysql_last_insert_id'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt index 24e2954b77265..91a67260f0397 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt @@ -4,7 +4,7 @@ ensure default for local infile is off pdo_mysql --SKIPIF-- --FILE-- false, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo" - ])); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo", + ]); try { exec_and_count(2, $db, sprintf('CREATE TABLE test_local_inifile_dir_allowed(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); @@ -77,7 +75,7 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_local_inifile_dir_allowed'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt index c0d3946363d2e..ccf2abd4a86d9 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt @@ -4,9 +4,9 @@ PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY vs access denied pdo_mysql --SKIPIF-- false, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar" - ])); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", + ]); try { exec_and_count(2, $db, sprintf('CREATE TABLE test_local_inifile_dir_denied(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); @@ -67,8 +65,9 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_local_inifile_dir_denied'); ?> --EXPECTF-- Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2068 LOAD DATA LOCAL INFILE %s in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt index 17d7de36a19a9..b99375c37b6ee 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt @@ -4,9 +4,9 @@ PDO::MYSQL_ATTR_LOCAL_INFILE overrides PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY pdo_mysql --SKIPIF-- true, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar" - ])); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", + ]); try { exec_and_count(2, $db, sprintf('CREATE TABLE test_local_inifile_overrides(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); @@ -77,7 +75,7 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_local_inifile_overrides'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt index bd79cc5e6828c..cbdbc063dd8a1 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt @@ -4,19 +4,18 @@ enable local infile pdo_mysql --SKIPIF-- --FILE-- true)); +$db = new PDO($dsn, $user, $pass, [PDO::MYSQL_ATTR_LOCAL_INFILE => true]); echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE)), "\n"; echo "done!\n"; ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt index e3d0bafa9488d..079b7ab29119a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt @@ -4,41 +4,34 @@ MySQL PDOStatement->nextRowSet() with PDO::MYSQL_ATTR_MULTI_STATEMENTS either tr pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(50000); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + $table = 'pdo_mysql_multi_stmt_nextrowset'; + $procedure = 'pdo_mysql_multi_stmt_nextrowset_p'; + MySQLPDOTest::createTestTable($table, $db); function test_proc($db) { + global $table; + global $procedure; - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); - $stmt = $db->query('CALL p()'); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT id FROM $table ORDER BY id ASC LIMIT 3; SELECT id, label FROM {$table} WHERE id < 4 ORDER BY id DESC LIMIT 3; END;"); + $stmt = $db->query("CALL {$procedure}()"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowSet()); var_dump($stmt->nextRowSet()); - } try { - // Using native PS for proc, since emulated fails. printf("Native PS...\n"); foreach (array(false, true) as $multi) { @@ -65,15 +58,13 @@ if ($version < 50000) // Switch back to emulated prepares to verify multi statement attribute. $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); // This will fail when $multi is false. - $stmt = $db->query("SELECT * FROM test; INSERT INTO test (id, label) VALUES (99, 'x')"); + $stmt = $db->query("SELECT * FROM {$table}; INSERT INTO {$table} (id, label) VALUES (99, 'x')"); if ($stmt !== false) { $stmt->closeCursor(); } $info = $db->errorInfo(); var_dump($info[0]); } - @$db->exec('DROP PROCEDURE IF EXISTS p'); - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); @@ -83,8 +74,10 @@ if ($version < 50000) ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_multi_stmt_nextrowset'); +$db->exec('DROP PROCEDURE IF EXISTS pdo_mysql_multi_stmt_nextrowset_p'); ?> --EXPECTF-- Native PS... @@ -177,7 +170,7 @@ array(0) { } bool(false) -Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'INSERT INTO test (id, label) VALUES (99, 'x')' at line 1 in %s on line %d +Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'INSERT INTO pdo_mysql_multi_stmt_nextrowset (id, label) VALUES (99, 'x')' at line 1 in %s on line %d string(5) "42000" Testing with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to true diff --git a/ext/pdo_mysql/tests/pdo_mysql_param_str_natl.phpt b/ext/pdo_mysql/tests/pdo_mysql_param_str_natl.phpt index 9c5c00ce06299..928a82c41c7df 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_param_str_natl.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_param_str_natl.phpt @@ -1,19 +1,16 @@ --TEST-- PDO MySQL national character set parameters don't affect true prepared statements --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); @@ -24,14 +21,13 @@ $stmt->bindValue(1, 'foo', PDO::PARAM_STR | PDO::PARAM_STR_NATL); $stmt->execute(); var_dump($db->query('SELECT * from test_param_str_natl')); -foreach ($db->query('SELECT * from test_param_str_natl') as $row) { +foreach ($db->query('SELECT * from test_param_str_natl') AS $row) { print_r($row); } - ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_param_str_natl'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt index 8c397bd7c762a..557493206b532 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt @@ -4,15 +4,14 @@ MySQL PDO->__construct(), PDO::ATTR_PERSISTENT pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $db1->exec('SET @pdo_persistent_connection=1'); - $stmt = $db2->query('SELECT @pdo_persistent_connection as _pers'); + $stmt = $db2->query('SELECT @pdo_persistent_connection AS _pers'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); if ($tmp['_pers'] != 1) printf("[001] Both handles should use the same connection."); - $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); + $stmt = $db1->query('SELECT CONNECTION_ID() AS _con1'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); $con1 = $tmp['_con1']; - $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); + $stmt = $db2->query('SELECT CONNECTION_ID() AS _con2'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); $con2 = $tmp['_con2']; @@ -39,7 +38,7 @@ MySQLPDOTest::skip(); printf("[002] Both handles should report the same MySQL thread ID"); $db1 = NULL; /* should be equal to closing to my understanding */ - $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $db1 = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]); $db1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); @@ -63,15 +62,15 @@ MySQLPDOTest::skip(); printf("[005] Wrong error info %s\n", $tmp); } - $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => false)); + $db1 = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => false]); $db1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); - $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); + $stmt = $db1->query('SELECT CONNECTION_ID() AS _con1'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); $con1 = $tmp['_con1']; - @$db2 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + @$db2 = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]); $db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); - $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); + $stmt = $db2->query('SELECT CONNECTION_ID() AS _con2'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); $con2 = $tmp['_con2']; @@ -79,9 +78,9 @@ MySQLPDOTest::skip(); printf("[006] Looks like the persistent and the non persistent connection are using the same link?!\n"); // lets go crazy and create a few pconnections... - $connections = array(); + $connections = []; for ($i = 0; $i <= 20; $i++) { - $connections[$i] = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $connections[$i] = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]); } do { $i = mt_rand(0, 20); diff --git a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt index 6106e8a30b9c0..f26cac2fd9bcd 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt @@ -4,13 +4,12 @@ MySQL PDO phpinfo() output pdo_mysql --SKIPIF-- --FILE-- prepare(), emulated PS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function prepex($offset, &$db, $query, $input_params = null, $error_info = null) { - try { - if (is_array($error_info) && isset($error_info['prepare'])) $stmt = @$db->prepare($query); else @@ -74,7 +71,6 @@ $db = MySQLPDOTest::factory(); return false; } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -97,7 +93,7 @@ $db = MySQLPDOTest::factory(); } // lets be fair and do the most simple SELECT first - $stmt = prepex(4, $db, 'SELECT 1 as "one"'); + $stmt = prepex(4, $db, 'SELECT 1 AS "one"'); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); prepex(6, $db, sprintf('CREATE TABLE test_prepare_emulated(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); @@ -161,8 +157,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_emulated'); ?> --EXPECTF-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt index 1e34e47ae7fca..f16f9078758ff 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt @@ -4,13 +4,12 @@ MySQL PDO->prepare(), emulated PS, anonymous placeholder pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_emulated_anonymous'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt index d70baf4e50c65..ea13fa229bb2c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt @@ -4,20 +4,17 @@ MySQL PDO->prepare(), emulated PS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function prepex($offset, &$db, $query, $input_params = null, $error_info = null) { - try { - if (is_array($error_info) && isset($error_info['prepare'])) $stmt = @$db->prepare($query); else @@ -44,7 +41,7 @@ $db = MySQLPDOTest::factory(); } if (is_null($input_params)) - $input_params = array(); + $input_params = []; if (is_array($error_info) && isset($error_info['execute'])) $ret = @$stmt->execute($input_params); @@ -159,8 +156,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- query('DROP TABLE IF EXISTS test_prepare_emulated_anonymous_placeholder'); ?> --EXPECTF-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt index 2461e206078b6..976219fc2320b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt @@ -4,20 +4,17 @@ MySQL PDO->prepare(), emulated PS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function prepex($offset, &$db, $query, $input_params = null, $error_info = null) { - try { - if (is_array($error_info) && isset($error_info['prepare'])) $stmt = @$db->prepare($query); else @@ -74,7 +71,6 @@ $db = MySQLPDOTest::factory(); return false; } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -151,9 +147,10 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_emulated_myisam'); ?> ---EXPECTF-- +--EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt index c263ef6281a60..f6d02031da3d1 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt @@ -4,13 +4,12 @@ MySQL PDO->prepare(), emulated PS pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); @@ -160,9 +159,10 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_emulated_myisam_index'); ?> ---EXPECTF-- +--EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt index 644fbf602e022..92f14a5b2e9bb 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt @@ -4,13 +4,13 @@ MySQL PDO->prepare(), emulated PS, anonymous placeholder pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_emulated_placeholder_everywhere'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt index 99f813fe6caaa..c6b2832e15fa7 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_match_against.phpt @@ -4,16 +4,15 @@ Bug #41876 (bindParam() and bindValue() do not work with MySQL MATCH () AGAINST pdo_mysql --SKIPIF-- --FILE-- exec('CREATE TABLE test_prepare_match_against(id INT, label CHAR(255)) ENGINE=MyISAM'); $db->exec('CREATE FULLTEXT INDEX idx1 ON test_prepare_match_against(label)'); @@ -28,19 +27,16 @@ MySQLPDOTest::skip(); $stmt = $db->prepare('SELECT id, label FROM test_prepare_match_against WHERE MATCH label AGAINST (?)'); $stmt->execute(array('row')); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { - printf("[001] %s, [%s} %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_match_against'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt index 0c806590bff4b..4c7497f69e5d9 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt @@ -4,19 +4,16 @@ MySQL PDO->prepare(), native PS pdo_mysql --SKIPIF-- --FILE-- prepare($query); else @@ -82,9 +79,7 @@ $db = MySQLPDOTest::factory(); } return false; - } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -165,8 +160,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native'); ?> --EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt index 60450d65bdd72..c469112c3d06a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt @@ -4,19 +4,16 @@ MySQL PDO->prepare(), native PS pdo_mysql --SKIPIF-- --FILE-- prepare($query); else @@ -82,9 +79,7 @@ $db = MySQLPDOTest::factory(); } return false; - } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -243,8 +238,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_anonymous_placeholder'); ?> --EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt index 04c91459a639d..5d40bc826233f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt @@ -4,18 +4,16 @@ MySQL PDO->prepare(), native PS, clear line after error pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - $db->exec(sprintf('CREATE TABLE test_prepare_native_clear_error(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); // We need to run the emulated version first. Native version will cause a fatal error @@ -60,8 +58,6 @@ $db = MySQLPDOTest::factory(); var_export($stmt->errorCode(), true), var_export($stmt->errorInfo(), true)); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); @@ -71,7 +67,7 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_clear_error'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt index f94d8f83abb33..5786b009500aa 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt @@ -4,25 +4,26 @@ MySQL PDO->prepare(), native PS, named placeholder pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare("SELECT :param FROM test ORDER BY id ASC LIMIT 1"); + $stmt = $db->prepare("SELECT :param FROM {$table} ORDER BY id ASC LIMIT 1"); $stmt->execute(array(':param' => 'id')); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->prepare('SELECT :placeholder FROM test WHERE :placeholder > :placeholder'); + $db->prepare("SELECT :placeholder FROM {$table} WHERE :placeholder > :placeholder"); $stmt->execute(array(':placeholder' => 'test')); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -31,9 +32,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_prepare_native_column'); ?> --EXPECTF-- array(1) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt index 768c70695d737..21bbe8728ed8b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt @@ -4,18 +4,16 @@ MySQL PDO->prepare(), native PS, named placeholder II pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - $db->exec(sprintf('CREATE TABLE test_prepare_native_dup_named(id INT, label1 CHAR(255), label2 CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); @@ -86,8 +84,6 @@ $db = MySQLPDOTest::factory(); var_export($stmt->errorCode(), true), var_export($stmt->errorInfo(), true)); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); @@ -97,7 +93,7 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_dup_named'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt index d1e4cc8d30134..9e5607fa4cefd 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt @@ -4,24 +4,25 @@ MySQL PDO->prepare(), native PS, mixed, wired style pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); - $stmt = $db->query('DELETE FROM test'); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?), (2, ?)'); + $stmt = $db->query("DELETE FROM {$table}"); + $stmt = $db->prepare("INSERT INTO {$table}(id, label) VALUES (1, ?), (2, ?)"); $stmt->execute(array('a', 'b')); - $stmt = $db->prepare("SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM {$table} WHERE id = ?)"); $stmt->execute(array(1, 1)); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -29,8 +30,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_prepare_native_mixed_style'); ?> --EXPECTF-- Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt index 155ab56d26e32..de40cbdbb0504 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt @@ -4,19 +4,16 @@ MySQL PDO->prepare(), native PS pdo_mysql --SKIPIF-- --FILE-- prepare($query); else @@ -82,9 +79,7 @@ $db = MySQLPDOTest::factory(); } return false; - } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -155,8 +150,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_myisam'); ?> --EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt index 5ce4c25c463b6..2bb6ea0caa7ee 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt @@ -4,19 +4,16 @@ MySQL PDO->prepare(), native PS pdo_mysql --SKIPIF-- --FILE-- prepare($query); else @@ -82,9 +79,7 @@ $db = MySQLPDOTest::factory(); } return false; - } - } catch (PDOException $e) { printf("[%03d] %s, [%s} %s\n", $offset, $e->getMessage(), @@ -175,8 +170,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_myisam_index'); ?> --EXPECT-- PDO::prepare(): Argument #1 ($query) cannot be empty diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt index da2e2a8cdd11c..2e23def163345 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt @@ -4,13 +4,12 @@ MySQL PDO->prepare(), native PS, named placeholder pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_named_placeholder'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt index 58e518445460c..575af4a8f2c8f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt @@ -4,13 +4,12 @@ MySQL PDO->prepare(),native PS, anonymous placeholder pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); @@ -54,7 +53,7 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_prepare_native_named_placeholder_everywhere'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_quote.phpt b/ext/pdo_mysql/tests/pdo_mysql_quote.phpt index 3c3cde297f1a9..3fe7b22dda8bf 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_quote.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_quote.phpt @@ -4,12 +4,12 @@ MySQL ensure quote function returns expected results pdo_mysql --SKIPIF-- --FILE-- quote('foo', PDO::PARAM_STR)); diff --git a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt index 81d4f143923fa..a118a1564a57f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt @@ -4,39 +4,40 @@ PDO::rollBack() pdo_mysql --SKIPIF-- +MySQLPDOTest::skipNotTransactionalEngine(); --FILE-- beginTransaction(); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); $num = $row['_num']; - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->query("INSERT INTO {$table}(id, label) VALUES (100, 'z')"); $num++; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[001] INSERT has failed, test will fail\n"); $db->rollBack(); $num--; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != $num) printf("[002] ROLLBACK has failed\n"); $db->beginTransaction(); - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); - $db->query('DROP TABLE IF EXISTS test2'); - $db->query('CREATE TABLE test2(id INT)'); + $db->query("INSERT INTO {$table}(id, label) VALUES (100, 'z')"); + $db->query("DROP TABLE IF EXISTS {$table2}"); + $db->query("CREATE TABLE {$table2}(id INT)"); $num++; try { $db->rollBack(); @@ -48,38 +49,38 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) printf("[003] Rollback should have failed\n"); } - $db->query('DROP TABLE IF EXISTS test2'); - $db->query('CREATE TABLE test2(id INT) ENGINE=MyISAM'); + $db->query("DROP TABLE IF EXISTS {$table2}"); + $db->query("CREATE TABLE {$table2}(id INT) ENGINE=MyISAM"); $db->beginTransaction(); - $db->query('INSERT INTO test2(id) VALUES (1)'); + $db->query("INSERT INTO {$table2}(id) VALUES (1)"); $db->rollBack(); - $row = $db->query('SELECT COUNT(*) AS _num FROM test2')->fetch(PDO::FETCH_ASSOC); + $row = $db->query("SELECT COUNT(*) AS _num FROM {$table2}")->fetch(PDO::FETCH_ASSOC); if ($row['_num'] != 1) printf("[003] ROLLBACK should have no effect\n"); - $db->query('DROP TABLE IF EXISTS test2'); + $db->query("DROP TABLE IF EXISTS {$table2}"); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); $db->beginTransaction(); - $db->query('DELETE FROM test'); + $db->query("DELETE FROM {$table}"); $db->rollBack(); var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); $db->beginTransaction(); - $db->query('DELETE FROM test'); + $db->query("DELETE FROM {$table}"); $db->rollBack(); var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); $db->beginTransaction(); - $db->query('DELETE FROM test'); + $db->query("DELETE FROM {$table}"); $db->commit(); var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); $db->beginTransaction(); - $db->query('DELETE FROM test'); + $db->query("DELETE FROM {$table}"); $db->commit(); var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); @@ -87,10 +88,10 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) ?> --CLEAN-- exec('DROP TABLE IF EXISTS test'); -$db->exec('DROP TABLE IF EXISTS test2'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_rollback'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_rollback_2'); ?> --EXPECT-- int(1) diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt index 218a6d702a43a..cce3dc9393a37 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt @@ -4,22 +4,23 @@ MySQL PDOStatement->bindColumn() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2"); $stmt->execute(); $id = $label = null; @@ -39,7 +40,7 @@ $db = MySQLPDOTest::factory(); $data[] = array('id' => $id, 'label' => $label); } - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2"); $index = 0; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($row['id'] != $data[$index]['id']) { @@ -59,7 +60,7 @@ $db = MySQLPDOTest::factory(); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[007] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2, 2"); $stmt->execute(); $id = $label = null; @@ -79,7 +80,7 @@ $db = MySQLPDOTest::factory(); $data[] = array('id' => $id, 'label' => $label); } - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); + $stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2, 2"); $index = 0; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($row['id'] != $data[$index]['id']) { @@ -104,9 +105,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_stmt_bindcolumn'); ?> --EXPECT-- id = 1 (integer) / label = 'a' (string) diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt index f20181010b969..b0bbad59d8e92 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt @@ -4,20 +4,22 @@ MySQL PDOStatement->bindParam() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - MySQLPDOTest::createTestTable($db); + $table = 'pdo_mysql_stmt_bindparam'; + MySQLPDOTest::createTestTable($table, $db); function pdo_mysql_stmt_bindparam($db, $offset) { + global $table; - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindParam(1, $in)) printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, @@ -50,7 +52,7 @@ MySQLPDOTest::skip(); // NULL values printf("NULL...\n"); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (100, ?)'); + $stmt = $db->prepare("INSERT INTO {$table}(id, label) VALUES (100, ?)"); $label = null; if (!$stmt->bindParam(1, $label)) printf("[%03d + 4] Cannot bind parameter, %s %s\n", $offset, @@ -61,7 +63,7 @@ MySQLPDOTest::skip(); $stmt->errorCode(), var_export($stmt->errorInfo(), true)); /* NOTE: you cannot use PDO::query() with unbuffered, native PS - see extra test */ - $stmt = $db->prepare('SELECT id, NULL AS _label FROM test WHERE label IS NULL'); + $stmt = $db->prepare("SELECT id, NULL AS _label FROM {$table} WHERE label IS NULL"); $stmt->execute(); $id = $label = 'bogus'; @@ -91,7 +93,7 @@ MySQLPDOTest::skip(); pdo_mysql_stmt_bindparam($db, 3); printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_bindparam($db, 4); @@ -101,12 +103,12 @@ MySQLPDOTest::skip(); printf("[004] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); pdo_mysql_stmt_bindparam($db, 5); printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_bindparam($db, 6); @@ -119,8 +121,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_bindparam'); ?> --EXPECT-- Emulated PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt index 2bdb9edc9cac7..542125639976f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt @@ -4,18 +4,15 @@ MySQL PDOStatement->bindParam() - SQL column types pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); else @@ -92,14 +89,11 @@ $db = MySQLPDOTest::factory(); } function pdo_mysql_stmt_bindparam_types($db, $offset, $sql_type, $value) { - pdo_mysql_stmt_bindparam_types_do($db, $offset, true, $sql_type, $value); pdo_mysql_stmt_bindparam_types_do($db, $offset, false, $sql_type, $value); - } try { - // pdo_mysql_stmt_bindparam_types($db, 2, 'BIT(8)', 1); pdo_mysql_stmt_bindparam_types($db, 3, 'TINYINT', -127); pdo_mysql_stmt_bindparam_types($db, 4, 'TINYINT UNSIGNED', 255); @@ -156,7 +150,6 @@ $db = MySQLPDOTest::factory(); pdo_mysql_stmt_bindparam_types($db, 55, 'LONGTEXT BINARY', str_repeat('d', 300)); pdo_mysql_stmt_bindparam_types($db, 56, "ENUM('yes', 'no') DEFAULT 'yes'", "no"); pdo_mysql_stmt_bindparam_types($db, 57, "SET('yes', 'no') DEFAULT 'yes'", "no"); - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); @@ -166,7 +159,7 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_bindparam_types'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt index 1bcc8e0e16575..c558eb6f81dad 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt @@ -4,15 +4,16 @@ MySQL PDOStatement->bindValue() pdo_mysql --SKIPIF-- --FILE-- prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[003] Cannot bind value, %s %s\n", @@ -92,7 +93,7 @@ $db = MySQLPDOTest::factory(); printf("Binding a variable and a value...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[012] Cannot bind value, %s %s\n", @@ -121,7 +122,7 @@ $db = MySQLPDOTest::factory(); printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); // variable value change shall have no impact - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[016] Cannot bind value, %s %s\n", @@ -161,7 +162,7 @@ $db = MySQLPDOTest::factory(); printf("[002] Unable to turn on emulated prepared statements\n"); printf("Binding variable...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[003] Cannot bind value, %s %s\n", @@ -232,7 +233,7 @@ $db = MySQLPDOTest::factory(); printf("Binding a variable and a value...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[012] Cannot bind value, %s %s\n", @@ -261,7 +262,7 @@ $db = MySQLPDOTest::factory(); printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); // variable value change shall have no impact - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindValue(1, $in)) printf("[016] Cannot bind value, %s %s\n", @@ -298,8 +299,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_bindvalue'); ?> --EXPECT-- Testing native PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromstream.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromstream.phpt index 8e958a230952f..48361f0d9ce2a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromstream.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobfromstream.phpt @@ -4,7 +4,7 @@ MySQL PDOStatement - inserting BLOB from stream pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_blobfromstream'); @unlink(MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . 'pdoblob.tst'); ?> --EXPECT-- diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt index d528d19d0ee4f..e2bea70f1d24c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_blobs.phpt @@ -4,12 +4,12 @@ MySQL Prepared Statements and BLOBs pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_blobs'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt index 45725853d3c40..af052a02423ff 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt @@ -4,40 +4,42 @@ MySQL PDOStatement->closeCursor() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); // query() shall fail! - $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt2 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); $stmt1->closeCursor(); // This is proper usage of closeCursor(). It shall prevent any further error messages. if (MySQLPDOTest::isPDOMySQLnd()) { - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); } else { // see pdo_mysql_stmt_unbuffered_2050.phpt for an explanation unset($stmt1); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); } // fetch only the first rows and let closeCursor() clean up $row1 = $stmt1->fetch(PDO::FETCH_ASSOC); $stmt1->closeCursor(); - $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); + $stmt2 = $db->prepare("UPDATE {$table} SET label = ? WHERE id = ?"); $stmt2->bindValue(1, "z"); $stmt2->bindValue(2, $row1['id']); @@ -54,18 +56,18 @@ $db = MySQLPDOTest::factory(); printf("Expecting array(id => 1, label => z) got %s\n", var_export($row2, true)); unset($stmt1); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); // should work - $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt2 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); $stmt1->closeCursor(); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); // fetch only the first rows and let closeCursor() clean up $row3 = $stmt1->fetch(PDO::FETCH_ASSOC); $stmt1->closeCursor(); assert($row3 == $row2); - $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); + $stmt2 = $db->prepare("UPDATE {$table} SET label = ? WHERE id = ?"); $stmt2->bindValue(1, "a"); $stmt2->bindValue(2, $row1['id']); $stmt2->execute(); @@ -77,7 +79,7 @@ $db = MySQLPDOTest::factory(); assert($row4 == $row1); $offset = 0; - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindParam(1, $in)) printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, @@ -107,7 +109,6 @@ $db = MySQLPDOTest::factory(); try { - printf("Testing emulated PS...\n"); $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) @@ -115,12 +116,12 @@ $db = MySQLPDOTest::factory(); printf("Buffered...\n"); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); pdo_mysql_stmt_closecursor($db); printf("Unbuffered...\n"); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); pdo_mysql_stmt_closecursor($db); printf("Testing native PS...\n"); @@ -129,12 +130,12 @@ $db = MySQLPDOTest::factory(); printf("[002] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); pdo_mysql_stmt_closecursor($db); printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_closecursor($db); @@ -147,9 +148,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test'); +$db->exec('DROP TABLE IF EXISTS pdo_mysql_stmt_closecursor'); ?> --EXPECTF-- Testing emulated PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt index bbdb61e3d569c..33127f4ee242f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt @@ -4,15 +4,15 @@ MySQL PDOStatement->closeCursor() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); $in = 0; if (!$stmt->bindParam(1, $in)) printf("[003] Cannot bind parameter, %s %s\n", @@ -59,13 +59,13 @@ $db = MySQLPDOTest::factory(); $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); } - $db->exec('DROP TABLE IF EXISTS test'); print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_closecursor_empty'); ?> --EXPECT-- in = 0 -> id = 1 (integer) / label = 'a' (string) diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt index 3607744d87a80..b55725057e234 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt @@ -4,18 +4,19 @@ MySQL PDOStatement->columnCount() pdo_mysql --SKIPIF-- --FILE-- getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare("SELECT id, label, '?' as foo FROM test"); + $stmt = $db->prepare("SELECT id, label, '?' as foo FROM {$table}"); $stmt->execute(); var_dump($stmt->columnCount()); - $stmt = $db->query('SELECT * FROM test'); + $stmt = $db->query("SELECT * FROM {$table}"); var_dump($stmt->columnCount()); } catch (PDOException $e) { @@ -41,11 +42,11 @@ $db = MySQLPDOTest::factory(); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM test"); + $stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM {$table}"); $stmt->execute(); var_dump($stmt->columnCount()); - $stmt = $db->query('SELECT * FROM test'); + $stmt = $db->query("SELECT * FROM {$table}"); var_dump($stmt->columnCount()); } catch (PDOException $e) { @@ -57,8 +58,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_columncount'); ?> --EXPECT-- Testing emulated PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt index c3c4c68a70dd7..de4cb8b97bfb6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt @@ -4,16 +4,15 @@ MySQL PDOStatement->errorCode(); pdo_mysql --SKIPIF-- --FILE-- exec('DROP TABLE IF EXISTS ihopeitdoesnotexist'); + $db->exec('DROP TABLE IF EXISTS pdo_mysql_stmt_errorcode_ihopeitdoesnotexist'); printf("Testing emulated PS...\n"); try { @@ -21,7 +20,7 @@ $db = MySQLPDOTest::factory(); if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorcode_ihopeitdoesnotexist ORDER BY id ASC'); $stmt->execute(); var_dump($stmt->errorCode()); @@ -37,7 +36,7 @@ $db = MySQLPDOTest::factory(); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorcode_ihopeitdoesnotexist ORDER BY id ASC'); $stmt->execute(); var_dump($stmt->errorCode()); @@ -51,11 +50,11 @@ $db = MySQLPDOTest::factory(); --EXPECTF-- Testing emulated PS... -Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d +Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorcode_ihopeitdoesnotexist' doesn't exist in %s on line %d string(5) "42S02" Testing native PS... -Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d +Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorcode_ihopeitdoesnotexist' doesn't exist in %s on line %d Fatal error: Uncaught Error: Call to a member function execute() on false in %s:%d Stack trace: diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt index 05770f198d2ee..6b2a9281d9c21 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt @@ -4,15 +4,16 @@ MySQL PDOStatement->errorInfo(); pdo_mysql --SKIPIF-- --FILE-- getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist ORDER BY id ASC'); var_dump($stmt->errorInfo()); $stmt->execute(); var_dump($stmt->errorInfo()); - MySQLPDOTest::createTestTable($db); - $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); - $db->exec('DROP TABLE test'); + MySQLPDOTest::createTestTable($table, $db); + $stmt = $db->prepare("SELECT label FROM {$table} ORDER BY id ASC LIMIT 1"); + $db->exec("DROP TABLE {$table}"); var_dump($stmt->execute()); var_dump($stmt->errorInfo()); var_dump($db->errorInfo()); @@ -43,13 +44,13 @@ $db = MySQLPDOTest::factory(); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist ORDER BY id ASC'); var_dump($stmt); - MySQLPDOTest::createTestTable($db); - $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); + MySQLPDOTest::createTestTable($table, $db); + $stmt = $db->prepare("SELECT label FROM {$table} ORDER BY id ASC LIMIT 1"); var_dump($stmt->errorInfo()); - $db->exec('DROP TABLE test'); + $db->exec("DROP TABLE {$table}"); $stmt->execute(); var_dump($stmt->errorInfo()); var_dump($db->errorInfo()); @@ -62,8 +63,9 @@ $db = MySQLPDOTest::factory(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_errorinfo'); ?> --EXPECTF-- Testing emulated PS... @@ -76,17 +78,17 @@ array(3) { NULL } -Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d +Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist' doesn't exist in %s on line %d array(3) { [0]=> string(5) "42S02" [1]=> int(1146) [2]=> - string(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist" + string(%d) "Table '%s.pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist' doesn't exist" } -Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d +Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorinfo' doesn't exist in %s on line %d bool(false) array(3) { [0]=> @@ -94,7 +96,7 @@ array(3) { [1]=> int(1146) [2]=> - string(%d) "Table '%s.test' doesn't exist" + string(%d) "Table '%s.pdo_mysql_stmt_errorinfo' doesn't exist" } array(3) { [0]=> @@ -106,7 +108,7 @@ array(3) { } Testing native PS... -Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d +Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist' doesn't exist in %s on line %d bool(false) array(3) { [0]=> @@ -117,14 +119,14 @@ array(3) { NULL } -Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d +Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.pdo_mysql_stmt_errorinfo' doesn't exist in %s on line %d array(3) { [0]=> string(5) "42S02" [1]=> int(1146) [2]=> - string(%d) "Table '%s.test' doesn't exist" + string(%d) "Table '%s.pdo_mysql_stmt_errorinfo' doesn't exist" } array(3) { [0]=> diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt index 69fe0dd33bb04..4d5db44ea91b4 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt @@ -4,12 +4,12 @@ MySQL PDOStatement->fetch(), PDO::FETCH_CLASS pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_fetch_class'); ?> --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt index b6e65f0c39701..0027d1ea52ff9 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt @@ -4,14 +4,16 @@ MySQL PDOStatement->execute()/fetch(), Non-SELECT pdo_mysql --SKIPIF-- --FILE-- getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); - if (!is_object($stmt = $db->query('DESCRIBE test id'))) + if (!is_object($stmt = $db->query("DESCRIBE {$table} id"))) printf("[003] Emulated PS, DESCRIBE failed, %s\n", var_export($db->errorInfo(), true)); $describe = array(); @@ -55,7 +57,7 @@ MySQLPDOTest::skip(); printf("[008] Emulated PS, SHOW data seems wrong, dumping %s\n", var_export($show, true)); - if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) + if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM {$table}"))) printf("[009] Emulated PS, EXPLAIN returned no results\n"); $explain = array(); @@ -71,12 +73,12 @@ MySQLPDOTest::skip(); printf("[011] Unable to turn off emulated prepared statements\n"); $native_support = 'no'; - if ($db->exec("PREPARE mystmt FROM 'DESCRIBE test id'")) { + if ($db->exec("PREPARE mystmt FROM 'DESCRIBE {$table} id'")) { $native_support = 'yes'; $db->exec('DEALLOCATE PREPARE mystmt'); } - if (!is_object($stmt = $db->query('DESCRIBE test id'))) + if (!is_object($stmt = $db->query("DESCRIBE {$table} id"))) printf("[012] Native PS (native support: %s), DESCRIBE failed, %s\n", $native_support, var_export($db->errorInfo(), true)); @@ -138,12 +140,12 @@ MySQLPDOTest::skip(); var_export($show_native, true)); $native_support = 'no'; - if ($db->exec("PREPARE mystmt FROM 'EXPLAIN SELECT id FROM test'")) { + if ($db->exec("PREPARE mystmt FROM 'EXPLAIN SELECT id FROM {$table}'")) { $native_support = 'yes'; $db->exec('DEALLOCATE PREPARE mystmt'); } - if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) + if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM {$table}"))) printf("[012] Native PS (native support: %s), EXPLAIN failed, %s\n", $native_support, var_export($db->errorInfo(), true)); @@ -185,8 +187,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_fetch_non_select'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt index 7158f7601aa2f..8aaf65f52d9ea 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt @@ -4,12 +4,12 @@ MySQL PDOStatement->fetch(), PDO::FETCH_SERIALIZE pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_fetch_serialize'); ?> --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt index a8783ff88746d..f2f6c89ad3897 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt @@ -4,12 +4,12 @@ MySQL PDOStatement->fetch(), PDO::FETCH_SERIALIZE|PDO::FETCH_CLASS pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_fetchserialize_fetch_class'); ?> --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt index 5b90a0ba1573b..011f52d8d4641 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt @@ -4,12 +4,12 @@ MySQL PDOStatement->fetch(), PDO::FETCH_SERIALIZE pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_fetchserialize_simple'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt index 9f1bbd2d0f6c6..87d8470d68078 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt @@ -4,7 +4,7 @@ MySQL PDO: PDOStatement->fetchObject() pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); -MySQLPDOTest::createTestTable($db); + +$table = 'pdo_mysql_stmt_fetchobject'; +MySQLPDOTest::createTestTable($table, $db); try { - $query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3"; + $query = "SELECT id, '', NULL, \"\" FROM {$table} ORDER BY id ASC LIMIT 3"; $stmt = $db->prepare($query); #[AllowDynamicProperties] @@ -85,8 +87,9 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_fetchobject'); ?> --EXPECTF-- myclass::__set(id, -'1'-) 1 diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt index 747d23700268e..1bedb7d880145 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt @@ -4,7 +4,7 @@ MySQL PDO: PDOStatement->fetchObject() with $constructorArgs pdo_mysql --SKIPIF-- --FILE-- prepare($query); class Foo { @@ -77,8 +79,9 @@ try { ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_fetchobject_ctor_args'); ?> --EXPECTF-- Too few arguments to function Foo::__construct(), 0 passed and exactly 1 expected diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt index 978a853c333db..ac6b3c7cc3c6a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt @@ -4,19 +4,13 @@ MySQL: PDOStatement->getColumnMeta() pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version'); -$row = $stmt->fetch(PDO::FETCH_ASSOC); -$version = ((int)substr($row['_version'], 0, 1) * 10) + (int)substr($row['_version'], 2, 1); -if ($version < 51) - die("skip Test needs MySQL 5.1+"); +MySQLPDOTest::skipVersionThanLess(50100); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); @@ -304,7 +298,7 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_stmt_getcolumnmeta'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt index b2cbe43561b04..6eb331cc3da81 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt @@ -4,43 +4,45 @@ PDOStatements and multi query pdo_mysql --SKIPIF-- --FILE-- query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); + $stmt = $db->query("SELECT label FROM {$table} ORDER BY id ASC LIMIT 1; SELECT label FROM {$table} ORDER BY id ASC LIMIT 1"); var_dump($stmt->errorInfo()); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); var_dump($stmt->errorInfo()); - } function mysql_stmt_multiquery_proper_usage($db) { + global $table; - $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); + $stmt = $db->query("SELECT label FROM {$table} ORDER BY id ASC LIMIT 1; SELECT label FROM {$table} ORDER BY id ASC LIMIT 1"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset()); - } try { printf("Emulated Prepared Statements...\n"); $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); mysql_stmt_multiquery_wrong_usage($db); mysql_stmt_multiquery_proper_usage($db); printf("Native Prepared Statements...\n"); $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); mysql_stmt_multiquery_wrong_usage($db); mysql_stmt_multiquery_proper_usage($db); @@ -54,8 +56,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_multiquery'); ?> --EXPECTF-- Emulated Prepared Statements... @@ -98,7 +101,7 @@ array(1) { } Native Prepared Statements... -Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near '%SSELECT label FROM test ORDER BY id ASC LIMIT 1' at line %d in %s on line %d +Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near '%SSELECT label FROM pdo_mysql_stmt_multiquery ORDER BY id ASC LIMIT 1' at line %d in %s on line %d Fatal error: Uncaught Error: Call to a member function errorInfo() on false in %s:%d Stack trace: diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt index 6114cc3d9aadd..febe8db6b8a6d 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt @@ -4,55 +4,49 @@ MySQL PDOStatement->nextRowSet() pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); - -if (!MySQLPDOTest::isPDOMySQLnd()) - die("skip This will not work with libmysql"); +MySQLPDOTest::skipVersionThanLess(50000); +MySQLPDOTest::skipNotMySQLnd(); ?> --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + $table = 'pdo_mysql_stmt_nextrowset'; + $procedure = 'pdo_mysql_stmt_nextrowset_p'; - $stmt = $db->query('SELECT id FROM test'); + MySQLPDOTest::createTestTable($table, $db); + + $stmt = $db->query("SELECT id FROM {$table}"); if (false !== ($tmp = $stmt->nextRowSet())) printf("[002] Expecting false got %s\n", var_export($tmp, true)); function test_proc1($db) { + global $procedure; $stmt = $db->query('SELECT @VERSION as _version'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); assert($tmp['_version'] === NULL); while ($stmt->fetch()) ; - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;'); - $db->exec('CALL p(@VERSION)'); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;"); + $db->exec("CALL {$procedure}(@VERSION)"); $stmt = $db->query('SELECT @VERSION as _version'); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); var_dump($stmt->nextRowSet()); - } function test_proc2($db) { + global $table; + global $procedure; - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); - $stmt = $db->query('CALL p()'); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT id FROM {$table} ORDER BY id ASC LIMIT 3; SELECT id, label FROM {$table} WHERE id < 4 ORDER BY id DESC LIMIT 3; END;"); + $stmt = $db->query("CALL {$procedure}()"); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowSet()); @@ -60,13 +54,12 @@ if (!MySQLPDOTest::isPDOMySQLnd()) echo "Skip fetchAll(): "; unset($stmt); - $stmt = $db->query('CALL p()'); + $stmt = $db->query("CALL {$procedure}()"); var_dump($stmt->nextRowSet()); $stmt->closeCursor(); } try { - // Emulated PS printf("Emulated PS...\n"); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); @@ -98,9 +91,6 @@ if (!MySQLPDOTest::isPDOMySQLnd()) test_proc1($db); test_proc2($db); - - @$db->exec('DROP PROCEDURE IF EXISTS p'); - } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); @@ -110,8 +100,10 @@ if (!MySQLPDOTest::isPDOMySQLnd()) ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_nextrowset'); +$db->exec('DROP PROCEDURE IF EXISTS pdo_mysql_stmt_nextrowset_p'); ?> --EXPECTF-- Emulated PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt index 4d411406cde8a..5107b2353e7b6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_rowcount.phpt @@ -4,21 +4,23 @@ MySQL PDOStatement->rowCount() @ SELECT pdo_mysql --SKIPIF-- --FILE-- query('SELECT id FROM test WHERE 1 = 0')->rowCount())) + if (0 !== ($tmp = $db->query("SELECT id FROM {$table} WHERE 1 = 0")->rowCount())) printf("[002] Expecting 0 got %s", var_export($tmp, true)); - if (1 !== ($tmp = $db->query('SELECT id FROM test WHERE id = 1')->rowCount())) + if (1 !== ($tmp = $db->query("SELECT id FROM {$table} WHERE id = 1")->rowCount())) printf("[003] Expecting 1 got %s", var_export($tmp, true)); } catch (PDOException $e) { @@ -30,8 +32,9 @@ MySQLPDOTest::skip(); ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_rowcount'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt index a2ddc43d726e0..aca3e6a084cbd 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt @@ -4,36 +4,36 @@ MySQL PDO:query() vs. PDO::prepare() and MySQL error 2050 pdo_mysql --SKIPIF-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($table, $db); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); /* NOTE - this will cause an error and it OK @@ -85,23 +85,23 @@ if (MYSQLPDOTest::isPDOMySQLnd()) - fix PDO::query() [not the driver, fix PDO itself] */ - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id = 1"); $stmt->execute(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id = 1"); $stmt->execute(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); unset($stmt); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); unset($stmt); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } catch (PDOException $e) { @@ -113,8 +113,9 @@ if (MYSQLPDOTest::isPDOMySQLnd()) ?> --CLEAN-- exec('DROP TABLE IF EXISTS pdo_mysql_stmt_unbuffered_2050'); ?> --EXPECTF-- Native PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt index 2b67e5ba2e406..9f02a031f913f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt @@ -4,25 +4,17 @@ MySQL Prepared Statements and different column counts pdo_mysql --SKIPIF-- query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); -$matches = array(); -if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) - die(sprintf("skip Cannot determine MySQL Server version\n")); - -$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; -if ($version < 50000) - die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", - $matches[1], $matches[2], $matches[3], $version)); +MySQLPDOTest::skipVersionThanLess(50000); ?> --FILE-- fetch(PDO::FETCH_ASSOC); $stmt->nextRowSet(); @@ -45,15 +37,14 @@ if ($version < 50000) } try { - // What will happen if a PS returns a different number of result set column upon each execution? // Lets try with a SP accepting parameters... - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p(IN cols INT) BEGIN IF cols < 2 THEN SELECT cols AS "one"; ELSE SELECT 1 AS "one", cols AS "two"; END IF; END;'); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}(IN cols INT) BEGIN IF cols < 2 THEN SELECT cols AS 'one'; ELSE SELECT 1 AS 'one', cols AS 'two'; END IF; END;"); // Emulates PS first $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $stmt = $db->prepare('CALL p(?)'); + $stmt = $db->prepare("CALL {$procedure}(?)"); $columns = null; $stmt->bindParam(1, $columns); @@ -69,7 +60,7 @@ if ($version < 50000) $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - $stmt = $db->prepare('CALL p(?)'); + $stmt = $db->prepare("CALL {$procedure}(?)"); $stmt->bindParam(1, $columns); for ($i = 5; $i < 10; $i++) { $columns = ($i % 2) + 1; @@ -79,13 +70,13 @@ if ($version < 50000) } // And now without parameters... - this gives a different control flow inside PDO - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN DECLARE cols INT; SELECT @numcols INTO cols; IF cols < 2 THEN SET @numcols = 2; SELECT cols AS "one"; ELSE SET @numcols = 1; SELECT 1 AS "one", cols AS "two"; END IF; END;'); + $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); + $db->exec("CREATE PROCEDURE {$procedure}() BEGIN DECLARE cols INT; SELECT @numcols INTO cols; IF cols < 2 THEN SET @numcols = 2; SELECT cols AS 'one'; ELSE SET @numcols = 1; SELECT 1 AS 'one', cols AS 'two'; END IF; END;"); // Emulates PS first $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $db->exec('SET @numcols = 1'); - $stmt = $db->prepare('CALL p()'); + $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); check_result(11, $stmt, 1); $stmt->execute(); @@ -101,7 +92,7 @@ if ($version < 50000) $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); $db->exec('SET @numcols = 1'); - $stmt = $db->prepare('CALL p()'); + $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); check_result(14, $stmt, 1); $stmt->execute(); @@ -120,9 +111,9 @@ if ($version < 50000) ?> --CLEAN-- query('DROP PROCEDURE IF EXISTS p'); +$pdo->query('DROP PROCEDURE IF EXISTS pdo_mysql_stmt_variable_columncount_p'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt index 1a0d9abd803b7..d74e348fb99a3 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt @@ -4,12 +4,12 @@ MySQL PDOStatement->execute()/fetch(), Non-SELECT pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_subclass'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_types.phpt index b0595d6428224..d116665452342 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_types.phpt @@ -4,12 +4,12 @@ MySQL PDO->exec(), native types wo ZEROFILL pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_mysql_types'); ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt index 88cf8ccaa2c53..2f1e29e2c6b71 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt @@ -4,12 +4,12 @@ MySQL PDO->exec(), native types - ZEROFILL pdo_mysql --SKIPIF-- --FILE-- --CLEAN-- exec('DROP TABLE IF EXISTS test_mysql_types_zerofill'); ?> diff --git a/ext/pdo_mysql/tests/pecl_bug_5200.phpt b/ext/pdo_mysql/tests/pecl_bug_5200.phpt index 768919f902856..5627dcc469966 100644 --- a/ext/pdo_mysql/tests/pecl_bug_5200.phpt +++ b/ext/pdo_mysql/tests/pecl_bug_5200.phpt @@ -1,18 +1,16 @@ --TEST-- PDO MySQL PECL Bug #5200 (Describe table gives unexpected result mysql and type enum) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec("CREATE TABLE test_pecl_bug_5200 (bar INT NOT NULL, phase enum('please_select', 'I', 'II', 'IIa', 'IIb', 'III', 'IV'))"); @@ -22,8 +20,9 @@ foreach ($db->query('DESCRIBE test_pecl_bug_5200 phase')->fetchAll(PDO::FETCH_AS ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_pecl_bug_5200'); ?> --EXPECT-- Array diff --git a/ext/pdo_mysql/tests/pecl_bug_5780.phpt b/ext/pdo_mysql/tests/pecl_bug_5780.phpt index 5df5af84ddcec..2d4fc9ce33cd2 100644 --- a/ext/pdo_mysql/tests/pecl_bug_5780.phpt +++ b/ext/pdo_mysql/tests/pecl_bug_5780.phpt @@ -1,18 +1,16 @@ --TEST-- PDO MySQL PECL Bug #5780 (Failure to produce an error when one is expected) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec("CREATE TABLE test_pecl_bug_5780 (login varchar(32) NOT NULL, data varchar(64) NOT NULL)"); $db->exec("CREATE TABLE test_pecl_bug_5780_2 (login varchar(32) NOT NULL, password varchar(64) NOT NULL)"); @@ -30,9 +28,10 @@ var_dump($info); ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_pecl_bug_5780'); +$db->exec('DROP TABLE IF EXISTS test_pecl_bug_5780_2'); ?> --EXPECT-- array(2) { diff --git a/ext/pdo_mysql/tests/pecl_bug_5802.phpt b/ext/pdo_mysql/tests/pecl_bug_5802.phpt index 1e25ab8dcd281..3ed0d8744e7de 100644 --- a/ext/pdo_mysql/tests/pecl_bug_5802.phpt +++ b/ext/pdo_mysql/tests/pecl_bug_5802.phpt @@ -1,18 +1,16 @@ --TEST-- PDO MySQL PECL Bug #5802 (bindParam/bindValue retain the is_null flag) --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- exec('create table test_pcl_bug_5802 ( bar char(3) NULL )'); $stmt = $db->prepare('insert into test_pcl_bug_5802 (bar) values(:bar)') or var_dump($db->errorInfo()); @@ -38,7 +36,7 @@ print "done!"; ?> --CLEAN-- exec('DROP TABLE IF EXISTS test_pcl_bug_5802'); ?> diff --git a/ext/pdo_mysql/tests/show_tables.phpt b/ext/pdo_mysql/tests/show_tables.phpt index ce2489647683e..50a731fd8a1ac 100644 --- a/ext/pdo_mysql/tests/show_tables.phpt +++ b/ext/pdo_mysql/tests/show_tables.phpt @@ -1,18 +1,16 @@ --TEST-- PDO MySQL SHOW TABLES --EXTENSIONS-- -pdo pdo_mysql --SKIPIF-- --FILE-- query('SHOW TABLES')); ?> diff --git a/ext/pdo_mysql/tests/skipifinfilenotallowed.inc b/ext/pdo_mysql/tests/skipifinfilenotallowed.inc deleted file mode 100644 index abfea299b75bd..0000000000000 --- a/ext/pdo_mysql/tests/skipifinfilenotallowed.inc +++ /dev/null @@ -1,6 +0,0 @@ -query("SHOW VARIABLES LIKE 'local_infile'"); -if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != 'ON')) - die("skip Server variable 'local_infile' seems not set to 'ON', found '". $row['value'] ."'"); -?> diff --git a/ext/pdo_mysql/tests/table.inc b/ext/pdo_mysql/tests/table.inc deleted file mode 100644 index 9ef8fac134ca5..0000000000000 --- a/ext/pdo_mysql/tests/table.inc +++ /dev/null @@ -1,9 +0,0 @@ -exec('DROP TABLE IF EXISTS test'); -$db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine); -$db->exec('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")'); -?> diff --git a/ext/pdo_mysql/tests/unsigned_bigint.phpt b/ext/pdo_mysql/tests/unsigned_bigint.phpt index e2fc9604f24ae..52ec1c032cd9f 100644 --- a/ext/pdo_mysql/tests/unsigned_bigint.phpt +++ b/ext/pdo_mysql/tests/unsigned_bigint.phpt @@ -1,21 +1,20 @@ --TEST-- Bug GH-7837 (large bigints may be truncated) --EXTENSIONS-- -pdo pdo_mysql mysqlnd --SKIPIF-- --FILE-- query("DROP TABLE IF EXISTS $tbl"); $pdo->query("CREATE TABLE $tbl (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB"); $pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (18446744073709551615)"); @@ -26,8 +25,9 @@ var_dump($result); ?> --CLEAN-- exec('DROP TABLE IF EXISTS unsigned_bigint_pdo_mysql'); ?> --EXPECT-- array(3) { From db5b7daeaaddd42c048b49236ee98804a8ff85fd Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Fri, 24 Nov 2023 20:44:20 +0900 Subject: [PATCH 2/3] Additional fixes --- ext/pdo_mysql/tests/bug53551.phpt | 1 - ext/pdo_mysql/tests/bug63185.phpt | 1 - ext/pdo_mysql/tests/bug76815.phpt | 2 -- ext/pdo_mysql/tests/bug_39858.phpt | 1 - ext/pdo_mysql/tests/bug_41125.phpt | 1 - ext/pdo_mysql/tests/bug_41997.phpt | 2 -- ext/pdo_mysql/tests/bug_42499.phpt | 1 - ext/pdo_mysql/tests/bug_44707.phpt | 1 - ext/pdo_mysql/tests/bug_50323.phpt | 2 +- ext/pdo_mysql/tests/bug_61411.phpt | 1 - ext/pdo_mysql/tests/bug_pecl_7976.phpt | 1 - ext/pdo_mysql/tests/inc/mysql_pdo_test.inc | 2 +- .../tests/pdo_mysql_attr_init_command.phpt | 2 -- .../pdo_mysql_attr_multi_statements.phpt | 2 +- .../tests/pdo_mysql_attr_oracle_nulls.phpt | 17 +++++++++------ ext/pdo_mysql/tests/pdo_mysql_commit.phpt | 1 - ext/pdo_mysql/tests/pdo_mysql_exec.phpt | 21 ++++++++++++------- ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt | 4 ---- .../pdo_mysql_multi_stmt_nextrowset.phpt | 1 - ext/pdo_mysql/tests/pdo_mysql_rollback.phpt | 1 - .../tests/pdo_mysql_stmt_getcolumnmeta.phpt | 1 - .../tests/pdo_mysql_stmt_nextrowset.phpt | 1 - .../pdo_mysql_stmt_variable_columncount.phpt | 2 -- ext/pdo_mysql/tests/unsigned_bigint.phpt | 1 - 24 files changed, 27 insertions(+), 43 deletions(-) diff --git a/ext/pdo_mysql/tests/bug53551.phpt b/ext/pdo_mysql/tests/bug53551.phpt index 2e4fb62d9e957..0e73822e4bed1 100644 --- a/ext/pdo_mysql/tests/bug53551.phpt +++ b/ext/pdo_mysql/tests/bug53551.phpt @@ -18,7 +18,6 @@ $createSql = "CREATE TABLE `bug53551` ( `count` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' )"; -$db->exec('DROP TABLE IF EXISTS bug53551'); $db->exec($createSql); $db->exec("INSERT INTO bug53551 SET `count` = 1 "); $db->exec("SET sql_mode = 'Traditional'"); diff --git a/ext/pdo_mysql/tests/bug63185.phpt b/ext/pdo_mysql/tests/bug63185.phpt index 948a626e17ca2..8a24734936949 100644 --- a/ext/pdo_mysql/tests/bug63185.phpt +++ b/ext/pdo_mysql/tests/bug63185.phpt @@ -16,7 +16,6 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $procedure = 'test_procedure_error_at_second_63185'; -$pdo->exec("DROP PROCEDURE IF EXISTS {$procedure}"); $pdo->exec("CREATE PROCEDURE {$procedure} () BEGIN SELECT 'x' AS foo; diff --git a/ext/pdo_mysql/tests/bug76815.phpt b/ext/pdo_mysql/tests/bug76815.phpt index ed9f422adc106..c89499296171b 100644 --- a/ext/pdo_mysql/tests/bug76815.phpt +++ b/ext/pdo_mysql/tests/bug76815.phpt @@ -17,8 +17,6 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $func = 'bug76815_pdo_mysql_f'; $procedure = 'bug76815_pdo_mysql_p'; -$pdo->query("DROP FUNCTION IF EXISTS {$func}"); -$pdo->query("DROP PROCEDURE IF EXISTS {$procedure}"); $pdo->query("CREATE FUNCTION {$func}() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN 'x12345'; END"); $pdo->query("CREATE PROCEDURE {$procedure}() BEGIN SELECT {$func}(); END"); diff --git a/ext/pdo_mysql/tests/bug_39858.phpt b/ext/pdo_mysql/tests/bug_39858.phpt index 66cb6d068de8a..f2f8952060e04 100644 --- a/ext/pdo_mysql/tests/bug_39858.phpt +++ b/ext/pdo_mysql/tests/bug_39858.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- --FILE-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $procedure = 'bug_41997_pdo_mysql_p'; -$db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT 1 AS 'one'; END"); $stmt = $db->query("CALL {$procedure}()"); diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt index 721f1b2834e09..6f1534859a0ca 100644 --- a/ext/pdo_mysql/tests/bug_42499.phpt +++ b/ext/pdo_mysql/tests/bug_42499.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- --FILE-- exec('DROP DATABASE IF EXISTS `crazy;dbname`'); +$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`'); ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/bug_61411.phpt b/ext/pdo_mysql/tests/bug_61411.phpt index 60582f8828dd9..27a5fce83acdd 100644 --- a/ext/pdo_mysql/tests/bug_61411.phpt +++ b/ext/pdo_mysql/tests/bug_61411.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- --FILE-- $v) { define($k, $v); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt index ff38ea86c1cf0..94db61e00ded4 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt @@ -19,7 +19,6 @@ error_reporting=E_ALL $table = 'pdo_mysql_attr_init_command'; $db = new PDO($dsn, $user, $pass); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); $create = sprintf('CREATE TABLE %s(id INT)', $table); var_dump($create); @@ -33,7 +32,6 @@ error_reporting=E_ALL $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); print "done!"; ?> --CLEAN-- diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt index b97c858530d51..7d0256500f555 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt @@ -22,7 +22,7 @@ error_reporting=E_ALL $db = new PDO($dsn, $user, $pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); + $create = sprintf('CREATE TABLE %s(id INT)', $table); $db->exec($create); $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table)); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index f2121de6d3682..f308f3384f854 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -12,6 +12,8 @@ MySQLPDOTest::skip(); require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); + $procedure = 'pdo_mysql_attr_oracle_nulls_p'; + try { $db->setAttribute(PDO::ATTR_ORACLE_NULLS, []); } catch (\TypeError $e) { @@ -47,10 +49,10 @@ MySQLPDOTest::skip(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) && - (false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) { + if ($have_procedures && (false !== $db->exec("DROP PROCEDURE IF EXISTS {$procedure}")) && + (false !== $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) { // requires MySQL 5+ - $stmt = $db->prepare('CALL p()'); + $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); do { var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -63,11 +65,14 @@ MySQLPDOTest::skip(); } - if ($have_procedures) - @$db->exec('DROP PROCEDURE IF EXISTS p'); - print "done!"; ?> +--CLEAN-- +exec("DROP PROCEDURE IF EXISTS pdo_mysql_attr_oracle_nulls_p"); +?> --EXPECTF-- Attribute value must be of type int for selected attribute, array given Attribute value must be of type int for selected attribute, stdClass given diff --git a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt index b32f40c7bed55..2698eb4f5bbbf 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt @@ -22,7 +22,6 @@ MySQLPDOTest::skipNotTransactionalEngine(); } // DDL will issue an implicit commit - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table2)); $db->exec(sprintf('CREATE TABLE %s (id INT) ENGINE=%s', $table2, MySQLPDOTest::detect_transactional_mysql_engine($db))); try { $db->commit(); diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt index 35a3fd908a178..a75f871524580 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt @@ -30,6 +30,8 @@ MySQLPDOTest::skip(); require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); + $procedure = 'pdo_mysql_exec_p'; + /* affected rows related */ try { exec_and_count(2, $db, 'DROP TABLE IF EXISTS test_mysql_exec', 0); @@ -66,11 +68,11 @@ MySQLPDOTest::skip(); // let's try to play with stored procedures try { $ignore_exception = true; - exec_and_count(18, $db, 'DROP PROCEDURE IF EXISTS p', 0); - exec_and_count(19, $db, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;', 0); + exec_and_count(18, $db, "DROP PROCEDURE IF EXISTS {$procedure}", 0); + exec_and_count(19, $db, "CREATE PROCEDURE {$procedure}(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;", 0); // we got this far without problems. If there's an issue from now on, its a failure $ignore_exception = false; - exec_and_count(20, $db, 'CALL p(@version)', 1); + exec_and_count(20, $db, "CALL {$procedure}(@version)", 1); $stmt = $db->query('SELECT @version AS p_version'); $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($tmp) > 1 || !isset($tmp[0]['p_version'])) { @@ -92,7 +94,7 @@ MySQLPDOTest::skip(); $tmp[0]['_version'], gettype($tmp[0]['_version'])); } } - exec_and_count(25, $db, 'DROP PROCEDURE IF EXISTS p', 0); + exec_and_count(25, $db, "DROP PROCEDURE IF EXISTS {$procedure}", 0); } catch (PDOException $e) { // ignore it, we might not have sufficient permissions @@ -103,13 +105,14 @@ MySQLPDOTest::skip(); } // stored function + $func = 'pdo_mysql_exec_f'; try { $ignore_exception = true; - exec_and_count(27, $db, 'DROP FUNCTION IF EXISTS f', 0); - exec_and_count(28, $db, 'CREATE FUNCTION f( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;', 0); + exec_and_count(27, $db, "DROP FUNCTION IF EXISTS {$func}", 0); + exec_and_count(28, $db, "CREATE FUNCTION {$func}( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;", 0); // we got this far without problems. If there's an issue from now on, its a failure $ignore_exception = false; - $stmt = $db->query('SELECT f(VERSION()) AS f_version'); + $stmt = $db->query("SELECT {$func}(VERSION()) AS f_version"); $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($tmp) > 1 || !isset($tmp[0]['f_version'])) { printf("[029] Data seems wrong, dumping\n"); @@ -129,7 +132,7 @@ MySQLPDOTest::skip(); $tmp[0]['_version'], gettype($tmp[0]['_version'])); } } - exec_and_count(32, $db, 'DROP FUNCTION IF EXISTS f', 0); + exec_and_count(32, $db, "DROP FUNCTION IF EXISTS {$func}", 0); } catch (PDOException $e) { // ignore it, we might not have sufficient permissions @@ -169,6 +172,8 @@ MySQLPDOTest::skip(); require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); $db->query('DROP TABLE IF EXISTS test_mysql_exec'); +$db->query('DROP PROCEDURE IF EXISTS pdo_mysql_exec_p'); +$db->query('DROP FUNCTION IF EXISTS pdo_mysql_exec_f'); ?> --EXPECTF-- Warning: PDO::exec(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'THIS IS NOT VALID SQL, I HOPE' at line 1 in %s on line %d diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt index 89586525b748b..6991370c39070 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_ddl.phpt @@ -41,15 +41,11 @@ MySQLPDOTest::skip(); $table2 = 'pdo_mysql_exec_ddl_2'; /* affected rows related */ try { - @$db->exec("DROP DATABASE IF EXISTS {$db_name}"); - @$db->exec("DROP DATABASE IF EXISTS {$db_name_2}"); if (1 === @$db->exec("CREATE DATABASE {$db_name}")) { // yippie - we can create databases etc. exec_and_count(3, $db, "ALTER DATABASE {$db_name} CHARACTER SET latin1", 1); } - exec_and_count(4, $db, "DROP TABLE IF EXISTS {$table}", 0); - exec_and_count(5, $db, "DROP TABLE IF EXISTS {$table2}", 0); if (0 === $db->exec("CREATE TABLE {$table} (id INT, col1 CHAR(2))")) { exec_and_count(5, $db, "CREATE INDEX idx1 ON {$table} (id)", 0); exec_and_count(6, $db, "DROP INDEX idx1 ON {$table}", 0); diff --git a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt index 079b7ab29119a..b699dbdaa5719 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- beginTransaction(); $db->query("INSERT INTO {$table}(id, label) VALUES (100, 'z')"); - $db->query("DROP TABLE IF EXISTS {$table2}"); $db->query("CREATE TABLE {$table2}(id INT)"); $num++; try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt index ac6b3c7cc3c6a..0552a87aa42d9 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- --FILE-- diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt index 9f02a031f913f..fb35381769744 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt @@ -6,7 +6,6 @@ pdo_mysql --FILE-- exec("DROP PROCEDURE IF EXISTS {$procedure}"); $db->exec("CREATE PROCEDURE {$procedure}(IN cols INT) BEGIN IF cols < 2 THEN SELECT cols AS 'one'; ELSE SELECT 1 AS 'one', cols AS 'two'; END IF; END;"); // Emulates PS first diff --git a/ext/pdo_mysql/tests/unsigned_bigint.phpt b/ext/pdo_mysql/tests/unsigned_bigint.phpt index 52ec1c032cd9f..d583620198e9a 100644 --- a/ext/pdo_mysql/tests/unsigned_bigint.phpt +++ b/ext/pdo_mysql/tests/unsigned_bigint.phpt @@ -15,7 +15,6 @@ require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $pdo = MySQLPDOTest::factory(); $tbl = "unsigned_bigint_pdo_mysql"; -$pdo->query("DROP TABLE IF EXISTS $tbl"); $pdo->query("CREATE TABLE $tbl (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB"); $pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (18446744073709551615)"); $pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (9223372036854775808)"); From 761cc2f5738f18a3f7e08b6f11b51fb0059ebede Mon Sep 17 00:00:00 2001 From: SakiTakamachi Date: Fri, 24 Nov 2023 21:02:18 +0900 Subject: [PATCH 3/3] remove suppress --- ext/pdo_mysql/tests/pdo_mysql_exec.phpt | 4 ++-- ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt | 4 ++-- ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt | 2 +- ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt | 2 +- ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt | 2 +- ext/pdo_mysql/tests/pdo_mysql_types.phpt | 2 +- ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt index a75f871524580..cd5fa3f0470e3 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt @@ -148,7 +148,7 @@ MySQLPDOTest::skip(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $exp = 0; - $tmp = @$db->exec(sprintf('DROP TABLE IF EXISTS test_mysql_exec; CREATE TABLE test_mysql_exec(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $tmp = $db->exec(sprintf('DROP TABLE IF EXISTS test_mysql_exec; CREATE TABLE test_mysql_exec(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); if ($exp !== $tmp) printf("[034] Expecting %s/%s got %s/%s, [%s] %s\n", $exp, gettype($exp), @@ -156,7 +156,7 @@ MySQLPDOTest::skip(); $db->errorCode(), var_export($db->errorInfo(), true)); // this is interesting: if we get sort of affected rows, what will happen now? - $tmp = @$db->exec('INSERT INTO test_mysql_exec(id) VALUES (1); INSERT INTO test_mysql_exec(id) VALUES (2)'); + $tmp = $db->exec('INSERT INTO test_mysql_exec(id) VALUES (1); INSERT INTO test_mysql_exec(id) VALUES (2)'); printf("[035] With emulated PS it works but makes no sense given that exec() returns sort of affected rows...\n"); } catch (PDOException $e) { printf("[033] %s, [%s] %s\n", diff --git a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt index 557493206b532..0012e6e3d5c43 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt @@ -52,7 +52,7 @@ MySQLPDOTest::skip(); sleep(1); if ('00000' == $db1->errorCode()) { // looks like KILL has worked ? Or not... TODO: why no warning with libmysql?! - @$db1->exec("SET @pdo_persistent_connection=2"); + $db1->exec("SET @pdo_persistent_connection=2"); // but now I want to see some error... if ('HY000' != $db1->errorCode()) printf("[004] Wrong error code %s\n", $db1->errorCode()); @@ -68,7 +68,7 @@ MySQLPDOTest::skip(); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); $con1 = $tmp['_con1']; - @$db2 = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]); + $db2 = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]); $db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $stmt = $db2->query('SELECT CONNECTION_ID() AS _con2'); $tmp = $stmt->fetch(PDO::FETCH_ASSOC); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt index 542125639976f..b315c97b91203 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt @@ -19,7 +19,7 @@ MySQLPDOTest::skip(); $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); $sql = sprintf('CREATE TABLE test_stmt_bindparam_types(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - if ((!$stmt = @$db->prepare($sql)) || (!@$stmt->execute())) + if ((!$stmt = $db->prepare($sql)) || (!$stmt->execute())) // Server might not support column type - skip it return true; diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt index 87d8470d68078..0690878bac09a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt @@ -11,7 +11,7 @@ $db = MySQLPDOTest::factory(); try { $query = "SELECT '', NULL, \"\" FROM DUAL"; $stmt = $db->prepare($query); - $ok = @$stmt->execute(); + $ok = $stmt->execute(); } catch (PDOException $e) { die("skip: Test cannot be run with SQL mode ANSI"); } diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt index 1bedb7d880145..ed5a67ed05b00 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject_ctor_args.phpt @@ -11,7 +11,7 @@ $db = MySQLPDOTest::factory(); try { $query = "SELECT '', NULL, \"\" FROM DUAL"; $stmt = $db->prepare($query); - $ok = @$stmt->execute(); + $ok = $stmt->execute(); } catch (PDOException $e) { die("skip: Test cannot be run with SQL mode ANSI"); } diff --git a/ext/pdo_mysql/tests/pdo_mysql_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_types.phpt index d116665452342..462a542c24c17 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_types.phpt @@ -15,7 +15,7 @@ MySQLPDOTest::skip(); $db->exec('DROP TABLE IF EXISTS test_mysql_types'); $sql = sprintf('CREATE TABLE test_mysql_types(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - @$db->exec($sql); + $db->exec($sql); if ($db->errorCode() != 0) { // not all MySQL Server versions and/or engines might support the type return true; diff --git a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt index 2f1e29e2c6b71..1a60eed96d7af 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt @@ -15,7 +15,7 @@ MySQLPDOTest::skip(); $db->exec('DROP TABLE IF EXISTS test_mysql_types_zerofill'); $sql = sprintf('CREATE TABLE test_mysql_types_zerofill(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - @$db->exec($sql); + $db->exec($sql); if ($db->errorCode() != 0) { // not all MySQL Server versions and/or engines might support the type return true;