From 6857a52538c39ecfc5233a5d555d5b9ff28b377b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 21 Mar 2008 22:10:56 +0000 Subject: [PATCH] Give an explicit error for serial[], rather than silently ignoring the array decoration as the code had been doing. --- src/backend/parser/parse_utilcmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index eec1e30d81..b6a9a09b95 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -266,7 +266,8 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, /* Check for SERIAL pseudo-types */ is_serial = false; - if (list_length(column->typename->names) == 1) + if (list_length(column->typename->names) == 1 && + !column->typename->pct_type) { char *typname = strVal(linitial(column->typename->names)); @@ -284,6 +285,16 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, column->typename->names = NIL; column->typename->typeid = INT8OID; } + + /* + * We have to reject "serial[]" explicitly, because once we've + * set typeid, LookupTypeName won't notice arrayBounds. We don't + * need any special coding for serial(typmod) though. + */ + if (is_serial && column->typename->arrayBounds != NIL) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("array of serial is not implemented"))); } /* Do necessary work on the column type declaration */ -- 2.39.5