db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-789) Usability issue: "Constraints have the same set of columns"
Date Tue, 02 Mar 2010 17:05:27 GMT

     [ https://issues.apache.org/jira/browse/DERBY-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Bryan Pendleton updated DERBY-789:

    Attachment: PrimaryImpliesUnique.diff

I became interested in this issue after seeing several reports that newer
versions of certain common libraries (Hibernate version 3 was mentioned)
are more likely to generate DDL which specifies both PRIMARY KEY and
UNIQUE for the same columns.

Attached is a proposal to alter this behavior.

The patch changes the constraint analysis in TableElementList.validate.

With the new behavior, if the user has specified both PRIMARY KEY and UNIQUE
for the same set of columns, then the UNIQUE is quietly ignored, and only the
PRIMARY KEY is processed.

The patch also contains a single new test case.

With the patch, all the existing tests still pass. However, the new behavior
may be somewhat controversial; I suspect it would be good to have additional
tests that explore the behavior:
 - PRIMARY KEY and UNIQUE on disjoint, but similar, sets of columns
 - multiple UNIQUE constraints on disjoing, but similar, sets of columns
 - columns specified in various orders in the constraints
 - addition and deletion of PRIMARY KEY and UNIQUE constraints

I'll try to think up some more tests to write, but suggestions for additional tests
would be most appreciated.

Comments about the desirability of the new behavior are also welcomed.

> Usability issue: "Constraints have the  same  set of columns"
> -------------------------------------------------------------
>                 Key: DERBY-789
>                 URL: https://issues.apache.org/jira/browse/DERBY-789
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Øystein Grøvlen
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: PrimaryImpliesUnique.diff
> Legolas Woodland reported on derby-user that derby return errors like :
> org.apache.derby.client.am.SqlException:                    Constraints
> 'SQL060103004635123'  and 'SQL060103004635121'  have the  same  set of
> columns, which is not allowed.
> He got this when creating a table like this:
> create  table  WEBSITES (USERID  integer  not  null unique,  WEBSITEID
> bigint  not  null unique,  DOMAINNAME  varchar(255)  not null  unique,
> DESCRIPTION  varchar(255),  PPVIEW   double,  PPCLICK  double,  PPWEEK
> double, totalClick bigint,  totalView bigint, active smallint, primary
> key (WEBSITEID));
> Omitting the unique specifier made things work. 
> I think this is a usability issue.   At least, one should not present names to the user,
that has been generated internally.  Instead, it would be helpful if the names of the columns
involved was mentioned. I see two ways to solve this:
> 1. Return error that says that  duplicate contraints on the following columns are not
> 2. Allow this and use same index for both constraints.  (I guess dropping constraints
will be more complicated in this case since one will have to check if other constraints are
using the same index.)

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

View raw message