From: imraan@techie.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14099: Altering temporary sequence in session has no effect
Date: Mon, 18 Apr 2016 17:13:47 +0000
Message-ID: <20160418171347.22920.22798@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14099
Logged by: Imraan Parker
Email address: imraan@techie.com
PostgreSQL version: 9.5.2
Operating system: Linux
Description:
Altering a temporary sequence using ALTER SEQUENCE within a session has no
effect. I am trying to set the starting value of the sequence. All this
happens within a PL/PGSQL function as seen below.
CREATE OR REPLACE FUNCTION _test_seq() RETURNS integer AS
$BODY$
BEGIN
BEGIN
CREATE TEMP SEQUENCE tt_seq;
EXCEPTION WHEN OTHERS THEN
ALTER SEQUENCE tt_seq START 1;
--PERFORM setval('tt_seq', 1);
END;
PERFORM nextval('tt_seq');
PERFORM nextval('tt_seq');
PERFORM nextval('tt_seq');
RETURN currval('tt_seq');
END;
$BODY$ LANGUAGE plpgsql VOLATILE;
SELECT * FROM _test_seq();
Running the function increments the sequence but never sets it back to 1. If
you uncomment the setval(), then it works.
The ALTER SEQUENCE works on 9.1 and 9.3. I do not have a 9.4 instance to
test on so I cannot be sure if the problem is there too.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: imraan@techie.com
Subject: Re: BUG #14099: Altering temporary sequence in session has no effect
In-Reply-To: <20160418171347.22920.22798@wrigleys.postgresql.org>
References: <20160418171347.22920.22798@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox