aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Jurka <books@ejurka.com>2005-04-22 14:48:18 +0000
committerKris Jurka <books@ejurka.com>2005-04-22 14:48:18 +0000
commita44f99024c43fa7cb4fb24e62033bc5704e0355c (patch)
tree1b33773979dff671138bbadf936597e980e2ce74
parentf5517ddbdafbb34e7aabd9fe041f1cbb24aad1f5 (diff)
downloadpostgresql-a44f99024c43fa7cb4fb24e62033bc5704e0355c.tar.gz
postgresql-a44f99024c43fa7cb4fb24e62033bc5704e0355c.zip
Updatable ResultSets need to check for an empty ResultSet because
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.
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors.properties1
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/errors.properties b/src/interfaces/jdbc/org/postgresql/errors.properties
index 15689894f18..2ede089016e 100644
--- a/src/interfaces/jdbc/org/postgresql/errors.properties
+++ b/src/interfaces/jdbc/org/postgresql/errors.properties
@@ -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)
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
index 6e182b43bbc..f9660445fba 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -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");
}