On Tuesday, February 4, 2025, PG Bug reporting form <
noreply@postgresql.org> wrote:
. The
exception is the varchar(n) fixed-length data type
That isn’t how this works. The (n) does not make it “fixed-width’. It simply is a way to enforce a maximum length to the value but otherwise the data type itself is still variable width. Mostly we recommend use of text, dealing with constraints in other more global ways.
Correctly working SQL script:
I’ll wait for a “minimal reproducer” to dive into specifics if there are still questions.
As far as I have determined, the Postgresql database engine somehow returns
the varchar(n) - Fixed Length - data type as a "character varying" -
indefinite length data type.
Mostly functions drop the (n) specifier and deal with the data type itself. The function only wants a concrete value and doesn’t deal with enforcing constraints in its signature. You can add code to the body if you need that.
I hope this situation, which I observed as a problem, will be fixed as soon
as possible.
If the absence of the typmod as it is called (the (n)) is problem there isn’t a change forthcoming to rework that part of the system. It’s a limitation we are living with.
David J.