Bug #650: using a trigger like a sequence doesn't work

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #650: using a trigger like a sequence doesn't work
Date: 2002-04-26 21:58:02
Message-ID: 20020426215802.712FF4758F0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Wolfgang Messingschlager (w(dot)mess(at)freenet(dot)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('<sequence name>')

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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message medassist 2002-04-27 07:22:57
Previous Message Shra 2002-04-26 19:29:55