Inconsistent behavior on select * from void_function()?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Inconsistent behavior on select * from void_function()?
Date: 2007-03-12 22:54:09
Message-ID: 200703121454.10140.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Folks,

This seems wrong to me:

postgres=# create table test1 ( testy int );
CREATE TABLE
postgres=# insert into test1 values ( 5 );
INSERT 0 1

postgres=# create function void_func ( IN theval int ) returns void as $f$
postgres$# update test1 set testy = $1;
postgres$# $f$ language sql;
CREATE FUNCTION
^
postgres=# select * from void_func( 9 );
void_func
-----------

(1 row)

postgres=# select void_func( 10 ) is null;
?column?
----------
t
(1 row)

postgres=# create function void_func2( IN theval int )
postgres-# returns void as $f$
postgres$# begin
postgres$# update test1 set testy = theval;
postgres$# return;
postgres$# end;$f$ language plpgsql;
CREATE FUNCTION
postgres=# select * from void_func2(19);
void_func2
------------

(1 row)

postgres=# select void_func2(19) is null;
?column?
----------
f
(1 row)

Why is a function which returns void returning a row? Why is that row
NULL if it's a SQL function and empty if it's a PLPGSQL function?

(version 8.2.3)

--
--Josh

Josh Berkus
PostgreSQL @ Sun
San Francisco

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2007-03-12 23:01:06 possible de-optimization of multi-column index plans in 8.3
Previous Message Heikki Linnakangas 2007-03-12 22:22:13 Re: CLUSTER and MVCC