types

package
v0.0.0-...-2900147 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: 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.New(codeInvalidDefault, "Invalid default value for '%s'")

ErrInvalidDefault is returned when meet a invalid default value.

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)

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)

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