types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnspecifiedLength = -1
)

UnspecifiedLength is unspecified length.

View Source
const VarStorageLen = -1

VarStorageLen indicates this column is a variable length column.

Variables

View Source
var ErrInvalidDefault = terror.ClassTypes.NewStd(mysql.ErrInvalidDefault)

ErrInvalidDefault is returned when meet a invalid default value.

View Source
var (
	TiDBStrictIntegerDisplayWidth bool
)

TiDBStrictIntegerDisplayWidth represent whether return warnings when integerType with (length) was parsed. The default is `false`, it will be parsed as warning, and the result in show-create-table will ignore the display length when it set to `true`. This is for compatibility with MySQL 8.0 in which integer max display length is deprecated, referring this issue #6688 for more details.

Functions

func HasCharset

func HasCharset(ft *FieldType) bool

HasCharset indicates if a COLUMN has an associated charset. Returning false here prevents some information statements(like `SHOW CREATE TABLE`) from attaching a CHARACTER SET clause to the column.

func IsTypeBlob

func IsTypeBlob(tp byte) bool

IsTypeBlob returns a boolean indicating whether the tp is a blob type.

func IsTypeChar

func IsTypeChar(tp byte) bool

IsTypeChar returns a boolean indicating whether the tp is the char type like a string type or a varchar type.

func TypeStr

func TypeStr(tp byte) (r string)

TypeStr converts tp to a string.

func TypeToStr

func TypeToStr(tp byte, cs string) (r string)

TypeToStr converts a field to a string. It is used for converting Text to Blob, or converting Char to Binary. Args:

tp: type enum
cs: charset

Types

type EvalType

type EvalType byte

EvalType indicates the specified types that arguments and result of a built-in function should be.

const (
	// ETInt represents type INT in evaluation.
	ETInt EvalType = iota
	// ETReal represents type REAL in evaluation.
	ETReal
	// ETDecimal represents type DECIMAL in evaluation.
	ETDecimal
	// ETString represents type STRING in evaluation.
	ETString
	// ETDatetime represents type DATETIME in evaluation.
	ETDatetime
	// ETTimestamp represents type TIMESTAMP in evaluation.
	ETTimestamp
	// ETDuration represents type DURATION in evaluation.
	ETDuration
	// ETJson represents type JSON in evaluation.
	ETJson
)

func (EvalType) IsStringKind

func (et EvalType) IsStringKind() bool

IsStringKind returns true for ETString, ETDatetime, ETTimestamp, ETDuration, ETJson EvalTypes.

type FieldType

type FieldType struct {
	Tp      byte
	Flag    uint
	Flen    int
	Decimal int
	Charset string
	Collate string
	// Elems is the element list for enum and set type.
	Elems []string
}

FieldType records field type information.

func NewFieldType

func NewFieldType(tp byte) *FieldType

NewFieldType returns a FieldType, with a type and other information about field type.

func (*FieldType) Clone

func (ft *FieldType) Clone() *FieldType

Clone returns a copy of itself.

func (*FieldType) CompactStr

func (ft *FieldType) CompactStr() string

CompactStr only considers Tp/CharsetBin/Flen/Deimal. This is used for showing column type in infoschema.

func (*FieldType) Equal

func (ft *FieldType) Equal(other *FieldType) bool

Equal checks whether two FieldType objects are equal.

func (*FieldType) EvalType

func (ft *FieldType) EvalType() EvalType

EvalType gets the type in evaluation.

func (*FieldType) FormatAsCastType

func (ft *FieldType) FormatAsCastType(w io.Writer, explicitCharset bool)

FormatAsCastType is used for write AST back to string.

func (*FieldType) Hybrid

func (ft *FieldType) Hybrid() bool

Hybrid checks whether a type is a hybrid type, which can represent different types of value in specific context.

func (*FieldType) InfoSchemaStr

func (ft *FieldType) InfoSchemaStr() string

InfoSchemaStr joins the CompactStr with unsigned flag and returns a string.

func (*FieldType) Init

func (ft *FieldType) Init(tp byte)

Init initializes the FieldType data.

func (*FieldType) Restore

func (ft *FieldType) Restore(ctx *format.RestoreCtx) error

Restore implements Node interface.

func (*FieldType) RestoreAsCastType

func (ft *FieldType) RestoreAsCastType(ctx *format.RestoreCtx, explicitCharset bool)

RestoreAsCastType is used for write AST back to string.

func (*FieldType) StorageLength

func (ft *FieldType) StorageLength() int

StorageLength is the length of stored value for the type.

func (*FieldType) String

func (ft *FieldType) String() string

String joins the information of FieldType and returns a string. Note: when flen or decimal is unspecified, this function will use the default value instead of -1.

Jump to

Keyboard shortcuts

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