pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: konst583@gmail.com
To: pgsql-bugs@postgresql.org
Cc: konst583@gmail.com
Subject: BUG #14879: Bug connected with table structure modification and trigger function query plan invalidation
Date: Mon, 30 Oct 2017 12:53:45 +0000
Message-ID: <20171030125345.1448.24038@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:      14879
Logged by:          Konstantin Evteev
Email address:      konst583@gmail.com
PostgreSQL version: 9.4.12
Operating system:    Debian GNU/Linux 8 (jessie)
Description:        

There is a bug connected with table structure modification and trigger
function query plan invalidation:

1) 1st session - create table:
create table test(test_id int, new_test_id bigint)

2) 1st session - create func and trigger after insert or update

CREATE OR REPLACE FUNCTION test_trg_func()
  RETURNS trigger AS
$BODY$

begin

    NEW.new_test_id = NEW.test_id;
    return NEW;

end;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

CREATE TRIGGER test_trg
  BEFORE INSERT OR UPDATE
  ON test
  FOR EACH ROW
  EXECUTE PROCEDURE test_trg_func();


3) 1st session  
insert into test (test_id) values (5)

4) 2nd session(another session) alter table :

    alter table test rename column test_id to old_test_id;
    alter table test rename column new_test_id to test_id;
    alter table test rename column old_test_id to new_test_id;

5) 1st session:

insert into test (test_id) values (5)

ERROR:  type of parameter 15 (bigint) does not match that when preparing the
plan (integer)
CONTEXT:  PL/pgSQL function test_trg_func() line 5 at assignment

********** Error **********

ERROR: type of parameter 15 (bigint) does not match that when preparing the
plan (integer)
SQL state: 42804
Context: PL/pgSQL function test_trg_func() line 5 at assignment

-----------------------------------------

Workaround - recreate trg_func to invalidate plan





-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Message-ID: <20171030125345.1448.24038@wrigleys.postgresql.org>
Permalink:  ../20171030125345.1448.24038@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20171030125345.1448.24038@wrigleys.postgresql.org

 · 

reply

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: konst583@gmail.com
  Subject: Re: BUG #14879: Bug connected with table structure modification and trigger function query plan invalidation
  In-Reply-To: <20171030125345.1448.24038@wrigleys.postgresql.org>
  References: <20171030125345.1448.24038@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