Doc of typmod arg perhaps deserves an update

Started by Steve Lauover 1 year ago3 messages
#1Steve Lau
stevelauc@outlook.com

# Context

I hit the issue described in this thread when building my toy pgvector implementation: /messages/by-id/162867790903161317q178e11e6ie276d1254c279dd1@mail.gmail.com, TLDR of the thread is that: When you define a new custom type that needs a type modifier, it is possible (I would say highly possible in my case) that you won’t receive the stored typmod in this type’s input function’s third argument even though it is **stored** in a column’s metadata.

# Documentation of CREATE TYPE perhaps needs more elaboration

The documentation of CREATE TYPE (https://www.postgresql.org/docs/current/sql-createtype.html) says that

“and the third is the typmod of the destination column, if known (-1 will be passed if not).”

Before hitting the issue, I thought -1 will be passed if and only if this type does not have type modifiers, as it is indeed unknown. However, it surprises me that it could also be unknown if your type needs type modifiers and the type modifiers have been successfully stored in the metadata. So I think we could elaborate on this a bit.

Regards, Steve.

#2Chapman Flack
jcflack@acm.org
In reply to: Steve Lau (#1)
Re: Doc of typmod arg perhaps deserves an update

On 10/11/24 01:33, Steve Lau wrote:

Before hitting the issue, I thought -1 will be passed if and only if
this type does not have type modifiers, as it is indeed unknown. However,
it surprises me that it could also be unknown if your type needs
type modifiers and the type modifiers have been successfully stored

This older thread may be of interest:

/messages/by-id/162867790903161317q178e11e6ie276d1254c279dd1@mail.gmail.com

Regards,
-Chap

#3Steve Lau
stevelauc@outlook.com
In reply to: Chapman Flack (#2)
Re: Doc of typmod arg perhaps deserves an update

Hi

Did you post the wrong link? This one looks same as the one I mentioned. Though I realized that you have replied to this thread: /messages/by-id/56EA3507.6090701@anastigmatix.net

Regards, Steve.

Show quoted text

On Oct 11, 2024, at 8:42 PM, Chapman Flack <jcflack@acm.org> wrote:

On 10/11/24 01:33, Steve Lau wrote:

Before hitting the issue, I thought -1 will be passed if and only if
this type does not have type modifiers, as it is indeed unknown. However,
it surprises me that it could also be unknown if your type needs
type modifiers and the type modifiers have been successfully stored

This older thread may be of interest:

/messages/by-id/162867790903161317q178e11e6ie276d1254c279dd1@mail.gmail.com

Regards,
-Chap