Skip to content

Commit

Permalink
Add support for new VECTOR type (#1609)
Browse files Browse the repository at this point in the history
MySQL 9.0.0 added support for the VECTOR type. This adds basic support
so it can be handled at the protocol level.

See also
https://dev.mysql.com/doc/dev/mysql-server/latest/field__types_8h.html
  • Loading branch information
dbussink committed Jul 19, 2024
1 parent 3484db1 commit 9c20169
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Daniel Montoya <dsmontoyam at gmail.com>
Daniel Nichter <nil at codenode.com>
Daniël van Eeden <git at myname.nl>
Dave Protasowski <dprotaso at gmail.com>
Dirkjan Bussink <d.bussink at gmail.com>
DisposaBoy <disposaboy at dby.me>
Egor Smolyakov <egorsmkv at gmail.com>
Erwan Martin <hello at erwan.io>
Expand Down
5 changes: 4 additions & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ const (
fieldTypeBit
)
const (
fieldTypeJSON fieldType = iota + 0xf5
fieldTypeVector fieldType = iota + 0xf2
fieldTypeInvalid
fieldTypeBool
fieldTypeJSON
fieldTypeNewDecimal
fieldTypeEnum
fieldTypeSet
Expand Down
4 changes: 3 additions & 1 deletion fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func (mf *mysqlField) typeDatabaseName() string {
return "VARCHAR"
case fieldTypeYear:
return "YEAR"
case fieldTypeVector:
return "VECTOR"
default:
return ""
}
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:])
Expand Down

0 comments on commit 9c20169

Please sign in to comment.