summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2008-10-29 11:24:53 +0000
committerPeter Eisentraut2008-10-29 11:24:53 +0000
commit67425391738fe936f03ce698c7548fad521a555c (patch)
tree20e1e3e10a0bb0ee81eae7ed3a7cc40f617af0c7
parentb3ee60ce9b16990e2f19922cbbc586bd078b41e9 (diff)
Since SQL:2003, the array size specification in the SQL ARRAY syntax has
been optional.
-rw-r--r--doc/src/sgml/array.sgml7
-rw-r--r--src/backend/parser/gram.y14
2 files changed, 17 insertions, 4 deletions
diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml
index f5888d7ff0..32fd58138b 100644
--- a/doc/src/sgml/array.sgml
+++ b/doc/src/sgml/array.sgml
@@ -76,9 +76,12 @@ CREATE TABLE tictactoe (
<programlisting>
pay_by_quarter integer ARRAY[4],
</programlisting>
- This syntax requires an integer constant to denote the array size.
+ Or, if no array size is to be specified:
+<programlisting>
+ pay_by_quarter integer ARRAY,
+</programlisting>
As before, however, <productname>PostgreSQL</> does not enforce the
- size restriction.
+ size restriction in any case.
</para>
</sect2>
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 70ea60a15a..94a91afe75 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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: