1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +03:00

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.
This commit is contained in:
Kris Jurka 2005-04-22 14:48:18 +00:00
parent f5517ddbda
commit a44f99024c
2 changed files with 9 additions and 4 deletions

View 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)

View 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");
}