Re: [PATCHES] Add checking in setMaxRows, setQueryTimeout, and setFetchSize

From: Barry Lind <blind(at)xythos(dot)com>
To: Kim Ho <kho(at)redhat(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, pgsql-jdbc-list <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [PATCHES] Add checking in setMaxRows, setQueryTimeout, and setFetchSize
Date: 2003-06-30 16:40:13
Message-ID: 3F0067ED.30502@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches

Patch applied.

--Barry

Kim Ho wrote:
> Problem:
> - If you try to setMaxRows(), setQueryTimeout() or setFetchSize()
> to negative values, it should throw an exception, but doesn't. JDBC CTS
> test failures.
>
> Fix:
> - Added new error messages to errors.properties file.
> - PSQLExceptions thrown when user attempts to set negative values.
>
> Cheers,
>
> Kim
>
>
>
>
> ------------------------------------------------------------------------
>
> ? cloudscape.LOG
> Index: org/postgresql/errors.properties
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/errors.properties,v
> retrieving revision 1.20
> diff -c -p -c -p -r1.20 errors.properties
> *** org/postgresql/errors.properties 29 May 2003 03:21:32 -0000 1.20
> --- org/postgresql/errors.properties 18 Jun 2003 12:38:29 -0000
> *************** postgresql.call.funcover:Cannot execute
> *** 97,99 ****
> --- 97,102 ----
> postgresql.call.wrongget:Parameter of type {0} was registered but call to get{1} (sqltype={2}) was made.
> postgresql.call.noreturnval:A CallableStatement Function was executed with nothing returned.
> postgresql.call.wrongrtntype:A CallableStatement Function was executed and the return was of type ({0}) however type={1} was registered.
> + postgresql.input.fetch.gt0:Fetch size must be a value greater than or equal to 0.
> + postgresql.input.query.gt0:Query Timeout must be a value greater than or equal to 0.
> + postgresql.input.rows.gt0:Maximum number of rows must be a value greater than or equal to 0.
> Index: org/postgresql/jdbc1/AbstractJdbc1Statement.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v
> retrieving revision 1.24
> diff -c -p -c -p -r1.24 AbstractJdbc1Statement.java
> *** org/postgresql/jdbc1/AbstractJdbc1Statement.java 29 May 2003 04:52:44 -0000 1.24
> --- org/postgresql/jdbc1/AbstractJdbc1Statement.java 18 Jun 2003 12:38:30 -0000
> *************** public abstract class AbstractJdbc1State
> *** 554,559 ****
> --- 554,560 ----
> */
> public void setMaxRows(int max) throws SQLException
> {
> + if (max<0) throw new PSQLException("postgresql.input.rows.gt0");
> maxrows = max;
> }
>
> *************** public abstract class AbstractJdbc1State
> *** 590,595 ****
> --- 591,597 ----
> */
> public void setQueryTimeout(int seconds) throws SQLException
> {
> + if (seconds<0) throw new PSQLException("postgresql.input.query.gt0");
> timeout = seconds;
> }
>
> Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v
> retrieving revision 1.14
> diff -c -p -c -p -r1.14 AbstractJdbc2Statement.java
> *** org/postgresql/jdbc2/AbstractJdbc2Statement.java 29 May 2003 04:52:44 -0000 1.14
> --- org/postgresql/jdbc2/AbstractJdbc2Statement.java 18 Jun 2003 12:38:30 -0000
> *************** public abstract class AbstractJdbc2State
> *** 151,156 ****
> --- 151,157 ----
>
> public void setFetchSize(int rows) throws SQLException
> {
> + if (rows<0) throw new PSQLException("postgresql.input.fetch.gt0");
> super.fetchSize = rows;
> }
>
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2003-06-30 16:41:17 Re: [PATCHES] IPv6 patch doesn't work fine
Previous Message Garrick Dasbach 2003-06-30 14:07:55 Re: java.lang.NullPointerException on imbricated queries

Browse pgsql-patches by date

  From Date Subject
Next Message Barry Lind 2003-06-30 16:41:17 Re: [PATCHES] IPv6 patch doesn't work fine
Previous Message Josh Berkus 2003-06-30 16:35:51 Postgresql.conf, initdb patch