[CONJ-811] Problem Accessing Columns Using Shadowed Names from 10.4 Servers Created: 2020-07-29  Updated: 2020-08-25  Resolved: 2020-07-30

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility
Affects Version/s: 2.6.1
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Juan Assignee: Diego Dupin
Resolution: Duplicate Votes: 0
Labels: None

Attachments: Java Source File 38924_error_demo.java    
Issue Links:
Problem/Incident
is caused by MDEV-23341 shadowed field wrong column name meta... Closed

 Description   

When the attached java program is compiled and run (with a mariadb-java-client jar in the classpath), the code contained in the program unexpected fails. Example run is below. This problem only occurs with 10.4 or higher, and was not present in 10.3.22.

The attached demo is the result of isolating a problem that occurred in a real world application, but the original problem has been mitigated by accessing the field alias rather than the shadowed name. However, this appears to be a MariaDB bug since the problem goes away the ORDER BY clause is removed, which should not affect queried columns. The nested join is also key to the problem, as it goes away when the join is removed.

I suspect this problem may be a combination of the server and Connector/J, as the attached queries can be run from the command line client with no issues.

{{$ javac error_demo.java && java -classpath ~/.gradle/caches/modules-2/files-2.1/org.mariadb.jdbc/mariadb-java-client/2.6.1/59dd916e0add8cd32eade36e420e91095cd61396/mariadb-java-client-2.6.1.jar:./ ColumnIssueDemo
Trying to access shadowed field with an order by...this should fail
java.sql.SQLSyntaxErrorException: No such column: original_id
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:62)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:187)
at org.mariadb.jdbc.internal.com.read.dao.ColumnLabelIndexer.getIndex(ColumnLabelIndexer.java:134)
at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.findColumn(SelectResultSet.java:1318)
at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getString(SelectResultSet.java:953)
at ColumnIssueDemo.main(error_demo.java:36)
The demo is working as intended
Trying to access shadowed field without an order by...this should work
value of original_id is oid_a
The demo is working as intended
Trying to access alias field with an order by...this should work
value of alt_id is oid_a
The demo is working as intended}}



 Comments   
Comment by Diego Dupin [ 2020-07-30 ]

Created MDEV-23341, because the issue is server side. Server send wrong column name in metata, driver cannot then return data based on this column name.

Comment by Juan [ 2020-07-30 ]

Incorrectly reported as connector issue. Moved to MDEV-23341

Generated at Thu Feb 08 03:18:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.