From: | "Florian G(dot) Pflug" <fgp(at)phlo(dot)org> |
---|---|
To: | Postgresql-Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | column DEFAULTs and prepared statements |
Date: | 2009-11-20 02:21:34 |
Message-ID: | 4B05FD2E.5030101@phlo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi
While trying to come up with a patch to handle domain DEFAULTs in
plpgsql I've stumbled across the following behavior regarding domain
DEFAULTs and prepared statements.
session 1: create domain myint as int default 0 ;
session 1: create table mytable (i myint) ;
session 2: prepare ins as insert into mytable (i) values (default);
session 2: execute ins;
session 1: alter domain myint set default 1;
session 2: execute ins;
select * from mytable returns:
i
---
0
0
while I'd have expected:
i
---
0
1
After doing the same without using a domain
session 1: create table mytable (i myint default 0) ;
session 2: prepare ins as insert into mytable (i) values (default);
session 2: execute ins;
session 1: alter table mytable alter column i default 1;
session 2: execute ins;
select * from mytable returns:
i
---
0
1
As far as I understand the code this happens because the dependency on
the domain (for the default value) is not recorded in the plan cache
entry. This would imply that the same error also occurs if the INSERT
happens from a pl/pgsql function instead of a manually prepared
statement, but I haven't tested that.
If someone gives me a general idea where to start, I could try to come
up with a patch
best regards,
Florian Pflug
From | Date | Subject | |
---|---|---|---|
Next Message | Kenneth Marshall | 2009-11-20 02:27:45 | Re: Union test case broken in make check? |
Previous Message | Joshua D. Drake | 2009-11-20 02:18:50 | Re: Summary and Plan for Hot Standby |