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 <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
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 ****
<para>
The general syntax of a variable declaration is:
<synopsis>
! <replaceable>name</replaceable> <optional> CONSTANT </optional> <replaceable>type</replaceable> <optional> COLLATE <replaceable>collation_name</replaceable> </optional> <optional> NOT NULL </optional> <optional> { DEFAULT | := } <replaceable>expression</replaceable> </optional>;
</synopsis>
The <literal>DEFAULT</> clause, if given, specifies the initial value assigned
to the variable when the block is entered. If the <literal>DEFAULT</> clause
--- 328,334 ----
<para>
The general syntax of a variable declaration is:
<synopsis>
! <replaceable>name</replaceable> <optional> CONSTANT </optional> <replaceable>type</replaceable> <optional> COLLATE <replaceable>collation_name</replaceable> </optional> <optional> NOT NULL </optional> <optional> { DEFAULT | := | = } <replaceable>expression</replaceable> </optional>;
</synopsis>
The <literal>DEFAULT</> clause, if given, specifies the initial value assigned
to the variable when the block is entered. If the <literal>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 <literal>NOT NULL</>
must have a nonnull default value specified.
+ Equals (<literal>=</>) can be used instead of <literal>:=</>.
</para>
<para>
*************** PREPARE <replaceable>statement_name</>(i
*** 866,872 ****
An assignment of a value to a <application>PL/pgSQL</application>
variable is written as:
<synopsis>
! <replaceable>variable</replaceable> := <replaceable>expression</replaceable>;
</synopsis>
As explained previously, the expression in such a statement is evaluated
by means of an SQL <command>SELECT</> command sent to the main
--- 867,873 ----
An assignment of a value to a <application>PL/pgSQL</application>
variable is written as:
<synopsis>
! <replaceable>variable</replaceable> { := | = } <replaceable>expression</replaceable>;
</synopsis>
As explained previously, the expression in such a statement is evaluated
by means of an SQL <command>SELECT</> command sent to the main
*************** PREPARE <replaceable>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.
</para>
<para>
--- 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 (<literal>=</>) can be
! used instead of <literal>:=</>.
</para>
<para>
*************** EXECUTE format('UPDATE tbl SET %I = $1 W
*** 1411,1417 ****
command, which has the form:
<synopsis>
! GET <optional> CURRENT </optional> DIAGNOSTICS <replaceable>variable</replaceable> = <replaceable>item</replaceable> <optional> , ... </optional>;
</synopsis>
This command allows retrieval of system status indicators. Each
--- 1413,1419 ----
command, which has the form:
<synopsis>
! GET <optional> CURRENT </optional> DIAGNOSTICS <replaceable>variable</replaceable> { = | := } <replaceable>item</replaceable> <optional> , ... </optional>;
</synopsis>
This command allows retrieval of system status indicators. Each
*************** GET <optional> CURRENT </optional> DIAGN
*** 1425,1430 ****
--- 1427,1434 ----
<acronym>SQL</acronym> command. Note that <varname>RESULT_OID</>
is only useful after an <command>INSERT</command> command into a
table containing OIDs.
+ Equals (<literal>:=</>) can be used instead of <literal>=</> for
+ <command>GET DIAGNOSTICS</>.
</para>
<para>
*************** SELECT merge_db(1, 'dennis');
*** 2672,2678 ****
<command>GET STACKED DIAGNOSTICS</command> command, which has the form:
<synopsis>
! GET STACKED DIAGNOSTICS <replaceable>variable</replaceable> = <replaceable>item</replaceable> <optional> , ... </optional>;
</synopsis>
Each <replaceable>item</replaceable> is a key word identifying a status
--- 2676,2682 ----
<command>GET STACKED DIAGNOSTICS</command> command, which has the form:
<synopsis>
! GET STACKED DIAGNOSTICS <replaceable>variable</replaceable> { = | := } <replaceable>item</replaceable> <optional> , ... </optional>;
</synopsis>
Each <replaceable>item</replaceable> is a key word identifying a status
*************** END;
*** 2776,2782 ****
<para>
<synopsis>
! GET <optional> CURRENT </optional> DIAGNOSTICS <replaceable>variable</replaceable> = <replaceable>PG_CONTEXT</replaceable> <optional> , ... </optional>;
</synopsis>
--- 2780,2786 ----
<para>
<synopsis>
! GET <optional> CURRENT </optional> DIAGNOSTICS <replaceable>variable</replaceable> { = | := } <replaceable>PG_CONTEXT</replaceable> <optional> , ... </optional>;
</synopsis>
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
;
--
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs