catalog

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogVersion_V1 uint32 = 1

	CatalogVersion_Curr uint32 = CatalogVersion_V1
)
View Source
const (
	MoIndexDefaultAlgo  = tree.INDEX_TYPE_INVALID  // used by UniqueIndex or default SecondaryIndex
	MoIndexBTreeAlgo    = tree.INDEX_TYPE_BTREE    // used for Mocking MySQL behaviour.
	MoIndexRTreeAlgo    = tree.INDEX_TYPE_RTREE    // used for Spatial Index on GEOMETRY columns
	MoIndexIvfFlatAlgo  = tree.INDEX_TYPE_IVFFLAT  // used for IVF flat index on Vector/Array columns
	MOIndexMasterAlgo   = tree.INDEX_TYPE_MASTER   // used for Master Index on VARCHAR columns
	MOIndexFullTextAlgo = tree.INDEX_TYPE_FULLTEXT // used for Fulltext Index on VARCHAR columns
	MoIndexHnswAlgo     = tree.INDEX_TYPE_HNSW     // used for HNSW Index on Vector/Array columns
	MoIndexCagraAlgo    = tree.INDEX_TYPE_CAGRA    // used for CAGRA Index on Vector/Array columns
	MoIndexIvfpqAlgo    = tree.INDEX_TYPE_IVFPQ    // used for IVFPQ Index on Vector/Array columns
)

Index Algorithm names

View Source
const (
	IndexAlgoParamLists     = "lists"
	IndexAlgoParamOpType    = "op_type"
	HnswM                   = "m"
	HnswEfConstruction      = "ef_construction"
	HnswEfSearch            = "ef_search"
	Async                   = "async"
	AutoUpdate              = "auto_update"
	Day                     = "day"
	Hour                    = "hour"
	DistributionMode        = "distribution_mode"
	Quantization            = "quantization"
	BitsPerCode             = "bits_per_code"
	IntermediateGraphDegree = "intermediate_graph_degree"
	GraphDegree             = "graph_degree"
	ITopkSize               = "itopk_size"
	IncludedColumns         = "included_columns"

	// Index-defining build params, settable as CREATE INDEX options (parsed by
	// each plugin's ParamsFromTree). Written into flat algo_params only when
	// explicitly specified, read back by the build path (table functions /
	// sync), and rendered by IndexParamsToStringList for SHOW CREATE.
	IndexAlgoParamKmeansTrainPercent = "kmeans_train_percent"
	IndexAlgoParamKmeansMaxIteration = "kmeans_max_iteration"
	IndexAlgoParamMaxIndexCapacity   = "max_index_capacity"

	IndexAlgoParamPrefixLengths = "prefix_lengths"
)

------------------------[START] IndexAlgoParams------------------------

View Source
const (
	// for schema
	PropSchemaExtra     = "schema_extra"
	PropFromPublication = "from_publication"

	Row_ID           = objectio.PhysicalAddr_Attr
	PrefixPriColName = "__mo_cpkey_"
	PrefixCBColName  = "__mo_cbkey_"

	// Wildcard characters for partition subtable name
	PartitionSubTableWildcard = "\\%!\\%%\\%!\\%%"

	ExternalFilePath = "__mo_filepath"

	// MOAutoIncrTable mo auto increment table name
	MOAutoIncrTable = "mo_increment_columns"
	// TableTailAttr are attrs in table tail
	TableTailAttrDeleteRowID = objectio.TombstoneAttr_Rowid_Attr
	TableTailAttrCommitTs    = objectio.TombstoneAttr_CommitTs_Attr
	TableTailAttrAborted     = objectio.TombstoneAttr_Abort_Attr
	TableTailAttrPKVal       = objectio.TombstoneAttr_PK_Attr

	MOAccountTable = "mo_account"
	// MOVersionTable mo version table. This table records information about the
	// versions of the MO cluster that have been upgraded. In other words, you can
	// query this table to find out all the versions of the MO cluster that have
	// been running.
	MOVersionTable = "mo_version"
	// MOUpgradeTable mo upgrade table. This table records the MO cluster version
	// upgrade paths, including upgrade paths for intermediate versions that are
	// upgraded across versions.
	MOUpgradeTable = "mo_upgrade"
	// MOUpgradeTenantTable MO is a cloud-native, multi-tenant database, and when
	// versions are upgraded, it may be necessary to upgrade all tenant-related metadata.
	// This table is used to record all the tenant records that need to be upgraded
	MOUpgradeTenantTable = "mo_upgrade_tenant"

	// MOForeignKeys saves the fk relationships
	MOForeignKeys = "mo_foreign_keys"

	// MOShardsMetadata is used to store the sharding information of the table. See detail
	// in shardservice.
	MOShardsMetadata = "mo_shards_metadata"
	// MOShards shards detail.
	MOShards = "mo_shards"
)
View Source
const (
	System_User    = uint32(0)
	System_Role    = uint32(0)
	System_Account = uint32(0)
)
View Source
const (
	// Non-hard-coded data dictionary table
	MO_INDEXES = "mo_indexes"

	// MO_TABLE_PARTITIONS Data dictionary table of record table partition
	MO_TABLE_PARTITIONS = "mo_table_partitions"

	// MOTaskDB mo task db name
	MOTaskDB = "mo_task"

	// MOSysDaemonTask is the table name of daemon task table in mo_task.
	MOSysDaemonTask = "sys_daemon_task"

	// MOSysAsyncTask is the table name of async task table in mo_task.
	MOSysAsyncTask = "sys_async_task"

	// MOSQLTask is the table name of sql task table in mo_task.
	MOSQLTask = "sql_task"

	// MOSQLTaskRun is the table name of sql task run table in mo_task.
	MOSQLTaskRun = "sql_task_run"

	// MOStages if the table name of mo_stages table in mo_cataglog.
	MO_STAGES = "mo_stages"

	// MO_PUBS publication meta table
	MO_PUBS = "mo_pubs"

	// MO_SUBS subscriptions meta table
	MO_SUBS = "mo_subs"

	// MO_SNAPSHOTS
	MO_SNAPSHOTS = "mo_snapshots"

	//MO_Pitr
	MO_PITR               = "mo_pitr"
	MO_PITR_OBJECT_ID     = "obj_id"
	MO_PITR_MODIFIED_TIME = "modified_time"
	MO_PITR_ACCOUNT_ID    = "account_id"
	MO_PITR_DB_NAME       = "database_name"
	MO_PITR_TABLE_NAME    = "table_name"
	MO_PITR_STATUS        = "pitr_status"
	MO_PITR_CHANGED_TIME  = "pitr_status_changed_time"

	MO_CDC_TASK      = "mo_cdc_task"
	MO_CDC_WATERMARK = "mo_cdc_watermark"

	MO_DATA_KEY = "mo_data_key"

	MO_TABLE_STATS = "mo_table_stats_alpha"

	MO_ACCOUNT_LOCK = "__mo_account_lock"

	MO_MERGE_SETTINGS = "mo_merge_settings"

	MO_ISCP_LOG         = "mo_iscp_log"
	MO_STORED_PROCEDURE = "mo_stored_procedure"

	MO_CCPR_LOG = "mo_ccpr_log"

	MO_INDEX_UPDATE = "mo_index_update"

	MO_BRANCH_METADATA  = "mo_branch_metadata"
	MO_FEATURE_LIMIT    = "mo_feature_limit"
	MO_FEATURE_REGISTRY = "mo_feature_registry"

	MO_CCPR_TABLES = "mo_ccpr_tables"
	MO_CCPR_DBS    = "mo_ccpr_dbs"
)
View Source
const (
	MO_SYSTEM    = "system"
	MO_STATEMENT = "statement_info"
	MO_RAWLOG    = "rawlog"

	MO_SYSTEM_METRICS = "system_metrics"
	MO_METRIC         = "metric"
	MO_SQL_STMT_CU    = "sql_statement_cu"

	// default database name for catalog
	MO_CATALOG   = "mo_catalog"
	MO_DATABASE  = "mo_database"
	MO_TABLES    = "mo_tables"
	MO_COLUMNS   = "mo_columns"
	MO_USER      = "mo_user"
	MO_ROLE_RULE = "mo_role_rule"

	// mo_tables logical_id index table name (fixed name, no UUID)
	MO_TABLES_LOGICAL_ID_INDEX_TABLE_NAME = "__mo_index_unique_mo_tables_logical_id"

	// 'mo_database' table
	SystemDBAttr_ID          = "dat_id"
	SystemDBAttr_Name        = "datname"
	SystemDBAttr_CatalogName = "dat_catalog_name"
	SystemDBAttr_CreateSQL   = "dat_createsql"
	SystemDBAttr_Owner       = "owner"
	SystemDBAttr_Creator     = "creator"
	SystemDBAttr_CreateAt    = "created_time"
	SystemDBAttr_AccID       = "account_id"
	SystemDBAttr_Type        = "dat_type"
	SystemDBAttr_CPKey       = CPrimaryKeyColName

	// 'mo_tables' table
	SystemRelAttr_ID             = "rel_id"
	SystemRelAttr_Name           = "relname"
	SystemRelAttr_DBName         = "reldatabase"
	SystemRelAttr_DBID           = "reldatabase_id"
	SystemRelAttr_Persistence    = "relpersistence"
	SystemRelAttr_Kind           = "relkind"
	SystemRelAttr_Comment        = "rel_comment"
	SystemRelAttr_CreateSQL      = "rel_createsql"
	SystemRelAttr_CreateAt       = "created_time"
	SystemRelAttr_Creator        = "creator"
	SystemRelAttr_Owner          = "owner"
	SystemRelAttr_AccID          = "account_id"
	SystemRelAttr_Partitioned    = "partitioned"
	SystemRelAttr_Partition      = "partition_info"
	SystemRelAttr_ViewDef        = "viewdef"
	SystemRelAttr_Constraint     = "constraint"
	SystemRelAttr_Version        = "rel_version"
	SystemRelAttr_CatalogVersion = "catalog_version"
	SystemRelAttr_ExtraInfo      = "extra_info"
	SystemRelAttr_CPKey          = CPrimaryKeyColName
	SystemRelAttr_LogicalID      = "rel_logical_id"

	// 'mo_indexes' table
	IndexAlgoName      = "algo"
	IndexAlgoTableType = "algo_table_type"
	IndexAlgoParams    = "algo_params"

	// 'mo_columns' table
	SystemColAttr_UniqName        = "att_uniq_name"
	SystemColAttr_AccID           = "account_id"
	SystemColAttr_Name            = "attname"
	SystemColAttr_DBID            = "att_database_id"
	SystemColAttr_DBName          = "att_database"
	SystemColAttr_RelID           = "att_relname_id"
	SystemColAttr_RelName         = "att_relname"
	SystemColAttr_Type            = "atttyp"
	SystemColAttr_Num             = "attnum"
	SystemColAttr_Length          = "att_length"
	SystemColAttr_NullAbility     = "attnotnull"
	SystemColAttr_HasExpr         = "atthasdef"
	SystemColAttr_DefaultExpr     = "att_default"
	SystemColAttr_IsDropped       = "attisdropped"
	SystemColAttr_ConstraintType  = "att_constraint_type"
	SystemColAttr_IsUnsigned      = "att_is_unsigned"
	SystemColAttr_IsAutoIncrement = "att_is_auto_increment"
	SystemColAttr_Comment         = "att_comment"
	SystemColAttr_IsHidden        = "att_is_hidden"
	SystemColAttr_HasUpdate       = "attr_has_update"
	SystemColAttr_Update          = "attr_update"
	SystemColAttr_IsClusterBy     = "attr_is_clusterby"
	SystemColAttr_Seqnum          = "attr_seqnum"
	SystemColAttr_EnumValues      = "attr_enum"
	SystemColAttr_CPKey           = CPrimaryKeyColName
	SystemColAttr_HasGenerated    = "attr_has_generated"
	SystemColAttr_Generated       = "attr_generated"

	BlockMeta_ID              = "block_id"
	BlockMeta_Delete_ID       = "block_delete_id"
	BlockMeta_EntryState      = "entry_state"
	BlockMeta_Sorted          = "sorted"
	BlockMeta_BlockInfo       = "%!%mo__block_info"
	BlockMeta_MetaLoc         = "%!%mo__meta_loc"
	BlockMeta_DeltaLoc        = "delta_loc"
	BlockMeta_CommitTs        = "committs"
	BlockMeta_SegmentID       = "segment_id"
	BlockMeta_MemTruncPoint   = "trunc_pointt"
	BlockMeta_TableIdx_Insert = "%!%mo__meta_tbl_index" // mark which table this metaLoc belongs to
	BlockMeta_Type            = "%!%mo__meta_type"
	BlockMeta_Deletes_Length  = "%!%mo__meta_deletes_length"
	BlockMeta_Partition       = "%!%mo__meta_partition"

	ObjectMeta_ObjectStats = "object_stats"

	// BlockMetaOffset_Min       = "%!%mo__meta_offset_min"
	// BlockMetaOffset_Max       = "%!%mo__meta_offset_max"
	BlockMetaOffset    = "%!%mo__meta_offset"
	SystemCatalogName  = "def"
	SystemPersistRel   = "p"
	SystemTransientRel = "t"

	SystemOrdinaryRel     = "r"
	SystemIndexRel        = "i"
	SystemSequenceRel     = "S"
	SystemViewRel         = "v"
	SystemMaterializedRel = "m"
	SystemExternalRel     = plan.SystemExternalRel
	SystemSourceRel       = "s"
	//the cluster table created by the sys account
	//and read only by the general account
	SystemClusterRel = "cluster"
	/*
		the partition table contains the data of the partition.
		the table partitioned has multiple partition tables
	*/
	SystemPartitionRel    = "partition"
	SystemColPKConstraint = "p"
	SystemColNoConstraint = "n"

	SystemDBTypeSubscription = "subscription"

	MOPartitionMetadata = "mo_partition_metadata"
	MOPartitionTables   = "mo_partition_tables"
)
View Source
const (
	UniqueIndexSuffix             = "unique_"
	FullTextIndexSuffix           = "fulltext_"
	HnswIndexSuffix               = "hnsw_"
	CagraIndexSuffix              = "cagra_"
	IvfpqIndexSuffix              = "ivfpq_"
	SecondaryIndexSuffix          = "secondary_"
	PrefixIndexTableName          = "__mo_index_"
	IndexTableNamePrefix          = PrefixIndexTableName
	UniqueIndexTableNamePrefix    = PrefixIndexTableName + UniqueIndexSuffix
	SecondaryIndexTableNamePrefix = PrefixIndexTableName + SecondaryIndexSuffix
	FullTextIndexTableNamePrefix  = PrefixIndexTableName + FullTextIndexSuffix
	HnswIndexTableNamePrefix      = PrefixIndexTableName + HnswIndexSuffix
	CagraIndexTableNamePrefix     = PrefixIndexTableName + CagraIndexSuffix
	IvfpqIndexTableNamePrefix     = PrefixIndexTableName + IvfpqIndexSuffix

	// Regualar secondary index table columns
	IndexTableIndexColName   = "__mo_index_idx_col"
	IndexTablePrimaryColName = "__mo_index_pri_col"

	CPrimaryKeyColName = "__mo_cpkey_col" // Compound primary key column name, which is a hidden column
	// FakePrimaryKeyColName for tables without a primary key, a new hidden primary key column
	// is added, which will not be sorted or used for any other purpose, but will only be used to add
	// locks to the Lock operator in pessimistic transaction mode.
	FakePrimaryKeyColName = "__mo_fake_pk_col"

	MasterIndexTableIndexColName   = IndexTableIndexColName
	MasterIndexTablePrimaryColName = IndexTablePrimaryColName

	// IVF_FLAT Table Types
	SystemSI_IVFFLAT_TblType_Metadata  = "metadata"
	SystemSI_IVFFLAT_TblType_Centroids = "centroids"
	SystemSI_IVFFLAT_TblType_Entries   = "entries"

	// IVF_FLAT MetadataTable - Column names
	SystemSI_IVFFLAT_TblCol_Metadata_key = "__mo_index_key"
	SystemSI_IVFFLAT_TblCol_Metadata_val = "__mo_index_val"

	// IVF_FLAT Centroids - Column names
	SystemSI_IVFFLAT_TblCol_Centroids_version  = "__mo_index_centroid_version"
	SystemSI_IVFFLAT_TblCol_Centroids_id       = "__mo_index_centroid_id"
	SystemSI_IVFFLAT_TblCol_Centroids_centroid = "__mo_index_centroid"

	// IVF_FLAT Entries - Column names
	SystemSI_IVFFLAT_TblCol_Entries_version = "__mo_index_centroid_fk_version"
	SystemSI_IVFFLAT_TblCol_Entries_id      = "__mo_index_centroid_fk_id"
	SystemSI_IVFFLAT_TblCol_Entries_pk      = IndexTablePrimaryColName
	SystemSI_IVFFLAT_TblCol_Entries_entry   = "__mo_index_centroid_fk_entry"

	// FULLTEXT Table Type
	FullTextIndex_TblType = "fulltext"

	FullTextIndex_TabCol_Word     = "word"
	FullTextIndex_TabCol_Id       = "doc_id"
	FullTextIndex_TabCol_Position = "pos"

	// HNSW Table Types
	// NOTE: avoid duplicate TblType name with IVFFLAT or other index
	Hnsw_TblType_Metadata = "hnsw_meta"
	Hnsw_TblType_Storage  = "hnsw_index"

	// HNSW Storage - Column names
	Hnsw_TblCol_Storage_Index_Id = "index_id"
	Hnsw_TblCol_Storage_Chunk_Id = "chunk_id"
	Hnsw_TblCol_Storage_Data     = "data"
	Hnsw_TblCol_Storage_Tag      = "tag"

	// HNSW Metadata - Column names
	Hnsw_TblCol_Metadata_Index_Id  = "index_id"
	Hnsw_TblCol_Metadata_Timestamp = "timestamp"
	Hnsw_TblCol_Metadata_Checksum  = "checksum"
	Hnsw_TblCol_Metadata_Filesize  = "filesize"

	// CAGRA Table Types
	// NOTE: avoid duplicate TblType name with IVFFLAT or other index
	Cagra_TblType_Metadata = "cagra_meta"
	Cagra_TblType_Storage  = "cagra_index"

	// CAGRA Storage - Column names
	Cagra_TblCol_Storage_Index_Id = "index_id"
	Cagra_TblCol_Storage_Chunk_Id = "chunk_id"
	Cagra_TblCol_Storage_Data     = "data"
	Cagra_TblCol_Storage_Tag      = "tag"

	// CAGRA Metadata - Column names
	Cagra_TblCol_Metadata_Index_Id  = "index_id"
	Cagra_TblCol_Metadata_Timestamp = "timestamp"
	Cagra_TblCol_Metadata_Checksum  = "checksum"
	Cagra_TblCol_Metadata_Filesize  = "filesize"

	// IVF-PQ Table Types
	// NOTE: avoid duplicate TblType name with IVFFLAT, CAGRA or other index
	Ivfpq_TblType_Metadata = "ivfpq_meta"
	Ivfpq_TblType_Storage  = "ivfpq_index"

	// IVF-PQ Storage - Column names
	Ivfpq_TblCol_Storage_Index_Id = "index_id"
	Ivfpq_TblCol_Storage_Chunk_Id = "chunk_id"
	Ivfpq_TblCol_Storage_Data     = "data"
	Ivfpq_TblCol_Storage_Tag      = "tag"

	// IVF-PQ Metadata - Column names
	Ivfpq_TblCol_Metadata_Index_Id  = "index_id"
	Ivfpq_TblCol_Metadata_Timestamp = "timestamp"
	Ivfpq_TblCol_Metadata_Checksum  = "checksum"
	Ivfpq_TblCol_Metadata_Filesize  = "filesize"

	// Query format for getting rowid from logical_id index table
	// Parameters: database_name, table_name, index_column_name, logical_id
	LogicalIdIndexRowidQueryFormat = "SELECT __mo_rowid FROM `%s`.`%s` WHERE `%s` = %d"

	SystemTemporaryTable = "temporary_table"
)

Key/Index related constants

View Source
const (
	// default database id for catalog
	MO_CATALOG_ID                 = 1
	MO_DATABASE_ID                = 1
	MO_TABLES_ID                  = 2
	MO_COLUMNS_ID                 = 3
	MO_TABLES_LOGICAL_ID_INDEX_ID = 4 // ID allocated for mo_tables logical_id index table

	// MO_RESERVED_MAX is the max reserved table ID.
	MO_RESERVED_MAX = 100
)
View Source
const (
	MO_TABLES_ALTER_TABLE       = 0
	MO_TABLES_UPDATE_CONSTRAINT = 4
)

index use to update constraint

View Source
const (
	MO_DATABASE_DAT_ID_IDX           = 0
	MO_DATABASE_DAT_NAME_IDX         = 1
	MO_DATABASE_DAT_CATALOG_NAME_IDX = 2
	MO_DATABASE_CREATESQL_IDX        = 3
	MO_DATABASE_OWNER_IDX            = 4
	MO_DATABASE_CREATOR_IDX          = 5
	MO_DATABASE_CREATED_TIME_IDX     = 6
	MO_DATABASE_ACCOUNT_ID_IDX       = 7
	MO_DATABASE_DAT_TYPE_IDX         = 8
	MO_DATABASE_CPKEY_IDX            = 9

	MO_TABLES_REL_ID_IDX          = 0
	MO_TABLES_REL_NAME_IDX        = 1
	MO_TABLES_RELDATABASE_IDX     = 2
	MO_TABLES_RELDATABASE_ID_IDX  = 3
	MO_TABLES_RELPERSISTENCE_IDX  = 4
	MO_TABLES_RELKIND_IDX         = 5
	MO_TABLES_REL_COMMENT_IDX     = 6
	MO_TABLES_REL_CREATESQL_IDX   = 7
	MO_TABLES_CREATED_TIME_IDX    = 8
	MO_TABLES_CREATOR_IDX         = 9
	MO_TABLES_OWNER_IDX           = 10
	MO_TABLES_ACCOUNT_ID_IDX      = 11
	MO_TABLES_PARTITIONED_IDX     = 12
	MO_TABLES_PARTITION_INFO_IDX  = 13
	MO_TABLES_VIEWDEF_IDX         = 14
	MO_TABLES_CONSTRAINT_IDX      = 15
	MO_TABLES_VERSION_IDX         = 16
	MO_TABLES_CATALOG_VERSION_IDX = 17
	MO_TABLES_EXTRA_INFO_IDX      = 18
	MO_TABLES_CPKEY_IDX           = 19
	MO_TABLES_LOGICAL_ID_IDX      = 20

	MO_COLUMNS_ATT_UNIQ_NAME_IDX         = 0
	MO_COLUMNS_ACCOUNT_ID_IDX            = 1
	MO_COLUMNS_ATT_DATABASE_ID_IDX       = 2
	MO_COLUMNS_ATT_DATABASE_IDX          = 3
	MO_COLUMNS_ATT_RELNAME_ID_IDX        = 4
	MO_COLUMNS_ATT_RELNAME_IDX           = 5
	MO_COLUMNS_ATTNAME_IDX               = 6
	MO_COLUMNS_ATTTYP_IDX                = 7
	MO_COLUMNS_ATTNUM_IDX                = 8
	MO_COLUMNS_ATT_LENGTH_IDX            = 9
	MO_COLUMNS_ATTNOTNULL_IDX            = 10
	MO_COLUMNS_ATTHASDEF_IDX             = 11
	MO_COLUMNS_ATT_DEFAULT_IDX           = 12
	MO_COLUMNS_ATTISDROPPED_IDX          = 13
	MO_COLUMNS_ATT_CONSTRAINT_TYPE_IDX   = 14
	MO_COLUMNS_ATT_IS_UNSIGNED_IDX       = 15
	MO_COLUMNS_ATT_IS_AUTO_INCREMENT_IDX = 16
	MO_COLUMNS_ATT_COMMENT_IDX           = 17
	MO_COLUMNS_ATT_IS_HIDDEN_IDX         = 18
	MO_COLUMNS_ATT_HAS_UPDATE_IDX        = 19
	MO_COLUMNS_ATT_UPDATE_IDX            = 20
	MO_COLUMNS_ATT_IS_CLUSTERBY          = 21
	MO_COLUMNS_ATT_SEQNUM_IDX            = 22
	MO_COLUMNS_ATT_ENUM_IDX              = 23
	MO_COLUMNS_ATT_CPKEY_IDX             = 24
	MO_COLUMNS_ATT_HAS_GENERATED_IDX     = 25
	MO_COLUMNS_ATT_GENERATED_IDX         = 26
	MO_COLUMNS_MAXIDX                    = MO_COLUMNS_ATT_GENERATED_IDX

	BLOCKMETA_ID_IDX            = 0
	BLOCKMETA_ENTRYSTATE_IDX    = 1
	BLOCKMETA_SORTED_IDX        = 2
	BLOCKMETA_METALOC_IDX       = 3
	BLOCKMETA_DELTALOC_IDX      = 4
	BLOCKMETA_COMMITTS_IDX      = 5
	BLOCKMETA_SEGID_IDX         = 6
	BLOCKMETA_MemTruncPoint_IDX = 7

	SKIP_ROWID_OFFSET = 2 //rowid and cpk occupied the first coluns in delete batch
)

column's index in catalog table

View Source
const (
	QUERY_ID_IDX        = 0
	STATEMENT_IDX       = 1
	ACCOUNT_ID_IDX      = 2
	ROLE_ID_IDX         = 3
	RESULT_PATH_IDX     = 4
	CREATE_TIME_IDX     = 5
	RESULT_SIZE_IDX     = 6
	COLUMNS_IDX         = 7
	TABLES_IDX          = 8
	USER_ID_IDX         = 9
	EXPIRED_TIME_IDX    = 10
	PLAN_IDX            = 11
	AST_IDX             = 12
	COLUMN_MAP_IDX      = 13
	SAVED_ROW_COUNT_IDX = 14
	QUERY_ROW_COUNT_IDX = 15
)
View Source
const (
	AliasPrefix = "__mo_alias_"
)
View Source
const IndexParamSessionVars = "session_vars"

IndexParamSessionVars is the reserved algo_params key whose value is a nested, typed sqlexec.Metadata object ({"cfg":{...}}) carrying the build-time session variables captured at CREATE INDEX (e.g. kmeans_train_percent). It is NOT a flat string param: IndexParamsStringToMap skips it (so flat consumers are unaffected), and it is read back via IndexParamsSessionVars.

View Source
const (
	MO_COMMENT_NO_DEL_HINT = "[mo_no_del_hint]"
)
View Source
const (
	Meta_Length = 6
)

Variables

View Source
var (
	MoDatabaseSchema = []string{
		SystemDBAttr_ID,
		SystemDBAttr_Name,
		SystemDBAttr_CatalogName,
		SystemDBAttr_CreateSQL,
		SystemDBAttr_Owner,
		SystemDBAttr_Creator,
		SystemDBAttr_CreateAt,
		SystemDBAttr_AccID,
		SystemDBAttr_Type,
		SystemDBAttr_CPKey,
	}
	MoDatabaseAllColsString  = strings.Join(append([]string{Row_ID}, MoDatabaseSchema...), ",")
	MoDatabaseAllQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q",
		MoDatabaseAllColsString, MO_CATALOG, MO_DATABASE,
		SystemDBAttr_AccID, SystemDBAttr_Name)

	// exclude mo_catlaog
	MoDatabaseBatchQuery = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s > 1",
		MoDatabaseAllColsString, MO_CATALOG, MO_DATABASE, SystemDBAttr_ID)

	MoDatabasesInEngineQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d",
		SystemDBAttr_Name, MO_CATALOG, MO_DATABASE,
		SystemDBAttr_AccID)

	MoDatabaseRowidQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q",
		Row_ID, MO_CATALOG, MO_DATABASE,
		SystemDBAttr_AccID, SystemDBAttr_Name)

	MoTablesSchema = []string{
		SystemRelAttr_ID,
		SystemRelAttr_Name,
		SystemRelAttr_DBName,
		SystemRelAttr_DBID,
		SystemRelAttr_Persistence,
		SystemRelAttr_Kind,
		SystemRelAttr_Comment,
		SystemRelAttr_CreateSQL,
		SystemRelAttr_CreateAt,
		SystemRelAttr_Creator,
		SystemRelAttr_Owner,
		SystemRelAttr_AccID,
		SystemRelAttr_Partitioned,
		SystemRelAttr_Partition,
		SystemRelAttr_ViewDef,
		SystemRelAttr_Constraint,
		SystemRelAttr_Version,
		SystemRelAttr_CatalogVersion,
		SystemRelAttr_ExtraInfo,
		SystemRelAttr_CPKey,
		SystemRelAttr_LogicalID,
	}
	MoTablesAllColsString = strings.Replace(
		strings.Join(append([]string{Row_ID}, MoTablesSchema...), ","),
		SystemRelAttr_Constraint,
		fmt.Sprintf("`%s`", SystemRelAttr_Constraint),
		-1)
	MoTablesAllQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q and %s = %%q",
		MoTablesAllColsString, MO_CATALOG, MO_TABLES,
		SystemRelAttr_AccID, SystemRelAttr_DBName, SystemRelAttr_Name)

	// exclude mo_database mo_tables mo_columns
	MoTablesBatchQuery = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s > %v",
		MoTablesAllColsString, MO_CATALOG, MO_TABLES, SystemRelAttr_ID, MO_RESERVED_MAX)

	MoTablesInDBQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q",
		SystemRelAttr_Name, MO_CATALOG, MO_TABLES,
		SystemRelAttr_AccID, SystemRelAttr_DBName)

	MoTablesRowidQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q and %s = %%q",
		Row_ID, MO_CATALOG, MO_TABLES,
		SystemRelAttr_AccID, SystemRelAttr_DBName, SystemRelAttr_Name)

	MoTablesQueryNameById = fmt.Sprintf(
		"select %s,%s from `%s`.`%s` where %s = %%d and %s = %%d",
		SystemRelAttr_Name, SystemRelAttr_DBName, MO_CATALOG, MO_TABLES,
		SystemRelAttr_AccID, SystemRelAttr_ID)

	MoColumnsSchema = []string{
		SystemColAttr_UniqName,
		SystemColAttr_AccID,
		SystemColAttr_DBID,
		SystemColAttr_DBName,
		SystemColAttr_RelID,
		SystemColAttr_RelName,
		SystemColAttr_Name,
		SystemColAttr_Type,
		SystemColAttr_Num,
		SystemColAttr_Length,
		SystemColAttr_NullAbility,
		SystemColAttr_HasExpr,
		SystemColAttr_DefaultExpr,
		SystemColAttr_IsDropped,
		SystemColAttr_ConstraintType,
		SystemColAttr_IsUnsigned,
		SystemColAttr_IsAutoIncrement,
		SystemColAttr_Comment,
		SystemColAttr_IsHidden,
		SystemColAttr_HasUpdate,
		SystemColAttr_Update,
		SystemColAttr_IsClusterBy,
		SystemColAttr_Seqnum,
		SystemColAttr_EnumValues,
		SystemColAttr_CPKey,
		SystemColAttr_HasGenerated,
		SystemColAttr_Generated,
	}
	MoColumnsAllColsString  = strings.Join(append([]string{Row_ID}, MoColumnsSchema...), ",")
	MoColumnsAllQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q and %s = %%q and %s = %%d",
		MoColumnsAllColsString, MO_CATALOG, MO_COLUMNS,
		SystemColAttr_AccID, SystemColAttr_DBName, SystemColAttr_RelName, SystemColAttr_RelID)

	// exclude mo_database mo_tables mo_columns
	MoColumnsBatchQuery = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s > %d order by %s, %s, %s",
		MoColumnsAllColsString, MO_CATALOG, MO_COLUMNS, SystemColAttr_RelID, MO_RESERVED_MAX,
		SystemColAttr_AccID, SystemColAttr_DBName, SystemColAttr_RelName)

	MoColumnsRowidsQueryFormat = fmt.Sprintf(
		"select %s from `%s`.`%s` where %s = %%d and %s = %%q and %s = %%q and %s = %%d order by %s",
		Row_ID, MO_CATALOG, MO_COLUMNS,
		SystemColAttr_AccID, SystemColAttr_DBName, SystemColAttr_RelName, SystemColAttr_RelID, SystemColAttr_Num)

	MoTableMetaSchema = []string{
		BlockMeta_ID,
		BlockMeta_EntryState,
		BlockMeta_Sorted,
		BlockMeta_MetaLoc,
		BlockMeta_DeltaLoc,
		BlockMeta_CommitTs,
		BlockMeta_SegmentID,
		BlockMeta_MemTruncPoint,
	}
	MoDatabaseTypes = []types.Type{
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_timestamp, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_varchar, 32, 0),
		types.New(types.T_varchar, 65535, 0),
	}
	MoTablesTypes = []types.Type{
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_timestamp, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_blob, 0, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_varchar, 5000, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_varchar, 0, 0),
		types.New(types.T_varchar, 65535, 0),
		types.New(types.T_uint64, 0, 0),
	}
	MoColumnsTypes = []types.Type{
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_int32, 0, 0),
		types.New(types.T_int32, 0, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_varchar, 2048, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_char, 1, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_varchar, 2048, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_varchar, 2048, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_uint16, 0, 0),
		types.New(types.T_varchar, types.MaxVarcharLen, 0),
		types.New(types.T_varchar, 65535, 0),
		types.New(types.T_int8, 0, 0),
		types.New(types.T_varchar, 2048, 0),
	}
	MoTableMetaTypes = []types.Type{
		types.New(types.T_Blockid, 0, 0),
		types.New(types.T_bool, 0, 0),
		types.New(types.T_bool, 0, 0),
		types.New(types.T_varchar, types.MaxVarcharLen, 0),
		types.New(types.T_varchar, types.MaxVarcharLen, 0),
		types.New(types.T_TS, 0, 0),
		types.New(types.T_uuid, 0, 0),
		types.New(types.T_TS, 0, 0),
	}

	// mo_ccpr_tables schema: tableid (pk), taskid, dbname, tablename, account_id
	MoCCPRTablesSchema = []string{
		"tableid",
		"taskid",
		"dbname",
		"tablename",
		"account_id",
	}
	MoCCPRTablesTypes = []types.Type{
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_uuid, 0, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_uint32, 0, 0),
	}

	// mo_ccpr_dbs schema: dbid (pk), taskid, dbname, account_id
	MoCCPRDbsSchema = []string{
		"dbid",
		"taskid",
		"dbname",
		"account_id",
	}
	MoCCPRDbsTypes = []types.Type{
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_uuid, 0, 0),
		types.New(types.T_varchar, 256, 0),
		types.New(types.T_uint32, 0, 0),
	}
)
View Source
var (
	QueryResultPath     string
	QueryResultMetaPath string
	QueryResultMetaDir  string
	//ProfileDir holds all profiles dumped by the runtime/pprof
	ProfileDir string
	TraceDir   string
)
View Source
var (
	MetaColTypes = []types.Type{
		types.New(types.T_uuid, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_timestamp, 0, 0),
		types.New(types.T_float64, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_uint32, 0, 0),
		types.New(types.T_timestamp, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_text, 0, 0),
		types.New(types.T_uint64, 0, 0),
		types.New(types.T_uint64, 0, 0),
	}

	MetaColNames = []string{
		"query_id",
		"statement",
		"account_id",
		"role_id",
		"result_path",
		"create_time",
		"result_size",
		"columns",
		"tables",
		"user_id",
		"expired_time",
		"plan",
		"Ast",
		"ColumnMap",
		"savedRowCount",
		"queryRowCount",
	}
)
View Source
var InternalColumns = map[string]int8{
	Row_ID:                                     0,
	PrefixPriColName:                           0,
	PrefixCBColName:                            0,
	PrefixIndexTableName:                       0,
	CPrimaryKeyColName:                         0,
	FakePrimaryKeyColName:                      0,
	IndexTableIndexColName:                     0,
	IndexTablePrimaryColName:                   0,
	SystemSI_IVFFLAT_TblCol_Metadata_key:       0,
	SystemSI_IVFFLAT_TblCol_Metadata_val:       0,
	SystemSI_IVFFLAT_TblCol_Centroids_version:  0,
	SystemSI_IVFFLAT_TblCol_Centroids_id:       0,
	SystemSI_IVFFLAT_TblCol_Centroids_centroid: 0,
	SystemSI_IVFFLAT_TblCol_Entries_version:    0,
	SystemSI_IVFFLAT_TblCol_Entries_id:         0,
	SystemSI_IVFFLAT_TblCol_Entries_entry:      0,
}
View Source
var InternalTableNames = map[string]int8{
	IndexTableNamePrefix: 0,
	MOAutoIncrTable:      0,
}
View Source
var SystemDatabases = []string{
	"information_schema",
	"mo_catalog",
	"mo_debug",
	"mo_task",
	"mysql",
	"system",
	"system_metrics",
}

Functions

func AddIndexPrefixLengthsToParams

func AddIndexPrefixLengthsToParams(indexParams string, keyParts []*tree.KeyPart) (string, error)

func BuildProfilePath added in v1.1.2

func BuildProfilePath(serviceTyp string, nodeId string, typ, name string) string

func BuildQueryResultMetaPath added in v0.7.0

func BuildQueryResultMetaPath(accountName, statementId string) string

func BuildQueryResultPath added in v0.7.0

func BuildQueryResultPath(accountName, statementId string, blockIdx int) string

func ContainExternalHidenCol added in v0.7.0

func ContainExternalHidenCol(col string) bool

func CreateAlias added in v1.1.0

func CreateAlias(column string) string

func DefaultIvfIndexAlgoOptions added in v1.1.0

func DefaultIvfIndexAlgoOptions() map[string]string

func GenCreateColumnTuples

func GenCreateColumnTuples(cols []Column, m *mpool.MPool, packer *types.Packer) (*batch.Batch, error)

genCreateColumnTuples yields a batch for insertion into mo_columns.

func GenCreateDatabaseTuple

func GenCreateDatabaseTuple(sql string, accountId, userId, roleId uint32,
	name string, databaseId uint64, typ string,
	m *mpool.MPool, packer *types.Packer,
) (*batch.Batch, error)

func GenCreateTableTuple

func GenCreateTableTuple(tbl Table, m *mpool.MPool, packer *types.Packer) (*batch.Batch, error)

genCreateTableTuple yields a batch for insertion into mo_tables.

func GenDropColumnTuples

func GenDropColumnTuples(rowids []types.Rowid, pks [][]byte, m *mpool.MPool) (*batch.Batch, error)

genDropColumnTuple generates the batch for deletion on mo_columns. the batch has rowid vector.

func GenDropDatabaseTuple

func GenDropDatabaseTuple(
	rowid types.Rowid, accid uint32, datid uint64, name string,
	m *mpool.MPool, packer *types.Packer,
) (*batch.Batch, error)

func GenDropTableTuple

func GenDropTableTuple(rowid types.Rowid, accid uint32, id, databaseId uint64, name, databaseName string,
	m *mpool.MPool, packer *types.Packer) (*batch.Batch, error)

genDropTableTuple generates the batch for deletion on mo_tables. the batch has rowid vector.

func GenLogicalIdIndexDeleteBatch

func GenLogicalIdIndexDeleteBatch(
	rowid types.Rowid,
	logicalId uint64,
	mp *mpool.MPool,
) (*batch.Batch, error)

GenLogicalIdIndexDeleteBatch generates the batch for deleting from logical_id index table The batch structure follows the standard delete batch pattern: Row_ID + PrimaryKey

func GenLogicalIdIndexInsertBatch

func GenLogicalIdIndexInsertBatch(
	logicalId uint64,
	compositePk []byte,
	mp *mpool.MPool,
) (*batch.Batch, error)

GenLogicalIdIndexInsertBatch generates the batch for inserting into logical_id index table

func GenMoTablesLogicalIdIndexTableDefs

func GenMoTablesLogicalIdIndexTableDefs() []engine.TableDef

GenMoTablesLogicalIdIndexTableDefs generates table definitions for mo_tables logical_id index table

func GenRows added in v0.6.0

func GenRows(bat *batch.Batch) [][]any

func GenTableAlterTuple

func GenTableAlterTuple(constraint [][]byte, m *mpool.MPool) (*batch.Batch, error)

func IndexParamsMapToJsonString added in v1.1.0

func IndexParamsMapToJsonString(res map[string]string) (string, error)

IndexParamsMapToJsonString used by AlterTableInPlace and CreateIndexDef

func IndexParamsMapToJsonStringWithSessionVars

func IndexParamsMapToJsonStringWithSessionVars(res map[string]string, sessionVars json.RawMessage) (string, error)

IndexParamsMapToJsonStringWithSessionVars marshals the flat params plus the nested session_vars object. A nil/empty sessionVars behaves exactly like IndexParamsMapToJsonString (no session_vars key), preserving the old format.

func IndexParamsSessionVars

func IndexParamsSessionVars(indexParams string) (json.RawMessage, error)

IndexParamsSessionVars extracts the nested session_vars object (the sqlexec.Metadata JSON, {"cfg":{...}}) from an algo_params string, or nil if absent. Pass the result to sqlexec.NewMetadata to resolve typed values.

func IndexParamsStringToMap added in v1.1.0

func IndexParamsStringToMap(indexParams string) (map[string]string, error)

IndexParamsStringToMap used by buildShowCreateTable and restoreDDL. The reserved IndexParamSessionVars key (a nested typed object) is skipped so flat-string consumers stay unchanged; read it via IndexParamsSessionVars.

func IndexParamsToJsonString added in v1.1.0

func IndexParamsToJsonString(def interface{}) (string, error)

IndexParamsToJsonString used by buildSecondaryIndexDef Eg:- {"lists":"10","op_type":"vector_l2_ops"}

func IndexParamsToStringList added in v1.1.0

func IndexParamsToStringList(indexParams string) (string, error)

IndexParamsToStringList used by buildShowCreateTable and restoreDDL Eg:- "LIST = 10 op_type 'vector_l2_ops'" NOTE: don't set default values here as it is used by SHOW and RESTORE DDL.

func IndexPrefixLengthsFromParams

func IndexPrefixLengthsFromParams(indexParams string) map[string]int

func IndexPrefixLengthsFromParamsWithError

func IndexPrefixLengthsFromParamsWithError(indexParams string) (map[string]int, error)

func IndexPrefixLengthsToString

func IndexPrefixLengthsToString(keyParts []*tree.KeyPart) string

func IsAlias added in v1.1.0

func IsAlias(column string) bool

func IsCagraIndexAlgo

func IsCagraIndexAlgo(algo string) bool

func IsFakePkName

func IsFakePkName(name string) bool

func IsFullTextIndexAlgo

func IsFullTextIndexAlgo(algo string) bool

func IsFullTextIndexTableType

func IsFullTextIndexTableType(tableType string, tableName string) bool

func IsHiddenTable added in v0.8.0

func IsHiddenTable(name string) bool

func IsHnswIndexAlgo

func IsHnswIndexAlgo(algo string) bool

func IsIndexAsync

func IsIndexAsync(indexAlgoParams string) (bool, error)

func IsIvfIndexAlgo added in v1.1.0

func IsIvfIndexAlgo(algo string) bool

func IsIvfpqIndexAlgo

func IsIvfpqIndexAlgo(algo string) bool

func IsMasterIndexAlgo added in v1.2.0

func IsMasterIndexAlgo(algo string) bool

func IsNullIndexAlgo added in v1.1.0

func IsNullIndexAlgo(algo string) bool

IsNullIndexAlgo is used to skip printing the default "" index algo in the restoreDDL and buildShowCreateTable

func IsRTreeIndexAlgo

func IsRTreeIndexAlgo(algo string) bool

func IsRegularIndexAlgo added in v1.1.0

func IsRegularIndexAlgo(algo string) bool

IsRegularIndexAlgo are indexes which will be handled by regular index flow, ie the one where we have one hidden table.

func IsSecondaryIndexTable

func IsSecondaryIndexTable(name string) bool

func IsSystemTable

func IsSystemTable(id uint64) bool

func IsSystemTableByName

func IsSystemTableByName(name string) bool

func IsUniqueIndexTable

func IsUniqueIndexTable(name string) bool

func ParseEntryList added in v0.6.0

func ParseEntryList(es []*api.Entry) (any, []*api.Entry, error)

consume a set of entries and return a command and the remaining entries

func ResolveAlias added in v1.1.0

func ResolveAlias(alias string) string

func SetupDefines

func SetupDefines(sid string)

func ShowReqs

func ShowReqs(reqs []any) string

func ToLower added in v1.1.0

func ToLower(str string) string

ToLower is used for before comparing AlgoType and IndexAlgoParamOpType. Reason why they are strings

  1. Changing AlgoType from string to Enum will break the backward compatibility. "panic: Unable to find target column from predefined table columns"
  2. IndexAlgoParamOpType is serialized and stored in the mo_indexes as JSON string.

Types

type Column

type Column struct {
	AccountId  uint32
	TableId    uint64
	DatabaseId uint64

	// column name, letter case: origin
	Name            string
	TableName       string
	DatabaseName    string
	Typ             []byte
	TypLen          int32
	Num             int32
	Comment         string
	NotNull         int8
	HasDef          int8
	DefaultExpr     []byte
	ConstraintType  string
	IsClusterBy     int8
	IsHidden        int8
	IsAutoIncrement int8
	HasUpdate       int8
	UpdateExpr      []byte
	Seqnum          uint16
	EnumValues      string
	HasGenerated    int8
	GeneratedExpr   []byte
}

func GenColumnsFromDefs

func GenColumnsFromDefs(accountId uint32, tableName, databaseName string,
	tableId, databaseId uint64, defs []engine.TableDef) ([]Column, error)

genColumnsFromDefs generates column struct from TableDef.

NOTE: 1. it will modify the input TableDef. 2. it is usually used in creating new table. 3. It will append rowid column as the last column, which is **incorrect** if we want impl alter column gracefully.

type CreateDatabase added in v0.6.0

type CreateDatabase struct {
	DatabaseId  uint64
	Name        string
	CreateSql   string
	DatTyp      string
	Owner       uint32 // roleid
	Creator     uint32 // userid
	AccountId   uint32 // tenantid
	CreatedTime types.Timestamp
}

used for memengine and tae tae and memengine do not make the catalog into a table for its convenience, a conversion interface is provided to ensure easy use.

type CreateDatabaseReq

type CreateDatabaseReq struct {
	Bat  *batch.Batch
	Cmds []CreateDatabase
}

type CreateTable added in v0.6.0

type CreateTable struct {
	TableId      uint64
	Name         string
	CreateSql    string
	Owner        uint32
	Creator      uint32
	AccountId    uint32
	DatabaseId   uint64
	DatabaseName string
	Comment      string
	Partitioned  int8
	Partition    string
	RelKind      string
	Viewdef      string
	Constraint   []byte
	ExtraInfo    []byte
	Defs         []engine.TableDef
}

func (CreateTable) String added in v1.2.1

func (t CreateTable) String() string

type CreateTableReq

type CreateTableReq struct {
	TableBat  *batch.Batch
	ColumnBat []*batch.Batch
	Cmds      []CreateTable
}

type Defines

type Defines struct {
	// used by memengine or tae
	MoDatabaseTableDefs []engine.TableDef
	// used by memengine or tae
	MoTablesTableDefs []engine.TableDef
	// used by memengine or tae
	MoColumnsTableDefs []engine.TableDef
	// used by memengine or tae or cn
	MoTableMetaDefs []engine.TableDef
	// used by tae for mo_tables logical_id index table
	MoTablesLogicalIdIndexTableDefs  []engine.TableDef
	MoTablesLogicalIdIndexConstraint []byte
	MoDatabaseConstraint             []byte
	MoTableConstraint                []byte
	MoColumnConstraint               []byte
}

func GetDefines

func GetDefines(sid string) *Defines

func NewDefines

func NewDefines() *Defines

type DropDatabase added in v0.6.0

type DropDatabase struct {
	Id   uint64
	Name string
}

type DropDatabaseReq

type DropDatabaseReq struct {
	Bat  *batch.Batch
	Cmds []DropDatabase
}

type DropTable

type DropTable struct {
	IsDrop       bool // true for Drop and false for Truncate
	Id           uint64
	NewId        uint64
	Name         string
	DatabaseId   uint64
	DatabaseName string
}

type DropTableReq

type DropTableReq struct {
	TableBat  *batch.Batch
	ColumnBat []*batch.Batch
	Cmds      []DropTable
}

type Meta added in v0.7.0

type Meta struct {
	QueryId       [16]byte
	Statement     string
	AccountId     uint32
	RoleId        uint32
	ResultPath    string
	CreateTime    types.Timestamp
	ResultSize    float64
	Columns       string
	Tables        string
	UserId        uint32
	ExpiredTime   types.Timestamp
	Plan          string
	Ast           string
	ColumnMap     string
	SaveRowCount  uint64
	QueryRowCount uint64
}

type Table

type Table struct {
	AccountId    uint32
	TableId      uint64
	DatabaseId   uint64
	TableName    string
	DatabaseName string

	Kind          string
	Comment       string
	CreateSql     string
	UserId        uint32
	RoleId        uint32
	Partitioned   int8
	PartitionInfo string
	Viewdef       string
	Constraint    []byte
	Version       uint32
	ExtraInfo     []byte
	LogicalId     uint64 // rel_logical_id, if 0, will use TableId
}

Jump to

Keyboard shortcuts

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