Skip to content

Commit 37e34f6

Browse files
committed
docs: correct pgvector table_dimension comment after real-Postgres testing
Validated the backend against a real Postgres 18.4 + pgvector 0.8.2 instance (full live roundtrip incl. close/reopen + same-dim write). The reviewer's claim that a vector(n) column's atttypmod is dimension+4 does NOT reproduce: raw atttypmod equals the bare dimension on 0.8.x, so the original direct read was already correct. Keep format_type() anyway as the canonical, version-proof way to read the typmod, and correct the comment to reflect reality instead of asserting a bug that does not exist.
1 parent f88951e commit 37e34f6

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

mempalace/backends/pgvector.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,13 @@ def table_exists(self, table: str) -> bool:
499499
return bool(rows)
500500

501501
def table_dimension(self, table: str) -> Optional[int]:
502-
# The raw ``atttypmod`` of a ``vector(n)`` column is NOT the bare
503-
# dimension (pgvector encodes it via its own typmod_in), so reading it
504-
# directly can be off and produce false DimensionMismatchErrors on
505-
# reopen. Round-trip through ``format_type`` instead, which invokes the
506-
# type's own typmod_out and yields the canonical ``vector(384)`` text
507-
# regardless of the internal encoding or pgvector version.
502+
# Read the declared dimension via ``format_type`` (which invokes the
503+
# type's own typmod_out and yields canonical ``vector(384)`` text)
504+
# rather than the raw ``atttypmod``. On the pgvector versions tested
505+
# (0.8.x) atttypmod already equals the bare dimension, so the direct
506+
# read also worked — but format_type is the canonical, version-proof
507+
# source of truth and avoids depending on the internal typmod encoding
508+
# staying stable across pgvector releases.
508509
try:
509510
rows = self._execute(
510511
"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a "

0 commit comments

Comments
 (0)