types

package
v0.14.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BitTypeMinBits returns the minimum number of bits for Bit.
	BitTypeMinBits = 1
	// BitTypeMaxBits returns the maximum number of bits for Bit.
	BitTypeMaxBits = 64
)
View Source
const (
	// DecimalTypeMaxPrecision returns the maximum precision allowed for the Decimal type.
	DecimalTypeMaxPrecision = 65
	// DecimalTypeMaxScale returns the maximum scale allowed for the Decimal type, assuming the
	// maximum precision is used. For a maximum scale that is relative to the precision of a given
	// decimal type, use its MaximumScale function.
	DecimalTypeMaxScale = 30
)
View Source
const (
	// EnumTypeMinElements returns the minimum number of enumerations for the Enum type.
	EnumTypeMinElements = 1
	// EnumTypeMaxElements returns the maximum number of enumerations for the Enum type.
	EnumTypeMaxElements = 65535
)
View Source
const (
	CartesianSRID  = uint32(0)
	GeoSpatialSRID = uint32(4326)
)
View Source
const (
	SRIDSize       = 4
	EndianSize     = 1
	TypeSize       = 4
	EWKBHeaderSize = SRIDSize + EndianSize + TypeSize
	WKBHeaderSize  = EndianSize + TypeSize

	PointSize             = 16
	CountSize             = 4
	GeometryMaxByteLength = 4*(1024*1024*1024) - 1
)
View Source
const (
	WKBUnknown = iota
	WKBPointID
	WKBLineID
	WKBPolyID
	WKBMultiPointID
	WKBMultiLineID
	WKBMultiPolyID
	WKBGeomCollID
)

Type IDs

View Source
const (
	TinyTextBlobMax   = charBinaryMax
	TextBlobMax       = varcharVarbinaryMax
	MediumTextBlobMax = 16_777_215
	LongTextBlobMax   = int64(4_294_967_295)
)
View Source
const OkResultColumnName = "__ok_result__"

OkResultColumnName should be used as the schema column name for Nodes that return an OkResult

View Source
const (
	// SetTypeMaxElements returns the maximum number of elements for the Set type.
	SetTypeMaxElements = 64
)

Variables

View Source
var (
	// ErrConvertingToTime is thrown when a value cannot be converted to a Time
	ErrConvertingToTime = errors.NewKind("Incorrect datetime value: '%s'")

	ErrConvertingToTimeOutOfRange = errors.NewKind("value %q is outside of %v range")

	// TimestampDatetimeLayouts hold extra timestamps allowed for parsing. It does
	// not have all the layouts supported by mysql. Missing are two digit year
	// versions of common cases and dates that use non common separators.
	//
	// https://github.com/MariaDB/server/blob/mysql-5.5.36/sql-common/my_time.c#L124
	TimestampDatetimeLayouts = []string{
		"2006-01-02 15:4",
		"2006-01-02 15:04",
		"2006-01-02 15:04:",
		"2006-01-02 15:04:.",
		"2006-01-02 15:04:05.",
		"2006-01-02 15:04:05.999999",
		"2006-01-02",
		"2006-1-2",
		"2006-1-2 15:4:5.999999",
		time.RFC3339,
		time.RFC3339Nano,
		"2006-01-02T15:04:05",
		"20060102150405",
		"20060102",
		"2006/01/02",
		"2006-01-02 15:04:05.999999999 -0700 MST",
	}

	// Date is a date with day, month and year.
	Date = MustCreateDatetimeType(sqltypes.Date)
	// Datetime is a date and a time
	Datetime = MustCreateDatetimeType(sqltypes.Datetime)
	// Timestamp is an UNIX timestamp.
	Timestamp = MustCreateDatetimeType(sqltypes.Timestamp)
)
View Source
var (
	ErrConvertingToDecimal   = errors.NewKind("value %v is not a valid Decimal")
	ErrConvertToDecimalLimit = errors.NewKind("Out of range value for column of Decimal type ")
	ErrMarshalNullDecimal    = errors.NewKind("Decimal cannot marshal a null value")
)
View Source
var (
	Null sql.NullType = nullType{}

	// ErrValueNotNil is thrown when a value that was expected to be nil, is not
	ErrValueNotNil = errors.NewKind("value not nil: %#v")
)
View Source
var (
	// Boolean is a synonym for TINYINT
	Boolean = Int8
	// Int8 is an integer of 8 bits
	Int8 = MustCreateNumberType(sqltypes.Int8)
	// Uint8 is an unsigned integer of 8 bits
	Uint8 = MustCreateNumberType(sqltypes.Uint8)
	// Int16 is an integer of 16 bits
	Int16 = MustCreateNumberType(sqltypes.Int16)
	// Uint16 is an unsigned integer of 16 bits
	Uint16 = MustCreateNumberType(sqltypes.Uint16)
	// Int24 is an integer of 24 bits.
	Int24 = MustCreateNumberType(sqltypes.Int24)
	// Uint24 is an unsigned integer of 24 bits.
	Uint24 = MustCreateNumberType(sqltypes.Uint24)
	// Int32 is an integer of 32 bits.
	Int32 = MustCreateNumberType(sqltypes.Int32)
	// Uint32 is an unsigned integer of 32 bits.
	Uint32 = MustCreateNumberType(sqltypes.Uint32)
	// Int64 is an integer of 64 bytes.
	Int64 = MustCreateNumberType(sqltypes.Int64)
	// Uint64 is an unsigned integer of 64 bits.
	Uint64 = MustCreateNumberType(sqltypes.Uint64)
	// Float32 is a floating point number of 32 bits.
	Float32 = MustCreateNumberType(sqltypes.Float32)
	// Float64 is a floating point number of 64 bits.
	Float64 = MustCreateNumberType(sqltypes.Float64)
)
View Source
var (
	// ErrLengthTooLarge is thrown when a string's length is too large given the other parameters.
	ErrLengthTooLarge    = errors.NewKind("length is %v but max allowed is %v")
	ErrLengthBeyondLimit = errors.NewKind("string '%v' is too large for column '%v'")
	ErrBinaryCollation   = errors.NewKind("binary types must have the binary collation")

	TinyText   = MustCreateStringWithDefaults(sqltypes.Text, TinyTextBlobMax)
	Text       = MustCreateStringWithDefaults(sqltypes.Text, TextBlobMax)
	MediumText = MustCreateStringWithDefaults(sqltypes.Text, MediumTextBlobMax)
	LongText   = MustCreateStringWithDefaults(sqltypes.Text, LongTextBlobMax)
	TinyBlob   = MustCreateBinary(sqltypes.Blob, TinyTextBlobMax)
	Blob       = MustCreateBinary(sqltypes.Blob, TextBlobMax)
	MediumBlob = MustCreateBinary(sqltypes.Blob, MediumTextBlobMax)
	LongBlob   = MustCreateBinary(sqltypes.Blob, LongTextBlobMax)
)
View Source
var (
	Year sql.YearType = YearType_{}

	ErrConvertingToYear = errors.NewKind("value %v is not a valid Year")
)
View Source
var (
	ErrConvertingToEnum = errors.NewKind("value %v is not valid for this Enum")
)
View Source
var (
	ErrNotGeomColl = errors.NewKind("value of type %T is not a point")
)
View Source
var (
	ErrNotGeometry = errors.NewKind("Value of type %T is not a geometry")
)
View Source
var (
	ErrNotMultiLineString = errors.NewKind("value of type %T is not a multilinestring")
)
View Source
var (
	ErrNotMultiPoint = errors.NewKind("value of type %T is not a multipoint")
)
View Source
var (
	ErrNotMultiPolygon = errors.NewKind("value of type %T is not a multipolygon")
)
View Source
var (
	ErrNotPolygon = errors.NewKind("value of type %T is not a polygon")
)
View Source
var InternalDecimalType sql.DecimalType = DecimalType_{
	// contains filtered or unexported fields
}

InternalDecimalType is a special DecimalType that is used internally for Decimal comparisons. Not intended for usage from integrators.

View Source
var JSON sql.Type = JsonType{}
View Source
var (
	MaxJsonFieldByteLength = int64(1024) * int64(1024) * int64(1024)
)
View Source
var OkResultColumnType = Int64

OkResultColumnType should be used as the schema column type for Nodes that return an OkResult

View Source
var OkResultSchema = sql.Schema{
	{
		Name: OkResultColumnName,
		Type: OkResultColumnType,
	},
}

OkResultSchema should be used as the schema of Nodes that return an OkResult

Functions

func AllocateGeoTypeBuffer

func AllocateGeoTypeBuffer(numPoints, numCounts, numWKBHeaders int) []byte

TODO: unexport

func AppendAndSliceBytes

func AppendAndSliceBytes(buffer, addition []byte) (slice []byte)

func AppendAndSliceString

func AppendAndSliceString(buffer []byte, addition string) (slice []byte)

TODO: move me

func ApproximateTypeFromValue

func ApproximateTypeFromValue(val interface{}) sql.Type

ApproximateTypeFromValue returns the closest matching type to the given value. For example, an int16 will return SMALLINT.

func ColumnTypeToType

func ColumnTypeToType(ct *sqlparser.ColumnType) (sql.Type, error)

ColumnTypeToType gets the column type using the column definition.

func CompareNulls

func CompareNulls(a interface{}, b interface{}) (bool, int)

CompareNulls compares two values, and returns true if either is null. The returned integer represents the ordering, with a rule that states nulls as being ordered before non-nulls.

func ConvertToBool

func ConvertToBool(v interface{}) (bool, error)

func ConvertToCollatedString

func ConvertToCollatedString(val interface{}, typ sql.Type) (string, sql.CollationID, error)

ConvertToCollatedString returns the given interface as a string, along with its collation. If the Type possess a collation, then that collation is returned. If the Type does not possess a collation (such as an integer), then the value is converted to a string and the default collation is used. If the value is already a string then no additional conversions are made. If the value is a byte slice then a non-copying conversion is made, which means that the original byte slice MUST NOT be modified after being passed to this function. If modifications need to be made, then you must allocate a new byte slice and pass that new one in.

func ConvertToString

func ConvertToString(v interface{}, t sql.StringType) (string, error)

func ConvertToTime

func ConvertToTime(v interface{}, t datetimeType) (time.Time, error)

func CreateBinary

func CreateBinary(baseType query.Type, lengthHint int64) (sql.StringType, error)

CreateBinary creates a StringType with a binary collation and character set of the given size.

func CreateColumnDecimalType

func CreateColumnDecimalType(precision uint8, scale uint8) (sql.DecimalType, error)

CreateColumnDecimalType creates a DecimalType for VALID-TABLE-COLUMN. Creating a decimal type for a column ensures that when operating on instances of this type, the result will be restricted to the defined precision and scale.

func CreateDatetimeType

func CreateDatetimeType(baseType query.Type) (sql.DatetimeType, error)

CreateDatetimeType creates a Type dealing with all temporal types that are not TIME nor YEAR.

func CreateDecimalType

func CreateDecimalType(precision uint8, scale uint8) (sql.DecimalType, error)

CreateDecimalType creates a DecimalType for NON-TABLE-COLUMN.

func CreateEnumType

func CreateEnumType(values []string, collation sql.CollationID) (sql.EnumType, error)

CreateEnumType creates a EnumType.

func CreateLongText

func CreateLongText(collation sql.CollationID) sql.StringType

CreateLongText creates a LONGTEXT with the given collation.

func CreateMediumText

func CreateMediumText(collation sql.CollationID) sql.StringType

CreateMediumText creates a MEDIUMTEXT with the given collation.

func CreateNumberType

func CreateNumberType(baseType query.Type) (sql.NumberType, error)

CreateNumberType creates a NumberType.

func CreateSetType

func CreateSetType(values []string, collation sql.CollationID) (sql.SetType, error)

CreateSetType creates a SetType.

func CreateString

func CreateString(baseType query.Type, length int64, collation sql.CollationID) (sql.StringType, error)

CreateString creates a new StringType based on the specified type, length, and collation. Length is interpreted as the length of bytes in the new StringType for SQL types that are based on bytes (i.e. TEXT, BLOB, BINARY, and VARBINARY). For all other char-based SQL types, length is interpreted as the length of chars in the new StringType (i.e. CHAR, and VARCHAR).

func CreateStringWithDefaults

func CreateStringWithDefaults(baseType query.Type, length int64) (sql.StringType, error)

CreateStringWithDefaults creates a StringType with the default character set and collation of the given size.

func CreateText

func CreateText(collation sql.CollationID) sql.StringType

CreateText creates a TEXT with the given collation.

func CreateTinyText

func CreateTinyText(collation sql.CollationID) sql.StringType

CreateTinyText creates a TINYTEXT with the given collation.

func CreateTuple

func CreateTuple(types ...sql.Type) sql.Type

CreateTuple returns a new tuple type with the given element types.

func DeepCopyJson

func DeepCopyJson(v interface{}) interface{}

DeepCopyJson implements deep copy of JSON document

func DeserializeEWKBHeader

func DeserializeEWKBHeader(buf []byte) (srid uint32, bigEndian bool, typ uint32, err error)

DeserializeEWKBHeader parses the header portion of a byte array in EWKB format to extract endianness and type

func DeserializeWKBHeader

func DeserializeWKBHeader(buf []byte) (bigEndian bool, typ uint32, err error)

DeserializeWKBHeader parses the header potion of a byte array in WKB format There is no SRID

func ErrIfMismatchedColumns

func ErrIfMismatchedColumns(t1, t2 sql.Type) error

ErrIfMismatchedColumns returns an operand error if the number of columns in t1 is not equal to the number of columns in t2. If the number of columns is equal, and both types are tuple types, it recurses into each subtype, asserting that those subtypes are structurally identical as well.

func ErrIfMismatchedColumnsInTuple

func ErrIfMismatchedColumnsInTuple(t1, t2 sql.Type) error

ErrIfMismatchedColumnsInTuple returns an operand error is t2 is not a tuple type whose subtypes are structurally identical to t1.

func IsBinaryType

func IsBinaryType(t sql.Type) bool

IsBinaryType checks if t is BINARY, VARBINARY, or BLOB

func IsBit

func IsBit(t sql.Type) bool

IsBit checks if t is a BIT type.

func IsBlobType

func IsBlobType(t sql.Type) bool

IsBlobType checks if t is BLOB

func IsDateType

func IsDateType(t sql.Type) bool

IsDateType checks if t is a date

func IsDatetimeType

func IsDatetimeType(t sql.Type) bool

IsDatetimeType checks if t is a datetime

func IsDecimal

func IsDecimal(t sql.Type) bool

IsDecimal checks if t is a DECIMAL type.

func IsDeferredType

func IsDeferredType(t sql.Type) bool

func IsEnum

func IsEnum(t sql.Type) bool

IsEnum checks if t is a enum

func IsFloat

func IsFloat(t sql.Type) bool

IsFloat checks if t is float type.

func IsGeometry

func IsGeometry(t sql.Type) bool

IsGeometry returns true if the specified type is a Geometry type.

func IsInteger

func IsInteger(t sql.Type) bool

IsInteger checks if t is an integer type.

func IsJSON

func IsJSON(t sql.Type) bool

IsJSON returns true if the specified type is a JSON type.

func IsNull

func IsNull(ex sql.Expression) bool

IsNull returns true if expression is nil or is Null Type, otherwise false.

func IsNumber

func IsNumber(t sql.Type) bool

IsNumber checks if t is a number type

func IsOkResult

func IsOkResult(row sql.Row) bool

IsOkResult returns whether the given row represents an OkResult.

func IsOkResultSchema

func IsOkResultSchema(schema sql.Schema) bool

func IsSet

func IsSet(t sql.Type) bool

IsSet checks if t is a set

func IsSigned

func IsSigned(t sql.Type) bool

IsSigned checks if t is a signed type.

func IsText

func IsText(t sql.Type) bool

IsText checks if t is a CHAR, VARCHAR, TEXT, BINARY, VARBINARY, or BLOB (including TEXT and BLOB variants).

func IsTextBlob

func IsTextBlob(t sql.Type) bool

IsTextBlob checks if t is one of the TEXTs or BLOBs.

func IsTextOnly

func IsTextOnly(t sql.Type) bool

IsTextOnly checks if t is CHAR, VARCHAR, or one of the TEXTs.

func IsTime

func IsTime(t sql.Type) bool

IsTime checks if t is a timestamp, date or datetime

func IsTimespan

func IsTimespan(t sql.Type) bool

IsTimespan checks if t is a time (timespan)

func IsTimestampType

func IsTimestampType(t sql.Type) bool

IsTimestampType checks if t is a timestamp

func IsTuple

func IsTuple(t sql.Type) bool

IsTuple checks if t is a tuple type. Note that TupleType instances with just 1 value are not considered as a tuple, but a parenthesized value.

func IsUnsigned

func IsUnsigned(t sql.Type) bool

IsUnsigned checks if t is an unsigned type.

func MustCreateBinary

func MustCreateBinary(baseType query.Type, lengthHint int64) sql.StringType

MustCreateBinary is the same as CreateBinary except it panics on errors.

func MustCreateColumnDecimalType

func MustCreateColumnDecimalType(precision uint8, scale uint8) sql.DecimalType

MustCreateColumnDecimalType is the same as CreateDecimalType except it panics on errors and for VALID-TABLE-COLUMN.

func MustCreateDatetimeType

func MustCreateDatetimeType(baseType query.Type) sql.DatetimeType

MustCreateDatetimeType is the same as CreateDatetimeType except it panics on errors.

func MustCreateDecimalType

func MustCreateDecimalType(precision uint8, scale uint8) sql.DecimalType

MustCreateDecimalType is the same as CreateDecimalType except it panics on errors and for NON-TABLE-COLUMN.

func MustCreateEnumType

func MustCreateEnumType(values []string, collation sql.CollationID) sql.EnumType

MustCreateEnumType is the same as CreateEnumType except it panics on errors.

func MustCreateNumberType

func MustCreateNumberType(baseType query.Type) sql.NumberType

MustCreateNumberType is the same as CreateNumberType except it panics on errors.

func MustCreateSetType

func MustCreateSetType(values []string, collation sql.CollationID) sql.SetType

MustCreateSetType is the same as CreateSetType except it panics on errors.

func MustCreateString

func MustCreateString(baseType query.Type, length int64, collation sql.CollationID) sql.StringType

MustCreateString is the same as CreateString except it panics on errors.

func MustCreateStringWithDefaults

func MustCreateStringWithDefaults(baseType query.Type, length int64) sql.StringType

MustCreateStringWithDefaults creates a StringType with the default CharacterSet and Collation.

func NewDeferredType

func NewDeferredType(name string) sql.Type

func NewSystemBoolType

func NewSystemBoolType(varName string) sql.SystemVariableType

NewSystemBoolType returns a new systemBoolType.

func NewSystemDoubleType

func NewSystemDoubleType(varName string, lowerbound, upperbound float64) sql.SystemVariableType

NewSystemDoubleType returns a new systemDoubleType.

func NewSystemEnumType

func NewSystemEnumType(varName string, values ...string) sql.SystemVariableType

NewSystemEnumType returns a new systemEnumType.

func NewSystemIntType

func NewSystemIntType(varName string, lowerbound, upperbound int64, negativeOne bool) sql.SystemVariableType

NewSystemIntType returns a new systemIntType.

func NewSystemSetType

func NewSystemSetType(varName string, values ...string) sql.SystemVariableType

NewSystemSetType returns a new systemSetType.

func NewSystemStringType

func NewSystemStringType(varName string) sql.SystemVariableType

NewSystemStringType returns a new systemStringType.

func NewSystemUintType

func NewSystemUintType(varName string, lowerbound, upperbound uint64) sql.SystemVariableType

NewSystemUintType returns a new systemUintType.

func NumColumns

func NumColumns(t sql.Type) int

NumColumns returns the number of columns in a type. This is one for all types, except tuples.

func NumericUnaryValue

func NumericUnaryValue(t sql.Type) interface{}

func TypesEqual

func TypesEqual(a, b sql.Type) bool

TypesEqual compares two Types and returns whether they are equivalent.

func ValidateTime

func ValidateTime(t time.Time) interface{}

ValidateTime receives a time and returns either that time or nil if it's not a valid time.

func WriteCount

func WriteCount(buf []byte, count uint32)

TODO: rename me, unexport

func WriteEWKBHeader

func WriteEWKBHeader(buf []byte, srid, typ uint32)

WriteEWKBHeader will write EWKB header to the given buffer

func WriteWKBHeader

func WriteWKBHeader(buf []byte, typ uint32)

WriteWKBHeader will write WKB header to the given buffer

Types

type BitType

type BitType interface {
	sql.Type
	NumberOfBits() uint8
}

BitType represents the BIT type. https://dev.mysql.com/doc/refman/8.0/en/bit-type.html The type of the returned value is uint64.

func CreateBitType

func CreateBitType(numOfBits uint8) (BitType, error)

CreateBitType creates a BitType.

func MustCreateBitType

func MustCreateBitType(numOfBits uint8) BitType

MustCreateBitType is the same as CreateBitType except it panics on errors.

type BitType_

type BitType_ struct {
	// contains filtered or unexported fields
}

func (BitType_) Compare

func (t BitType_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (BitType_) Convert

func (t BitType_) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (BitType_) Equals

func (t BitType_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (BitType_) MaxTextResponseByteLength

func (t BitType_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements Type interface

func (BitType_) MustConvert

func (t BitType_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (BitType_) NumberOfBits

func (t BitType_) NumberOfBits() uint8

NumberOfBits returns the number of bits that this type may contain.

func (BitType_) Promote

func (t BitType_) Promote() sql.Type

Promote implements the Type interface.

func (BitType_) SQL

func (t BitType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (BitType_) String

func (t BitType_) String() string

String implements Type interface.

func (BitType_) Type

func (t BitType_) Type() query.Type

Type implements Type interface.

func (BitType_) ValueType

func (t BitType_) ValueType() reflect.Type

ValueType implements Type interface.

func (BitType_) Zero

func (t BitType_) Zero() interface{}

Zero implements Type interface. Returns a uint64 value.

type DecimalType_

type DecimalType_ struct {
	// contains filtered or unexported fields
}

func (DecimalType_) BoundsCheck

func (t DecimalType_) BoundsCheck(v decimal.Decimal) (decimal.Decimal, error)

func (DecimalType_) Compare

func (t DecimalType_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (DecimalType_) Convert

func (t DecimalType_) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (DecimalType_) ConvertNoBoundsCheck

func (t DecimalType_) ConvertNoBoundsCheck(v interface{}) (decimal.Decimal, error)

func (DecimalType_) ConvertToNullDecimal

func (t DecimalType_) ConvertToNullDecimal(v interface{}) (decimal.NullDecimal, error)

ConvertToNullDecimal implements DecimalType interface.

func (DecimalType_) Equals

func (t DecimalType_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (DecimalType_) ExclusiveUpperBound

func (t DecimalType_) ExclusiveUpperBound() decimal.Decimal

ExclusiveUpperBound implements DecimalType interface.

func (DecimalType_) MaxTextResponseByteLength

func (t DecimalType_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (DecimalType_) MaximumScale

func (t DecimalType_) MaximumScale() uint8

MaximumScale implements DecimalType interface.

func (DecimalType_) MustConvert

func (t DecimalType_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (DecimalType_) Precision

func (t DecimalType_) Precision() uint8

Precision implements DecimalType interface.

func (DecimalType_) Promote

func (t DecimalType_) Promote() sql.Type

Promote implements the Type interface.

func (DecimalType_) SQL

func (t DecimalType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (DecimalType_) Scale

func (t DecimalType_) Scale() uint8

Scale implements DecimalType interface.

func (DecimalType_) String

func (t DecimalType_) String() string

String implements Type interface.

func (DecimalType_) Type

func (t DecimalType_) Type() query.Type

Type implements Type interface.

func (DecimalType_) ValueType

func (t DecimalType_) ValueType() reflect.Type

ValueType implements Type interface.

func (DecimalType_) Zero

func (t DecimalType_) Zero() interface{}

Zero implements Type interface.

type EnumType

type EnumType struct {
	// contains filtered or unexported fields
}

func (EnumType) At

func (t EnumType) At(index int) (string, bool)

At implements EnumType interface.

func (EnumType) CharacterSet

func (t EnumType) CharacterSet() sql.CharacterSetID

CharacterSet implements EnumType interface.

func (EnumType) Collation

func (t EnumType) Collation() sql.CollationID

Collation implements EnumType interface.

func (EnumType) Compare

func (t EnumType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (EnumType) Convert

func (t EnumType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (EnumType) Equals

func (t EnumType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (EnumType) IndexOf

func (t EnumType) IndexOf(v string) int

IndexOf implements EnumType interface.

func (EnumType) MaxTextResponseByteLength

func (t EnumType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (EnumType) MustConvert

func (t EnumType) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (EnumType) NumberOfElements

func (t EnumType) NumberOfElements() uint16

NumberOfElements implements EnumType interface.

func (EnumType) Promote

func (t EnumType) Promote() sql.Type

Promote implements the Type interface.

func (EnumType) SQL

func (t EnumType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (EnumType) String

func (t EnumType) String() string

String implements Type interface.

func (EnumType) Type

func (t EnumType) Type() query.Type

Type implements Type interface.

func (EnumType) ValueType

func (t EnumType) ValueType() reflect.Type

ValueType implements Type interface.

func (EnumType) Values

func (t EnumType) Values() []string

Values implements EnumType interface.

func (EnumType) WithNewCollation

func (t EnumType) WithNewCollation(collation sql.CollationID) (sql.Type, error)

WithNewCollation implements TypeWithCollation interface.

func (EnumType) Zero

func (t EnumType) Zero() interface{}

Zero implements Type interface.

type GeomColl

type GeomColl struct {
	SRID  uint32
	Geoms []GeometryValue
}

GeomColl is the value type returned from GeomCollType. Implements GeometryValue.

func DeserializeGeomColl

func DeserializeGeomColl(buf []byte, isBig bool, srid uint32) (GeomColl, int, error)

DeserializeGeomColl parses the data portion of a byte array in WKB format to a GeometryCollection object

func (GeomColl) BBox

func (g GeomColl) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (GeomColl) CalculateSize

func (g GeomColl) CalculateSize() (numPoints int, numCounts int, numHeaders int)

CalculateSize is a helper method to determine how much space to allocate for geometry collections TODO: recursion could be better; possible to expand to fit all types

func (GeomColl) GetSRID

func (g GeomColl) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (GeomColl) Serialize

func (g GeomColl) Serialize() (buf []byte)

Serialize implements GeometryValue interface. TODO: actually count all points to allocate

func (GeomColl) SetSRID

func (g GeomColl) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (GeomColl) Swap

func (g GeomColl) Swap() GeometryValue

Swap implements GeometryValue interface.

func (GeomColl) WriteData

func (g GeomColl) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type GeomCollType

type GeomCollType struct {
	SRID        uint32
	DefinedSRID bool
}

GeomCollType represents the GeometryCollection type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-point.html The type of the returned value is GeomColl.

func (GeomCollType) Compare

func (t GeomCollType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (GeomCollType) Convert

func (t GeomCollType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (GeomCollType) Equals

func (t GeomCollType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (GeomCollType) GetSpatialTypeSRID

func (t GeomCollType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (GeomCollType) MatchSRID

func (t GeomCollType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (GeomCollType) MaxTextResponseByteLength

func (t GeomCollType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (GeomCollType) Promote

func (t GeomCollType) Promote() sql.Type

Promote implements the Type interface.

func (GeomCollType) SQL

func (t GeomCollType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (GeomCollType) SetSRID

func (t GeomCollType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (GeomCollType) String

func (t GeomCollType) String() string

String implements Type interface.

func (GeomCollType) Type

func (t GeomCollType) Type() query.Type

Type implements Type interface.

func (GeomCollType) ValueType

func (t GeomCollType) ValueType() reflect.Type

ValueType implements Type interface.

func (GeomCollType) Zero

func (t GeomCollType) Zero() interface{}

Zero implements Type interface.

type GeometryType

type GeometryType struct {
	SRID        uint32
	DefinedSRID bool
}

GeometryType represents the GEOMETRY type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-geometry.html The type of the returned value is one of the following (each implements GeometryValue): Point, Polygon, LineString.

func (GeometryType) Compare

func (t GeometryType) Compare(a any, b any) (int, error)

Compare implements Type interface.

func (GeometryType) Convert

func (t GeometryType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (GeometryType) Equals

func (t GeometryType) Equals(otherType sql.Type) (ok bool)

Equals implements the Type interface.

func (GeometryType) GetSpatialTypeSRID

func (t GeometryType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (GeometryType) MatchSRID

func (t GeometryType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (GeometryType) MaxTextResponseByteLength

func (t GeometryType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (GeometryType) Promote

func (t GeometryType) Promote() sql.Type

Promote implements the Type interface.

func (GeometryType) SQL

func (t GeometryType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (GeometryType) SetSRID

func (t GeometryType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (GeometryType) String

func (t GeometryType) String() string

String implements Type interface.

func (GeometryType) Type

func (t GeometryType) Type() query.Type

Type implements Type interface.

func (GeometryType) ValueType

func (t GeometryType) ValueType() reflect.Type

ValueType implements Type interface.

func (GeometryType) Zero

func (t GeometryType) Zero() interface{}

Zero implements Type interface.

type GeometryValue

type GeometryValue interface {
	GetSRID() uint32
	SetSRID(srid uint32) GeometryValue
	Serialize() []byte
	WriteData(buf []byte) int
	Swap() GeometryValue
	BBox() (float64, float64, float64, float64)
	// contains filtered or unexported methods
}

GeometryValue is the value type returned from GeometryType, which is an interface over the following types: Point, Polygon, LineString, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection.

type JSONDocument

type JSONDocument struct {
	Val interface{}
}

func MustJSON

func MustJSON(s string) JSONDocument

func (JSONDocument) Compare

func (doc JSONDocument) Compare(ctx *sql.Context, v JSONValue) (int, error)

func (JSONDocument) Contains

func (doc JSONDocument) Contains(ctx *sql.Context, candidate JSONValue) (val interface{}, err error)

Contains returns nil in case of a nil value for either the doc.Val or candidate. Otherwise it returns a bool

func (JSONDocument) Extract

func (doc JSONDocument) Extract(ctx *sql.Context, path string) (JSONValue, error)

func (JSONDocument) Keys

func (doc JSONDocument) Keys(ctx *sql.Context, path string) (val JSONValue, err error)

func (JSONDocument) Overlaps

func (doc JSONDocument) Overlaps(ctx *sql.Context, val SearchableJSONValue) (ok bool, err error)

func (JSONDocument) Search

func (doc JSONDocument) Search(ctx *sql.Context) (path string, err error)

func (JSONDocument) ToString

func (doc JSONDocument) ToString(_ *sql.Context) (string, error)

func (JSONDocument) Unmarshall

func (doc JSONDocument) Unmarshall(_ *sql.Context) (JSONDocument, error)

func (JSONDocument) Value

func (doc JSONDocument) Value() (driver.Value, error)

Value implements driver.Valuer for interoperability with other go libraries

type JSONValue

type JSONValue interface {
	// Unmarshall converts a JSONValue to a JSONDocument
	Unmarshall(ctx *sql.Context) (val JSONDocument, err error)
	// Compare compares two JSONValues. It maintains the same return value
	// semantics as Type.Compare()
	Compare(ctx *sql.Context, v JSONValue) (cmp int, err error)
	// ToString marshalls a JSONValue to a valid JSON-encoded string.
	ToString(ctx *sql.Context) (string, error)
}

JSONValue is an integrator specific implementation of a JSON field value.

func ConcatenateJSONValues

func ConcatenateJSONValues(ctx *sql.Context, vals ...JSONValue) (JSONValue, error)

type JsonType

type JsonType struct{}

func (JsonType) Compare

func (t JsonType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (JsonType) Convert

func (t JsonType) Convert(v interface{}) (doc interface{}, err error)

Convert implements Type interface.

func (JsonType) Equals

func (t JsonType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (JsonType) MaxTextResponseByteLength

func (t JsonType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (JsonType) Promote

func (t JsonType) Promote() sql.Type

Promote implements the Type interface.

func (JsonType) SQL

func (t JsonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (JsonType) String

func (t JsonType) String() string

String implements Type interface.

func (JsonType) Type

func (t JsonType) Type() query.Type

Type implements Type interface.

func (JsonType) ValueType

func (t JsonType) ValueType() reflect.Type

ValueType implements Type interface.

func (JsonType) Zero

func (t JsonType) Zero() interface{}

Zero implements Type interface.

type LineString

type LineString struct {
	SRID   uint32
	Points []Point
}

LineString is the value type returned from LineStringType. Implements GeometryValue.

func DeserializeLine

func DeserializeLine(buf []byte, isBig bool, srid uint32) (LineString, int, error)

DeserializeLine parses the data portion of a byte array in WKB format to a LineString object

func (LineString) BBox

func (l LineString) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (LineString) GetSRID

func (l LineString) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (LineString) Serialize

func (l LineString) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (LineString) SetSRID

func (l LineString) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (LineString) Swap

func (l LineString) Swap() GeometryValue

Swap implements GeometryValue interface. TODO: possible in place?

func (LineString) WriteData

func (l LineString) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type LineStringType

type LineStringType struct {
	SRID        uint32
	DefinedSRID bool
}

LineStringType represents the LINESTRING type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-linestring.html The type of the returned value is LineString.

func (LineStringType) Compare

func (t LineStringType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (LineStringType) Convert

func (t LineStringType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (LineStringType) Equals

func (t LineStringType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (LineStringType) GetSpatialTypeSRID

func (t LineStringType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (LineStringType) MatchSRID

func (t LineStringType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (LineStringType) MaxTextResponseByteLength

func (t LineStringType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (LineStringType) Promote

func (t LineStringType) Promote() sql.Type

Promote implements the Type interface.

func (LineStringType) SQL

func (t LineStringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (LineStringType) SetSRID

func (t LineStringType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (LineStringType) String

func (t LineStringType) String() string

String implements Type interface.

func (LineStringType) Type

func (t LineStringType) Type() query.Type

Type implements Type interface.

func (LineStringType) ValueType

func (t LineStringType) ValueType() reflect.Type

ValueType implements Type interface.

func (LineStringType) Zero

func (t LineStringType) Zero() interface{}

Zero implements Type interface.

type MultiLineString

type MultiLineString struct {
	SRID  uint32
	Lines []LineString
}

MultiLineString is the value type returned from MultiLineStringType. Implements GeometryValue.

func DeserializeMLine

func DeserializeMLine(buf []byte, isBig bool, srid uint32) (MultiLineString, int, error)

DeserializeMLine parses the data portion of a byte array in WKB format to a MultiLineString object

func (MultiLineString) BBox

BBox implements GeometryValue interface.

func (MultiLineString) GetSRID

func (p MultiLineString) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (MultiLineString) Serialize

func (p MultiLineString) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (MultiLineString) SetSRID

func (p MultiLineString) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (MultiLineString) Swap

func (p MultiLineString) Swap() GeometryValue

Swap implements GeometryValue interface.

func (MultiLineString) WriteData

func (p MultiLineString) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type MultiLineStringType

type MultiLineStringType struct {
	SRID        uint32
	DefinedSRID bool
}

MultiLineStringType represents the MUTILINESTRING type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-multilinestring.html The type of the returned value is MultiLineString.

func (MultiLineStringType) Compare

func (t MultiLineStringType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (MultiLineStringType) Convert

func (t MultiLineStringType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (MultiLineStringType) Equals

func (t MultiLineStringType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (MultiLineStringType) GetSpatialTypeSRID

func (t MultiLineStringType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (MultiLineStringType) MatchSRID

func (t MultiLineStringType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (MultiLineStringType) MaxTextResponseByteLength

func (t MultiLineStringType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (MultiLineStringType) Promote

func (t MultiLineStringType) Promote() sql.Type

Promote implements the Type interface.

func (MultiLineStringType) SQL

func (t MultiLineStringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (MultiLineStringType) SetSRID

func (t MultiLineStringType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (MultiLineStringType) String

func (t MultiLineStringType) String() string

String implements Type interface.

func (MultiLineStringType) Type

func (t MultiLineStringType) Type() query.Type

Type implements Type interface.

func (MultiLineStringType) ValueType

func (t MultiLineStringType) ValueType() reflect.Type

ValueType implements Type interface.

func (MultiLineStringType) Zero

func (t MultiLineStringType) Zero() interface{}

Zero implements Type interface.

type MultiPoint

type MultiPoint struct {
	SRID   uint32
	Points []Point
}

MultiPoint is the value type returned from MultiPointType. Implements GeometryValue.

func DeserializeMPoint

func DeserializeMPoint(buf []byte, isBig bool, srid uint32) (MultiPoint, int, error)

DeserializeMPoint parses the data portion of a byte array in WKB format to a MultiPoint object

func (MultiPoint) BBox

func (p MultiPoint) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (MultiPoint) GetSRID

func (p MultiPoint) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (MultiPoint) Serialize

func (p MultiPoint) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (MultiPoint) SetSRID

func (p MultiPoint) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (MultiPoint) Swap

func (p MultiPoint) Swap() GeometryValue

Swap implements GeometryValue interface.

func (MultiPoint) WriteData

func (p MultiPoint) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type MultiPointType

type MultiPointType struct {
	SRID        uint32
	DefinedSRID bool
}

MultiPointType represents the MULTIPOINT type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-multipoint.html The type of the returned value is MultiPoint.

func (MultiPointType) Compare

func (t MultiPointType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (MultiPointType) Convert

func (t MultiPointType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (MultiPointType) Equals

func (t MultiPointType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (MultiPointType) GetSpatialTypeSRID

func (t MultiPointType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (MultiPointType) MatchSRID

func (t MultiPointType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (MultiPointType) MaxTextResponseByteLength

func (t MultiPointType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (MultiPointType) Promote

func (t MultiPointType) Promote() sql.Type

Promote implements the Type interface.

func (MultiPointType) SQL

func (t MultiPointType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (MultiPointType) SetSRID

func (t MultiPointType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (MultiPointType) String

func (t MultiPointType) String() string

String implements Type interface.

func (MultiPointType) Type

func (t MultiPointType) Type() query.Type

Type implements Type interface.

func (MultiPointType) ValueType

func (t MultiPointType) ValueType() reflect.Type

ValueType implements Type interface.

func (MultiPointType) Zero

func (t MultiPointType) Zero() interface{}

Zero implements Type interface.

type MultiPolygon

type MultiPolygon struct {
	SRID     uint32
	Polygons []Polygon
}

MultiPolygon is the value type returned from MultiPolygonType. Implements GeometryValue.

func DeserializeMPoly

func DeserializeMPoly(buf []byte, isBig bool, srid uint32) (MultiPolygon, int, error)

DeserializeMPoly parses the data portion of a byte array in WKB format to a MultiPolygon object

func (MultiPolygon) BBox

func (p MultiPolygon) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (MultiPolygon) GetSRID

func (p MultiPolygon) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (MultiPolygon) Serialize

func (p MultiPolygon) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (MultiPolygon) SetSRID

func (p MultiPolygon) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (MultiPolygon) Swap

func (p MultiPolygon) Swap() GeometryValue

Swap implements GeometryValue interface.

func (MultiPolygon) WriteData

func (p MultiPolygon) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type MultiPolygonType

type MultiPolygonType struct {
	SRID        uint32
	DefinedSRID bool
}

MultiPolygonType represents the MULTIPOLYGON type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-multipolygon.html The type of the returned value is MultiPolygon.

func (MultiPolygonType) Compare

func (t MultiPolygonType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (MultiPolygonType) Convert

func (t MultiPolygonType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (MultiPolygonType) Equals

func (t MultiPolygonType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (MultiPolygonType) GetSpatialTypeSRID

func (t MultiPolygonType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (MultiPolygonType) MatchSRID

func (t MultiPolygonType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (MultiPolygonType) MaxTextResponseByteLength

func (t MultiPolygonType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (MultiPolygonType) Promote

func (t MultiPolygonType) Promote() sql.Type

Promote implements the Type interface.

func (MultiPolygonType) SQL

func (t MultiPolygonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (MultiPolygonType) SetSRID

func (t MultiPolygonType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (MultiPolygonType) String

func (t MultiPolygonType) String() string

String implements Type interface.

func (MultiPolygonType) Type

func (t MultiPolygonType) Type() query.Type

Type implements Type interface.

func (MultiPolygonType) ValueType

func (t MultiPolygonType) ValueType() reflect.Type

ValueType implements Type interface.

func (MultiPolygonType) Zero

func (t MultiPolygonType) Zero() interface{}

Zero implements Type interface.

type NumberTypeImpl_

type NumberTypeImpl_ struct {
	// contains filtered or unexported fields
}

func (NumberTypeImpl_) Compare

func (t NumberTypeImpl_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (NumberTypeImpl_) Compare2

func (t NumberTypeImpl_) Compare2(a sql.Value, b sql.Value) (int, error)

func (NumberTypeImpl_) Convert

func (t NumberTypeImpl_) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (NumberTypeImpl_) Convert2

func (t NumberTypeImpl_) Convert2(value sql.Value) (sql.Value, error)

func (NumberTypeImpl_) Equals

func (t NumberTypeImpl_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (NumberTypeImpl_) IsFloat

func (t NumberTypeImpl_) IsFloat() bool

IsFloat implements NumberType interface.

func (NumberTypeImpl_) IsSigned

func (t NumberTypeImpl_) IsSigned() bool

IsSigned implements NumberType interface.

func (NumberTypeImpl_) MaxTextResponseByteLength

func (t NumberTypeImpl_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (NumberTypeImpl_) MustConvert

func (t NumberTypeImpl_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (NumberTypeImpl_) Promote

func (t NumberTypeImpl_) Promote() sql.Type

Promote implements the Type interface.

func (NumberTypeImpl_) SQL

func (t NumberTypeImpl_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (NumberTypeImpl_) SQL2

SQL2 implements Type2 interface.

func (NumberTypeImpl_) String

func (t NumberTypeImpl_) String() string

String implements Type interface.

func (NumberTypeImpl_) Type

func (t NumberTypeImpl_) Type() query.Type

Type implements Type interface.

func (NumberTypeImpl_) ValueType

func (t NumberTypeImpl_) ValueType() reflect.Type

ValueType implements Type interface.

func (NumberTypeImpl_) Zero

func (t NumberTypeImpl_) Zero() interface{}

Zero implements Type interface.

func (NumberTypeImpl_) Zero2

func (t NumberTypeImpl_) Zero2() sql.Value

type OkResult

type OkResult struct {
	RowsAffected uint64       // Number of rows affected by this operation
	InsertID     uint64       // Inserted ID, if any, or -1 if not
	Info         fmt.Stringer // Human-readable status string for extra status info, echoed verbatim to clients.
}

OkResult is a representation of the OK packet MySQL sends for non-select queries such as UPDATE, INSERT, etc. It can be returned as the only element in the row for a Node that doesn't select anything. See https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html

func GetOkResult

func GetOkResult(row sql.Row) OkResult

GetOkResult extracts the OkResult from the row given

func NewOkResult

func NewOkResult(rowsAffected int) OkResult

NewOkResult returns a new OkResult with the given number of rows affected.

type Point

type Point struct {
	SRID uint32
	X    float64
	Y    float64
}

Point is the value type returned from PointType. Implements GeometryValue.

func DeserializePoint

func DeserializePoint(buf []byte, isBig bool, srid uint32) (Point, int, error)

DeserializePoint parses the data portion of a byte array in WKB format to a Point object

func (Point) BBox

func (p Point) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (Point) GetSRID

func (p Point) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (Point) Serialize

func (p Point) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (Point) SetSRID

func (p Point) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (Point) Swap

func (p Point) Swap() GeometryValue

Swap implements GeometryValue interface. TODO: possible in place?

func (Point) WriteData

func (p Point) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type PointType

type PointType struct {
	SRID        uint32
	DefinedSRID bool
}

PointType represents the POINT type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-point.html The type of the returned value is Point.

func (PointType) Compare

func (t PointType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (PointType) Convert

func (t PointType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (PointType) Equals

func (t PointType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (PointType) GetSpatialTypeSRID

func (t PointType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (PointType) MatchSRID

func (t PointType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (PointType) MaxTextResponseByteLength

func (t PointType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (PointType) Promote

func (t PointType) Promote() sql.Type

Promote implements the Type interface.

func (PointType) SQL

func (t PointType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (PointType) SetSRID

func (t PointType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (PointType) String

func (t PointType) String() string

String implements Type interface.

func (PointType) Type

func (t PointType) Type() query.Type

Type implements Type interface.

func (PointType) ValueType

func (t PointType) ValueType() reflect.Type

ValueType implements Type interface.

func (PointType) Zero

func (t PointType) Zero() interface{}

Zero implements Type interface.

type Polygon

type Polygon struct {
	SRID  uint32
	Lines []LineString
}

Polygon is the value type returned from PolygonType. Implements GeometryValue.

func DeserializePoly

func DeserializePoly(buf []byte, isBig bool, srid uint32) (Polygon, int, error)

DeserializePoly parses the data portion of a byte array in WKB format to a Polygon object

func (Polygon) BBox

func (p Polygon) BBox() (float64, float64, float64, float64)

BBox implements GeometryValue interface.

func (Polygon) GetSRID

func (p Polygon) GetSRID() uint32

GetSRID implements GeometryValue interface.

func (Polygon) Serialize

func (p Polygon) Serialize() (buf []byte)

Serialize implements GeometryValue interface.

func (Polygon) SetSRID

func (p Polygon) SetSRID(srid uint32) GeometryValue

SetSRID implements GeometryValue interface.

func (Polygon) Swap

func (p Polygon) Swap() GeometryValue

Swap implements GeometryValue interface. TODO: possible in place?

func (Polygon) WriteData

func (p Polygon) WriteData(buf []byte) int

WriteData implements GeometryValue interface.

type PolygonType

type PolygonType struct {
	SRID        uint32
	DefinedSRID bool
}

PolygonType represents the POLYGON type. https://dev.mysql.com/doc/refman/8.0/en/gis-class-polygon.html The type of the returned value is Polygon.

func (PolygonType) Compare

func (t PolygonType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (PolygonType) Convert

func (t PolygonType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (PolygonType) Equals

func (t PolygonType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (PolygonType) GetSpatialTypeSRID

func (t PolygonType) GetSpatialTypeSRID() (uint32, bool)

GetSpatialTypeSRID implements SpatialColumnType interface.

func (PolygonType) MatchSRID

func (t PolygonType) MatchSRID(v interface{}) error

MatchSRID implements SpatialColumnType interface

func (PolygonType) MaxTextResponseByteLength

func (t PolygonType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (PolygonType) Promote

func (t PolygonType) Promote() sql.Type

Promote implements the Type interface.

func (PolygonType) SQL

func (t PolygonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (PolygonType) SetSRID

func (t PolygonType) SetSRID(v uint32) sql.Type

SetSRID implements SpatialColumnType interface.

func (PolygonType) String

func (t PolygonType) String() string

String implements Type interface.

func (PolygonType) Type

func (t PolygonType) Type() query.Type

Type implements Type interface.

func (PolygonType) ValueType

func (t PolygonType) ValueType() reflect.Type

ValueType implements Type interface.

func (PolygonType) Zero

func (t PolygonType) Zero() interface{}

Zero implements Type interface.

type SearchableJSONValue

type SearchableJSONValue interface {
	JSONValue

	// Contains is value-specific implementation of JSON_Contains()
	Contains(ctx *sql.Context, candidate JSONValue) (val interface{}, err error)
	// Extract is value-specific implementation of JSON_Extract()
	Extract(ctx *sql.Context, path string) (val JSONValue, err error)
	// Keys is value-specific implementation of JSON_Keys()
	Keys(ctx *sql.Context, path string) (val JSONValue, err error)
	// Overlaps is value-specific implementation of JSON_Overlaps()
	Overlaps(ctx *sql.Context, val SearchableJSONValue) (ok bool, err error)
	// Search is value-specific implementation of JSON_Search()
	Search(ctx *sql.Context) (path string, err error)
}

SearchableJSONValue is JSONValue supporting in-place access operations. The query engine can utilize these optimized access methods improve performance by minimizing the need to unmarshall a JSONValue into a JSONDocument.

type SetType

type SetType struct {
	// contains filtered or unexported fields
}

func (SetType) BitsToString

func (t SetType) BitsToString(v uint64) (string, error)

BitsToString implements SetType interface.

func (SetType) CharacterSet

func (t SetType) CharacterSet() sql.CharacterSetID

CharacterSet implements SetType interface.

func (SetType) Collation

func (t SetType) Collation() sql.CollationID

Collation implements SetType interface.

func (SetType) Compare

func (t SetType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (SetType) Convert

func (t SetType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface. Returns the string representing the given value if applicable.

func (SetType) Equals

func (t SetType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (SetType) MaxTextResponseByteLength

func (t SetType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (SetType) MustConvert

func (t SetType) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (SetType) NumberOfElements

func (t SetType) NumberOfElements() uint16

NumberOfElements implements SetType interface.

func (SetType) Promote

func (t SetType) Promote() sql.Type

Promote implements the Type interface.

func (SetType) SQL

func (t SetType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (SetType) String

func (t SetType) String() string

String implements Type interface.

func (SetType) Type

func (t SetType) Type() query.Type

Type implements Type interface.

func (SetType) ValueType

func (t SetType) ValueType() reflect.Type

ValueType implements Type interface.

func (SetType) Values

func (t SetType) Values() []string

Values implements SetType interface.

func (SetType) WithNewCollation

func (t SetType) WithNewCollation(collation sql.CollationID) (sql.Type, error)

WithNewCollation implements TypeWithCollation interface.

func (SetType) Zero

func (t SetType) Zero() interface{}

Zero implements Type interface.

type StringType

type StringType struct {
	// contains filtered or unexported fields
}

func (StringType) CharacterSet

func (t StringType) CharacterSet() sql.CharacterSetID

func (StringType) Collation

func (t StringType) Collation() sql.CollationID

func (StringType) Compare

func (t StringType) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (StringType) Convert

func (t StringType) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (StringType) Equals

func (t StringType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (StringType) Length

func (t StringType) Length() int64

func (StringType) MaxByteLength

func (t StringType) MaxByteLength() int64

MaxByteLength is the maximum number of bytes that may be consumed by a string that conforms to this type.

func (StringType) MaxCharacterLength

func (t StringType) MaxCharacterLength() int64

MaxCharacterLength is the maximum character length for this type.

func (StringType) MaxTextResponseByteLength

func (t StringType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (StringType) MustConvert

func (t StringType) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (StringType) Promote

func (t StringType) Promote() sql.Type

Promote implements the Type interface.

func (StringType) SQL

func (t StringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (StringType) String

func (t StringType) String() string

String implements Type interface.

func (StringType) Type

func (t StringType) Type() query.Type

Type implements Type interface.

func (StringType) ValueType

func (t StringType) ValueType() reflect.Type

ValueType implements Type interface.

func (StringType) WithNewCollation

func (t StringType) WithNewCollation(collation sql.CollationID) (sql.Type, error)

WithNewCollation implements TypeWithCollation interface.

func (StringType) Zero

func (t StringType) Zero() interface{}

Zero implements Type interface.

type SystemBoolType_

type SystemBoolType_ struct {
	// contains filtered or unexported fields
}

SystemBoolType_ is an internal boolean type ONLY for system variables.

func (SystemBoolType_) Compare

func (t SystemBoolType_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (SystemBoolType_) Convert

func (t SystemBoolType_) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (SystemBoolType_) DecodeValue

func (t SystemBoolType_) DecodeValue(val string) (interface{}, error)

DecodeValue implements SystemVariableType interface.

func (SystemBoolType_) EncodeValue

func (t SystemBoolType_) EncodeValue(val interface{}) (string, error)

EncodeValue implements SystemVariableType interface.

func (SystemBoolType_) Equals

func (t SystemBoolType_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (SystemBoolType_) MaxTextResponseByteLength

func (t SystemBoolType_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (SystemBoolType_) MustConvert

func (t SystemBoolType_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (SystemBoolType_) Promote

func (t SystemBoolType_) Promote() sql.Type

Promote implements the Type interface.

func (SystemBoolType_) SQL

func (t SystemBoolType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (SystemBoolType_) String

func (t SystemBoolType_) String() string

String implements Type interface.

func (SystemBoolType_) Type

func (t SystemBoolType_) Type() query.Type

Type implements Type interface.

func (SystemBoolType_) ValueType

func (t SystemBoolType_) ValueType() reflect.Type

ValueType implements Type interface.

func (SystemBoolType_) Zero

func (t SystemBoolType_) Zero() interface{}

Zero implements Type interface.

type TimeType

type TimeType interface {
	sql.Type
	// ConvertToTimespan returns a Timespan from the given interface. Follows the same conversion rules as
	// Convert(), in that this will process the value based on its base-10 visual representation (for example, Convert()
	// will interpret the value `1234` as 12 minutes and 34 seconds). Returns an error for nil values.
	ConvertToTimespan(v interface{}) (Timespan, error)
	// ConvertToTimeDuration returns a time.Duration from the given interface. Follows the same conversion rules as
	// Convert(), in that this will process the value based on its base-10 visual representation (for example, Convert()
	// will interpret the value `1234` as 12 minutes and 34 seconds). Returns an error for nil values.
	ConvertToTimeDuration(v interface{}) (time.Duration, error)
	// MicrosecondsToTimespan returns a Timespan from the given number of microseconds. This differs from Convert(), as
	// that will process the value based on its base-10 visual representation (for example, Convert() will interpret
	// the value `1234` as 12 minutes and 34 seconds). This clamps the given microseconds to the allowed range.
	MicrosecondsToTimespan(v int64) Timespan
}

TimeType represents the TIME type. https://dev.mysql.com/doc/refman/8.0/en/time.html TIME is implemented as TIME(6). The type of the returned value is Timespan. TODO: implement parameters on the TIME type

var (
	Time TimeType = TimespanType_{}

	ErrConvertingToTimeType = errors.NewKind("value %v is not a valid Time")
)

type Timespan

type Timespan int64

Timespan is the value type returned by TimeType.Convert().

func (Timespan) Add

func (t Timespan) Add(other Timespan) Timespan

Add returns a new Timespan that is the sum of the calling Timespan and given Timespan. The resulting Timespan is clamped to the allowed range.

func (Timespan) AsMicroseconds

func (t Timespan) AsMicroseconds() int64

AsMicroseconds returns the Timespan in microseconds.

func (Timespan) AsTimeDuration

func (t Timespan) AsTimeDuration() time.Duration

AsTimeDuration returns the Timespan as a time.Duration.

func (Timespan) Compare

func (t Timespan) Compare(other Timespan) int

Compare returns an integer comparing two values. The result will be 0 if t==other, -1 if t < other, and +1 if t > other.

func (Timespan) Equals

func (t Timespan) Equals(other Timespan) bool

Equals returns whether the calling Timespan and given Timespan are equivalent.

func (Timespan) Negate

func (t Timespan) Negate() Timespan

Negate returns a new Timespan that has been negated.

func (Timespan) String

func (t Timespan) String() string

String returns the Timespan formatted as a string (such as for display purposes).

func (Timespan) Subtract

func (t Timespan) Subtract(other Timespan) Timespan

Subtract returns a new Timespan that is the difference of the calling Timespan and given Timespan. The resulting Timespan is clamped to the allowed range.

type TimespanType_

type TimespanType_ struct{}

func (TimespanType_) Compare

func (t TimespanType_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (TimespanType_) Convert

func (t TimespanType_) Convert(v interface{}) (interface{}, error)

func (TimespanType_) ConvertToTimeDuration

func (t TimespanType_) ConvertToTimeDuration(v interface{}) (time.Duration, error)

ConvertToTimeDuration implements the TimeType interface.

func (TimespanType_) ConvertToTimespan

func (t TimespanType_) ConvertToTimespan(v interface{}) (Timespan, error)

ConvertToTimespan converts the given interface value to a Timespan. This follows the conversion rules of MySQL, which are based on the base-10 visual representation of numbers (for example, Time.Convert() will interpret the value `1234` as 12 minutes and 34 seconds). Returns an error on a nil value.

func (TimespanType_) Equals

func (t TimespanType_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (TimespanType_) MaxTextResponseByteLength

func (t TimespanType_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (TimespanType_) MicrosecondsToTimespan

func (_ TimespanType_) MicrosecondsToTimespan(v int64) Timespan

MicrosecondsToTimespan implements the TimeType interface.

func (TimespanType_) MustConvert

func (t TimespanType_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (TimespanType_) Promote

func (t TimespanType_) Promote() sql.Type

Promote implements the Type interface.

func (TimespanType_) SQL

func (t TimespanType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (TimespanType_) String

func (t TimespanType_) String() string

String implements Type interface.

func (TimespanType_) Type

func (t TimespanType_) Type() query.Type

Type implements Type interface.

func (TimespanType_) ValueType

func (t TimespanType_) ValueType() reflect.Type

ValueType implements Type interface.

func (TimespanType_) Zero

func (t TimespanType_) Zero() interface{}

Zero implements Type interface.

type TupleType

type TupleType []sql.Type

func (TupleType) Compare

func (t TupleType) Compare(a, b interface{}) (int, error)

func (TupleType) Convert

func (t TupleType) Convert(v interface{}) (interface{}, error)

func (TupleType) Equals

func (t TupleType) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (TupleType) MaxTextResponseByteLength

func (t TupleType) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (TupleType) MustConvert

func (t TupleType) MustConvert(v interface{}) interface{}

func (TupleType) Promote

func (t TupleType) Promote() sql.Type

func (TupleType) SQL

func (t TupleType) SQL(*sql.Context, []byte, interface{}) (sqltypes.Value, error)

func (TupleType) String

func (t TupleType) String() string

func (TupleType) Type

func (t TupleType) Type() query.Type

func (TupleType) ValueType

func (t TupleType) ValueType() reflect.Type

ValueType implements Type interface.

func (TupleType) Zero

func (t TupleType) Zero() interface{}

type YearType_

type YearType_ struct{}

func (YearType_) Compare

func (t YearType_) Compare(a interface{}, b interface{}) (int, error)

Compare implements Type interface.

func (YearType_) Convert

func (t YearType_) Convert(v interface{}) (interface{}, error)

Convert implements Type interface.

func (YearType_) Equals

func (t YearType_) Equals(otherType sql.Type) bool

Equals implements the Type interface.

func (YearType_) MaxTextResponseByteLength

func (t YearType_) MaxTextResponseByteLength() uint32

MaxTextResponseByteLength implements the Type interface

func (YearType_) MustConvert

func (t YearType_) MustConvert(v interface{}) interface{}

MustConvert implements the Type interface.

func (YearType_) Promote

func (t YearType_) Promote() sql.Type

Promote implements the Type interface.

func (YearType_) SQL

func (t YearType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Value, error)

SQL implements Type interface.

func (YearType_) String

func (t YearType_) String() string

String implements Type interface.

func (YearType_) Type

func (t YearType_) Type() query.Type

Type implements Type interface.

func (YearType_) ValueType

func (t YearType_) ValueType() reflect.Type

ValueType implements Type interface.

func (YearType_) Zero

func (t YearType_) Zero() interface{}

Zero implements Type interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL