Since SQL:2003, the array size specification in the SQL ARRAY syntax has
authorPeter Eisentraut
Wed, 29 Oct 2008 11:24:53 +0000 (11:24 +0000)
committerPeter Eisentraut
Wed, 29 Oct 2008 11:24:53 +0000 (11:24 +0000)
been optional.

doc/src/sgml/array.sgml
src/backend/parser/gram.y

index b0d6e19abf7e7a42eef3ab27332b76437b6300b1..4d762c53d3575aa152f40a2e9604bea3d200f14b 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  Arrays
@@ -76,9 +76,12 @@ CREATE TABLE tictactoe (
 
     pay_by_quarter  integer ARRAY[4],
 
-  This syntax requires an integer constant to denote the array size.
+  Or, if no array size is to be specified:
+
+    pay_by_quarter  integer ARRAY,
+
   As before, however, PostgreSQL does not enforce the
-  size restriction.
+  size restriction in any case.
  
  
 
index 4759e041340680942e7a919848dd8bc97af603c9..8b44e5b6ba4aebdd53b5b371a0aaf597585d9454 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.631 2008/10/28 14:09:45 petere Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.632 2008/10/29 11:24:53 petere Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -7124,19 +7124,29 @@ Typename:   SimpleTypename opt_array_bounds
                    $$->arrayBounds = $3;
                    $$->setof = TRUE;
                }
+           /* SQL standard syntax, currently only one-dimensional */
            | SimpleTypename ARRAY '[' Iconst ']'
                {
-                   /* SQL99's redundant syntax */
                    $$ = $1;
                    $$->arrayBounds = list_make1(makeInteger($4));
                }
            | SETOF SimpleTypename ARRAY '[' Iconst ']'
                {
-                   /* SQL99's redundant syntax */
                    $$ = $2;
                    $$->arrayBounds = list_make1(makeInteger($5));
                    $$->setof = TRUE;
                }
+           | SimpleTypename ARRAY
+               {
+                   $$ = $1;
+                   $$->arrayBounds = list_make1(makeInteger(-1));
+               }
+           | SETOF SimpleTypename ARRAY
+               {
+                   $$ = $2;
+                   $$->arrayBounds = list_make1(makeInteger(-1));
+                   $$->setof = TRUE;
+               }
        ;
 
 opt_array_bounds: