Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3SVK-0000vA-3C for pgsql-docs@arkaria.postgresql.org; Wed, 15 Jan 2014 15:35:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W3SVJ-000891-G9 for pgsql-docs@arkaria.postgresql.org; Wed, 15 Jan 2014 15:35:41 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3SVI-00088v-Om for pgsql-docs@postgresql.org; Wed, 15 Jan 2014 15:35:40 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3SVF-00010Q-7a for pgsql-docs@postgresql.org; Wed, 15 Jan 2014 15:35:40 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1W3SVD-0002v8-Jm; Wed, 15 Jan 2014 10:35:35 -0500 Date: Wed, 15 Jan 2014 10:35:35 -0500 From: Bruce Momjian To: Pavel Stehule Cc: Tom Lane , pgsql-docs Subject: Re: remove undocumented assign syntax from plpgsql doc Message-ID: <20140115153535.GA7607@momjian.us> References: <24577.1389467569@sss.pgh.pa.us> <20140112042306.GM28089@momjian.us> <20140113025904.GB22464@momjian.us> <20140113140433.GA7868@momjian.us> <20140114202128.GA7761@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.2 (--) 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 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Jan 15, 2014 at 11:07:29AM +0100, Pavel Stehule wrote: > I thought you would say that.  :-)  I don't see how this detail makes > sense in the sections related to the syntax usage, so I looked in the > section Porting from Oracle PL/SQL, and I don't see how it fits there > either. > > > > :) > > just notice - sorry for my English > > ==Assign== > Using ":=" is preffered as assign statement due conformity with ADA language (a > plpgsql ancestor). > > > ==GET DIAGNOSTICS== > > Using "=" is highly preferred due conformity with ANSI/SQL The problem is that these are philosophical issues that are not normally covered in our docs. What I have done is to add a mention of which option is compliant to the new text. Patch attached. Is GET DIAGNOSTICS defined in the standard for SQL/PSM only or for generic SQL? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --ew6BAiZeqk4r7MaW 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..0ca9458 *** 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,350 ---- 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 PL/SQL-compliant + :=. *************** 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 --- 868,874 ---- 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. --- 876,883 ---- 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 PL/SQL-compliant :=. *************** 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 --- 1414,1420 ---- command, which has the form: ! GET CURRENT DIAGNOSTICS variable { = | := } item , ... ; This command allows retrieval of system status indicators. Each *************** GET CURRENT DIAGN *** 1425,1430 **** --- 1428,1435 ---- SQL command. Note that RESULT_OID is only useful after an INSERT command into a table containing OIDs. + Equals (:=) can be used instead of SQL/PSM-compliant + = 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 --- 2677,2683 ---- 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 , ... ; --- 2781,2787 ---- ! 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..55c8e25 *** 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 SQL/PSM uses equals for these cases and for GET ! * DIAGNOSTICS, so we support both. FOR and OPEN only support :=. ! */ ! assign_operator : '=' | COLON_EQUALS ; --ew6BAiZeqk4r7MaW 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 --ew6BAiZeqk4r7MaW--