[ 
https://issues.apache.org/jira/browse/DERBY-991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806150#action_12806150
 ] 

Knut Anders Hatlen commented on DERBY-991:
------------------------------------------

When I said that it worked in PostgreSQL, I was referring to the statement that 
combined PRIMARY KEY and UNIQUE found in Rob's comment.

The statements in Dan's original report fail in PostgreSQL too:

kah=# create table t ( i int, b int, primary key (i,b), primary key (i,b)); 
ERROR:  multiple primary keys for table "t" are not allowed
kah=# create table t ( i int primary key primary key primary key); 
ERROR:  multiple primary keys for table "t" are not allowed
kah=# create table t ( i int, b int, primary key (i,b), primary key (b)); 
ERROR:  multiple primary keys for table "t" are not allowed
kah=# create table t ( i int primary key, b int primary key); 
ERROR:  multiple primary keys for table "t" are not allowed

So I think there are two separate issues being discussed here:

1) What Dan originally reported, which is that Derby fails with the wrong error 
message for some occurrences of multiple primary keys (but it is correct to 
fail).

2) That columns cannot be specified as both PRIMARY KEY and UNIQUE at the same 
time.

Rob, please file a separate JIRA issue to track (2) if you want to see that 
issue addressed. Thanks.

> Defining the same  primary key twice on a table actually attempts to create 
> two constraints.
> --------------------------------------------------------------------------------------------
>
>                 Key: DERBY-991
>                 URL: https://issues.apache.org/jira/browse/DERBY-991
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.2.1.6
>            Reporter: Daniel John Debrunner
>            Priority: Minor
>         Attachments: w.sql
>
>
> Defining the same  primary key twice on a table actually attempts to create 
> two constraints.
> ij> create table t ( i int, b int,  primary key (i,b), primary key (i,b));
> ERROR 42Z93: Constraints 'SQL060215062628851' and 'SQL060215062628850' have 
> the
> same set of columns, which is not allowed.
> ij> create table t ( i int primary key primary key primary key);
> ERROR 42Z93: Constraints 'SQL060214082337951' and 'SQL060214082337950' have 
> the
> same set of columns, which is not allowed.
> Other combinations of two primary keys (that I could think of) return the 
> correct error.
> ij> create table t ( i int, b int,  primary key (i,b), primary key (b));
> ERROR 42X90: More than one primary key constraint specified for table 'T'.
> ij> create table t ( i int primary key, b int primary key);
> ERROR 42X90: More than one primary key constraint specified for table 'T'.

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

Reply via email to