Modified:
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/CursorRowProvider.java
trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java
trunk/connector-j/src/com/mysql/jdbc/ResultSet.java
trunk/connector-j/src/com/mysql/jdbc/RowData.java
trunk/connector-j/src/com/mysql/jdbc/RowDataDynamic.java
trunk/connector-j/src/com/mysql/jdbc/RowDataStatic.java
trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Merged from 5.0.
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/CHANGES 2006-11-17 14:15:31 UTC (rev 6041)
@@ -12,6 +12,8 @@
session variables if the current values on the server do not match
what is required.
+ - Fixed BUG#24360 .setFetchSize() breaks prepared SHOW and other commands.
+
10-20-06 - Version 5.0.4
- Fixed BUG#21379 - column names don't match metadata in cases
Modified: trunk/connector-j/src/com/mysql/jdbc/CursorRowProvider.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/CursorRowProvider.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/CursorRowProvider.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
@@ -97,6 +97,8 @@
*/
private boolean firstFetchCompleted = false;
+ private boolean wasEmpty = false;
+
/**
* Creates a new cursor-backed row provider.
*
@@ -363,6 +365,8 @@
}
synchronized (this.owner.connection.getMutex()) {
+ boolean oldFirstFetchCompleted = this.firstFetchCompleted;
+
if (!this.firstFetchCompleted) {
this.firstFetchCompleted = true;
}
@@ -386,6 +390,10 @@
if ((this.mysql.getServerStatus() & SERVER_STATUS_LAST_ROW_SENT) != 0) {
this.lastRowFetched = true;
+
+ if (!oldFirstFetchCompleted && this.fetchedRows.size() == 0) {
+ this.wasEmpty = true;
+ }
}
}
}
@@ -437,4 +445,8 @@
return this.owner;
}
+ public boolean wasEmpty() {
+ return this.wasEmpty;
+ }
+
}
Modified: trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -390,6 +390,7 @@
//
if (this.connection.versionMeetsMinimum(5, 0, 2)
+ && this.connection.getUseCursorFetch()
&& isBinaryEncoded
&& callingStatement != null
&& callingStatement.getFetchSize() != 0
Modified: trunk/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -7044,7 +7044,7 @@
// Report on any columns that were selected but
// not referenced
//
- if (this.columnUsed.length > 0) {
+ if (this.columnUsed.length > 0 && !this.rowData.wasEmpty()) {
StringBuffer buf = new StringBuffer(
Messages
.getString("ResultSet.The_following_columns_were__160")); //$NON-NLS-1$
Modified: trunk/connector-j/src/com/mysql/jdbc/RowData.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/RowData.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/RowData.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
@@ -234,4 +234,9 @@
* if a database error occurs
*/
int size() throws SQLException;
+
+ /**
+ * Did this result set have no rows?
+ */
+ boolean wasEmpty();
}
Modified: trunk/connector-j/src/com/mysql/jdbc/RowDataDynamic.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/RowDataDynamic.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/RowDataDynamic.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
@@ -65,6 +65,8 @@
private ResultSet owner;
private boolean streamerClosed = false;
+
+ private boolean wasEmpty = false; // we don't know until we attempt to traverse
// ~ Methods
// ----------------------------------------------------------------
@@ -354,6 +356,7 @@
return ret;
}
+
private void nextRecord() throws SQLException {
try {
@@ -365,6 +368,10 @@
if (this.nextRow == null) {
this.isAtEnd = true;
+
+ if (this.index == -1) {
+ this.wasEmpty = true;
+ }
}
} else {
this.isAfterEnd = true;
@@ -433,4 +440,10 @@
return RESULT_SET_SIZE_UNKNOWN;
}
+ public boolean wasEmpty() {
+ return this.wasEmpty;
+ }
+
+
+
}
Modified: trunk/connector-j/src/com/mysql/jdbc/RowDataStatic.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/RowDataStatic.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/com/mysql/jdbc/RowDataStatic.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
@@ -253,4 +253,8 @@
public int size() {
return this.rows.size();
}
+
+ public boolean wasEmpty() {
+ return (this.rows != null && this.rows.size() == 0);
+ }
}
Modified: trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-11-17 13:46:28 UTC (rev 6040)
+++ trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-11-17 14:15:31 UTC (rev 6041)
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
@@ -3498,4 +3498,35 @@
closeMemberJDBCResources();
}
}
+
+ /**
+ * Tests fix for BUG#24360 .setFetchSize() breaks prepared
+ * SHOW and other commands.
+ *
+ * @throws Exception if the test fails
+ */
+ public void testBug24360() throws Exception {
+ if (!versionMeetsMinimum(5, 0)) {
+ return;
+ }
+
+ Connection c = null;
+
+ Properties props = new Properties();
+ props.setProperty("useServerPrepStmts", "true");
+
+ try {
+ c = getConnectionWithProps(props);
+
+ this.pstmt = c.prepareStatement("SHOW PROCESSLIST");
+ this.pstmt.setFetchSize(5);
+ this.pstmt.execute();
+ } finally {
+ closeMemberJDBCResources();
+
+ if (c != null) {
+ c.close();
+ }
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6041 - in trunk/connector-j: . src/com/mysql/jdbc src/testsuite/regression | mmatthews | 17 Nov |