Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Duplicate
-
10.4(EOL)
Description
Some shadowed field return alias name in place of column name. (This is only since 10.4)
Connector then return an exception when using column name to retrieve data.
To reproduced :
|
try (Connection con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testj?user=root&log")) { |
Statement stmt = con.createStatement();
|
stmt.execute("CREATE TABLE IF NOT EXISTS foo_outer (original_id varchar(100), key_p2 DATETIME, some_value text, PRIMARY KEY (original_id, key_p2))"); |
stmt.execute("INSERT IGNORE INTO foo_outer (original_id, key_p2, some_value) VALUES ('oid_a', '2020-06-01 00:00', 'some_value_a')"); |
stmt.execute("CREATE TABLE IF NOT EXISTS foo_inner (original_id varchar(100), other_id varchar(100), PRIMARY KEY (original_id, other_id))"); |
stmt.execute("INSERT IGNORE INTO foo_inner (original_id, other_id) VALUES ('oid_a', 'otherid_1')"); |
stmt.execute("INSERT IGNORE INTO foo_inner (original_id, other_id) VALUES ('oid_b', 'otherid_1')"); |
|
ResultSet r = stmt.executeQuery("SELECT original_id AS alt_id, key_p2 as p2, some_value " |
+ "FROM foo_outer " |
+ "WHERE original_id IN (" |
+ "SELECT DISTINCT(inner1.original_id) " |
+ "FROM foo_inner AS inner1 " |
+ "RIGHT JOIN foo_inner AS inner2 ON inner1.other_id = inner2.other_id " |
+ "WHERE inner1.original_id = 'oid_a'" |
+ ") ORDER BY key_p2"); |
while (r.next()) { |
// will throw an error, since column name meta return alt_id |
ResultSetMetaData meta = r.getMetaData();
|
System.out.println(meta.getColumnLabel(1)); // return alt_id, as expected |
System.out.println(meta.getColumnName(1)); // return alt_id, not original_id |
|
r.getString("original_id"); // will throw an exception |
}
|
} catch (Exception ex) { |
ex.printStackTrace();
|
}
|
same code without order by work without issue.
metadata is wrong :
+--------------------------------------------------+
|
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
|
+--------------------------------------------------+------------------+
|
| 39 00 00 02 03 64 65 66 05 74 65 73 74 6A 09 66 | 9....def.testj.f |
|
| 6F 6F 5F 6F 75 74 65 72 09 66 6F 6F 5F 6F 75 74 | oo_outer.foo_out |
|
| 65 72 06 61 6C 74 5F 69 64 06 61 6C 74 5F 69 64 | er.alt_id.alt_id |
|
| 0C E0 00 90 01 00 00 FD 01 10 00 00 00 | ............. |
|
+--------------------------------------------------+------------------+
|
with 10.3, no problem, original_id is returned as column name :
+--------------------------------------------------+
|
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
|
+--------------------------------------------------+------------------+
|
| 3E 00 00 02 03 64 65 66 05 74 65 73 74 6A 09 66 | >....def.testj.f |
|
| 6F 6F 5F 6F 75 74 65 72 09 66 6F 6F 5F 6F 75 74 | oo_outer.foo_out |
|
| 65 72 06 61 6C 74 5F 69 64 0B 6F 72 69 67 69 6E | er.alt_id.origin |
|
| 61 6C 5F 69 64 0C 2D 00 90 01 00 00 FD 01 10 00 | al_id.-......... |
|
| 00 00 | .. |
|
+--------------------------------------------------+------------------+
|
|
Attachments
Issue Links
- causes
-
CONJ-811 Problem Accessing Columns Using Shadowed Names from 10.4 Servers
- Closed
- is part of
-
MDEV-23519 Protocol packet - "Original Name" info is showing alias name, instead of original name of the column
- Closed
- relates to
-
CONJ-826 After roughly 24 hours of moderate DB load, "No such column" errors on Aurora
- Closed