Bug #15065 The usage advisor sometimes reports a referenced column as unreferenced
Submitted: 19 Nov 2005 10:22 Modified: 23 Nov 2005 6:15
Reporter: Yuan WANG
Status: Closed
Category:Connector/J Severity:S3 (Non-critical)
Version:3.1.11 OS:Microsoft Windows (WinXP)
Assigned to: Mark Matthews Target Version:

[19 Nov 2005 10:22] Yuan WANG
Description:
I set the usage advisor flag of the JDBC connection to find out unreferenced columns
return by queries in my application. However, I find that the usage advisor sometimes
makes false statements that some columns have not been referenced, even through they' re
indeed. Here is a simple test.
			((com.mysql.jdbc.Connection)conn).setUseUsageAdvisor(true);
			java.sql.Statement stmt = conn.createStatement();
			java.sql.ResultSet rs = stmt.executeQuery("select count(*) from t1 limit 1");
			rs.next();
			System.out.println("T1 has " + rs.getInt(1) + " rows");
			rs.close();
Where "conn" is the connection to the database and "t1" can be any table. While runing the
test above, the JDBC driver will report "The following columns were  part of the SELECT
statement for this result set, but were never referenced: .count(*)". This is simply
wrong.

How to repeat:
Connection to any database and execute the following.
			((com.mysql.jdbc.Connection)conn).setUseUsageAdvisor(true);
			java.sql.Statement stmt = conn.createStatement();
			java.sql.ResultSet rs = stmt.executeQuery("select count(*) from t1 limit 1");
			rs.next();
			System.out.println("T1 has " + rs.getInt(1) + " rows");
			rs.close();
Where "conn" is the connection to the database and "t1" can be any table.
[20 Nov 2005 10:01] Vasily Kishkin
Thanks for the bug report. I was able to reproduce the bug. I would like to notice that I
had java.lang.NullPointerException with any query. My test case is attached.
[20 Nov 2005 10:01] Vasily Kishkin
Test case

Attachment: Bug15065.java (text/java), 1002 bytes.

[23 Nov 2005 6:15] Mark Matthews
Fixed for 3.1.12  and 5.0.0. See nightly snapshot from
http://downloads.mysql.com/snapshots.php#connector-j after 00:00 GMT Nov 24th, or
subversion repository at http://svn.mysql.com/svnpublic/connector-j/branches/branch_3_1
immediately (i.e. build from source) for the fix.

Thanks for the bug report.
[25 Oct 2006 20:21] Robert DiFalco
I still see this sometimes with 5.0.4. I cannot create a reproducible test case.