public inbox for [email protected]
help / color / mirror / Atom feedplpgsql, declare blocks, and '=' versus ':='
2+ messages / 2 participants
[nested] [flat]
* plpgsql, declare blocks, and '=' versus ':='
@ 2008-07-11 16:25 James Robinson <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: James Robinson @ 2008-07-11 16:25 UTC (permalink / raw)
To: pgsql-docs
It seems that [ in 8.2.9 at least ], in a plpgsql declare block,
assignment to declared variable can use either the proper ':='
operator or the unexpected and undocumented '=' operator. See
following script. The magic handling of '=' ought to get documented at
least.
[ plpgsql-declarations.html makes no mention of '=' token handling in
either 8.3 or 8.2. docs ]
---
create or replace function test_1() returns int as
$$
declare
value int = 12; -- wow -- no colon!
begin
return value;
end;
$$ language plpgsql;
create or replace function test_2() returns int as
$$
declare
value int := 14; -- correct
begin
return value;
end;
$$ language plpgsql;
select test_1();
-- returns 12
select test_2();
-- returns 14
-----
----
James Robinson
Socialserve.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: plpgsql, declare blocks, and '=' versus ':='
@ 2008-07-11 17:08 Alvaro Herrera <[email protected]>
parent: James Robinson <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2008-07-11 17:08 UTC (permalink / raw)
To: James Robinson <[email protected]>; +Cc: pgsql-docs
James Robinson wrote:
> It seems that [ in 8.2.9 at least ], in a plpgsql declare block,
> assignment to declared variable can use either the proper ':=' operator
> or the unexpected and undocumented '=' operator. See following script.
> The magic handling of '=' ought to get documented at least.
>
> [ plpgsql-declarations.html makes no mention of '=' token handling in
> either 8.3 or 8.2. docs ]
Yes.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-07-11 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-11 16:25 plpgsql, declare blocks, and '=' versus ':=' James Robinson <[email protected]>
2008-07-11 17:08 ` Alvaro Herrera <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox