Bug #106633 Table names missing from ResultSet metadata with certain queries against 5.7

Submitted: 3 Mar 2022 18:18 Modified: 4 Mar 2022 21:59
Reporter: Jason Young Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.7 OS:Debian (official Docker image)
Assigned to: Assigned Account CPU Architecture:x86 (64-bit)

[3 Mar 2022 18:18] Jason Young
Description:
I'll start with a brief description; will provide complete code or any other info upon request.

VERY particular queries run with either MysQL Connector/J or MariaDB's driver against MySQL 5.6 result in missing table names from the ResultSet metadata when there should be table names, i.e. `resultSet.getMetadata().getTableName(x)` should return a non-empty String.

I am aware that `SELECT COUNT(*) ...` results in no table names because there is no table names because COUNT(..) does not correspond to a specific column, but `SELECT t0.*, COUNT(*)` should have table names for each column from table `t0`.

I have found some queries where `resultSet.getMetadata().getTableName(x)` returns empty string for every column (for any valid column index `x`) even though only one of the columns should have an empty table name. See below.

Kinda similar to bug 92092.

How to repeat:
Can give a complete Java Gradle or Maven project upon request.

The following SQL:

SELECT
   COUNT(DISTINCT t1.id) AS blah,
   t0.*
 FROM t0
   LEFT JOIN t1 ON t1.t0_id = t0.id
   LEFT JOIN t2 ON t2.id = t1.t2_id
WHERE EXISTS(SELECT 1)
GROUP BY t0.id
ORDER BY blah ASC

run via MySQL Connector/J or MariaDB's driver against a 5.7 MySQL gives a ResultSet where `resultSet.getMetadata().getTableName(x)` is always empty. Any of the following mutations to the above code will make the table names for t0 appear in the result set (e.g. `resultSet.getMetadata().getTableName(2)` returns `t0`):
* Remove the `DISTINCT` or the entire `COUNT(DISTINCT t1.id) AS blah,`
* remove the second `LEFT JOIN`
* remove the GROUP BY clause
* remove the ORDER BY clause
* remove the WHERE clause

This bug is Not Reproducible with MySQL 5.6 or 8.0. It _is_ reproducible with the latest Connector/J and MariaDB drivers.

Tested with official Debian-based MySQL Docker images, OpenJ9 JDK 17, and MySQL driver 8.0.28 on Ubuntu 21.10.
[4 Mar 2022 9:32] MySQL Verification Team
Hi,

I verified the 92092 and I'm not sure what is different here? From what I see this is just a subset of Bug #92092? What am I missing?

thanks
[4 Mar 2022 21:29] Jason Young
The two may very well have a common root cause. The case I submitted in not reproducible against MySQL 8 whereas 92092 is (or was when it was logged). I also provided different SQL and other info. If you consider this one a duplicate, that is fine by me.
[4 Mar 2022 21:59] MySQL Verification Team
Hi,

I see that sql is different but it looks like identical bug to me. I'll set this up as a duplicate.

Thanks for the report

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.