Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
7ecb6ede
Commit
7ecb6ede
authored
Oct 29, 2003
by
Dave Cramer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patches from Oliver Jowett to fix CursorFetchTest, 7.4 now does not automatically delete cursors
parent
15c6764b
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
416 additions
and
235 deletions
+416
-235
src/interfaces/jdbc/org/postgresql/core/BaseConnection.java
src/interfaces/jdbc/org/postgresql/core/BaseConnection.java
+2
-2
src/interfaces/jdbc/org/postgresql/core/BaseStatement.java
src/interfaces/jdbc/org/postgresql/core/BaseStatement.java
+3
-3
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
...es/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
+2
-3
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
...ces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
+46
-25
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
...ces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
+250
-187
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
...ces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+1
-15
src/interfaces/jdbc/org/postgresql/test/jdbc2/CursorFetchTest.java
...faces/jdbc/org/postgresql/test/jdbc2/CursorFetchTest.java
+112
-0
No files found.
src/interfaces/jdbc/org/postgresql/core/BaseConnection.java
View file @
7ecb6ede
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.
3 2003/05/29 03:21:32 barry
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.
4 2003/10/29 02:39:09 davec
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -26,7 +26,7 @@ public interface BaseConnection extends PGConnection
...
@@ -26,7 +26,7 @@ public interface BaseConnection extends PGConnection
public
void
cancelQuery
()
throws
SQLException
;
public
void
cancelQuery
()
throws
SQLException
;
public
Statement
createStatement
()
throws
SQLException
;
public
Statement
createStatement
()
throws
SQLException
;
public
BaseResultSet
execSQL
(
String
s
)
throws
SQLException
;
public
BaseResultSet
execSQL
(
String
s
)
throws
SQLException
;
public
boolean
getAutoCommit
()
throws
SQLException
;
public
boolean
getAutoCommit
();
public
String
getCursorName
()
throws
SQLException
;
public
String
getCursorName
()
throws
SQLException
;
public
Encoding
getEncoding
()
throws
SQLException
;
public
Encoding
getEncoding
()
throws
SQLException
;
public
DatabaseMetaData
getMetaData
()
throws
SQLException
;
public
DatabaseMetaData
getMetaData
()
throws
SQLException
;
...
...
src/interfaces/jdbc/org/postgresql/core/BaseStatement.java
View file @
7ecb6ede
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.
5 2003/08/24 22:10:09 barry
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.
6 2003/10/29 02:39:09 davec
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -30,11 +30,11 @@ public interface BaseStatement extends org.postgresql.PGStatement
...
@@ -30,11 +30,11 @@ public interface BaseStatement extends org.postgresql.PGStatement
*/
*/
public
void
addWarning
(
String
p_warning
)
throws
SQLException
;
public
void
addWarning
(
String
p_warning
)
throws
SQLException
;
public
void
close
()
throws
SQLException
;
public
void
close
()
throws
SQLException
;
public
int
getFetchSize
()
throws
SQLException
;
public
int
getFetchSize
();
public
int
getMaxFieldSize
()
throws
SQLException
;
public
int
getMaxFieldSize
()
throws
SQLException
;
public
int
getMaxRows
()
throws
SQLException
;
public
int
getMaxRows
()
throws
SQLException
;
public
int
getResultSetConcurrency
()
throws
SQLException
;
public
int
getResultSetConcurrency
()
throws
SQLException
;
public
String
get
Statement
Name
();
public
String
get
FetchingCursor
Name
();
public
SQLWarning
getWarnings
()
throws
SQLException
;
public
SQLWarning
getWarnings
()
throws
SQLException
;
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
;
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
View file @
7ecb6ede
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.2
6 2003/09/13 04:02:15 barry
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.2
7 2003/10/29 02:39:09 davec
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1270,10 +1270,9 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
...
@@ -1270,10 +1270,9 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
* gets the current auto-commit state
* gets the current auto-commit state
*
*
* @return Current state of the auto-commit mode
* @return Current state of the auto-commit mode
* @exception SQLException (why?)
* @see setAutoCommit
* @see setAutoCommit
*/
*/
public
boolean
getAutoCommit
()
throws
SQLException
public
boolean
getAutoCommit
()
{
{
return
this
.
autoCommit
;
return
this
.
autoCommit
;
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
View file @
7ecb6ede
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.2
1 2003/09/22 04:54:59 barry
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.2
2 2003/10/29 02:39:09 davec
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -61,6 +61,9 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -61,6 +61,9 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
private
SimpleDateFormat
m_tstzFormat
=
null
;
private
SimpleDateFormat
m_tstzFormat
=
null
;
private
SimpleDateFormat
m_dateFormat
=
null
;
private
SimpleDateFormat
m_dateFormat
=
null
;
private
int
fetchSize
;
// Fetch size for next read (might be 0).
private
int
lastFetchSize
;
// Fetch size of last read (might be 0).
public
abstract
ResultSetMetaData
getMetaData
()
throws
SQLException
;
public
abstract
ResultSetMetaData
getMetaData
()
throws
SQLException
;
public
AbstractJdbc1ResultSet
(
BaseStatement
statement
,
public
AbstractJdbc1ResultSet
(
BaseStatement
statement
,
...
@@ -82,6 +85,8 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -82,6 +85,8 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
this
.
this_row
=
null
;
this
.
this_row
=
null
;
this
.
current_row
=
-
1
;
this
.
current_row
=
-
1
;
this
.
binaryCursor
=
binaryCursor
;
this
.
binaryCursor
=
binaryCursor
;
this
.
lastFetchSize
=
this
.
fetchSize
=
(
statement
==
null
?
0
:
statement
.
getFetchSize
());
}
}
public
BaseStatement
getPGStatement
()
{
public
BaseStatement
getPGStatement
()
{
...
@@ -112,6 +117,20 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -112,6 +117,20 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
this
.
binaryCursor
=
binaryCursor
;
this
.
binaryCursor
=
binaryCursor
;
}
}
//
// Part of the JDBC2 support, but convenient to implement here.
//
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
fetchSize
=
rows
;
}
public
int
getFetchSize
()
throws
SQLException
{
return
fetchSize
;
}
public
boolean
next
()
throws
SQLException
public
boolean
next
()
throws
SQLException
{
{
...
@@ -120,30 +139,32 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
...
@@ -120,30 +139,32 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
if
(++
current_row
>=
rows
.
size
())
if
(++
current_row
>=
rows
.
size
())
{
{
int
fetchSize
=
statement
.
getFetchSiz
e
();
String
cursorName
=
statement
.
getFetchingCursorNam
e
();
// Must be false if we weren't batching.
if
(
cursorName
==
null
||
lastFetchSize
==
0
||
rows
.
size
()
<
lastFetchSize
)
if
(
fetchSize
==
0
)
return
false
;
// Not doing a cursor-based fetch or the last fetch was the end of the query
return
false
;
// Use the ref to the statement to get
// Use the ref to the statement to get
// the details we need to do another cursor
// the details we need to do another cursor
// query - it will use reinit() to repopulate this
// query - it will use reinit() to repopulate this
// with the right data.
// with the right data.
String
[]
sql
=
new
String
[
1
];
String
[]
binds
=
new
String
[
0
];
// NB: We can reach this point with fetchSize == 0
// Is this the correct query???
// if the fetch size is changed halfway through reading results.
String
cursorName
=
statement
.
getStatementName
();
// Use "FETCH FORWARD ALL" in that case to complete the query.
//if cursorName is null, we are not batching (likely because the
String
[]
sql
=
new
String
[]
{
//query itself can't be batched)
fetchSize
==
0
?
(
"FETCH FORWARD ALL FROM "
+
cursorName
)
:
if
(
cursorName
==
null
)
(
"FETCH FORWARD "
+
fetchSize
+
" FROM "
+
cursorName
)
return
false
;
}
;
sql
[
0
]
=
"FETCH FORWARD "
+
fetchSize
+
" FROM "
+
cursorName
;
QueryExecutor
.
execute
(
sql
,
QueryExecutor
.
execute
(
sql
,
binds
,
new
String
[
0
]
,
this
);
this
);
// Test the new rows array.
// Test the new rows array.
lastFetchSize
=
fetchSize
;
if
(
rows
.
size
()
==
0
)
if
(
rows
.
size
()
==
0
)
return
false
;
return
false
;
// Otherwise reset the counter and let it go on...
// Otherwise reset the counter and let it go on...
current_row
=
0
;
current_row
=
0
;
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
View file @
7ecb6ede
This diff is collapsed.
Click to expand it.
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
View file @
7ecb6ede
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
* Copyright (c) 2003, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.2
4 2003/09/17 05:14:52 barry
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.2
5 2003/10/29 02:39:09 davec
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -389,13 +389,6 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
...
@@ -389,13 +389,6 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
}
public
int
getFetchSize
()
throws
SQLException
{
// Returning the current batch size seems the right thing to do.
return
rows
.
size
();
}
public
Object
getObject
(
String
columnName
,
java
.
util
.
Map
map
)
throws
SQLException
public
Object
getObject
(
String
columnName
,
java
.
util
.
Map
map
)
throws
SQLException
{
{
return
getObject
(
findColumn
(
columnName
),
map
);
return
getObject
(
findColumn
(
columnName
),
map
);
...
@@ -518,13 +511,6 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
...
@@ -518,13 +511,6 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
}
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
// Sub-classes should implement this as part of their cursor support
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
public
synchronized
void
cancelRowUpdates
()
public
synchronized
void
cancelRowUpdates
()
throws
SQLException
throws
SQLException
{
{
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/CursorFetchTest.java
View file @
7ecb6ede
...
@@ -51,7 +51,10 @@ public class CursorFetchTest extends TestCase
...
@@ -51,7 +51,10 @@ public class CursorFetchTest extends TestCase
int
[]
testSizes
=
{
0
,
1
,
49
,
50
,
51
,
99
,
100
,
101
};
int
[]
testSizes
=
{
0
,
1
,
49
,
50
,
51
,
99
,
100
,
101
};
for
(
int
i
=
0
;
i
<
testSizes
.
length
;
++
i
)
{
for
(
int
i
=
0
;
i
<
testSizes
.
length
;
++
i
)
{
stmt
.
setFetchSize
(
testSizes
[
i
]);
stmt
.
setFetchSize
(
testSizes
[
i
]);
assertEquals
(
testSizes
[
i
],
stmt
.
getFetchSize
());
ResultSet
rs
=
stmt
.
executeQuery
();
ResultSet
rs
=
stmt
.
executeQuery
();
assertEquals
(
testSizes
[
i
],
rs
.
getFetchSize
());
int
count
=
0
;
int
count
=
0
;
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
...
@@ -63,6 +66,115 @@ public class CursorFetchTest extends TestCase
...
@@ -63,6 +66,115 @@ public class CursorFetchTest extends TestCase
}
}
}
}
//
// Tests for ResultSet.setFetchSize().
//
// test one:
// set fetchsize = 0
// run query (all rows should be fetched)
// set fetchsize = 50 (should have no effect)
// process results
public
void
testResultSetFetchSizeOne
()
throws
Exception
{
createRows
(
100
);
PreparedStatement
stmt
=
con
.
prepareStatement
(
"select * from test_fetch order by value"
);
stmt
.
setFetchSize
(
0
);
ResultSet
rs
=
stmt
.
executeQuery
();
stmt
.
setFetchSize
(
50
);
// Should have no effect.
int
count
=
0
;
while
(
rs
.
next
())
{
assertEquals
(
count
,
rs
.
getInt
(
1
));
++
count
;
}
assertEquals
(
100
,
count
);
}
// test two:
// set fetchsize = 25
// run query (25 rows fetched)
// set fetchsize = 0
// process results:
// process 25 rows
// should do a FETCH ALL to get more data
// process 75 rows
public
void
testResultSetFetchSizeTwo
()
throws
Exception
{
createRows
(
100
);
PreparedStatement
stmt
=
con
.
prepareStatement
(
"select * from test_fetch order by value"
);
stmt
.
setFetchSize
(
25
);
ResultSet
rs
=
stmt
.
executeQuery
();
stmt
.
setFetchSize
(
0
);
int
count
=
0
;
while
(
rs
.
next
())
{
assertEquals
(
count
,
rs
.
getInt
(
1
));
++
count
;
}
assertEquals
(
100
,
count
);
}
// test three:
// set fetchsize = 25
// run query (25 rows fetched)
// set fetchsize = 50
// process results:
// process 25 rows. should NOT hit end-of-results here.
// do a FETCH FORWARD 50
// process 50 rows
// do a FETCH FORWARD 50
// process 25 rows. end of results.
public
void
testResultSetFetchSizeThree
()
throws
Exception
{
createRows
(
100
);
PreparedStatement
stmt
=
con
.
prepareStatement
(
"select * from test_fetch order by value"
);
stmt
.
setFetchSize
(
25
);
ResultSet
rs
=
stmt
.
executeQuery
();
stmt
.
setFetchSize
(
50
);
int
count
=
0
;
while
(
rs
.
next
())
{
assertEquals
(
count
,
rs
.
getInt
(
1
));
++
count
;
}
assertEquals
(
100
,
count
);
}
// test four:
// set fetchsize = 50
// run query (50 rows fetched)
// set fetchsize = 25
// process results:
// process 50 rows.
// do a FETCH FORWARD 25
// process 25 rows
// do a FETCH FORWARD 25
// process 25 rows. end of results.
public
void
testResultSetFetchSizeFour
()
throws
Exception
{
createRows
(
100
);
PreparedStatement
stmt
=
con
.
prepareStatement
(
"select * from test_fetch order by value"
);
stmt
.
setFetchSize
(
50
);
ResultSet
rs
=
stmt
.
executeQuery
();
stmt
.
setFetchSize
(
25
);
int
count
=
0
;
while
(
rs
.
next
())
{
assertEquals
(
count
,
rs
.
getInt
(
1
));
++
count
;
}
assertEquals
(
100
,
count
);
}
// Test odd queries that should not be transformed into cursor-based fetches.
// Test odd queries that should not be transformed into cursor-based fetches.
public
void
TODO_FAILS_testInsert
()
throws
Exception
public
void
TODO_FAILS_testInsert
()
throws
Exception
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment