ALTERed DEFAULTS not visible to PL/pgSQL cached plans - Mailing list pgsql-bugs

From Josh Berkus
Subject ALTERed DEFAULTS not visible to PL/pgSQL cached plans
Date
Msg-id 200603111731.45809.josh@agliodbs.com
Whole thread Raw
Responses Re: ALTERed DEFAULTS not visible to PL/pgSQL cached plans
List pgsql-bugs
Folks,

Version: 8.1.3
Platform: SuSE Linux, GCC
Severity: mild data corruption
Reproducability: 100%

Steps to Reproduce:
(sample code attached)
1) Create a table.
2) Create a function which inserts a row into that table.
3) Run the function once.
4) ALTER the table with a new column and SET DEFAULT for that column.
5) Run the function again.
6) Re-load the function (via REPLACE)
7) Insert one more row using the function.
8) The table will have NULL values in the first TWO rows, not the first ONE
row as it should.   This is because the DEFAULT value is not being "seen"
by the cached plan of the function. As an example, the attached code
produces:

ltreetest=# select * from bugtest;
 id |      name      | is_true
----+----------------+---------
  1 | Before ALTER   |
  2 | Look, its null |
  3 | Now its true.  | t

When it should produce:

ltreetest=# select * from bugtest;
 id |      name      | is_true
----+----------------+---------
  1 | Before ALTER   |
  2 | Look, its null | t
  3 | Now its true.  | t

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-bugs by date:

Previous
From: berndlosert@netscape.net
Date:
Subject: Re: BUG #2310: "ALTER TYPE name OWNER TO new_owner" not working
Next
From: Alvaro Herrera
Date:
Subject: Re: ALTERed DEFAULTS not visible to PL/pgSQL cached plans