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

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

From
Gerardo Herzig
Date:
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