Skip to content

Commit cbdd83e

Browse files
committed
Fix test t/40server_prepare.t for MariaDB 10.6.2+
MariaDB server version 10.6.2 and new can prepare all statements except PREPARE, EXECUTE, and DEALLOCATE / DROP PREPARE. So change test case for non-preparable statement to: PREPARE stmt FROM "SELECT 1" Fixes: #167
1 parent cbcd2ba commit cbdd83e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

t/40server_prepare.t

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ ok($sth3->execute(1, 2), "insert t3");
7272

7373
is_deeply($dbh->selectall_arrayref('SELECT id, mydata FROM t3'), [[1, 2]]);
7474

75+
# 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.
76+
my $non_preparable_statement = ($dbh->{mariadb_serverversion} >= 100602) ? q(PREPARE stmt FROM "SELECT 1") : ("USE " . $dbh->quote_identifier($test_db));
77+
7578
$dbh->{mariadb_server_prepare_disable_fallback} = 1;
7679
my $error_handler_called = 0;
7780
$dbh->{HandleError} = sub { $error_handler_called = 1; die $_[0]; };
78-
eval { $dbh->prepare("USE " . $dbh->quote_identifier($test_db)) };
81+
eval { $dbh->prepare($non_preparable_statement); };
7982
$dbh->{HandleError} = undef;
80-
ok($error_handler_called, 'USE is not supported with mariadb_server_prepare_disable_fallback=1');
83+
ok($error_handler_called, "Non-preparable statement '$non_preparable_statement' is not supported with mariadb_server_prepare_disable_fallback=1");
8184

8285
$dbh->{mariadb_server_prepare_disable_fallback} = 0;
8386
my $sth4;
84-
ok($sth4 = $dbh->prepare("USE " . $dbh->quote_identifier($test_db)), 'USE is supported with mariadb_server_prepare_disable_fallback=0');
87+
ok($sth4 = $dbh->prepare($non_preparable_statement), "Non-preparable statement '$non_preparable_statement' is supported with mariadb_server_prepare_disable_fallback=0");
8588
ok($sth4->execute());
8689

8790
ok ($dbh->do(qq{DROP TABLE t3}), "cleaning up");

0 commit comments

Comments
 (0)