Bug #650: using a trigger like a sequence doesn't work - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Bug #650: using a trigger like a sequence doesn't work
Date
Msg-id 20020426215802.712FF4758F0@postgresql.org
Whole thread Raw
Responses mistakes in postgresql-snapshots (7.3)  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
List pgsql-bugs
Wolfgang Messingschlager (w.mess@freenet.de) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
using a trigger like a sequence doesn't work

Long Description
The purpose of my trigger is to build the same as a sequence, but it is not necessary to use every time
nextval('<sequencename>') 

Sample Code
> createlang plpgsql test
> psql test
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

test=# drop   table person ;
DROP
test=# create table person (person_id       integer PRIMARY KEY,
test(# vorname         VARCHAR(40), name            VARCHAR(40) );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'person_pkey' for table 'person'
CREATE
test=# drop   table person_id ;
DROP
test=# create table person_id ( person_id      integer);
CREATE
test=# insert into person_id values (0);
INSERT 16701 1
test=# create or replace function before_insert_person_id () returns opaque
test-# as 'Begin
test'#         update person_id set person_id = person_id + 1;
test'#         select into NEW.person_id person_id from person_id;
test'# End;'
test-# LANGUAGE 'plpgsql';
CREATE
test=# create trigger person_id before insert on person for each row
test-#         EXECUTE PROCEDURE  before_insert_person_id ();
CREATE
test=# insert into person (vorname, name)  values ('John', 'Miller');
NOTICE:  Error occurred while executing PL/pgSQL function before_insert_person_id
NOTICE:  at END of toplevel PL block
ERROR:  control reaches end of trigger procedure without RETURN
test=# 


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: regular expression and index on 7.2
Next
From: Shra
Date:
Subject: ...