Re: Custom type's modifiers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marthin Laubscher <postgres(at)lobeshare(dot)co(dot)za>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Custom type's modifiers
Date: 2024-06-27 16:24:16
Message-ID: 1749733.1719505456@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Marthin Laubscher <postgres(at)lobeshare(dot)co(dot)za> writes:
> I don't see another function getting passed the value so I'd assume that (unless I return a MyType value from one of my own functions which would follow its internal logic to determine which type modifiers to use) the only way a MyType can get an initial value is via the input function. If the type is in a table column the input function would be called with the default value specified in external format if a value isn't specified during insert, but either way it would always originate from the eternal format. I suppose when a cast is involved it goes via the external format as well, right?

The only code anywhere in the system that can produce a MyType value
is code you've written. So that has to come originally from your
input function, or cast functions or constructor functions you write.

You'd be well advised to read the CREATE CAST doco about how to
support notations like 'something'::MyType(x,y,z). Although the
input function is expected to be able to apply a typemod if it's
passed one, in most situations coercion to a specific typemod is
handled by invoking a multi-parameter cast function.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2024-06-27 16:31:11 Re: JIT causes core dump during error recovery
Previous Message Tom Lane 2024-06-27 16:18:31 Re: JIT causes core dump during error recovery