Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ecb6ed

Browse files
author
Dave Cramer
committed
Patches from Oliver Jowett to fix CursorFetchTest, 7.4 now does not automatically delete cursors
1 parent15c6764 commit7ecb6ed

File tree

7 files changed

+416
-235
lines changed

7 files changed

+416
-235
lines changed

‎src/interfaces/jdbc/org/postgresql/core/BaseConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.3 2003/05/2903:21:32 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.4 2003/10/2902:39:09 davec Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -26,7 +26,7 @@ public interface BaseConnection extends PGConnection
2626
publicvoidcancelQuery()throwsSQLException;
2727
publicStatementcreateStatement()throwsSQLException;
2828
publicBaseResultSetexecSQL(Strings)throwsSQLException;
29-
publicbooleangetAutoCommit()throwsSQLException;
29+
publicbooleangetAutoCommit();
3030
publicStringgetCursorName()throwsSQLException;
3131
publicEncodinggetEncoding()throwsSQLException;
3232
publicDatabaseMetaDatagetMetaData()throwsSQLException;

‎src/interfaces/jdbc/org/postgresql/core/BaseStatement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.5 2003/08/24 22:10:09barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.6 2003/10/29 02:39:09davec Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -30,11 +30,11 @@ public interface BaseStatement extends org.postgresql.PGStatement
3030
*/
3131
publicvoidaddWarning(Stringp_warning)throwsSQLException;
3232
publicvoidclose()throwsSQLException;
33-
publicintgetFetchSize()throwsSQLException;
33+
publicintgetFetchSize();
3434
publicintgetMaxFieldSize()throwsSQLException;
3535
publicintgetMaxRows()throwsSQLException;
3636
publicintgetResultSetConcurrency()throwsSQLException;
37-
publicStringgetStatementName();
37+
publicStringgetFetchingCursorName();
3838
publicSQLWarninggetWarnings()throwsSQLException;
3939
publicvoidsetMaxFieldSize(intmax)throwsSQLException;
4040

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.26 2003/09/13 04:02:15 barry Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.27 2003/10/2902:39:09 davec Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1270,10 +1270,9 @@ public void setAutoCommit(boolean autoCommit) throws SQLException
12701270
* gets the current auto-commit state
12711271
*
12721272
* @return Current state of the auto-commit mode
1273-
* @exception SQLException (why?)
12741273
* @see setAutoCommit
12751274
*/
1276-
publicbooleangetAutoCommit()throwsSQLException
1275+
publicbooleangetAutoCommit()
12771276
{
12781277
returnthis.autoCommit;
12791278
}

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.21 2003/09/22 04:54:59 barry Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.22 2003/10/29 02:39:09 davec Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -61,6 +61,9 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
6161
privateSimpleDateFormatm_tstzFormat =null;
6262
privateSimpleDateFormatm_dateFormat =null;
6363

64+
privateintfetchSize;// Fetch size for next read (might be 0).
65+
privateintlastFetchSize;// Fetch size of last read (might be 0).
66+
6467
publicabstractResultSetMetaDatagetMetaData()throwsSQLException;
6568

6669
publicAbstractJdbc1ResultSet(BaseStatementstatement,
@@ -82,6 +85,8 @@ public AbstractJdbc1ResultSet(BaseStatement statement,
8285
this.this_row =null;
8386
this.current_row = -1;
8487
this.binaryCursor =binaryCursor;
88+
89+
this.lastFetchSize =this.fetchSize = (statement ==null ?0 :statement.getFetchSize());
8590
}
8691

8792
publicBaseStatementgetPGStatement() {
@@ -111,7 +116,21 @@ public void reInit (Field[] fields, Vector tuples, String status,
111116
this.current_row = -1;
112117
this.binaryCursor =binaryCursor;
113118
}
119+
120+
//
121+
// Part of the JDBC2 support, but convenient to implement here.
122+
//
114123

124+
publicvoidsetFetchSize(introws)throwsSQLException
125+
{
126+
fetchSize =rows;
127+
}
128+
129+
130+
publicintgetFetchSize()throwsSQLException
131+
{
132+
returnfetchSize;
133+
}
115134

116135
publicbooleannext()throwsSQLException
117136
{
@@ -120,30 +139,32 @@ public boolean next() throws SQLException
120139

121140
if (++current_row >=rows.size())
122141
{
123-
intfetchSize =statement.getFetchSize();
124-
// Must be false if we weren't batching.
125-
if (fetchSize ==0)
126-
returnfalse;
127-
// Use the ref to the statement to get
128-
// the details we need to do another cursor
129-
// query - it will use reinit() to repopulate this
130-
// with the right data.
131-
String[]sql =newString[1];
132-
String[]binds =newString[0];
133-
// Is this the correct query???
134-
StringcursorName =statement.getStatementName();
135-
//if cursorName is null, we are not batching (likely because the
136-
//query itself can't be batched)
137-
if (cursorName ==null)
138-
returnfalse;
139-
sql[0] ="FETCH FORWARD " +fetchSize +" FROM " +cursorName;
140-
QueryExecutor.execute(sql,
141-
binds,
142-
this);
143-
144-
// Test the new rows array.
145-
if (rows.size() ==0)
146-
returnfalse;
142+
StringcursorName =statement.getFetchingCursorName();
143+
if (cursorName ==null ||lastFetchSize ==0 ||rows.size() <lastFetchSize)
144+
returnfalse;// Not doing a cursor-based fetch or the last fetch was the end of the query
145+
146+
// Use the ref to the statement to get
147+
// the details we need to do another cursor
148+
// query - it will use reinit() to repopulate this
149+
// with the right data.
150+
151+
// NB: We can reach this point with fetchSize == 0
152+
// if the fetch size is changed halfway through reading results.
153+
// Use "FETCH FORWARD ALL" in that case to complete the query.
154+
String[]sql =newString[] {
155+
fetchSize ==0 ? ("FETCH FORWARD ALL FROM " +cursorName) :
156+
("FETCH FORWARD " +fetchSize +" FROM " +cursorName)
157+
};
158+
159+
QueryExecutor.execute(sql,
160+
newString[0],
161+
this);
162+
163+
// Test the new rows array.
164+
lastFetchSize =fetchSize;
165+
if (rows.size() ==0)
166+
returnfalse;
167+
147168
// Otherwise reset the counter and let it go on...
148169
current_row =0;
149170
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp