Inconsistent error message for varchar(n)

From: Japin Li <japinli(at)hotmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Inconsistent error message for varchar(n)
Date: 2021-11-13 03:04:12
Message-ID: MEYP282MB1669613B56A4CBFCAA8E8425B6969@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2021-11-13 03:31:57 Invalid Unicode escape value at or near "\u0000"
Previous Message Bharath Rupireddy 2021-11-13 03:00:10 Re: Logical Replication - improve error message while adding tables to the publication in check_publication_add_relation