Inconsistent error message for varchar(n) - Mailing list pgsql-hackers

From Japin Li
Subject Inconsistent error message for varchar(n)
Date
Msg-id MEYP282MB1669613B56A4CBFCAA8E8425B6969@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Inconsistent error message for varchar(n)
List pgsql-hackers
Hi, hackers

When I try to create table that has a varchar(n) data type, I find an
inconsistent error message for it.

postgres=# CREATE TABLE tbl (s varchar(2147483647));
ERROR:  length for type varchar cannot exceed 10485760
LINE 1: CREATE TABLE tbl (s varchar(2147483647));
                            ^

postgres=# CREATE TABLE tbl (s varchar(2147483648));
ERROR:  syntax error at or near "2147483648"
LINE 1: CREATE TABLE tbl (s varchar(2147483648));
                                    ^

I find that in gram.y the varchar has an integer parameter which
means its value don't exceed 2147483647.

The first error message is reported by anychar_typmodin(), and the later
is reported by gram.y.  IMO, the syntax error for varchar(n) is more
confused.

Any thoughts?

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Logical Replication - improve error message while adding tables to the publication in check_publication_add_relation
Next
From: Japin Li
Date:
Subject: Invalid Unicode escape value at or near "\u0000"