Skip to content

Commit 881390f

Browse files
author
Dave Cramer
committed
patch to allow insertRow on an empty resultSet
1 parent 6a5168a commit 881390f

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.postgresql.util.PSQLException;
1616

1717

18-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.5 2002/08/23 20:45:49 barry Exp $
18+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.6 2002/09/01 23:40:36 davec Exp $
1919
* This class defines methods of the jdbc2 specification. This class extends
2020
* org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
2121
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet
@@ -191,10 +191,12 @@ public void beforeFirst() throws SQLException {
191191
}
192192

193193

194-
public boolean first() throws SQLException {
194+
public boolean first() throws SQLException
195+
{
195196
if (rows.size() <= 0)
196197
return false;
197198

199+
onInsertRow = false;
198200
current_row = 0;
199201
this_row = (byte[][]) rows.elementAt(current_row);
200202

@@ -449,16 +451,19 @@ public void setFetchSize(int rows) throws SQLException {
449451
}
450452

451453

452-
public synchronized void cancelRowUpdates() throws SQLException {
453-
if (doingUpdates) {
454+
public synchronized void cancelRowUpdates() throws SQLException
455+
{
456+
if (doingUpdates)
457+
{
454458
doingUpdates = false;
455459

456460
clearRowBuffer();
457461
}
458462
}
459463

460464

461-
public synchronized void deleteRow() throws SQLException {
465+
public synchronized void deleteRow() throws SQLException
466+
{
462467
if ( !isUpdateable() ) {
463468
throw new PSQLException( "postgresql.updateable.notupdateable" );
464469
}
@@ -593,12 +598,15 @@ public synchronized void moveToCurrentRow() throws SQLException {
593598
}
594599

595600

596-
public synchronized void moveToInsertRow() throws SQLException {
597-
if (!updateable) {
601+
public synchronized void moveToInsertRow() throws SQLException
602+
{
603+
if ( !isUpdateable() )
604+
{
598605
throw new PSQLException( "postgresql.updateable.notupdateable" );
599606
}
600607

601-
if (insertStatement != null) {
608+
if (insertStatement != null)
609+
{
602610
insertStatement = null;
603611
}
604612

@@ -612,7 +620,8 @@ public synchronized void moveToInsertRow() throws SQLException {
612620
}
613621

614622

615-
private synchronized void clearRowBuffer() throws SQLException {
623+
private synchronized void clearRowBuffer() throws SQLException
624+
{
616625
// rowBuffer is the temporary storage for the row
617626
rowBuffer = new byte[fields.length][];
618627

@@ -1180,7 +1189,8 @@ private int _findColumn( String columnName ) {
11801189
* Is this ResultSet updateable?
11811190
*/
11821191

1183-
boolean isUpdateable() throws SQLException {
1192+
boolean isUpdateable() throws SQLException
1193+
{
11841194

11851195
if (updateable) return true;
11861196

0 commit comments

Comments
 (0)