Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2CZt-0002r0-Tg for pgsql-docs@arkaria.postgresql.org; Sun, 12 Jan 2014 04:23:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W2CZt-00036R-49 for pgsql-docs@arkaria.postgresql.org; Sun, 12 Jan 2014 04:23:13 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2CZs-00036K-3O for pgsql-docs@postgresql.org; Sun, 12 Jan 2014 04:23:12 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2CZo-0004Nk-KX for pgsql-docs@postgresql.org; Sun, 12 Jan 2014 04:23:11 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1W2CZm-0001ML-Eb; Sat, 11 Jan 2014 23:23:06 -0500 Date: Sat, 11 Jan 2014 23:23:06 -0500 From: Bruce Momjian To: Pavel Stehule Cc: Tom Lane , pgsql-docs Subject: Re: remove undocumented assign syntax from plpgsql doc Message-ID: <20140112042306.GM28089@momjian.us> References: <20140111184106.GF28089@momjian.us> <24220.1389466350@sss.pgh.pa.us> <20140111190246.GG28089@momjian.us> <24577.1389467569@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pAwQNkOnpTn9IO2O" 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 --pAwQNkOnpTn9IO2O Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Jan 11, 2014 at 10:06:27PM +0100, Pavel Stehule wrote: > > > > 2014/1/11 Tom Lane > > Bruce Momjian writes: > > Oh, I think you are right.  I have reverted the patch.  Attached is > > proposed documentation for '='. > > Meh.  Variable initialization is only one of multiple cases (assignment, > GET DIAGNOSTICS; maybe others, I've not examined the grammar).  Also, > if we do it like this, we're implying that both := and = are equally > preferred, which might not be the impression we want to leave. > > > GET DIAGNOSTICS is defined by standard - and there "=" should be allowed only - > although we allow ":=" too. It is a embedded SQL statement - although it is > implemented as plpgsql statement. OK, docs updated for that. I assume OPEN and FOR also can take := or =, right? > Same situation is with UPDATE statement - we don't allow ":=" there. >   > > > I'd be a bit inclined to just stick a NOTE somewhere saying that "=" > can be used in place of ":=" for assignment. > > > ok > > If we accept it and we close this topic, then following comment should be > removed > > assign_operator : '='   /* not documented because it might be removed someday * Comment updated. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --pAwQNkOnpTn9IO2O 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..da1d35c *** 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 *************** 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 --- 2674,2680 ---- 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 , ... ; --- 2778,2784 ---- ! GET CURRENT DIAGNOSTICS variable { = | := } PG_CONTEXT , ... ; *************** OPEN curs1 FOR EXECUTE 'SELECT * FROM ' *** 2980,2986 **** Opening a Bound Cursor ! OPEN bound_cursorvar ( argument_name := argument_value , ... ) ; --- 2982,2988 ---- Opening a Bound Cursor ! OPEN bound_cursorvar ( argument_name { := | = } argument_value , ... ) ; *************** COMMIT; *** 3333,3339 **** <<label>> ! FOR recordvar IN bound_cursorvar ( argument_name := argument_value , ... ) LOOP statements END LOOP label ; --- 3335,3341 ---- <<label>> ! FOR recordvar IN bound_cursorvar ( argument_name { := | = } argument_value , ... ) LOOP statements END LOOP label ; diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y new file mode 100644 index 3fd6655..03a132d *** 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,802 ---- | K_DEFAULT ; ! assign_operator : '=' /* alternative to := */ | COLON_EQUALS ; --pAwQNkOnpTn9IO2O 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 --pAwQNkOnpTn9IO2O--