public inbox for [email protected]  
help / color / mirror / Atom feed
From: James Robinson <[email protected]>
To: [email protected]
Subject: plpgsql, declare blocks, and '=' versus ':='
Date: Fri, 11 Jul 2008 12:25:35 -0400
Message-ID: <[email protected]> (raw)

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




view thread (2+ messages)  latest in thread

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: [email protected]
  Cc: [email protected]
  Subject: Re: plpgsql, declare blocks, and '=' versus ':='
  In-Reply-To: <[email protected]>

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

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