mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 18:49:14 -06:00
error instead of blob panic (#3561)
This commit is contained in:
committed by
GitHub
parent
dc738b77d1
commit
fe7ff993d9
@@ -16,7 +16,9 @@ package index
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
@@ -28,6 +30,8 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/val"
|
||||
)
|
||||
|
||||
var ErrValueExceededMaxFieldSize = errors.New("value exceeded max field size of 65kb")
|
||||
|
||||
// todo(andy): this should go in GMS
|
||||
func DenormalizeRow(sch sql.Schema, row sql.Row) (sql.Row, error) {
|
||||
var err error
|
||||
@@ -201,13 +205,23 @@ func PutField(tb *val.TupleBuilder, i int, v interface{}) error {
|
||||
tb.PutString(i, v.(string))
|
||||
case val.ByteStringEnc:
|
||||
if s, ok := v.(string); ok {
|
||||
if len(s) > math.MaxUint16 {
|
||||
return ErrValueExceededMaxFieldSize
|
||||
}
|
||||
v = []byte(s)
|
||||
}
|
||||
tb.PutByteString(i, v.([]byte))
|
||||
case val.GeometryEnc:
|
||||
geo := serializeGeometry(v)
|
||||
if len(geo) > math.MaxUint16 {
|
||||
return ErrValueExceededMaxFieldSize
|
||||
}
|
||||
tb.PutGeometry(i, serializeGeometry(v))
|
||||
case val.JSONEnc:
|
||||
buf, err := convJson(v)
|
||||
if len(buf) > math.MaxUint16 {
|
||||
return ErrValueExceededMaxFieldSize
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user