db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Korneliussen (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-231) "FOR UPDATE" required for updatable result set to work
Date Thu, 27 Oct 2005 15:49:02 GMT
    [ http://issues.apache.org/jira/browse/DERBY-231?page=comments#action_12356096 ] 

Andreas Korneliussen commented on DERBY-231:

Currently, the updatemode for the resultset node is determined in the bind() phase of the
query compilation. If the updatability clause is unspecified, the updatemode is set to READ_ONLY.

To get rid of the requirement of having "for update" in the query string, I plan doing the
following :

1. In the bind() phase, the nodes do currently not have any information about the concurrency
mode for the java.sql.Statement object.  I would like to provide a mechanism to bring it down
to the compiler by adding a field to the StatementContext object.

2. If the concurrency mode for the java.sql.Statement object is CONCUR_READ_ONLY, the updatemode
will be set to READ_ONLY. If the query string contains "for update" an error will be thrown.

3. If the concurrency mode for the Statement object is CONCUR_UPDATABLE, the updatemode will
be UPDATABLE if the resultset can be updatable (i.e contains no joins, order by etc). Otherwise
it will be READ_ONLY and a warning will be given. 

4. Lockmodes: I do not plan to make any distinction between "for update" and unspecified updatability
clause when it comes to determining the lock mode.

It seems important that the update mode is determined in the bind() phase, because the compiler
can do some optimizations if the cursor is not updatable (i.e not produce a target resultset).

> "FOR UPDATE" required for updatable result set to work
> ------------------------------------------------------
>          Key: DERBY-231
>          URL: http://issues.apache.org/jira/browse/DERBY-231
>      Project: Derby
>         Type: Improvement
>   Components: SQL
>     Versions:
>     Reporter: Dag H. Wanvik
>     Assignee: Andreas Korneliussen
>     Priority: Minor
>  Attachments: fff
> To get an updatable result set, the JDBC 3.0 spec, section 14.2.4 
> "Modifying ResultSet Objects" states: 
>     "ResultSet objects with concurrency CONCUR_UPDATABLE can be updated
>      using ResultSet objects".
> In addition, Derby requires the SQL SELECT statement to have a "FOR
> UPDATE" clause for updates to be allowed. This may be a usability issue, as
> many examples, e.g. in "JDBC API tutorial and reference and reference"
> book and the JDBC 3.0 Specification ( do not include a "FOR
> UPDATE" clause in the SQL SELECT.
> Mamta Satoor says:
> "Derby implements the JDBC updatable resultset by using the existing
>  updatable cursor implementation. And in order to do that, it requires
>  that the SELECT statement should include the FOR UPDATE clause. One
>  can change the Derby implementation so that it does not require FOR
>  UPDATE clause to piggyback on updatable cursor implementation."
> Dan DeBrunner says:
> "Technically I wonder if this is covered by the JDBC standard, I see
>  nothing in the JDBC 3.0 that states any requirements for the SQL
>  statement for an updateable result set. I know the JDBC tutorial book
>  has some guidelines as to what will typically work, but isn't it up to
>  the database engine to define what works here?
>  Having said that I think that not requiring the FOR UPDATE would be a
>  useful improvement."

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message