types

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 29 Imported by: 6

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 (
	SET = iota
	INSERT
	REPLACE
	REMOVE
	ARRAY_APPEND
	ARRAY_INSERT
)
View Source
const (
	MaxRowLength = 65_535

	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, 0)
	// Datetime is a date and a time with default precision (no fractional seconds).
	Datetime = MustCreateDatetimeType(sqltypes.Datetime, 0)
	// DatetimeMaxPrecision is a date and a time with maximum precision
	DatetimeMaxPrecision = MustCreateDatetimeType(sqltypes.Datetime, 6)
	// Timestamp is a UNIX timestamp with default precision (no fractional seconds).
	Timestamp = MustCreateDatetimeType(sqltypes.Timestamp, 0)
	// TimestampMaxPrecision is a UNIX timestamp with maximum precision
	TimestampMaxPrecision = MustCreateDatetimeType(sqltypes.Timestamp, 6)
)
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(1)
	Boolean = MustCreateNumberTypeWithDisplayWidth(sqltypes.Int8, 1)
	// 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: %v")

	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 ErrCharacterSetOnInvalidType = errors.NewKind("Only character columns, enums, and sets can have a CHARACTER SET option")
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

View Source
var SupportedSRIDs = map[uint32]SpatialRef{}/* 5152 elements not displayed */

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 CoalesceInt added in v0.18.0

func CoalesceInt(val interface{}) (int, bool)

CoalesceInt converts a int8/int16/... to int

func ColumnTypeToType

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

ColumnTypeToType gets the column type using the column definition.

func CompareJSON added in v0.18.0

func CompareJSON(a, b interface{}) (int, error)

CompareJSON compares two JSON values. It returns 0 if the values are equal, -1 if a < b, and 1 if a > b. JSON values can be compared using the =, <, <=, >, >=, <>, !=, and <=> operators. BETWEEN IN() GREATEST() LEAST() are not yet supported with JSON values.

For comparison of JSON and non-JSON values, the non-JSON value is first converted to JSON (see JsonType.Convert()). Comparison of JSON values takes place at two levels. The first level of comparison is based on the JSON types of the compared values. If the types differ, the comparison result is determined solely by which type has higher precedence. If the two values have the same JSON type, a second level of comparison occurs using type-specific rules. The following list shows the precedences of JSON types, from highest precedence to the lowest. (The type names are those returned by the JSON_TYPE() function.) Types shown together on a line have the same precedence. Any value having a JSON type listed earlier in the list compares greater than any value having a JSON type listed later in the list.

		BLOB, BIT, OPAQUE, DATETIME, TIME, DATE, BOOLEAN, ARRAY, OBJECT, STRING, INTEGER, DOUBLE, NULL
		TODO(andy): implement BLOB BIT OPAQUE DATETIME TIME DATE
     current precedence: BOOLEAN, ARRAY, OBJECT, STRING, DOUBLE, NULL

For JSON values of the same precedence, the comparison rules are type specific:

  • ARRAY Two JSON arrays are equal if they have the same length and values in corresponding positions in the arrays are equal. If the arrays are not equal, their order is determined by the elements in the first position where there is a difference. The array with the smaller value in that position is ordered first. If all values of the shorter array are equal to the corresponding values in the longer array, the shorter array is ordered first. e.g. [] < ["a"] < ["ab"] < ["ab", "cd", "ef"] < ["ab", "ef"]

  • BOOLEAN The JSON false literal is less than the JSON true literal.

  • OBJECT Two JSON objects are equal if they have the same set of keys, and each key has the same value in both objects. The order of two objects that are not equal is unspecified but deterministic. e.g. {"a": 1, "b": 2} = {"b": 2, "a": 1}

  • STRING Strings are ordered lexically on the first N bytes of the utf8mb4 representation of the two strings being compared, where N is the length of the shorter string. If the first N bytes of the two strings are identical, the shorter string is considered smaller than the longer string. e.g. "a" < "ab" < "b" < "bc" This ordering is equivalent to the ordering of SQL strings with collation utf8mb4_bin. Because utf8mb4_bin is a binary collation, comparison of JSON values is case-sensitive: e.g. "A" < "a"

  • DOUBLE JSON values can contain exact-value numbers and approximate-value numbers. For a general discussion of these types of numbers, see Section 9.1.2, “Numeric Literals”. The rules for comparing native MySQL numeric types are discussed in Section 12.3, “Type Conversion in Expression Evaluation”, but the rules for comparing numbers within JSON values differ somewhat:

  • In a comparison between two columns that use the native MySQL INT and DOUBLE numeric types, respectively, it is known that all comparisons involve an integer and a double, so the integer is converted to double for all rows. That is, exact-value numbers are converted to approximate-value numbers.

  • On the other hand, if the query compares two JSON columns containing numbers, it cannot be known in advance whether numbers are integer or double. To provide the most consistent behavior across all rows, MySQL converts approximate-value numbers to exact-value numbers. The resulting ordering is consistent and does not lose precision for the exact-value numbers. e.g. 9223372036854775805 < 9223372036854775806 < 9223372036854775807 < 9.223372036854776e18 = 9223372036854776000 < 9223372036854776001

  • NULL For comparison of any JSON value to SQL NULL, the result is UNKNOWN.

    TODO(andy): BLOB, BIT, OPAQUE, DATETIME, TIME, DATE, INTEGER

https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison

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 ConcatenateJSONValues

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

func ContainsJSON added in v0.18.0

func ContainsJSON(a, b interface{}) (interface{}, 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, precision int) (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 CreateNumberTypeWithDisplayWidth added in v0.18.0

func CreateNumberTypeWithDisplayWidth(baseType query.Type, displayWidth int) (sql.NumberType, error)

CreateNumberTypeWithDisplayWidth creates a NumberType that includes optional |displayWidth| metadata. Note that MySQL only allows a |displayWidth| of 1 for Int8 (i.e. TINYINT(1)); any other combination of |displayWidth| and |baseType| is not supported and will cause this function to return an error.

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 IsBinary added in v0.18.0

func IsBinary(sqlType query.Type) bool

IsBinary returns whether the type represents binary data.

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 IsExtendedType added in v0.18.0

func IsExtendedType(typ sql.Type) bool

IsExtendedType returns whether the given sql.Type is an ExtendedType.

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 IsYear added in v0.18.0

func IsYear(t sql.Type) bool

IsYear checks if t is a year type.

func LookupJSONValue added in v0.18.0

func LookupJSONValue(j sql.JSONWrapper, path string) (sql.JSONWrapper, error)

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, precision int) 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 MustCreateNumberTypeWithDisplayWidth added in v0.18.0

func MustCreateNumberTypeWithDisplayWidth(baseType query.Type, displayWidth int) sql.NumberType

MustCreateNumberTypeWithDisplayWidth is the same as CreateNumberTypeWithDisplayWidth 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 SerializeType added in v0.18.0

func SerializeType(typ ExtendedType) ([]byte, error)

SerializeType serializes the given extended type into a byte slice.

func SerializeTypeToString added in v0.18.0

func SerializeTypeToString(typ ExtendedType) (string, error)

SerializeTypeToString serializes the given extended type into a hex-encoded string.

func SetExtendedTypeSerializers added in v0.18.0

func SetExtendedTypeSerializers(serializer ExtendedTypeSerializer, deserializer ExtendedTypeDeserializer)

SetExtendedTypeSerializers sets the handlers that are able to serialize and deserialize extended types. It is recommended to set these from within an init function within the calling package.

func TypesEqual

func TypesEqual(a, b sql.Type) bool

TypesEqual compares two Types and returns whether they are equivalent.

func ValidateSRID added in v0.16.0

func ValidateSRID(srid int, funcName string) error

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 WriteStrings added in v0.16.0

func WriteStrings(wr io.Writer, strs ...string) (int, error)

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_) CollationCoercibility

func (BitType_) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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 (DecimalType_) CollationCoercibility

func (DecimalType_) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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_) DecimalValueStringFixed added in v0.18.0

func (t DecimalType_) DecimalValueStringFixed(v decimal.Decimal) string

DecimalValueStringFixed returns string value for the given decimal value. If decimal type value is for valid table column only, it should use scale defined by the column. Otherwise, the result value should use its own precision and scale.

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(_ *sql.Context) 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) CollationCoercibility

func (t EnumType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible 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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) StringWithTableCollation added in v0.17.0

func (t EnumType) StringWithTableCollation(tableCollation sql.CollationID) string

StringWithTableCollation implements sql.TypeWithCollation 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 sql.TypeWithCollation interface.

func (EnumType) Zero

func (t EnumType) Zero() interface{}

Zero implements Type interface.

type ExtendedType added in v0.18.0

type ExtendedType interface {
	sql.Type
	// SerializedCompare compares two byte slices that each represent a serialized value, without first deserializing
	// the value. This should return the same result as the Compare function.
	SerializedCompare(v1 []byte, v2 []byte) (int, error)
	// SerializeValue converts the given value into a binary representation.
	SerializeValue(val any) ([]byte, error)
	// DeserializeValue converts a binary representation of a value into its canonical type.
	DeserializeValue(val []byte) (any, error)
	// FormatValue returns a string version of the value. Primarily intended for display.
	FormatValue(val any) (string, error)
	// MaxSerializedWidth returns the maximum size that the serialized value may represent.
	MaxSerializedWidth() ExtendedTypeSerializedWidth
}

ExtendedType is a serializable type that offers an extended interface for interacting with types in a wider context.

func DeserializeType added in v0.18.0

func DeserializeType(typ []byte) (ExtendedType, error)

DeserializeType deserializes a byte slice representing a serialized extended type.

func DeserializeTypeFromString added in v0.18.0

func DeserializeTypeFromString(typ string) (ExtendedType, error)

DeserializeTypeFromString deserializes a hex-encoded string representing a serialized extended type.

type ExtendedTypeDeserializer added in v0.18.0

type ExtendedTypeDeserializer func(serializedType []byte) (ExtendedType, error)

ExtendedTypeDeserializer is the function signature for the extended type deserializer.

type ExtendedTypeSerializedWidth added in v0.18.0

type ExtendedTypeSerializedWidth uint8
const (
	ExtendedTypeSerializedWidth_64K       ExtendedTypeSerializedWidth = iota // Represents a variably-sized value. The maximum number of bytes is (2^16)-1.
	ExtendedTypeSerializedWidth_Unbounded                                    // Represents a variably-sized value. The maximum number of bytes is (2^64)-1, which is practically unbounded.
)

type ExtendedTypeSerializer added in v0.18.0

type ExtendedTypeSerializer func(extendedType ExtendedType) ([]byte, error)

ExtendedTypeSerializer is the function signature for the extended type serializer.

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) CollationCoercibility

func (GeomCollType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (GeometryType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) ArrayAppend added in v0.18.0

func (doc JSONDocument) ArrayAppend(path string, val sql.JSONWrapper) (MutableJSON, bool, error)

func (JSONDocument) ArrayInsert added in v0.18.0

func (doc JSONDocument) ArrayInsert(path string, val sql.JSONWrapper) (MutableJSON, bool, error)

func (JSONDocument) Compare

func (doc JSONDocument) Compare(other sql.JSONWrapper) (int, error)

func (JSONDocument) Contains

func (doc JSONDocument) Contains(candidate sql.JSONWrapper) (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(path string) (sql.JSONWrapper, error)

func (JSONDocument) Insert added in v0.18.0

func (doc JSONDocument) Insert(path string, val sql.JSONWrapper) (MutableJSON, bool, error)

func (JSONDocument) JSONString added in v0.18.0

func (doc JSONDocument) JSONString() (string, error)

func (JSONDocument) Remove added in v0.18.0

func (doc JSONDocument) Remove(path string) (MutableJSON, bool, error)

func (JSONDocument) Replace added in v0.18.0

func (doc JSONDocument) Replace(path string, val sql.JSONWrapper) (MutableJSON, bool, error)

func (JSONDocument) Set added in v0.18.0

func (doc JSONDocument) Set(path string, val sql.JSONWrapper) (MutableJSON, bool, error)

func (JSONDocument) String added in v0.18.0

func (doc JSONDocument) String() string

JSONDocument implements the fmt.Stringer interface.

func (JSONDocument) ToInterface added in v0.18.0

func (doc JSONDocument) ToInterface() interface{}

func (JSONDocument) Value

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

Value implements driver.Valuer for interoperability with other go libraries

type JSONIter added in v0.18.0

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

func NewJSONIter added in v0.18.0

func NewJSONIter(json JsonObject) JSONIter

func (*JSONIter) HasNext added in v0.18.0

func (iter *JSONIter) HasNext() bool

func (*JSONIter) Next added in v0.18.0

func (iter *JSONIter) Next() (key string, value interface{}, err error)

type JSONStringer added in v0.18.0

type JSONStringer interface {
	JSONString() (string, error)
}

type JsonArray added in v0.18.0

type JsonArray = []interface{}

type JsonObject added in v0.18.0

type JsonObject = map[string]interface{}

type JsonType

type JsonType struct{}

func (JsonType) CollationCoercibility

func (JsonType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, inRange sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (LineStringType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (MultiLineStringType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (MultiPointType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (MultiPolygonType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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 MutableJSON added in v0.18.0

type MutableJSON interface {
	// Insert Adds the value at the given path, only if it is not present. Updated value returned, and bool indicating if
	// a change was made.
	Insert(path string, val sql.JSONWrapper) (MutableJSON, bool, error)
	// Remove the value at the given path. Updated value returned, and bool indicating if a change was made.
	Remove(path string) (MutableJSON, bool, error)
	// Set the value at the given path. Updated value returned, and bool indicating if a change was made.
	Set(path string, val sql.JSONWrapper) (MutableJSON, bool, error)
	// Replace the value at the given path with the new value. If the path does not exist, no modification is made.
	Replace(path string, val sql.JSONWrapper) (MutableJSON, bool, error)
	// ArrayInsert inserts into the array object referenced by the given path. If the path does not exist, no modification is made.
	ArrayInsert(path string, val sql.JSONWrapper) (MutableJSON, bool, error)
	// ArrayAppend appends to an  array object referenced by the given path. If the path does not exist, no modification is made,
	// or if the path exists and is not an array, the element will be converted into an array and the element will be
	// appended to it.
	ArrayAppend(path string, val sql.JSONWrapper) (MutableJSON, bool, error)
}

type NoCopyBuilder added in v0.16.0

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

func NewNoCopyBuilder added in v0.16.0

func NewNoCopyBuilder(initialAlloc int64) *NoCopyBuilder

func (*NoCopyBuilder) Bytes added in v0.16.0

func (b *NoCopyBuilder) Bytes() []byte

func (*NoCopyBuilder) String added in v0.16.0

func (b *NoCopyBuilder) String() string

func (*NoCopyBuilder) Write added in v0.16.0

func (b *NoCopyBuilder) Write(p []byte) (int, error)

type NumberTypeImpl_

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

func (NumberTypeImpl_) CollationCoercibility

func (NumberTypeImpl_) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, error)

Convert implements Type interface.

func (NumberTypeImpl_) Convert2

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

func (NumberTypeImpl_) DisplayWidth added in v0.18.0

func (t NumberTypeImpl_) DisplayWidth() int

DisplayWidth() implements NumberType inteface.

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(_ *sql.Context) 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) CollationCoercibility

func (PointType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (PolygonType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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 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) CollationCoercibility

func (t SetType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible 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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) StringWithTableCollation added in v0.17.0

func (t SetType) StringWithTableCollation(tableCollation sql.CollationID) string

StringWithTableCollation implements sql.TypeWithCollation 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 sql.TypeWithCollation interface.

func (SetType) Zero

func (t SetType) Zero() interface{}

Zero implements Type interface.

type SpatialRef added in v0.16.0

type SpatialRef struct {
	Name          string
	ID            uint32
	Organization  interface{}
	OrgCoordsysId interface{}
	Definition    string
	Description   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) CollationCoercibility

func (t StringType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(ctx *sql.Context) 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) StringWithTableCollation added in v0.17.0

func (t StringType) StringWithTableCollation(tableCollation sql.CollationID) string

StringWithTableCollation implements sql.TypeWithCollation 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 added in v0.16.0

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

SystemBoolType is an internal boolean type ONLY for system variables.

func (SystemBoolType) CollationCoercibility added in v0.16.0

func (SystemBoolType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

func (SystemBoolType) Compare added in v0.16.0

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

Compare implements Type interface.

func (SystemBoolType) Convert added in v0.16.0

func (t SystemBoolType) Convert(v interface{}) (interface{}, sql.ConvertInRange, error)

Convert implements Type interface.

func (SystemBoolType) DecodeValue added in v0.16.0

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

DecodeValue implements SystemVariableType interface.

func (SystemBoolType) EncodeValue added in v0.16.0

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

EncodeValue implements SystemVariableType interface.

func (SystemBoolType) Equals added in v0.16.0

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

Equals implements the Type interface.

func (SystemBoolType) MaxTextResponseByteLength added in v0.16.0

func (t SystemBoolType) MaxTextResponseByteLength(ctx *sql.Context) uint32

MaxTextResponseByteLength implements the Type interface

func (SystemBoolType) MustConvert added in v0.16.0

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

MustConvert implements the Type interface.

func (SystemBoolType) Promote added in v0.16.0

func (t SystemBoolType) Promote() sql.Type

Promote implements the Type interface.

func (SystemBoolType) SQL added in v0.16.0

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

SQL implements Type interface.

func (SystemBoolType) String added in v0.16.0

func (t SystemBoolType) String() string

String implements Type interface.

func (SystemBoolType) Type added in v0.16.0

func (t SystemBoolType) Type() query.Type

Type implements Type interface.

func (SystemBoolType) UnderlyingType added in v0.16.0

func (t SystemBoolType) UnderlyingType() sql.Type

func (SystemBoolType) ValueType added in v0.16.0

func (t SystemBoolType) ValueType() reflect.Type

ValueType implements Type interface.

func (SystemBoolType) Zero added in v0.16.0

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_) CollationCoercibility

func (TimespanType_) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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) CollationCoercibility

func (TupleType) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

func (TupleType) Compare

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

func (TupleType) Convert

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

func (TupleType) Equals

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

Equals implements the Type interface.

func (TupleType) MaxTextResponseByteLength

func (t TupleType) MaxTextResponseByteLength(_ *sql.Context) 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_) CollationCoercibility

func (YearType_) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte)

CollationCoercibility implements sql.CollationCoercible interface.

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{}, sql.ConvertInRange, 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(_ *sql.Context) 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