From e1647473c91c561e9d0f10990fc731125092be6c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Apr 2024 09:25:07 -0700 Subject: [PATCH] Updated IvfflatGetType [skip ci] --- src/ivfutils.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ivfutils.c b/src/ivfutils.c index 02e3cbb..2a40ed6 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -1,9 +1,11 @@ #include "postgres.h" #include "access/generic_xlog.h" +#include "catalog/pg_type.h" #include "ivfflat.h" #include "storage/bufmgr.h" #include "vector.h" +#include "utils/syscache.h" /* * Allocate a vector array @@ -72,7 +74,27 @@ IvfflatOptionalProcInfo(Relation index, uint16 procnum) IvfflatType IvfflatGetType(Relation index) { - return IVFFLAT_TYPE_VECTOR; + Oid typid = TupleDescAttr(index->rd_att, 0)->atttypid; + HeapTuple tuple; + Form_pg_type type; + IvfflatType result; + + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + if (!HeapTupleIsValid(tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + + type = (Form_pg_type) GETSTRUCT(tuple); + if (strcmp(NameStr(type->typname), "vector") == 0) + result = IVFFLAT_TYPE_VECTOR; + else + { + ReleaseSysCache(tuple); + elog(ERROR, "type not supported for ivfflat index"); + } + + ReleaseSysCache(tuple); + + return result; } /*