Referencing uninitialized variables in plpgsql

Поиск
Список
Период
Сортировка
От Karl O. Pinc
Тема Referencing uninitialized variables in plpgsql
Дата
Msg-id 1107663651l.23980l.2l@mofo
обсуждение исходный текст
Ответы Re: Referencing uninitialized variables in plpgsql  (John DeSoi <desoi@pgedit.com>)
Список 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 по дате отправления:

Предыдущее
От: Ron Peterson
Дата:
Сообщение: security
Следующее
От: "Karl O. Pinc"
Дата:
Сообщение: Re: security