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

Fix broken DatabaseMetaData.getColumns() on older server versions #182

Conversation

eirikbakke
Copy link
Contributor

@eirikbakke eirikbakke commented Jan 11, 2023

On older versions of MariaDB and MySQL, DatabaseMetaData.getColumns() will fail with the error Unknown column 'DATETIME_PRECISION' in 'field list'. This is due to the DATETIME_PRECISION column not being present in the INFORMATION_SCHEMA.COLUMNS table. This column was introduced as part of the introduction of microsecond precision in TIME/DATETIME/TIMESTAMP types, in MariaDB 5.3.0 (I believe) and MySQL 5.6.4.

The proposed fix adjusts the metadata query for the relevant older server versions. The fixed behavior in these cases is as if the DATETIME_PRECISION field had a value of 0, which is consistent with the fact that these older database versions did not support any fractional seconds digits.

Similar conditional logic already exist in the MySQL project's JDBC driver.

(This bug was reported by a user of Ultorg, a graphical database client. To test the modified MariaDB JDBC driver, I ran Ultorg's integration test suite with it while connecting to MariaDB 10.6.11, MySQL 5.5.62, and MySQL 8.0.26.)

On older versions of MariaDB and MySQL, DatabaseMetaData.getColumns() will fail with the error "Unknown column 'DATETIME_PRECISION' in 'field list'". This is due to the DATETIME_PRECISION column not being present in the INFORMATION_SCHEMA.COLUMNS table. This column was introduced as part of the introduction of microsecond precision in TIME/DATETIME/TIMESTAMP types, in MariaDB 5.3.0 (I believe) and MySQL 5.6.4.

The proposed fix adjusts the metadata query for the relevant older server versions. The behavior is as if the DATETIME_PRECISION field had a value of 0, which is consistent with the fact that these older database versions did not support any fractional seconds digits.

Similar conditional logic already exist in the MySQL project's JDBC driver.
@rusher
Copy link
Collaborator

rusher commented Jan 18, 2023

Thanks for the PR.
Those version are not supported anymore, but no reason to add correction for them.
merged on develop branch. Will be on 3.1.2 release

@rusher rusher closed this Jan 18, 2023
@eirikbakke
Copy link
Contributor Author

Thank you for the quick review and merge! (Handling some older unsupported server versions is useful for tools that are supposed to be able to connect to arbitrary MySQL/MariaDB instances, and lets us use the MariaDB driver for both.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants