Re: Type modifier parameter of input function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Schneider <mschneid(at)mpi-bremen(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Type modifier parameter of input function
Date: 2012-07-13 17:50:28
Message-ID: 5754.1342201828@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Schneider <mschneid(at)mpi-bremen(dot)de> writes:
> whenever pg calls my input function, the type modifier parameter is
> ALWAYS (-1).
> ...
> How can I convince pg to call the input function with the correct type
> modifier?

You can't. Per the comment in coerce_type:

* For most types we pass typmod -1 to the input routine, because
* existing input routines follow implicit-coercion semantics for
* length checks, which is not always what we want here. Any length
* constraint will be applied later by our caller. An exception
* however is the INTERVAL type, for which we *must* pass the typmod
* or it won't be able to obey the bizarre SQL-spec input rules. (Ugly
* as sin, but so is this part of the spec...)

If the SQL standard didn't have such bizarrely inconsistent rules for
the results of implicit vs explicit coercions to char(n) and varchar(n),
we'd have more flexibility here.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2012-07-13 17:52:30 Re: pl/perl and utf-8 in sql_ascii databases
Previous Message Michael Schneider 2012-07-13 16:08:16 Type modifier parameter of input function