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

Commitd3ef753

Browse files
committed
This patch fixes the 0-based/1-based result set indexing problem for
absolute. It also makes it more compliant with the interfacespecification in Sun's documentation;1. absolute(0) should throw an exception.2. absolute(>num-records) should set the current row to after the lastrecord in addition to returning false.3. absolute(<num-records) should set the current row to before the firstrecord in addition to returning false.These operations in the existing code just return false and don't changecurrent_row.These changes required a minor change to relative(int) since it callsabsolute(int)The attached patch is against the cvs repository tree as of this morning.Also, who is in charge of maintaining the jdbc driver? I'm working ongetArray for the jdbc2 driver, but it's going to require three moreclasses to be added to the driver, and thus three more source filesin the repository. Is there someone I can contact directly to ask aboutthis?Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
1 parentbd29cb0 commitd3ef753

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,34 @@ public int findColumn(String columnName) throws SQLException
801801

802802
publicbooleanabsolute(intindex)throwsSQLException
803803
{
804-
// Peter: Added because negative indices read from the end of the
805-
// ResultSet
806-
if(index<0)
807-
index=rows.size()+index;
808-
809-
if (index >rows.size())
804+
// index is 1-based, but internally we use 0-based indices
805+
intinternalIndex;
806+
807+
if (index==0)
808+
thrownewSQLException("Cannot move to index of 0");
809+
810+
//if index<0, count from the end of the result set, but check
811+
//to be sure that it is not beyond the first index
812+
if (index<0)
813+
if (index>=-rows.size())
814+
internalIndex=rows.size()+index;
815+
else {
816+
beforeFirst();
817+
returnfalse;
818+
}
819+
820+
//must be the case that index>0,
821+
//find the correct place, assuming that
822+
//the index is not too large
823+
if (index<=rows.size())
824+
internalIndex =index-1;
825+
else {
826+
afterLast();
810827
returnfalse;
811-
812-
current_row=index;
813-
this_row = (byte [][])rows.elementAt(index);
828+
}
829+
830+
current_row=internalIndex;
831+
this_row = (byte [][])rows.elementAt(internalIndex);
814832
returntrue;
815833
}
816834

@@ -1041,7 +1059,8 @@ public void refreshRow() throws SQLException
10411059
// Peter: Implemented in 7.0
10421060
publicbooleanrelative(introws)throwsSQLException
10431061
{
1044-
returnabsolute(current_row+rows);
1062+
//have to add 1 since absolute expects a 1-based index
1063+
returnabsolute(current_row+1+rows);
10451064
}
10461065

10471066
publicbooleanrowDeleted()throwsSQLException

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp