differences between function returning 'setof table' and 'table'

From: Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar>
To: pgsql-sql(at)postgresql(dot)org
Subject: differences between function returning 'setof table' and 'table'
Date: 2010-06-24 22:26:14
Message-ID: 4C23DB86.5040805@fmed.uba.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all. I dont understand why this is happening. Simple hardcoded
function, looking for an id who doesn't exists:

REATE FUNCTION pp()
returns setof public.pp
as
$$
select * from public.pp where id=999999;
$$ language sql;

So there is no id=99999 in table public.pp
test=# SELECT * from pp();
id| descripcion|
------------+-------------+
(0 filas)

Great

Now, when the function is defined to return
`returns public.pp', when i execute it...

test=# SELECT * from pp();
id | descripcion
------------+-------------
| |
(1 fila)

1 record? Why? Is this the expected behaviour?

this is pg 8.3.11

Thanks!
Gerardo

Browse pgsql-sql by date

  From Date Subject
Next Message Lee Hachadoorian 2010-06-25 16:21:01 Average of Array?
Previous Message Petru Ghita 2010-06-24 20:17:53 Re: question about partitioning