Skip to content

Do not call mariadb_db_reconnect() during changing $dbh attributes unless needed #212

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

Merged
merged 2 commits into from
May 4, 2025

Conversation

choroba
Copy link
Member

@choroba choroba commented Dec 9, 2024

Fixes #211.

pali added 2 commits May 3, 2025 22:44
…en not needed

Currently mariadb_db_STORE_attrib() function (handler for changing dbh
attributes via $dbh->{...} = ... syntax) at its beginning calls function
mariadb_db_reconnect() to ensure that imp_dbh->pmysql connection structure
is initialized.

Change logic of mariadb_db_STORE_attrib() function to call function
mariadb_db_reconnect() only when the changing of attribute really requires
active connection.

This change fixes a problem that Perl for locatized variables is trying to
restore its original value after leaving the scope, and this is failing for
restoring the DBI attributes.

Trying to change common DBI attributes (those which first letter is upper
case) except the AutoConnect, is not handled by DBD::MariaDB driver, and
therefore DBD::MariaDB driver does not have to check if the connection is
still active.
Add test case that custom HandleError and also localized custom HandleError
does not trigger any error after disconnect.
@choroba choroba removed the review needed This PR needs a review label May 4, 2025
@choroba choroba merged commit 91f122d into perl5-dbi:master May 4, 2025
216 checks passed
@choroba choroba deleted the reconnect branch May 4, 2025 10:14
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

Successfully merging this pull request may close these issues.

DBD::MariaDB V1.23 - STORE raise error '2006 - MySQL server has gone away' after requested disconnect
2 participants