A question about PL/pgSQL DECLAREd variable behavior

From: Dane Foster <studdugie(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: A question about PL/pgSQL DECLAREd variable behavior
Date: 2015-10-22 01:48:12
Message-ID: CA+Wxin+c2G7h72fVMkTOfDnRGwk2Mej7-0fZypXMYarGFWMCsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I wrote the following simple function to try to learn what happens to a
DECLAREd variable whose assignment comes from an INTO statement where the
query being executed does not return a result.

CREATE OR REPLACE FUNCTION _test() RETURNS BOOLEAN AS $$
DECLARE r RECORD;
BEGIN SELECT 1 AS one INTO r WHERE false; RETURN r IS NULL; END;
$$ LANGUAGE plpgsql;

The function returns true. Given that I can't find any explicit reference
in the documentation about the behavior I've just described is it safe to
assume that the current behavior is the expected behavior but it's just not
documented?

Dane

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Munro 2015-10-22 02:23:19 Re: A question about PL/pgSQL DECLAREd variable behavior
Previous Message NTPT 2015-10-22 01:34:43 Migrate whole cluster to utf8