Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2i8D-0007io-Kj for pgsql-docs@arkaria.postgresql.org; Mon, 13 Jan 2014 14:04:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W2i8C-0008LX-VE for pgsql-docs@arkaria.postgresql.org; Mon, 13 Jan 2014 14:04:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2i8A-0008LI-Uf for pgsql-docs@postgresql.org; Mon, 13 Jan 2014 14:04:43 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2i82-0003HS-SD for pgsql-docs@postgresql.org; Mon, 13 Jan 2014 14:04:42 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1W2i81-0003ER-4n; Mon, 13 Jan 2014 09:04:33 -0500 Date: Mon, 13 Jan 2014 09:04:33 -0500 From: Bruce Momjian To: Pavel Stehule Cc: Tom Lane , pgsql-docs Subject: Re: remove undocumented assign syntax from plpgsql doc Message-ID: <20140113140433.GA7868@momjian.us> References: <20140111184106.GF28089@momjian.us> <24220.1389466350@sss.pgh.pa.us> <20140111190246.GG28089@momjian.us> <24577.1389467569@sss.pgh.pa.us> <20140112042306.GM28089@momjian.us> <20140113025904.GB22464@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PEIAKu/WMn1b1Hv9" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --PEIAKu/WMn1b1Hv9 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Jan 13, 2014 at 06:10:24AM +0100, Pavel Stehule wrote: > I find the rules above so complex that I don't see how we can recommend > a best syntax.  What I did in the patch I just posted was to put the > preferred operator first, but I don't see why we want to get into these > details in the docs. > > > just a note about preferred variant should be ok. Using ':=' in GET DIAGNOSTICS > statement is just bad idea. Agreed. I added a sentence in the first mention of GET DIAGNOSTICS, and indicated it was generic for that command. What I also added was your description of when to use := and =, but I put it in the C comments so we have a record of it and if we need to expand the description or behavior later. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --PEIAKu/WMn1b1Hv9 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="assign.diff" diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml new file mode 100644 index ca2c2b5..b937580 *** a/doc/src/sgml/plpgsql.sgml --- b/doc/src/sgml/plpgsql.sgml *************** arow RECORD; *** 328,334 **** The general syntax of a variable declaration is: ! name CONSTANT type COLLATE collation_name NOT NULL { DEFAULT | := } expression ; The DEFAULT clause, if given, specifies the initial value assigned to the variable when the block is entered. If the DEFAULT clause --- 328,334 ---- The general syntax of a variable declaration is: ! name CONSTANT type COLLATE collation_name NOT NULL { DEFAULT | := | = } expression ; The DEFAULT clause, if given, specifies the initial value assigned to the variable when the block is entered. If the DEFAULT clause *************** arow RECORD; *** 343,348 **** --- 343,349 ---- is specified, an assignment of a null value results in a run-time error. All variables declared as NOT NULL must have a nonnull default value specified. + Equals (=) can be used instead of :=. *************** PREPARE statement_name(i *** 866,872 **** An assignment of a value to a PL/pgSQL variable is written as: ! variable := expression; As explained previously, the expression in such a statement is evaluated by means of an SQL SELECT command sent to the main --- 867,873 ---- An assignment of a value to a PL/pgSQL variable is written as: ! variable { := | = } expression; As explained previously, the expression in such a statement is evaluated by means of an SQL SELECT command sent to the main *************** PREPARE statement_name(i *** 874,880 **** a row value, if the variable is a row or record variable). The target variable can be a simple variable (optionally qualified with a block name), a field of a row or record variable, or an element of an array ! that is a simple variable or field. --- 875,882 ---- a row value, if the variable is a row or record variable). The target variable can be a simple variable (optionally qualified with a block name), a field of a row or record variable, or an element of an array ! that is a simple variable or field. Equals (=) can be ! used instead of :=. *************** EXECUTE format('UPDATE tbl SET %I = $1 W *** 1411,1417 **** command, which has the form: ! GET CURRENT DIAGNOSTICS variable = item , ... ; This command allows retrieval of system status indicators. Each --- 1413,1419 ---- command, which has the form: ! GET CURRENT DIAGNOSTICS variable { = | := } item , ... ; This command allows retrieval of system status indicators. Each *************** GET CURRENT DIAGN *** 1425,1430 **** --- 1427,1434 ---- SQL command. Note that RESULT_OID is only useful after an INSERT command into a table containing OIDs. + Equals (:=) can be used instead of = for + GET DIAGNOSTICS. *************** SELECT merge_db(1, 'dennis'); *** 2672,2678 **** GET STACKED DIAGNOSTICS command, which has the form: ! GET STACKED DIAGNOSTICS variable = item , ... ; Each item is a key word identifying a status --- 2676,2682 ---- GET STACKED DIAGNOSTICS command, which has the form: ! GET STACKED DIAGNOSTICS variable { = | := } item , ... ; Each item is a key word identifying a status *************** END; *** 2776,2782 **** ! GET CURRENT DIAGNOSTICS variable = PG_CONTEXT , ... ; --- 2780,2786 ---- ! GET CURRENT DIAGNOSTICS variable { = | := } PG_CONTEXT , ... ; diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y new file mode 100644 index 3fd6655..9284cf3 *** a/src/pl/plpgsql/src/pl_gram.y --- b/src/pl/plpgsql/src/pl_gram.y *************** decl_defkey : assign_operator *** 796,802 **** | K_DEFAULT ; ! assign_operator : '=' /* not documented because it might be removed someday */ | COLON_EQUALS ; --- 796,807 ---- | K_DEFAULT ; ! /* ! * Ada-based PL/SQL uses := for assignment and variable defaults, while ! * standards-based PSM uses equals for these cases and for GET DIAGNOSTICS, ! * so we support both. FOR and OPEN only support :=. ! */ ! assign_operator : '=' | COLON_EQUALS ; --PEIAKu/WMn1b1Hv9 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs --PEIAKu/WMn1b1Hv9--