]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Updatable ResultSets need to check for an empty ResultSet because
authorKris Jurka <books@ejurka.com>
Fri, 22 Apr 2005 14:48:18 +0000 (14:48 +0000)
committerKris Jurka <books@ejurka.com>
Fri, 22 Apr 2005 14:48:18 +0000 (14:48 +0000)
isBeforeFirst and isAfterLast both return false for an empty result
so the checking to make sure the user is on a valid row wasn't
working.

Also don't allow an insert without specifying at least one column
value because INSERT INTO tab() values() is a syntax error.

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

index 15689894f18939de970f8c7abc6adbfade1b7611..2ede089016eaba935ff5189cd89d6182dc1c1ceb 100644 (file)
@@ -94,6 +94,7 @@ postgresql.updateable.beforestartdelete:Before start of result set. Can not call
 postgresql.updateable.afterlastdelete:After end of result set. Can not call deleteRow().
 postgresql.updateable.badupdateposition:Cannot update the result set because it is either before the start or after the end of the results.
 postgresql.updateable.notoninsertrow:Not on insert row.
+postgresql.updateable.noinsertvalues:You must specify at least one column value to insert a row.
 postgresql.updateable.ioerror:Input Stream Error - {0}
 postgresql.call.noreturntype:A CallableStatement Function was declared but no call to 'registerOutParameter (1, <some_type>)' was made.
 postgresql.call.noinout:PostgreSQL only supports function return value [@ 1] (no OUT or INOUT arguments)
index 6e182b43bbc961bebc1307b0376031e3ef0e49fc..f9660445fba0faf7327bd0b92681719afcca6055 100644 (file)
@@ -9,7 +9,7 @@
  * Copyright (c) 2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25.2.11 2005/04/22 14:36:48 jurka Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25.2.12 2005/04/22 14:48:18 jurka Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -617,6 +617,10 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
                {
                        throw new PSQLException( "postgresql.updateable.notoninsertrow" );
                }
+               if (updateValues.size() == 0)
+               {
+                       throw new PSQLException( "postgresql.updateable.noinsertvalues" );
+               }
                else
                {
 
@@ -1011,7 +1015,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
                if (onInsertRow)
                        throw new PSQLException("postgresql.res.oninsertrow");
 
-               if (isBeforeFirst() || isAfterLast())
+               if (isBeforeFirst() || isAfterLast() || rows.size() == 0)
                        return;
 
                StringBuffer selectSQL = new StringBuffer( "select ");
@@ -1081,7 +1085,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
                {
                        throw new PSQLException( "postgresql.updateable.notupdateable" );
                }
-               if (isBeforeFirst() || isAfterLast())
+               if (isBeforeFirst() || isAfterLast() || rows.size() == 0)
                {
                        throw new PSQLException("postgresql.updateable.badupdateposition");
                }
@@ -1592,7 +1596,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
                {
                        throw new PSQLException( "postgresql.updateable.notupdateable" );
                }
-               if (!onInsertRow && (isBeforeFirst() || isAfterLast()))
+               if (!onInsertRow && (isBeforeFirst() || isAfterLast() || rows.size() == 0))
                {
                        throw new PSQLException("postgresql.updateable.badupdateposition");
                }