Documentation ¶
Index ¶
- Constants
- Variables
- func HasCharset(ft *FieldType) bool
- func IsTypeBlob(tp byte) bool
- func IsTypeChar(tp byte) bool
- func StrToType(ts string) (tp byte)
- func TypeStr(tp byte) (r string)
- func TypeToStr(tp byte, cs string) (r string)
- type EvalType
- type FieldType
- func (ft *FieldType) AddFlag(flag uint)
- func (ft *FieldType) AndFlag(flag uint)
- func (ft *FieldType) ArrayType() *FieldType
- func (ft *FieldType) CleanElemIsBinaryLit()
- func (ft *FieldType) Clone() *FieldType
- func (ft *FieldType) CompactStr() string
- func (ft *FieldType) DelFlag(flag uint)
- func (ft *FieldType) Equal(other *FieldType) bool
- func (ft *FieldType) EvalType() EvalType
- func (ft *FieldType) FormatAsCastType(w io.Writer, explicitCharset bool)
- func (ft *FieldType) GetCharset() string
- func (ft *FieldType) GetCollate() string
- func (ft *FieldType) GetDecimal() int
- func (ft *FieldType) GetElem(idx int) string
- func (ft *FieldType) GetElemIsBinaryLit(idx int) bool
- func (ft *FieldType) GetElems() []string
- func (ft *FieldType) GetFlag() uint
- func (ft *FieldType) GetFlen() int
- func (ft *FieldType) GetType() byte
- func (ft *FieldType) Hybrid() bool
- func (ft *FieldType) InfoSchemaStr() string
- func (ft *FieldType) Init(tp byte)
- func (ft *FieldType) IsArray() bool
- func (ft *FieldType) IsDecimalValid() bool
- func (ft *FieldType) IsVarLengthType() bool
- func (ft *FieldType) MarshalJSON() ([]byte, error)
- func (ft *FieldType) MemoryUsage() (sum int64)
- func (ft *FieldType) PartialEqual(other *FieldType, unsafe bool) bool
- func (ft *FieldType) Restore(ctx *format.RestoreCtx) error
- func (ft *FieldType) RestoreAsCastType(ctx *format.RestoreCtx, explicitCharset bool)
- func (ft *FieldType) SetArray(array bool)
- func (ft *FieldType) SetCharset(charset string)
- func (ft *FieldType) SetCollate(collate string)
- func (ft *FieldType) SetDecimal(decimal int)
- func (ft *FieldType) SetDecimalUnderLimit(decimal int)
- func (ft *FieldType) SetElem(idx int, element string)
- func (ft *FieldType) SetElemWithIsBinaryLit(idx int, element string, isBinaryLit bool)
- func (ft *FieldType) SetElems(elems []string)
- func (ft *FieldType) SetFlag(flag uint)
- func (ft *FieldType) SetFlen(flen int)
- func (ft *FieldType) SetFlenUnderLimit(flen int)
- func (ft *FieldType) SetType(tp byte)
- func (ft *FieldType) StorageLength() int
- func (ft *FieldType) String() string
- func (ft *FieldType) ToggleFlag(flag uint)
- func (ft *FieldType) UnmarshalJSON(data []byte) error
- func (ft *FieldType) UpdateFlenAndDecimalUnderLimit(old *FieldType, deltaDecimal int, deltaFlen int)
Constants ¶
const (
UnspecifiedLength = -1
)
UnspecifiedLength is unspecified length.
const VarStorageLen = -1
VarStorageLen indicates this column is a variable length column.
Variables ¶
var ( // ErrInvalidDefault is returned when meet a invalid default value. ErrInvalidDefault = terror.ClassTypes.NewStd(mysql.ErrInvalidDefault) // ErrDataOutOfRange is returned when meet a value out of range. ErrDataOutOfRange = terror.ClassTypes.NewStd(mysql.ErrDataOutOfRange) // ErrTruncatedWrongValue is returned when meet a value bigger than 99999999999999999999999999999999999999999999999999999999999999999 during parsing. ErrTruncatedWrongValue = terror.ClassTypes.NewStd(mysql.ErrTruncatedWrongValue) // ErrIllegalValueForType is returned when strconv.ParseFloat meet strconv.ErrRange during parsing. ErrIllegalValueForType = terror.ClassTypes.NewStd(mysql.ErrIllegalValueForType) )
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 ¶
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 ¶
IsTypeBlob returns a boolean indicating whether the tp is a blob type.
func IsTypeChar ¶
IsTypeChar returns a boolean indicating whether the tp is the char type like a string type or a varchar type.
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 ¶
IsStringKind returns true for ETString, ETDatetime, ETTimestamp, ETDuration, ETJson EvalTypes.
type FieldType ¶
type FieldType struct {
// contains filtered or unexported fields
}
FieldType records field type information.
func NewFieldType ¶
NewFieldType returns a FieldType, with a type and other information about field type.
func (*FieldType) CleanElemIsBinaryLit ¶
func (ft *FieldType) CleanElemIsBinaryLit()
CleanElemIsBinaryLit cleans the binary literal flag of the element at index idx.
func (*FieldType) CompactStr ¶
CompactStr only considers tp/CharsetBin/flen/Deimal. This is used for showing column type in infoschema.
func (*FieldType) FormatAsCastType ¶
FormatAsCastType is used for write AST back to string.
func (*FieldType) GetCharset ¶
GetCharset returns the field's charset
func (*FieldType) GetCollate ¶
GetCollate returns the collation of the field.
func (*FieldType) GetDecimal ¶
GetDecimal returns the decimal of the FieldType.
func (*FieldType) GetElemIsBinaryLit ¶
GetElemIsBinaryLit returns the binary literal flag of the element at index idx.
func (*FieldType) Hybrid ¶
Hybrid checks whether a type is a hybrid type, which can represent different types of value in specific context.
func (*FieldType) InfoSchemaStr ¶
InfoSchemaStr joins the CompactStr with unsigned flag and returns a string.
func (*FieldType) IsDecimalValid ¶
IsDecimalValid checks whether the decimal is valid.
func (*FieldType) IsVarLengthType ¶
IsVarLengthType Determine whether the column type is a variable-length type
func (*FieldType) MarshalJSON ¶
MarshalJSON marshals the FieldType to JSON.
func (*FieldType) MemoryUsage ¶
MemoryUsage return the memory usage of FieldType
func (*FieldType) PartialEqual ¶
PartialEqual checks whether two FieldType objects are equal. If unsafe is true and the objects is string type, PartialEqual will ignore flen. See https://github.com/lemon-mint/tidb/v7/issues/35490#issuecomment-1211658886 for more detail.
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) SetCharset ¶
SetCharset sets the charset of the FieldType.
func (*FieldType) SetCollate ¶
SetCollate sets the collation of the FieldType.
func (*FieldType) SetDecimal ¶
SetDecimal sets the decimal of the FieldType.
func (*FieldType) SetDecimalUnderLimit ¶
SetDecimalUnderLimit sets the decimal of the field to the value of the argument
func (*FieldType) SetElemWithIsBinaryLit ¶
SetElemWithIsBinaryLit sets the element of the FieldType.
func (*FieldType) SetFlenUnderLimit ¶
SetFlenUnderLimit sets the length of the field to the value of the argument
func (*FieldType) StorageLength ¶
StorageLength is the length of stored value for the type.
func (*FieldType) 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.
func (*FieldType) ToggleFlag ¶
ToggleFlag toggle the flag of the FieldType.
func (*FieldType) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.