pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug)
4+ messages / 4 participants
[nested] [flat]

* BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug)
@ 2011-08-17 05:21 raf <raf@raf.org>
  2011-08-22 16:34 ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: raf @ 2011-08-17 05:21 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      6165
Logged by:          raf
Email address:      raf@raf.org
PostgreSQL version: 9.0.4
Operating system:   N/A
Description:        documentation bug in plpgsql-declarations.html and
plpgsql-statements.html (or plpgsql parser bug)
Details: 

the documentation available at:

  http://www.postgresql.org/docs/current/static/plpgsql-declarations.html

states that the general syntax of a variable declaration is:

  name [ CONSTANT ] type [ NOT NULL ] [ { DEFAULT | := } expression ];

when it is really:

  name [ CONSTANT ] type [ NOT NULL ] [ { DEFAULT | := | = } expression ];

i.e. an sql equality operator ("=") is accepted and acts as if it were
a plpgsql assignment operator (":=").

similarly, the documentation available at:

  http://www.postgresql.org/docs/current/static/plpgsql-statements.html

states that an assignment of a value to a PL/pgSQL variable is written as:

  variable := expression;

even though the sql equality operator works too:

  variable = expression;

so, there is either a plpgsql parser bug that treats the sql equality
operator as the plpgsql assignment operator, or "=" is an undocumented
alternative to the documented plpgsql assignment operator (":=").

the only mention i have found of "=" being an assignment operator is in
the documentation that shows:

  GET DIAGNOSTICS variable = item [ , ... ];

but i think that might be a special case.

example demonstration:

  do $$
  declare
    i integer = 5;
  begin
    raise notice '%', i;
    i = 6;
    raise notice %', i;
  end
  $$;

will output 5 and then 6 (as expected by someone who doesn't know that
they should be using ":=" according to the documentation).



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug)
  2011-08-17 05:21 BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) raf <raf@raf.org>
@ 2011-08-22 16:34 ` Robert Haas <robertmhaas@gmail.com>
  2011-08-22 20:17   ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Robert Haas @ 2011-08-22 16:34 UTC (permalink / raw)
  To: raf <raf@raf.org>; +Cc: pgsql-bugs

On Wed, Aug 17, 2011 at 1:21 AM, raf <raf@raf.org> wrote:
> so, there is either a plpgsql parser bug that treats the sql equality
> operator as the plpgsql assignment operator, or "=" is an undocumented
> alternative to the documented plpgsql assignment operator (":=").

I think it's the latter.  I have a vague recollection that we might
have left that undocumented on purpose, but I'm not actually sure why
we support it in the first place.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug)
  2011-08-17 05:21 BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) raf <raf@raf.org>
  2011-08-22 16:34 ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Robert Haas <robertmhaas@gmail.com>
@ 2011-08-22 20:17   ` Tom Lane <tgl@sss.pgh.pa.us>
  2012-08-15 16:02     ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2011-08-22 20:17 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: raf <raf@raf.org>; pgsql-bugs

Robert Haas <robertmhaas@gmail.com> writes:
> On Wed, Aug 17, 2011 at 1:21 AM, raf <raf@raf.org> wrote:
>> so, there is either a plpgsql parser bug that treats the sql equality
>> operator as the plpgsql assignment operator, or "=" is an undocumented
>> alternative to the documented plpgsql assignment operator (":=").

> I think it's the latter.

It's definitely intentional, not a bug, so far as the source code is
concerned:

assign_operator : '='
                | COLON_EQUALS
                ;

> I have a vague recollection that we might
> have left that undocumented on purpose, but I'm not actually sure why
> we support it in the first place.

I think it's legacy at this point.  We have discussed before whether to
document it, and IIRC the general feeling was "if we do document it,
we'll never be able to get rid of it".  Whether we could get rid of it
now (instead of documenting it) was not seriously discussed.  I've seen
at least a few people saying that they do rely on it ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug)
  2011-08-17 05:21 BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) raf <raf@raf.org>
  2011-08-22 16:34 ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Robert Haas <robertmhaas@gmail.com>
  2011-08-22 20:17   ` Re: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) Tom Lane <tgl@sss.pgh.pa.us>
@ 2012-08-15 16:02     ` Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2012-08-15 16:02 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Robert Haas <robertmhaas@gmail.com>; raf <raf@raf.org>; pgsql-bugs

On Mon, Aug 22, 2011 at 04:17:04PM -0400, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > On Wed, Aug 17, 2011 at 1:21 AM, raf <raf@raf.org> wrote:
> >> so, there is either a plpgsql parser bug that treats the sql equality
> >> operator as the plpgsql assignment operator, or "=" is an undocumented
> >> alternative to the documented plpgsql assignment operator (":=").
> 
> > I think it's the latter.
> 
> It's definitely intentional, not a bug, so far as the source code is
> concerned:
> 
> assign_operator : '='
>                 | COLON_EQUALS
>                 ;
> 
> > I have a vague recollection that we might
> > have left that undocumented on purpose, but I'm not actually sure why
> > we support it in the first place.
> 
> I think it's legacy at this point.  We have discussed before whether to
> document it, and IIRC the general feeling was "if we do document it,
> we'll never be able to get rid of it".  Whether we could get rid of it
> now (instead of documenting it) was not seriously discussed.  I've seen
> at least a few people saying that they do rely on it ...

I think the question is whether '=' is used enough that we have to
mention that it is a non-standard extension that might be removed
someday, or something.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2012-08-15 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-08-17 05:21 BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) raf <raf@raf.org>
2011-08-22 16:34 ` Robert Haas <robertmhaas@gmail.com>
2011-08-22 20:17   ` Tom Lane <tgl@sss.pgh.pa.us>
2012-08-15 16:02     ` Bruce Momjian <bruce@momjian.us>

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