pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: jiangshan.liu@tju.edu.cn
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17860: Possible Bugs in PL/pgSQL Functions' Return Values
Date: Wed, 22 Mar 2023 10:19:11 -0400
Message-ID: <1496421.1679494751@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbQuy5j_n1kk36KbrsFK2z6q=8zBwdycAFht6kbGMC1rw@mail.gmail.com>
References: <17860-3e3a34519be852ad@postgresql.org>
	<CAKFQuwbQuy5j_n1kk36KbrsFK2z6q=8zBwdycAFht6kbGMC1rw@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Mar 22, 2023 at 6:15 AM PG Bug reporting form <
> noreply@postgresql.org> wrote:
>> Moreover, regarding function test2(), the result is also perplexing.
>> According to the documentation,
>> "Data type void Indicates that a function returns no value."
>> 
>> Therefore, it is reasonable to expect that the returned value should be an
>> empty table, as it should not be returning any value. However, in reality,
>> it returns a table with one row.

> The system retains the data type "void" for that singular value as the
> representation of the fact that the function that was called did not itself
> return any particular value.

"void" is a bit of a hack.  As far as the system is concerned, it's
an actual scalar type, having no operations and exactly one value,
which prints as an empty string.  The point of doing that rather than
just returning (say) an empty string is the lack of operations: if you
accidentally try to do something with the result of a void-returning
function, it'll fail because void can't be coerced to anything else.

As David says, this is not the same as a set result containing
zero rows.

			regards, tom lane





view thread (3+ messages)

Message-ID: <1496421.1679494751@sss.pgh.pa.us>
Permalink:  ../1496421.1679494751@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1496421.1679494751@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, jiangshan.liu@tju.edu.cn, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17860: Possible Bugs in PL/pgSQL Functions' Return Values
  In-Reply-To: <1496421.1679494751@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox