Skip to content

Commit 9c20169

Browse files
authoredJul 19, 2024
Add support for new VECTOR type (go-sql-driver#1609)
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
1 parent 3484db1 commit 9c20169

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed
 

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Daniel Montoya <dsmontoyam at gmail.com>
3333
Daniel Nichter <nil at codenode.com>
3434
Daniël van Eeden <git at myname.nl>
3535
Dave Protasowski <dprotaso at gmail.com>
36+
Dirkjan Bussink <d.bussink at gmail.com>
3637
DisposaBoy <disposaboy at dby.me>
3738
Egor Smolyakov <egorsmkv at gmail.com>
3839
Erwan Martin <hello at erwan.io>

‎const.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ const (
125125
fieldTypeBit
126126
)
127127
const (
128-
fieldTypeJSON fieldType = iota + 0xf5
128+
fieldTypeVector fieldType = iota + 0xf2
129+
fieldTypeInvalid
130+
fieldTypeBool
131+
fieldTypeJSON
129132
fieldTypeNewDecimal
130133
fieldTypeEnum
131134
fieldTypeSet

‎fields.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func (mf *mysqlField) typeDatabaseName() string {
112112
return "VARCHAR"
113113
case fieldTypeYear:
114114
return "YEAR"
115+
case fieldTypeVector:
116+
return "VECTOR"
115117
default:
116118
return ""
117119
}
@@ -198,7 +200,7 @@ func (mf *mysqlField) scanType() reflect.Type {
198200
return scanTypeNullFloat
199201

200202
case fieldTypeBit, fieldTypeTinyBLOB, fieldTypeMediumBLOB, fieldTypeLongBLOB,
201-
fieldTypeBLOB, fieldTypeVarString, fieldTypeString, fieldTypeGeometry:
203+
fieldTypeBLOB, fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeVector:
202204
if mf.charSet == binaryCollationID {
203205
return scanTypeBytes
204206
}

‎packets.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,8 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
13291329
case fieldTypeDecimal, fieldTypeNewDecimal, fieldTypeVarChar,
13301330
fieldTypeBit, fieldTypeEnum, fieldTypeSet, fieldTypeTinyBLOB,
13311331
fieldTypeMediumBLOB, fieldTypeLongBLOB, fieldTypeBLOB,
1332-
fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeJSON:
1332+
fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeJSON,
1333+
fieldTypeVector:
13331334
var isNull bool
13341335
var n int
13351336
dest[i], isNull, n, err = readLengthEncodedString(data[pos:])

0 commit comments

Comments
 (0)
Please sign in to comment.