docs: update PL/pgSQL docs about the use of := and =
authorBruce Momjian
Thu, 16 Jan 2014 21:40:17 +0000 (16:40 -0500)
committerBruce Momjian
Thu, 16 Jan 2014 21:40:58 +0000 (16:40 -0500)
doc/src/sgml/plpgsql.sgml
src/pl/plpgsql/src/pl_gram.y

index ca2c2b5851b6910a194531308a2909cd61622b0a..48880ce625a446c92dec3ceac3f85e004b4c29b4 100644 (file)
@@ -328,7 +328,7 @@ arow RECORD;
     
      The general syntax of a variable declaration is:
 
-name  CONSTANT  type  COLLATE collation_name   NOT NULL   { DEFAULT | := } expression ;
+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
@@ -343,6 +343,8 @@ arow RECORD;
       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
+      :=.
      
 
      
@@ -866,7 +868,7 @@ PREPARE statement_name(integer, integer) AS SELECT $1 < $2;
      An assignment of a value to a PL/pgSQL
      variable is written as:
 
-variable := expression;
+variable { := | = } expression;
 
      As explained previously, the expression in such a statement is evaluated
      by means of an SQL SELECT command sent to the main
@@ -874,7 +876,8 @@ PREPARE statement_name(integer, integer) AS SELECT $1 < $2;
      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.
+     that is a simple variable or field.  Equals (=) can be
+     used instead of PL/SQL-compliant :=.
     
 
     
@@ -1411,7 +1414,7 @@ EXECUTE format('UPDATE tbl SET %I = $1 WHERE key = $2', colname)
      command, which has the form:
 
 
-GET  CURRENT  DIAGNOSTICS variable = item  , ... ;
+GET  CURRENT  DIAGNOSTICS variable { = | := } item  , ... ;
 
 
      This command allows retrieval of system status indicators.  Each
@@ -1425,6 +1428,8 @@ GET  CURRENT  DIAGNOSTICS variable
      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-standard
+     = for GET DIAGNOSTICS.
     
 
     
@@ -2672,7 +2677,7 @@ SELECT merge_db(1, 'dennis');
      GET STACKED DIAGNOSTICS command, which has the form:
 
 
-GET STACKED DIAGNOSTICS variable = item  , ... ;
+GET STACKED DIAGNOSTICS variable { = | := } item  , ... ;
 
 
      Each item is a key word identifying a status
@@ -2776,7 +2781,7 @@ END;
    
 
 
-GET  CURRENT  DIAGNOSTICS variable = PG_CONTEXT  , ... ;
+GET  CURRENT  DIAGNOSTICS variable { = | := } PG_CONTEXT  , ... ;
 
 
 
index 3fd6655e1beecf3314df6daf113ff393309d6710..c0cb58530bea8d84095f475de63f087045251538 100644 (file)
@@ -796,7 +796,12 @@ decl_defkey        : assign_operator
                | K_DEFAULT
                ;
 
-assign_operator    : '='   /* not documented because it might be removed someday */
+/*
+ * Ada-based PL/SQL uses := for assignment and variable defaults, while
+ * the SQL standard uses equals for these cases and for GET
+ * DIAGNOSTICS, so we support both.  FOR and OPEN only support :=.
+ */
+assign_operator    : '='
                | COLON_EQUALS
                ;