Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asCl4-0001dG-W1 for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Apr 2016 17:14:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1asCl3-0007Mh-QI for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Apr 2016 17:14:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asCkQ-0006f8-RD for pgsql-bugs@postgresql.org; Mon, 18 Apr 2016 17:14:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asCkN-0001Wk-NE for pgsql-bugs@postgresql.org; Mon, 18 Apr 2016 17:14:06 +0000 MIME-Version: 1.0 Subject: BUG #14099: Altering temporary sequence in session has no effect To: pgsql-bugs@postgresql.org From: imraan@techie.com Date: Mon, 18 Apr 2016 17:13:47 +0000 Message-ID: <20160418171347.22920.22798@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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