PostgreSQL sequences revisited

From: Kevin Menard (kmenar..ervprise.com)
Date: Thu Aug 02 2007 - 07:08:48 EDT

  • Next message: Andrus Adamchik: "Re: [JIRA] Commented: (CAY-811) Meaningful identity columns: user provided PK values are ignored"

    I'd like to solicit feedback on PostgreSQL sequences, especially from
    Tore. When I added the code to generate PKs from sequences, I think I
    did so rather naively. I assumed sequences were sequences and
    essentially lifted the code from the Oracle PK generator. This was
    simple and easy to digest because it was so similar to Oracle.

    Fast forward a couple years and now I've seen the use of the "serial"
    type to create an int field, a sequence, and set up the default value.
    There's nothing really magical about "serial" and it is very similar to
    what the PostgreSQL PK generator does now. What is different is the
    name of the sequence. Serial types created sequences named in a
    particular format, just as Cayenne does, but neither use the same
    format. This turns out not to be merely cosmetic. The dynamic language
    frameworks with their built-in ORMs can only integrate with a legacy DB
    if the sequences are named appropriately (i.e., I've yet to see one that
    will allow overriding the sequence name as Cayenne does).

    So, is it worth re-visiting the generator to create sequences named the
    same way that "serial" would? Should we simply modify the creation DDL
    to use the serial type (similar to MySQL)? Or should we consider it
    someone else's problem and continue with a "non-standard", but sound, PK
    creation strategy?

    -- 
    Kevin Menard
    Servprise International, Inc.
    800.832.3823 x308
    



    This archive was generated by hypermail 2.0.0 : Thu Aug 02 2007 - 07:09:20 EDT