Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2B2CFB5DBC4 for ; Wed, 17 Aug 2011 02:21:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 98689-03 for ; Wed, 17 Aug 2011 05:21:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 1A1A7B5D803 for ; Wed, 17 Aug 2011 02:21:02 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p7H5L16v084475 for ; Wed, 17 Aug 2011 05:21:01 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p7H5L1LY084474; Wed, 17 Aug 2011 05:21:01 GMT (envelope-from www) Date: Wed, 17 Aug 2011 05:21:01 GMT Message-Id: <201108170521.p7H5L1LY084474@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6165: documentation bug in plpgsql-declarations.html and plpgsql-statements.html (or plpgsql parser bug) From: "raf" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201108/100 X-Sequence-Number: 30912 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).