Skip to content

c/driver/postgresql: add parser for int2vector type #2903

@lidavidm

Description

@lidavidm

Appears to be list[int16].

Discussed in #2899

Originally posted by michalc May 31, 2025
I'm looking to query int2vector fields in PostgreSQL (and specifically those in pg_catalog, and specifically indoption from pg_index https://www.postgresql.org/docs/current/catalog-pg-index.html)

However, if I run:

import adbc_driver_postgresql.dbapi

with adbc_driver_postgresql.dbapi.connect("postgresql://postgres:[email protected]:5432/") as conn:
    with conn.cursor() as cursor:
        cursor.execute("SELECT indoption FROM pg_index LIMIT 1")
        print(cursor.fetchall())

Then I get something that I'm not quite sure how to use:

[(b'\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x02\x00\x00',)]

Running the same query using psycopg results in

[('0 0',)]

And using psql:

 indoption
-----------
 0 0

How can I get a non binary results from int2vector fields, similar to psql or psycopg? (Including maybe, how to adjust the query?)

Context - I'm making a SQLAlchemy dialect for ADBC, and especially would like to support its reflection capabilities, so querying the catalogue, including its int2vector fields, is needed for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions