pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: workingjubilee (@workingjubilee) <noreply+workingjubilee@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #693: Question: why is pgvector skipping vector dimenstion check when `typmod` is `-1`
Date: Thu, 10 Oct 2024 17:25:50 +0000
Message-ID: <gh-pgvector-pgvector-693-c2405670022@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-693@github.com>
References: <gh-pgvector-pgvector-693@github.com>

Specifically, because I am having trouble getting people to read what he posted:
For every SQL statement in a form like
```sql
insert into foo values ('[1]');
```

It is **not always** implemented via:
1. determine typmod for foo's columns
2. call `TYPE_IN` with determined typmod

It **can also** be implemented via:
1. call `TYPE_IN` with typmod -1
2. **cast** input types when performing insert


The latter is the behavior Tom Lane describes as not only common but _more prevalent_ in the Postgres codebase at the time. While Postgres has likely changed its internals, proving that Postgres NEVER does the input-then-cast behavior would require auditing every site at which Postgres does these kinds of type conversions.

@ankane What you did not know in answering this question is that Steve is actually asking the question, "can I ALWAYS ASSERT (and thus ereport if failed) that the `TYPE_IN` function is provided a non-`(-1)` typmod, and fail to create the type if it is not provided one?" That is not the behavior that pgvector has, your source code does not assert if you do this, as it specifically skips the assert:

https://github.com/pgvector/pgvector/blob/fa6782985ab9fd6c3f289196b7cf3053c1d46eef/src/vector.c#L65-...

In doing so, you implement a behavior actually compatible with Postgres. This may be more critical than you may imagine.

So have you actually tried to run pgvector in production with an assertion that demands the typmod on every call to the type's input function, or were you just answering off-the-cuff?

view thread (11+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-693-c2405670022@github.com>
Permalink:  ../gh-pgvector-pgvector-693-c2405670022@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox