Commit f7ad874c authored by Peter Eisentraut's avatar Peter Eisentraut

Since SQL:2003, the array size specification in the SQL ARRAY syntax has

been optional.
parent f7ef575f
<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.66 2008/04/28 14:48:57 alvherre Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.67 2008/10/29 11:24:52 petere Exp $ -->
<sect1 id="arrays"> <sect1 id="arrays">
<title>Arrays</title> <title>Arrays</title>
...@@ -76,9 +76,12 @@ CREATE TABLE tictactoe ( ...@@ -76,9 +76,12 @@ CREATE TABLE tictactoe (
<programlisting> <programlisting>
pay_by_quarter integer ARRAY[4], pay_by_quarter integer ARRAY[4],
</programlisting> </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 As before, however, <productname>PostgreSQL</> does not enforce the
size restriction. size restriction in any case.
</para> </para>
</sect2> </sect2>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -7124,19 +7124,29 @@ Typename: SimpleTypename opt_array_bounds ...@@ -7124,19 +7124,29 @@ Typename: SimpleTypename opt_array_bounds
$$->arrayBounds = $3; $$->arrayBounds = $3;
$$->setof = TRUE; $$->setof = TRUE;
} }
/* SQL standard syntax, currently only one-dimensional */
| SimpleTypename ARRAY '[' Iconst ']' | SimpleTypename ARRAY '[' Iconst ']'
{ {
/* SQL99's redundant syntax */
$$ = $1; $$ = $1;
$$->arrayBounds = list_make1(makeInteger($4)); $$->arrayBounds = list_make1(makeInteger($4));
} }
| SETOF SimpleTypename ARRAY '[' Iconst ']' | SETOF SimpleTypename ARRAY '[' Iconst ']'
{ {
/* SQL99's redundant syntax */
$$ = $2; $$ = $2;
$$->arrayBounds = list_make1(makeInteger($5)); $$->arrayBounds = list_make1(makeInteger($5));
$$->setof = TRUE; $$->setof = TRUE;
} }
| SimpleTypename ARRAY
{
$$ = $1;
$$->arrayBounds = list_make1(makeInteger(-1));
}
| SETOF SimpleTypename ARRAY
{
$$ = $2;
$$->arrayBounds = list_make1(makeInteger(-1));
$$->setof = TRUE;
}
; ;
opt_array_bounds: opt_array_bounds:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment