db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3343) Subsequent calls to PreparedStatement cause SQLIntegrityConstraintViolationException on column that is "Generated always"
Date Thu, 24 Jan 2008 09:35:36 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561990#action_12561990

Knut Anders Hatlen commented on DERBY-3343:

The comment in ResultColumn.getOrderableVariantType() says "note that there is no expression
associated with an autoincrement column in an insert statement." As noted by Dyre, this statement
is false, as values(default) will cause a non-null expression also when the column is auto-generated.
I therefore think d3343.diff is a correct fix (it should also update the incorrect comment).
The tests (derbyall + suites.All) ran cleanly.

As to the predicates that are false, I think they could be explained. The default node is
replaced with a placeholder node for the auto-generated value during the bind phase, so it
is correct that isDefaultColumn() returns false. isAutoincrement() seems to be used for columns
that reference an auto-increment column in a table in a select statement, whereas values(default)
doesn't actually reference a column in a table. isGenerated() seems to be used for a different
kind of generated columns than isAutoincrementGenerated() (aggregated columns and internal
helpers like row location columns).

> Subsequent calls to PreparedStatement cause SQLIntegrityConstraintViolationException
on column that is  "Generated always"
> --------------------------------------------------------------------------------------------------------------------------
>                 Key: DERBY-3343
>                 URL: https://issues.apache.org/jira/browse/DERBY-3343
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:
>         Environment: gentoo linux amd64
>            Reporter: William Becker
>            Assignee: Dyre Tjeldvoll
>         Attachments: d3343.diff, defaults.sql
> The following series of statements fails:
> j> connect 'jdbc:derby:test;create=true';
> ij> create table t (id int primary key generated always as identity);
> 0 rows inserted/updated/deleted
> ij> prepare p as 'insert into t(id) values (default)';
> ij> execute p;
> 1 row inserted/updated/deleted
> ij> execute p;
> ERROR 23505: The statement was aborted because it would have caused a duplicate key value
in a unique or primary key constraint or unique index identified by 'SQL080123140906700' defined
on 'T'.
> There is a more detailed discussion about it here: http://www.nabble.com/Generate-Always-and-SQLIntegrityConstraintViolationException-td15012038.html#a15018054

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message