From: Peter Eisentraut Date: Wed, 29 Oct 2008 11:24:53 +0000 (+0000) Subject: Since SQL:2003, the array size specification in the SQL ARRAY syntax has X-Git-Tag: recoveryinfrav9~461 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=67425391738fe936f03ce698c7548fad521a555c;p=users%2Fsimon%2Fpostgres.git Since SQL:2003, the array size specification in the SQL ARRAY syntax has been optional. --- 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 ( 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. 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: