Thread

  1. SEQUENCES and COPY FROM

    Mike Embry <membry@nserv.sps.mot.com> — 1998-07-14T20:37:31Z

    In the process of upgrading from 6.1 to 6.3.2+patches at long last.
    Just bumped into an interesting
    problem with sequences.  With 6.1, you could use sequences with COPY
    FROM.  This no longer
    seems to be true with 6.3.2+patches.  INSERT and UPDATE still work fine
    but when using COPY FROM
    all sequence fields are either 0 or NULL.
    
    Can live without but curious if it's a bug or feature?  Maybe fixed in
    6.4?  Wasn't COPY FROM changed
    at the time pg_shadow was added?
    
    Here's the affected schema:
    
    CREATE SEQUENCE history_seq;
    
    CREATE TABLE history (
        gid                   INTEGER,
        state                 TEXT,
        dtin                  DATETIME,
        dtout                DATETIME,
        seqno               INTEGER DEFAULT nextval('history_seq') NOT NULL
    );
    
    MikE
    
    
    
    
  2. Re: [HACKERS] SEQUENCES and COPY FROM

    Vadim Mikheev <vadim@krs.ru> — 1998-07-15T02:29:31Z

    Mike Embry wrote:
    > 
    > In the process of upgrading from 6.1 to 6.3.2+patches at long last.
    > Just bumped into an interesting
    > problem with sequences.  With 6.1, you could use sequences with COPY
    > FROM.  This no longer
    > seems to be true with 6.3.2+patches.  INSERT and UPDATE still work fine
    > but when using COPY FROM
    > all sequence fields are either 0 or NULL.
    > 
    > Can live without but curious if it's a bug or feature?  Maybe fixed in
    > 6.4?  Wasn't COPY FROM changed
    > at the time pg_shadow was added?
    
    Feature...
    DEFAULT is for INSERT only (when column was not specified at all)!
    Use triggers from contrib/spi/autoinc.* - triggers work
    for everything :)
    
    Vadim