parser: Index | Files

package types

import ""


Package Files

etc.go eval_type.go field_type.go


const (
    UnspecifiedLength = -1

UnspecifiedLength is unspecified length.

const VarStorageLen = -1

VarStorageLen indicates this column is a variable length column.


var ErrInvalidDefault = terror.ClassTypes.New(mysql.ErrInvalidDefault, mysql.MySQLErrName[mysql.ErrInvalidDefault])

ErrInvalidDefault is returned when meet a invalid default value.

func HasCharset Uses

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 Uses

func IsTypeBlob(tp byte) bool

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

func IsTypeChar Uses

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 Uses

func TypeStr(tp byte) (r string)

TypeStr converts tp to a string.

func TypeToStr Uses

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

type EvalType Uses

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.
    // ETDecimal represents type DECIMAL in evaluation.
    // ETString represents type STRING in evaluation.
    // ETDatetime represents type DATETIME in evaluation.
    // ETTimestamp represents type TIMESTAMP in evaluation.
    // ETDuration represents type DURATION in evaluation.
    // ETJson represents type JSON in evaluation.

func (EvalType) IsStringKind Uses

func (et EvalType) IsStringKind() bool

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

type FieldType Uses

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 Uses

func NewFieldType(tp byte) *FieldType

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

func (*FieldType) Clone Uses

func (ft *FieldType) Clone() *FieldType

Clone returns a copy of itself.

func (*FieldType) CompactStr Uses

func (ft *FieldType) CompactStr() string

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

func (*FieldType) Equal Uses

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

Equal checks whether two FieldType objects are equal.

func (*FieldType) EvalType Uses

func (ft *FieldType) EvalType() EvalType

EvalType gets the type in evaluation.

func (*FieldType) FormatAsCastType Uses

func (ft *FieldType) FormatAsCastType(w io.Writer)

FormatAsCastType is used for write AST back to string.

func (*FieldType) Hybrid Uses

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 Uses

func (ft *FieldType) InfoSchemaStr() string

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

func (*FieldType) Init Uses

func (ft *FieldType) Init(tp byte)

Init initializes the FieldType data.

func (*FieldType) Restore Uses

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

Restore implements Node interface.

func (*FieldType) RestoreAsCastType Uses

func (ft *FieldType) RestoreAsCastType(ctx *format.RestoreCtx)

RestoreAsCastType is used for write AST back to string.

func (*FieldType) StorageLength Uses

func (ft *FieldType) StorageLength() int

StorageLength is the length of stored value for the type.

func (*FieldType) String Uses

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.

Package types imports 7 packages (graph) and is imported by 45 packages. Updated 2020-05-01. Refresh now. Tools for package owners.