From fcb28a6db68ea7fce453528fe268fe0eda52d247 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Thu, 18 Jul 2024 14:10:40 +0200 Subject: [PATCH] Add support for new VECTOR type MySQL 9.0.0 added support for the VECTOR type. This adds basic support so it can be handled at the protocol level. Signed-off-by: Dirkjan Bussink --- AUTHORS | 1 + const.go | 5 ++++- fields.go | 4 +++- packets.go | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4021b96cc..bab66a3b2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,6 +33,7 @@ Daniel Montoya Daniel Nichter Daniƫl van Eeden Dave Protasowski +Dirkjan Bussink DisposaBoy Egor Smolyakov Erwan Martin diff --git a/const.go b/const.go index 22526e031..0cee9b2ee 100644 --- a/const.go +++ b/const.go @@ -125,7 +125,10 @@ const ( fieldTypeBit ) const ( - fieldTypeJSON fieldType = iota + 0xf5 + fieldTypeVector fieldType = iota + 0xf2 + fieldTypeInvalid + fieldTypeBool + fieldTypeJSON fieldTypeNewDecimal fieldTypeEnum fieldTypeSet diff --git a/fields.go b/fields.go index 286084247..be5cd809a 100644 --- a/fields.go +++ b/fields.go @@ -112,6 +112,8 @@ func (mf *mysqlField) typeDatabaseName() string { return "VARCHAR" case fieldTypeYear: return "YEAR" + case fieldTypeVector: + return "VECTOR" default: return "" } @@ -198,7 +200,7 @@ func (mf *mysqlField) scanType() reflect.Type { return scanTypeNullFloat case fieldTypeBit, fieldTypeTinyBLOB, fieldTypeMediumBLOB, fieldTypeLongBLOB, - fieldTypeBLOB, fieldTypeVarString, fieldTypeString, fieldTypeGeometry: + fieldTypeBLOB, fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeVector: if mf.charSet == binaryCollationID { return scanTypeBytes } diff --git a/packets.go b/packets.go index df850fd41..ccdd532b3 100644 --- a/packets.go +++ b/packets.go @@ -1329,7 +1329,8 @@ func (rows *binaryRows) readRow(dest []driver.Value) error { case fieldTypeDecimal, fieldTypeNewDecimal, fieldTypeVarChar, fieldTypeBit, fieldTypeEnum, fieldTypeSet, fieldTypeTinyBLOB, fieldTypeMediumBLOB, fieldTypeLongBLOB, fieldTypeBLOB, - fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeJSON: + fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeJSON, + fieldTypeVector: var isNull bool var n int dest[i], isNull, n, err = readLengthEncodedString(data[pos:])