t/40server_prepare.t fails
gregoa opened this issue · 3 comments
Cloned from #164 to separate the two issues, as proposed by @pali:
Both @Tux on OpenSUSEand and me on Debian see failures in t/40server_prepare.t:
# Failed test 'USE is not supported with mariadb_server_prepare_disable_fallback=1'
# at t/40server_prepare.t line 80.
# Looks like you failed 1 test of 29.
t/40server_prepare.t ....................
1..29
ok 1 - connecting
ok 2 - making slate clean
ok 3 - creating table
ok 4 - loading data
ok 5
ok 6
ok 7 - binding parameter
ok 8 - fetching data
ok 9
ok 10 - cleaning up
ok 11 - making slate clean
ok 12 - creating test table
ok 13
ok 14 - binding int
ok 15 - binding smallint
ok 16 - binding tinyint
ok 17 - binding bigint
ok 18 - inserting data
ok 19
ok 20 - cleaning up
ok 21 - making slate clean
ok 22 - creating test table
ok 23
ok 24 - insert t3
ok 25
not ok 26 - USE is not supported with mariadb_server_prepare_disable_fallback=1
ok 27 - USE is supported with mariadb_server_prepare_disable_fallback=0
ok 28
ok 29 - cleaning up
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/29 subtests
[…]
Test Summary Report
-------------------
t/40server_prepare.t (Wstat: 256 Tests: 29 Failed: 1)
Failed test: 26
Non-zero exit status: 1
Files=90, Tests=3516, 36 wallclock secs ( 0.63 usr 0.13 sys + 6.90 cusr 0.97 csys = 8.63 CPU)
Result: FAIL
Failed 1/90 test programs. 1/3516 subtests failed.
t/40server_prepare.t:
not ok 26 - USE is not supported with mariadb_server_prepare_disable_fallback=1
This test is checking if mariadb_server_prepare_disable_fallback
is working by trying to call some statement which cannot be executed as prepared statement but can be executed as normal statement. That testing statement is USE test_db
.
In MariaDB 10.6.2 release notes is written:
All statements can be prepared, except PREPARE, EXECUTE, and DEALLOCATE / DROP PREPARE (MDEV-16708)
In previous versions USE
statement was not supported, hence was chosen as a test case.
Could you test this change if it is working with your server version?
diff --git a/t/40server_prepare.t b/t/40server_prepare.t
index 6eb2cf1fd78f..d4208cd34953 100644
--- a/t/40server_prepare.t
+++ b/t/40server_prepare.t
@@ -75,7 +75,9 @@ is_deeply($dbh->selectall_arrayref('SELECT id, mydata FROM t3'), [[1, 2]]);
$dbh->{mariadb_server_prepare_disable_fallback} = 1;
my $error_handler_called = 0;
$dbh->{HandleError} = sub { $error_handler_called = 1; die $_[0]; };
-eval { $dbh->prepare("USE " . $dbh->quote_identifier($test_db)) };
+# MariaDB server since version 10.6.2 can prepare all statements except PREPARE, EXECUTE, and DEALLOCATE / DROP PREPARE. Previous MariaDB and Mysql versions cannot prepare USE statement
+my $non_preparable_statement = ($dbh->{mariadb_serverversion} >= 100602) ? q(PREPARE stmt FROM "SELECT 1") : ("USE " . $dbh->quote_identifier($test_db));
+eval { $dbh->prepare($non_preparable_statement); };
$dbh->{HandleError} = undef;
ok($error_handler_called, 'USE is not supported with mariadb_server_prepare_disable_fallback=1');
I hope that PREPARE stmt FROM "SELECT 1"
is not really preparable and would not be in future versions...
New version of DBD::MariaDB with this fix was release on CPAN.