Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: support ivfflat index type from pgvector (#6785)

Danny Xue89b8caeff15
diff --git a/backend/plugin/advisor/catalog/walk_through_for_pg.go b/backend/plugin/advisor/catalog/walk_through_for_pg.go
index a6995a77a8..cb7b996d48 100644
--- a/backend/plugin/advisor/catalog/walk_through_for_pg.go
+++ b/backend/plugin/advisor/catalog/walk_through_for_pg.go
@@ -946,6 +946,8 @@ func getIndexMethod(method ast.IndexMethodType) string {
return "gin"
case ast.IndexMethodTypeBrin:
return "brin"
+ case ast.IndexMethodTypeIvfflat:
+ return "ivfflat"
}
return ""
}
diff --git a/backend/plugin/parser/sql/ast/index_def.go b/backend/plugin/parser/sql/ast/index_def.go
index 271154b950..d7d795c834 100644
--- a/backend/plugin/parser/sql/ast/index_def.go
+++ b/backend/plugin/parser/sql/ast/index_def.go
@@ -16,6 +16,10 @@ const (
IndexMethodTypeGin
// IndexMethodTypeBrin is the index method type for BRIN.
IndexMethodTypeBrin
+ // IndexMethodTypeIvfflat is the index method type for ivfflat.
+ // https://github.com/bytebase/bytebase/issues/6783.
+ // https://github.com/pgvector/pgvector.
+ IndexMethodTypeIvfflat
)
// String implements fmt.Stringer interface.
@@ -33,6 +37,8 @@ func (tp IndexMethodType) String() string {
return "gin"
case IndexMethodTypeBrin:
return "brin"
+ case IndexMethodTypeIvfflat:
+ return "ivfflat"
default:
return ""
}
diff --git a/backend/plugin/parser/sql/engine/pg/convert.go b/backend/plugin/parser/sql/engine/pg/convert.go
index 73689b5967..96d2019e14 100644
--- a/backend/plugin/parser/sql/engine/pg/convert.go
+++ b/backend/plugin/parser/sql/engine/pg/convert.go
@@ -1035,8 +1035,11 @@ func convertMethodType(method string) (ast.IndexMethodType, error) {
return ast.IndexMethodTypeGin, nil
case "brin":
return ast.IndexMethodTypeBrin, nil
+ case "ivfflat":
+ return ast.IndexMethodTypeIvfflat, nil
default:
- return ast.IndexMethodTypeBTree, parser.NewConvertErrorf("unsupported index method type: %s", method)
+ // Fallback to btree for index from plugins.
+ return ast.IndexMethodTypeBTree, nil
}
}
diff --git a/backend/plugin/parser/sql/engine/pg/deparse.go b/backend/plugin/parser/sql/engine/pg/deparse.go
index b50afa2a22..fa56d621e3 100644
--- a/backend/plugin/parser/sql/engine/pg/deparse.go
+++ b/backend/plugin/parser/sql/engine/pg/deparse.go
@@ -237,6 +237,8 @@ func deparseIndexMethod(method ast.IndexMethodType, buf *strings.Builder) (err e
_, err = buf.WriteString("gin")
case ast.IndexMethodTypeBrin:
_, err = buf.WriteString("brin")
+ case ast.IndexMethodTypeIvfflat:
+ _, err = buf.WriteString("ivfflat")
}
return err
}