Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-811

Problem Accessing Columns Using Shadowed Names from 10.4 Servers




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


        Issue Links



              diego dupin Diego Dupin
              juan.vera Juan
              0 Vote for this issue
              2 Start watching this issue



                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.