[dev] CRITICAL: Postgresql broken(?)

Michael M Slusarz slusarz at horde.org
Thu Mar 24 20:41:23 UTC 2011


Quoting Michael M Slusarz <slusarz at horde.org>:

> Don't want to post a bug yet in case I am missing something obvious,  
> but this change to Horde/Db has completely broken autoincrementing  
> in Postgresql:
>
>
> commit 324f067adc7d36c9efff1641fcd8b08b5c6ad26a
> Author: Jan Schneider <jan at horde.org>
> Date:   Fri Mar 4 14:13:07 2011 +0100
>
>     Changing arbitrary columns to autoincrementing simply doesn't work,
>     because this is not supported by all databases. Use the virtual column
>     type "primaryKey" instead, which does exactly what we want.
>
>
> This is an incorrect statement.  In Postgresql primary keys in  
> postgres are defined as a combination of a unique constraint and a  
> *not-null* constraint.  Obviously, primary keys can not be used for  
> an autoincrementing column, since this column will always be null  
> when adding an entry.
>
> So it looks like another 'virtual column' will need to be created -  
> e.g. 'autoincrementKey'.

Forgot to add - in Postgresql, we need to be using a UNIQUE  
constraint, not a PRIMARY KEY constraint:

http://www.postgresql.org/docs/9.0/static/ddl-constraints.html

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list