Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/40server_prepare.t fails #167

Closed
gregoa opened this issue Apr 7, 2022 · 3 comments
Closed

t/40server_prepare.t fails #167

gregoa opened this issue Apr 7, 2022 · 3 comments

Comments

@gregoa
Copy link

gregoa commented Apr 7, 2022

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.
@pali
Copy link
Member

pali commented Apr 7, 2022

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...

@gregoa
Copy link
Author

gregoa commented Apr 7, 2022 via email

pali added a commit to pali/DBD-MariaDB that referenced this issue Apr 8, 2022
MariaDB server version 10.6.2 and new can prepare all statements statements
except PREPARE, EXECUTE, and DEALLOCATE / DROP PREPARE.

So change test case for non-preparable statement to:
PREPARE stmt FROM "SELECT 1"

Fixes: perl5-dbi#167
@pali pali closed this as completed in cbdd83e Apr 21, 2022
@pali
Copy link
Member

pali commented Apr 21, 2022

New version of DBD::MariaDB with this fix was release on CPAN.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 2, 2024
Upstream changes:
1.23 2023-09-10
 - Add a missing break
   (perl5-dbi/DBD-MariaDB#163)
 - Signal error if mariadb_db_async_result() fails
   (perl5-dbi/DBD-MariaDB#162)
 - Update links to project website, issues and years
 - Fix compilation with some MariaDB client library 10.2 and 10.3 versions
 - Fix mariadb_use_result attribute
   (perl5-dbi/DBD-MariaDB#173)
 - Fix statements with multiple result sets in asynchronous mode
 - Fix mariadb_sockfd attribute for Windows
 - Croaks when changing AutoCommit attribute fails
   (perl5-dbi/dbi#104)
 - Various documentation and tests fixes
 - Fix support for MariaDB Connector/C prior to 3.1.3 version
 - Fix usage of Win32::GetShortPathName() in Makefile.PL
 - Build release tarball in TAR format (instead of PAX)
 - Allow to query and change mariadb_multi_statements attribute
 - Add connect option mariadb_auth_plugin for specifying auth plugin
 - Fix support for MySQL 8.0+ client library
   (perl5-dbi/DBD-MariaDB#191)
   (perl5-dbi/DBD-mysql#329)
 - Add Github Actions CI and Cirrus CI (FreeBSD) for automated testing

1.22 2022-04-22
 - Disable usage of libmysqld.a from MySQL 8.x series
 - Install README.pod into DBD/MariaDB/ subdirectory
   (perl5-dbi/DBD-MariaDB#146)
 - Do not export driver private C functions
 - Fix typo in error message
 - Fix compatibility with new MariaDB client and server versions
   (perl5-dbi/DBD-MariaDB#164)
   (perl5-dbi/DBD-MariaDB#167)
   (perl5-dbi/DBD-mysql#333)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants