types

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package types 定义 VDS SQL 层的类型系统。 M1 支持 7 种基础类型:NULL、INT、FLOAT、VARCHAR、BOOL、TIMESTAMP、BLOB。 M3 新增:DATE、TIME、DATETIME 独立时间类型。 M4 新增:DECIMAL 精确数值、JSON 半结构化类型、TEXT/ENUM/BIT 扩展类型。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TypeID

type TypeID uint8

TypeID 列类型标识符枚举

const (
	// TypeNull NULL 类型(占位,列值为空)
	TypeNull TypeID = 0
	// TypeInt 64 位有符号整数
	TypeInt TypeID = 1
	// TypeFloat 64 位浮点数
	TypeFloat TypeID = 2
	// TypeVarchar 可变长字符串(最大长度由 ColumnDesc.Size 指定)
	TypeVarchar TypeID = 3
	// TypeBool 布尔值(true/false)
	TypeBool TypeID = 4
	// TypeTimestamp Unix 纳秒时间戳(int64 存储)
	TypeTimestamp TypeID = 5
	// TypeBlob 二进制大对象(>= 64KB 时由存储引擎 Blob 子系统处理)
	TypeBlob TypeID = 6
	// TypeDate 日期类型(int64 存储 Unix 天数;格式 YYYY-MM-DD)
	TypeDate TypeID = 7
	// TypeTime 时间类型(int64 存储自午夜起的纳秒数;格式 HH:MM:SS)
	TypeTime TypeID = 8
	// TypeDatetime 日期时间类型(int64 存储 Unix 纳秒;格式 YYYY-MM-DD HH:MM:SS)
	TypeDatetime TypeID = 9
	// TypeDecimal 精确小数类型(string 存储规范化十进制字符串,如 "123.4500")
	TypeDecimal TypeID = 10
	// TypeJSON JSON 类型(string 存储标准 JSON 文本,支持 json_extract 等函数)
	TypeJSON TypeID = 11
	// TypeText 可变长文本类型(与 VARCHAR 编码一致,无显式长度限制,Go 映射为 string)
	TypeText TypeID = 12
	// TypeEnum 枚举类型(string 存储,运行时验证值在允许列表中)
	TypeEnum TypeID = 13
	// TypeBit 位串类型([]byte 存储,BIT(n) 打包到 n bits)
	TypeBit TypeID = 14
)

func (TypeID) String

func (t TypeID) String() string

String 返回类型名称(用于错误信息和调试)

type Value

type Value = interface{}

Value 单列值(Go 原生类型映射):

  • TypeNull → nil
  • TypeInt → int64
  • TypeFloat → float64
  • TypeVarchar → string
  • TypeBool → bool
  • TypeTimestamp → int64(Unix 纳秒)
  • TypeBlob → []byte
  • TypeDate → int64(Unix 天数,UTC)
  • TypeTime → int64(自午夜起纳秒数)
  • TypeDatetime → int64(Unix 纳秒,UTC)
  • TypeDecimal → string(规范化十进制字符串,如 "123.4500")
  • TypeJSON → string(标准 JSON 文本)
  • TypeText → string(可变长文本)
  • TypeEnum → string(枚举值)
  • TypeBit → []byte(位串)

Jump to

Keyboard shortcuts

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