Referencing uninitialized variables in plpgsql - Mailing list pgsql-general

From Karl O. Pinc
Subject Referencing uninitialized variables in plpgsql
Date
Msg-id 1107663651l.23980l.2l@mofo
Whole thread Raw
Responses Re: Referencing uninitialized variables in plpgsql
List pgsql-general
Hi,

I've a plpgsql procedure I'm pretty sure is referencing
variables, array elements really, that have not been
initialized.  Is this a well defined operation?
If so, what is the result? (NULL?) If not, shouldn't I be
getting some sort of error or warning?

I've
SET client_min_messages='debug';
and don't seem to get any messages.  AFICT there is no
run time configuration that would affect this, right?

The documentation seems silent on uninitialized plpgsql
variables.  Be nice if something was written.

I don't care for code that references unititialized variables.
It'd be nice to be able to get a warning even if the result
was well defined, just for those cases where you don't intend
to reference uninitialized variables.

Is this example telling me I get NULL for unitialized references?
I don't believe I should count on this behavior unless it's
documented, should I?

=> create or replace function foo() returns int language plpgsql
as 'declare a int; b int; begin a := b; return a; end; ';
CREATE FUNCTION
=> select foo();
 foo
-----

(1 row)


 PostgreSQL 7.4.6 on i686-redhat-linux-gnu, compiled by GCC gcc
(GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42)


Thanks for all the postgresql work.  I don't mean to sound
grumpy, I'm tired.

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein



pgsql-general by date:

Previous
From: Ron Peterson
Date:
Subject: security
Next
From: "Karl O. Pinc"
Date:
Subject: Re: security