Marc Balmer (marc@msys.ch) reports a bug with a severity of 2
The lower the number the more severe it is.
Short Description
create table xy as select a,b from t_a left join t_b on cond fails in PL/pgSQL
Long Description
A SQL statement "create table t2 as select a,b from t_a left join t_b on <condition>;" works as expected when entered
inpsql but fails if it is part of PL/pgSQL function.
If executed in a PL/pgSQL function, the result table t2 will be created with columns a and b but only the values of a
areinserted, column b remains empty in all rows.
Sample Code
-- works in psql, fails in PL/pgsql
create table datum (datum date);
create table termin (datum date, titel varchar(64), i integer);
create table t2 as select datum.datum,termin.titel from datum
left join termin on datum.datum >= termin.datum
and ((datum.datum - termin.datum) % i = 0)
and (enddatum >= datum.datum or enddatum = null);
No file was uploaded with this report