frontend

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: 149 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaveQueryResult    = "save_query_result"
	QueryResultMaxsize = "query_result_maxsize"
	QueryResultTimeout = "query_result_timeout"
	ProtectedDatabases = "protected_databases"
)
View Source
const (
	ExecutorType_BGExecutor  = 1
	ExecutorType_SQLExecutor = 2
)
View Source
const (
	CDCShowOutputColumnsNameTaskID_Idx     = 0
	CDCShowOutputColumnsNameTaskName_Idx   = 1
	CDCShowOutputColumnsNameSourceURI_Idx  = 2
	CDCShowOutputColumnsNameSinkURI_Idx    = 3
	CDCShowOutputColumnsNameState_Idx      = 4
	CDCShowOutputColumnsNameErrMsg_Idx     = 5
	CDCShowOutputColumnsNameCheckpoint_Idx = 6
	CDCShowOutputColumnsNameTimestamp_Idx  = 7

	CDCShowOutputColumnsCount = 8
)
View Source
const (
	DefaultReadBufferSize  int = 512
	DefaultWriteBufferSize int = 512
)
View Source
const (
	Leader   = "Leader"
	Follower = "Follower"
)
View Source
const (
	// NonVotingReplicaNum is the number of logservice non-voting replicas.
	NonVotingReplicaNum = "non_voting_replica_num"
	// NonVotingLocality is the locality of logservice non-voting locality.
	NonVotingLocality = "non_voting_locality"
)
View Source
const (
	Utf8mb4CollationID uint8 = 45

	AuthNativePassword string = "mysql_native_password"

	//the length of the mysql protocol header
	HeaderLengthOfTheProtocol int = 4
	HeaderOffset              int = 0

	// MaxPayloadSize If the payload is larger than or equal to 2^24−1 bytes the length is set to 2^24−1 (ff ff ff)
	//and additional packets are sent with the rest of the payload until the payload of a packet
	//is less than 2^24−1 bytes.
	MaxPayloadSize uint32 = (1 << 24) - 1

	// DefaultMySQLState is the default state of the mySQL
	DefaultMySQLState string = "HY000"
)
View Source
const (
	CLIENT_LONG_PASSWORD                  uint32 = 0x00000001
	CLIENT_FOUND_ROWS                     uint32 = 0x00000002
	CLIENT_LONG_FLAG                      uint32 = 0x00000004
	CLIENT_CONNECT_WITH_DB                uint32 = 0x00000008
	CLIENT_NO_SCHEMA                      uint32 = 0x00000010
	CLIENT_COMPRESS                       uint32 = 0x00000020
	CLIENT_LOCAL_FILES                    uint32 = 0x00000080
	CLIENT_IGNORE_SPACE                   uint32 = 0x00000100
	CLIENT_PROTOCOL_41                    uint32 = 0x00000200
	CLIENT_INTERACTIVE                    uint32 = 0x00000400
	CLIENT_SSL                            uint32 = 0x00000800
	CLIENT_IGNORE_SIGPIPE                 uint32 = 0x00001000
	CLIENT_TRANSACTIONS                   uint32 = 0x00002000
	CLIENT_RESERVED                       uint32 = 0x00004000
	CLIENT_SECURE_CONNECTION              uint32 = 0x00008000
	CLIENT_MULTI_STATEMENTS               uint32 = 0x00010000
	CLIENT_MULTI_RESULTS                  uint32 = 0x00020000
	CLIENT_PS_MULTI_RESULTS               uint32 = 0x00040000
	CLIENT_PLUGIN_AUTH                    uint32 = 0x00080000
	CLIENT_CONNECT_ATTRS                  uint32 = 0x00100000
	CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA uint32 = 0x00200000
	CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS   uint32 = 0x00400000
	CLIENT_SESSION_TRACK                  uint32 = 0x00800000
	CLIENT_DEPRECATE_EOF                  uint32 = 0x01000000
	CLIENT_ZSTD_COMPRESSION_ALGORITHM     uint32 = 0x04000000
)

mysql client capabilities

View Source
const (
	SERVER_STATUS_IN_TRANS             uint16 = 0x0001 // A transaction is currently active
	SERVER_STATUS_AUTOCOMMIT           uint16 = 0x0002 // Autocommit mode is set
	SERVER_MORE_RESULTS_EXISTS         uint16 = 0x0008 // More results exists (more packet follow)
	SERVER_STATUS_NO_GOOD_INDEX_USED   uint16 = 0x0010
	SERVER_STATUS_NO_INDEX_USED        uint16 = 0x0020
	SERVER_STATUS_CURSOR_EXISTS        uint16 = 0x0040 // When using COM_STMT_FETCH, indicate that current cursor still has result
	SERVER_STATUS_LAST_ROW_SENT        uint16 = 0x0080 // When using COM_STMT_FETCH, indicate that current cursor has finished to send results
	SERVER_STATUS_DB_DROPPED           uint16 = 0x0100 // Database has been dropped
	SERVER_STATUS_NO_BACKSLASH_ESCAPES uint16 = 0x0200 // Current escape mode is "no backslash escape"
	SERVER_STATUS_METADATA_CHANGED     uint16 = 0x0400 // A DDL change did have an impact on an existing PREPARE (an automatic reprepare has been executed)
	SERVER_QUERY_WAS_SLOW              uint16 = 0x0800
	SERVER_PS_OUT_PARAMS               uint16 = 0x1000 // This resultset contain stored procedure output parameter
	SERVER_STATUS_IN_TRANS_READONLY    uint16 = 0x2000 // Current transaction is a read-only transaction
	SERVER_SESSION_STATE_CHANGED       uint16 = 0x4000 // Session state change. see Session change type for more information
)

server status

View Source
const (
	OPTION_AUTOCOMMIT                     uint32 = 1 << 8
	OPTION_BIG_SELECTS                    uint32 = 1 << 9
	OPTION_LOG_OFF                        uint32 = 1 << 10
	OPTION_QUOTE_SHOW_CREATE              uint32 = 1 << 11
	TMP_TABLE_ALL_COLUMNS                 uint32 = 1 << 12
	OPTION_WARNINGS                       uint32 = 1 << 13
	OPTION_AUTO_IS_NULL                   uint32 = 1 << 14
	OPTION_FOUND_COMMENT                  uint32 = 1 << 15
	OPTION_SAFE_UPDATES                   uint32 = 1 << 16
	OPTION_BUFFER_RESULT                  uint32 = 1 << 17
	OPTION_BIN_LOG                        uint32 = 1 << 18
	OPTION_NOT_AUTOCOMMIT                 uint32 = 1 << 19
	OPTION_BEGIN                          uint32 = 1 << 20
	OPTION_TABLE_LOCK                     uint32 = 1 << 21
	OPTION_QUICK                          uint32 = 1 << 22
	OPTION_NO_CONST_TABLES                uint32 = 1 << 23
	OPTION_ATTACH_ABORT_TRANSACTION_ERROR uint32 = 1 << 24 //defined in mo
)

reference to sql/query_options.h in mysql server 8.0.23

View Source
const (
	// ValidatePasswordCheckUserNameInPassword is the name of the global system variable
	ValidatePasswordCheckUserNameInPassword = "validate_password.check_user_name"
	ValidatePasswordVar                     = "validate_password"
	ValidatePasswordCheckCasePercentage     = "validate_password.changed_characters_percentage"
	ValidatePasswordPolicy                  = "validate_password.policy"
	ValidatePasswordLength                  = "validate_password.length"
	ValidatePasswordNumberCount             = "validate_password.number_count"
	ValidatePasswordSpecialCharCount        = "validate_password.special_char_count"
	ValidatePasswordMixedCount              = "validate_password.mixed_case_count"

	// password expiration management
	DefaultPasswordLifetime = "default_password_lifetime"

	// password history management
	PasswordHistory       = "password_history"
	PasswordReuseInterval = "password_reuse_interval"
	PasswordTimestamp     = "password_timestamp"
	Password              = "password"

	// password lock management
	ConnectionControlFailedConnectionsThreshold = "connection_control_failed_connections_threshold"
	ConnectionControlMaxConnectionDelay         = "connection_control_max_connection_delay"

	// ip whitelist management
	ValidnodeChecking = "validnode_checking"
	InvitedNodes      = "invited_nodes"
)
View Source
const (
	// OkResponse OK message
	OkResponse = iota
	// ErrorResponse Error message
	ErrorResponse
	// EoFResponse EOF message
	EoFResponse
	// ResultResponse result message
	ResultResponse
	// LocalInfileRequest local infile message
	LocalInfileRequest
)

Response Categories

View Source
const (
	FPHandleRequest = iota
	FPExecRequest
	FPDoComQuery
	FPDoComQueryInBack
	FPStmtWithResponse
	FPStmtWithResponseCreateAsSelect
	FPDispatchStmt
	FPExecStmt
	FPExecStmtBeforeCompile
	FPExecStmtInBack
	FPExecStmtInBackBeforeCompile
	FPExecStmtWithTxn
	FPExecStmtWithWorkspace
	FPExecStmtWithWorkspaceBeforeStart
	FPExecStmtWithWorkspaceBeforeEnd
	FPExecStmtWithIncrStmt
	FPExecStmtWithIncrStmtBeforeIncr
	FPExecStmtInSameSession
	FPExecInFrontEnd
	FPExecInFrontEndInBack
	FPInBackUse
	FPInBackCreateDatabase
	FPInBackDropDatabase
	FPInBackGrant
	FPInBackRevoke
	FPStatusStmtInBack
	FPCleanup
	FPBeginTxn
	FPSetRole
	FPUse
	FPPrepareStmt
	FPPrepareString
	FPCreateConnector
	FPPauseDaemonTask
	FPCancelDaemonTask
	FPResumeDaemonTask
	FPCreateSQLTask
	FPAlterSQLTask
	FPDropSQLTask
	FPExecuteSQLTask
	FPShowSQLTasks
	FPShowSQLTaskRuns
	FPDropConnector
	FPShowConnectors
	FPDeallocate
	FPReset
	FPSetVar
	FPShowVariables
	FPShowErrors
	FPAnalyzeStmt
	FPExplainStmt
	FPInternalCmdFieldList
	FPInternalCmdGetSnapshotTs
	FPInternalCmdGetDatabases
	FPInternalCmdGetMoIndexes
	FPInternalCmdGetDdl
	FPInternalCmdGetObject
	FPInternalCmdObjectList
	FPInternalCmdCheckSnapshotFlushed
	FPCreatePublication
	FPAlterPublication
	FPDropPublication
	FPCreateSubscription
	FPShowSubscriptions
	FPCreateStage
	FPDropStage
	FPAlterStage
	FPRemoveStageFiles
	FPCreateAccount
	FPDropAccount
	FPAlterAccount
	FPAlterDataBaseConfig
	FPCreateUser
	FPDropUser
	FPAlterUser
	FPAlterRole
	FPAlterRoleAddRule
	FPAlterRoleDropRule
	FPShowRules
	FPCreateRole
	FPDropRole
	FPCreateFunction
	FPDropFunction
	FPCreateProcedure
	FPDropProcedure
	FPCallStmt
	FPGrant
	FPRevoke
	FPKill
	FPShowAccounts
	FPShowCollation
	FPShowBackendServers
	FPSetTransaction
	FPBackupStart
	FPCreateSnapShot
	FPDropSnapShot
	FPCheckSnapshotFlushed
	FPRestoreSnapShot
	FPUpgradeStatement
	FPCreatePitr
	FPDropPitr
	FPAlterPitr
	FPRestorePitr
	FPSetConnectionID
	FPRollbackTxn
	FPCommitTxn
	FPFinishTxn
	FPCommit
	FPCommitBeforeCommitUnsafe
	FPCommitUnsafe
	FPCommitUnsafeBeforeCommit
	FPCommitUnsafeBeforeCommitWithTxn
	FPRollback
	FPRollbackUnsafe1
	FPRollbackUnsafe2
	FPRollbackUnsafe
	FPRollbackUnsafeBeforeRollback
	FPRollbackUnsafeBeforeRollbackWithTxn
	FPSetAutoCommit
	FPResultRowStmt
	FPResultRowStmtInBack
	FPResultRowStmtSelect1
	FPResultRowStmtSelect2
	FPResultRowStmtExplainAnalyze1
	FPResultRowStmtExplainAnalyze2
	FPResultRowStmtDefault1
	FPResultRowStmtDefault2
	FPRespStreamResultRow
	FPrespPrebuildResultRow
	FPrespMixedResultRow
	FPRespStatus
	FPMigrate
	FPMigrateDB
	FPMigratePrepareStmt
	FPGetBackgroundExec
	FPGetShareTxnBackgroundExec
	FPGetRawBatchBackgroundExec
	FPBackExecExec
	FPBackExecRestore
	FPGetShareTxnBackgroundExecInBackSession
	FPGetBackgroundExecInBackSession
	FPInternalExecutorExec
	FPInternalExecutorQuery
	FPHandleAnalyzeStmt
	FPShowPublications
	FPCreateCDC
	FPPauseCDC
	FPDropCDC
	FPRestartCDC
	FPResumeCDC
	FPShowCDC
	FPCommitUnsafeBeforeRollbackWhenCommitPanic
	FPShowRecoveryWindow
	FPCloneDatabase
	FPCloneTable
	FPObjectList
	FPGetDdl
	FPGetObject
	FPDataBranch
)
View Source
const (
	ConnectionInfoKey = "connection_info"
)
View Source
const (
	DefaultRpcBufferSize = 1 << 10
)
View Source
const DefaultTenantMoAdmin = "sys:internal:moadmin"
View Source
const KeySep = "#"
View Source
const MoDefaultErrorCount = 64

TODO: this variable should be configure by set variable

View Source
const PacketHeaderLength = 4
View Source
const (
	SYSMOCATALOGPITR = "sys_mo_catalog_pitr"
)

Variables

View Source
var (
	// the sqls creating many tables for the tenant.
	// Wrap them in a transaction
	MoCatalogMoUserDDL = `` /* 573-byte string literal not displayed */

	MoCatalogMoAccountDDL = `` /* 380-byte string literal not displayed */

	MoCatalogMoRoleDDL = `` /* 220-byte string literal not displayed */

	MoCatalogMoUserGrantDDL = `` /* 182-byte string literal not displayed */

	MoCatalogMoRoleGrantDDL = `` /* 262-byte string literal not displayed */

	MoCatalogMoRolePrivsDDL = `` /* 407-byte string literal not displayed */

	MoCatalogMoUserDefinedFunctionDDL = `` /* 580-byte string literal not displayed */

	MoCatalogMoMysqlCompatibilityModeDDL = `` /* 323-byte string literal not displayed */

	MoCatalogMoSnapshotsDDL = fmt.Sprintf(`CREATE TABLE %s.%s (
			snapshot_id uuid unique key,
			sname varchar(64) primary key,
			ts bigint,
			level enum('cluster','account','database','table'),
	        account_name varchar(300),
			database_name varchar(5000),
			table_name  varchar(5000),
			obj_id bigint unsigned,
    		kind varchar(32) not null default 'user'
			)`, catalog.MO_CATALOG, catalog.MO_SNAPSHOTS)

	MoCatalogMoPitrDDL = fmt.Sprintf(`CREATE TABLE %s.%s (
			pitr_id uuid unique key,
			pitr_name varchar(5000),
			create_account bigint unsigned,
			create_time bigint not null,
			modified_time bigint not null,
			level varchar(10),
			account_id bigint unsigned,
			account_name varchar(300),
			database_name varchar(5000),
			table_name varchar(5000),
			obj_id bigint unsigned,
			pitr_length tinyint unsigned,
			pitr_unit varchar(10),
			pitr_status tinyint unsigned default 1 comment '1: active, 0: inactive',
			pitr_status_changed_time bigint not null,
    		kind varchar(32) not null default 'user',
			primary key(pitr_name, create_account)
			)`, catalog.MO_CATALOG, catalog.MO_PITR)

	MoCatalogMoPubsDDL = `` /* 449-byte string literal not displayed */

	MoCatalogMoSubsDDL = `` /* 562-byte string literal not displayed */

	MoCatalogMoStoredProcedureDDL = `` /* 551-byte string literal not displayed */

	MoCatalogMoStagesDDL = `` /* 265-byte string literal not displayed */

	MoCatalogMoCdcTaskDDL = `` /* 1061-byte string literal not displayed */

	MoCatalogMoCdcWatermarkDDL = `` /* 279-byte string literal not displayed */

	MoCatalogMoISCPLogDDL = `` /* 428-byte string literal not displayed */

	MoCatalogMoCcprLogDDL = `` /* 681-byte string literal not displayed */

	MoCatalogMoCcprTablesDDL = fmt.Sprintf(`CREATE TABLE %s.%s (
				tableid BIGINT UNSIGNED PRIMARY KEY,
				taskid UUID NOT NULL,
				dbname VARCHAR(256) NOT NULL,
				tablename VARCHAR(256) NOT NULL,
				account_id INT UNSIGNED NOT NULL
			)`, catalog.MO_CATALOG, catalog.MO_CCPR_TABLES)

	MoCatalogMoCcprDbsDDL = fmt.Sprintf(`CREATE TABLE %s.%s (
				dbid BIGINT UNSIGNED PRIMARY KEY,
				taskid UUID NOT NULL,
				dbname VARCHAR(256) NOT NULL,
				account_id INT UNSIGNED NOT NULL
			)`, catalog.MO_CATALOG, catalog.MO_CCPR_DBS)

	MoCatalogMoIndexUpdateDDL = `` /* 591-byte string literal not displayed */

	MoCatalogMoSessionsDDL       = `` /* 277-byte string literal not displayed */
	MoCatalogMoConfigurationsDDL = `` /* 165-byte string literal not displayed */
	MoCatalogMoLocksDDL          = `` /* 156-byte string literal not displayed */
	MoCatalogMoVariablesDDL      = `` /* 191-byte string literal not displayed */
	MoCatalogMoTransactionsDDL   = `` /* 244-byte string literal not displayed */
	MoCatalogMoCacheDDL          = `CREATE VIEW mo_catalog.mo_cache AS SELECT node_type, node_id, type, used, free, hit_ratio FROM mo_cache() AS mo_cache_tmp`

	MoCatalogMoDataKeyDDL = `` /* 328-byte string literal not displayed */

	MoCatalogMoTableStatsDDL = fmt.Sprintf(`create table mo_catalog.%s (
    			account_id bigint signed,
    			database_id bigint signed,
    			table_id bigint signed,
    			database_name varchar(255),
    			table_name varchar(255),
    			table_stats json,
    			update_time datetime(6) not null,
    			takes bigint unsigned,
    			primary key(account_id, database_id, table_id)
			)`, catalog.MO_TABLE_STATS)

	MoCatalogMoAccountLockDDL = fmt.Sprintf(`create table mo_catalog.%s(
    			account_name varchar(300) primary key
				)`, catalog.MO_ACCOUNT_LOCK)

	MoCatalogMergeSettingsDDL = fmt.Sprintf(`create table mo_catalog.%s (
		account_id int unsigned not null,
		tid bigint unsigned not null,
		version int unsigned not null,
		settings json not null,
		extra_info text,
		primary key(account_id, tid)
	)`, catalog.MO_MERGE_SETTINGS)

	MoCatalogMergeSettingsInitData = fmt.Sprintf(`insert into mo_catalog.%s values (
		0, 0, %d, '%s', '')`,
		catalog.MO_MERGE_SETTINGS,
		merge.MergeSettingsVersion_Curr,
		merge.DefaultMergeSettings.String())

	MoCatalogBranchMetadataDDL = fmt.Sprintf(`create table mo_catalog.%s(
    	table_id bigint unsigned comment 'id of the table this branch points to',
   	 	clone_ts bigint signed not null comment 'branch creation timestamp in nanoseconds',
    	p_table_id bigint unsigned not null comment 'id of the parent table this branch is based on',
    	creator bigint unsigned not null comment 'account id of the creator',
    	level varchar not null,
    	table_deleted bool not null default false,
    	index(p_table_id),
    	index(creator),
    	primary key(table_id)
	)`, catalog.MO_BRANCH_METADATA)

	MoCatalogFeatureLimitDDL = fmt.Sprintf(`create table mo_catalog.%s(
    	account_id bigint unsigned not null comment 'this limit applies on this account',
    	feature_code varchar(50) NOT NULL comment 'snapshot/branch/...',
		scope varchar(50) NOT NULL DEFAULT '' comment 'feature limit applies on this scope',
    	quota bigint NOT NULL DEFAULT 100 comment '0: disabled this feature; -1 unlimited; >0: max allowed value',
    	created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
		updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    	primary key(account_id, feature_code, scope)
	)`, catalog.MO_FEATURE_LIMIT)

	MoCatalogFeatureRegistryDDL = fmt.Sprintf(`create table mo_catalog.%s(
    	feature_code varchar(50) NOT NULL comment 'snapshot/branch/...',
    	description varchar(1024) NOT NULL DEFAULT '',
        scope_spec JSON NOT NULL comment 'allowed scope values',
		enabled boolean NOT NULL DEFAULT TRUE,
    	created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
		updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    	primary key(feature_code)
	)`, catalog.MO_FEATURE_REGISTRY)

	MoCatalogFeatureRegistryInitData = fmt.Sprintf(`insert into mo_catalog.%s(feature_code, scope_spec) values 
		('SNAPSHOT', '{"allowed_scope":["account","database","table"]}'),
		('BRANCH', '{"allowed_scope":[]}')
		on duplicate key update scope_spec = values(scope_spec);`, catalog.MO_FEATURE_REGISTRY)

	MoCatalogMoRoleRuleDDL = fmt.Sprintf("create table %s.%s ("+
		"role_id int signed,"+
		"rule_name varchar(200),"+
		"`rule` text,"+
		"primary key(role_id, rule_name)"+
		")", catalog.MO_CATALOG, catalog.MO_ROLE_RULE)
)
View Source
var (
	MoCatalogMoAutoIncrTableDDL = fmt.Sprintf(`create table %s.%s (
			table_id   bigint unsigned, 
			col_name   varchar(770), 
			col_index  int,
			offset     bigint unsigned, 
			step       bigint unsigned,  
			primary key(table_id, col_name)
		)`, catalog.MO_CATALOG, catalog.MOAutoIncrTable)

	MoCatalogMoIndexesDDL = fmt.Sprintf(`create table %s.%s (
			id                  bigint unsigned not null,
			table_id            bigint unsigned not null,
			database_id         bigint unsigned not null,
			name                varchar(64) not null,
			type                varchar(11) not null,
			algo                varchar(11),
			algo_table_type     varchar(11),
			algo_params         varchar(2048),
			is_visible          tinyint not null,
			hidden              tinyint not null,
			comment             varchar(2048) not null,
			column_name         varchar(256) not null,
			ordinal_position    int unsigned  not null,
			options             text,
			index_table_name    varchar(5000),
			primary key(id, column_name)
		)`, catalog.MO_CATALOG, catalog.MO_INDEXES)

	MoCatalogMoForeignKeysDDL = fmt.Sprintf(`create table %s.%s (
			constraint_name varchar(5000) not null,
			constraint_id BIGINT UNSIGNED not null default 0,
			db_name varchar(5000) not null,
			db_id BIGINT UNSIGNED not null default 0,
			table_name varchar(5000) not null,
			table_id BIGINT UNSIGNED not null default 0,
			column_name varchar(256) not null,
			column_id BIGINT UNSIGNED not null default 0,
			refer_db_name varchar(5000) not null,
			refer_db_id BIGINT UNSIGNED not null default 0,
			refer_table_name varchar(5000) not null,
			refer_table_id BIGINT UNSIGNED not null default 0,
			refer_column_name varchar(256) not null,
			refer_column_id BIGINT UNSIGNED not null default 0,
			on_delete varchar(128) not null,
			on_update varchar(128) not null,
	
			primary key(
				constraint_name,
				constraint_id,
				db_name,
				db_id,
				table_name,
				table_id,
				column_name,
				column_id,
				refer_db_name,
				refer_db_id,
				refer_table_name,
				refer_table_id,
				refer_column_name,
				refer_column_id)
		)`, catalog.MO_CATALOG, catalog.MOForeignKeys)

	MoCatalogMoTablePartitionsDDL = fmt.Sprintf(`CREATE TABLE %s.%s (
			table_id bigint unsigned NOT NULL,
			database_id bigint unsigned not null,
			number smallint unsigned NOT NULL,
			name varchar(64) NOT NULL,
			partition_type varchar(50) NOT NULL,
			partition_expression varchar(2048) NULL,
			description_utf8 text,
			comment varchar(2048) NOT NULL,
			options text,
			partition_table_name varchar(1024) NOT NULL,
			PRIMARY KEY table_id (table_id, name)
		)`, catalog.MO_CATALOG, catalog.MO_TABLE_PARTITIONS)
)

`mo_catalog` database system tables Note: The following tables belong to data dictionary table, and system tables's creation will depend on the following system tables. Therefore, when creating tenants, they must be created first

View Source
var (
	MoCatalogMoVersionDDL = fmt.Sprintf(`create table %s.%s (
			version             varchar(50) not null,
		    version_offset      int unsigned default 0,
			state               int,
			create_at           timestamp not null,
			update_at           timestamp not null,
			primary key(version, version_offset)
		)`, catalog.MO_CATALOG, catalog.MOVersionTable)

	MoCatalogMoUpgradeDDL = fmt.Sprintf(`create table %s.%s (
			id                   bigint unsigned not null primary key auto_increment,
			from_version         varchar(50) not null,
			to_version           varchar(50) not null,
			final_version        varchar(50) not null,
            final_version_offset int unsigned default 0,
			state                int,
			upgrade_cluster      int,
			upgrade_tenant       int,
			upgrade_order        int,
			total_tenant         int,
			ready_tenant         int,
			create_at            timestamp not null,
			update_at            timestamp not null
		)`, catalog.MO_CATALOG, catalog.MOUpgradeTable)

	MoCatalogMoUpgradeTenantDDL = fmt.Sprintf(`create table %s.%s (
			id                  bigint unsigned not null primary key auto_increment,
			upgrade_id		    bigint unsigned not null,
			target_version      varchar(50) not null,
			from_account_id     int not null,
			to_account_id       int not null,
			ready               int,
			create_at           timestamp not null,
			update_at           timestamp not null
		)`, catalog.MO_CATALOG, catalog.MOUpgradeTenantTable)
)

step3InitSQLs `mo_catalog` database system tables They are all Cluster level system tables for system upgrades

View Source
var (
	MoTaskSysAsyncTaskDDL = fmt.Sprintf(`create table %s.sys_async_task (
			task_id                     bigint primary key auto_increment,
			task_metadata_id            varchar(50) not null,
			task_metadata_executor      int,
			task_metadata_context       blob,
			task_metadata_option        varchar(1000),
			task_parent_id              varchar(50),
			task_status                 int,
			task_runner                 varchar(50),
			task_epoch                  int,
			last_heartbeat              bigint,
			result_code                 int null,
			error_msg                   varchar(1000) null,
			create_at                   bigint,
			end_at                      bigint)`,
		catalog.MOTaskDB)

	MoTaskSysCronTaskDDL = fmt.Sprintf(`create table %s.sys_cron_task (
			cron_task_id				bigint primary key auto_increment,
    		task_metadata_id            varchar(50) unique not null,
			task_metadata_executor      int,
			task_metadata_context       blob,
			task_metadata_option 		varchar(1000),
			cron_expr					varchar(100) not null,
			next_time					bigint,
			trigger_times				int,
			create_at					bigint,
			update_at					bigint)`,
		catalog.MOTaskDB)

	MoTaskSysDaemonTaskDDL = fmt.Sprintf(`create table %s.sys_daemon_task (
				task_id                     bigint primary key auto_increment,
				task_metadata_id            varchar(50),
			task_metadata_executor      int,
			task_metadata_context       blob,
			task_metadata_option        varchar(1000),
			account_id                  int unsigned not null,
			account                     varchar(128) not null,
			task_type                   varchar(64) not null,
			task_runner                 varchar(64),
			task_status                 int not null,
			last_heartbeat              timestamp,
			create_at                   timestamp not null,
			update_at                   timestamp not null,
				end_at                      timestamp,
				last_run                    timestamp,
				details                     blob)`,
		catalog.MOTaskDB)

	MoTaskSQLTaskDDL = fmt.Sprintf(`create table %s.%s (
				task_id                     bigint primary key auto_increment,
				task_name                   varchar(128) not null,
				account_id                  int unsigned not null,
				database_name               varchar(128) not null default '',
				cron_expr                   varchar(128) not null default '',
				`+"`timezone`"+`                  varchar(64) not null default 'UTC',
				sql_body                    text not null,
				gate_condition              text not null default '',
				retry_limit                 int not null default 0,
				timeout_seconds             int not null default 0,
				enabled                     tinyint not null default 1,
				next_fire_time              bigint not null default 0,
				trigger_count               bigint not null default 0,
				creator                     varchar(128) not null default '',
				creator_user_id             int unsigned not null default 0,
				creator_role_id             int unsigned not null default 0,
				created_at                  timestamp not null default current_timestamp,
				updated_at                  timestamp not null default current_timestamp,
				unique key uk_task_name_account (task_name, account_id))`,
		catalog.MOTaskDB, catalog.MOSQLTask)

	MoTaskSQLTaskRunDDL = fmt.Sprintf(`create table %s.%s (
				run_id                      bigint primary key auto_increment,
				task_id                     bigint not null,
				task_name                   varchar(128) not null,
				account_id                  int unsigned not null,
				scheduled_at                timestamp null,
				started_at                  timestamp null,
				finished_at                 timestamp null,
				duration_seconds            double not null default 0,
				status                      varchar(20) not null default 'RUNNING',
				trigger_type                varchar(20) not null default 'SCHEDULED',
				attempt_number              int not null default 1,
				rows_affected               bigint not null default 0,
				error_code                  int not null default 0,
				error_message               text,
				gate_result                 tinyint not null default 1,
				runner_cn                   varchar(128) not null default '',
				index idx_task_id (task_id),
				index idx_status (status),
				index idx_started_at (started_at))`,
		catalog.MOTaskDB, catalog.MOSQLTaskRun)
)

---------------------------------------------------------------------------------------------------------------------- step2InitSQLs `mo_task` database system tables They are all Cluster level system tables

View Source
var AllocNewBlock = func(c *Conn, allocLength int) error {
	return c.AllocNewBlock(allocLength)
}
View Source
var AppendCountOfBytesLenEnc = func(mp *MysqlProtocolImpl, value []byte) error {
	return mp.appendCountOfBytesLenEnc(value)
}
View Source
var AppendPart = func(c *Conn, elems []byte) error {
	return c.AppendPart(elems)
}
View Source
var AppendStringLenEnc = func(mp *MysqlProtocolImpl, value string) error {
	return mp.appendStringLenEnc(value)
}
View Source
var BeginPacket = func(c *Conn) error {
	return c.BeginPacket()
}
View Source
var CDCCheckPitrGranularity = func(
	ctx context.Context,
	bh BackgroundExec,
	accName string,
	pts *cdc.PatternTuples,
	minLength ...int64,
) error {
	var minPitrLen int64 = 2
	if len(minLength) > 1 {
		return moerr.NewInternalErrorf(ctx, "only one length parameter allowed")
	}
	if len(minLength) > 0 {
		minPitrLen = max(minLength[0]+1, minPitrLen)
	}

	getPitrConfig := func(level, dbName, tblName string) (*PitrConfig, error) {
		config := NewPitrConfig(level)
		length, unit, ok, err := getPitrLengthAndUnit(ctx, bh, level, accName, dbName, tblName)
		if err != nil {
			return nil, err
		}
		config.Length = length
		config.Unit = unit
		config.Exists = ok
		return config, nil
	}

	if config, err := getPitrConfig(cdc.CDCPitrGranularity_Cluster, "", ""); err != nil {
		return err
	} else if config.IsValid(minPitrLen) {
		return nil
	}

	for _, pt := range pts.Pts {
		dbName := pt.Source.Database
		tblName := pt.Source.Table

		level := cdc.CDCPitrGranularity_Table
		if dbName == cdc.CDCPitrGranularity_All && tblName == cdc.CDCPitrGranularity_All {
			level = cdc.CDCPitrGranularity_Account
		} else if tblName == cdc.CDCPitrGranularity_All {
			level = cdc.CDCPitrGranularity_DB
		}

		if config, err := getPitrConfig(cdc.CDCPitrGranularity_Account, dbName, tblName); err != nil {
			return err
		} else if config.IsValid(minPitrLen) {
			continue
		}

		if level == cdc.CDCPitrGranularity_DB || level == cdc.CDCPitrGranularity_Table {
			if config, err := getPitrConfig(cdc.CDCPitrGranularity_DB, dbName, tblName); err != nil {
				return err
			} else if config.IsValid(minPitrLen) {
				continue
			}
		}

		if level == cdc.CDCPitrGranularity_Table {
			if config, err := getPitrConfig(cdc.CDCPitrGranularity_Table, dbName, tblName); err != nil {
				return err
			} else if config.IsValid(minPitrLen) {
				continue
			}
		}

		return moerr.NewInternalErrorf(ctx,
			"no valid PITR configuration found for pattern: %s, minimum required length: %d hours",
			pt.OriginString, minPitrLen)
	}
	return nil
}

CDCCheckPitrGranularity checks if the PITR (Point-in-Time Recovery) granularity settings meet the minimum requirements for CDC tasks at different levels (cluster/account/db/table) It verifies the PITR configuration in descending order of priority (cluster > account > database > table) to ensure that at least one level satisfies the minimum time requirement (2 hours).

Parameters: - ctx: Context for managing the lifecycle of the function. - bh: Background handler for executing database queries. - accName: The account name associated with the CDC task. - pts: Pattern tuples representing the database and table patterns to be checked. - minLength: the minimum time requirement of pitr

Returns: - error: Returns an error if no PITR configuration meets the minimum requirement, otherwise nil.

View Source
var CDCExectorError_QueryDaemonTaskTimeout = moerr.NewInternalErrorNoCtx("query daemon task timeout")
View Source
var CDCExeutorAllocator *mpool.MPool
View Source
var CDCShowOutputColumns = [CDCShowOutputColumnsCount]Column{
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTaskID_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTaskID_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTaskName_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTaskName_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameSourceURI_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameSourceURI_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameSinkURI_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameSinkURI_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameState_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameState_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameErrMsg_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameErrMsg_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameCheckpoint_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameCheckpoint_Idx].columnType,
		},
	},
	&MysqlColumn{
		ColumnImpl: ColumnImpl{
			name:       CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTimestamp_Idx].name,
			columnType: CDCShowOutputColumnsSpec[CDCShowOutputColumnsNameTimestamp_Idx].columnType,
		},
	},
}
View Source
var CDCShowOutputColumnsSpec = map[int]struct {
	name       string
	columnType defines.MysqlType
}{
	CDCShowOutputColumnsNameTaskID_Idx:     {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameTaskName_Idx:   {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameSourceURI_Idx:  {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameSinkURI_Idx:    {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameState_Idx:      {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameErrMsg_Idx:     {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameCheckpoint_Idx: {/* contains filtered or unexported fields */},
	CDCShowOutputColumnsNameTimestamp_Idx:  {/* contains filtered or unexported fields */},
}
View Source
var Close = func(ep *ExportConfig) error {
	ep.FileCnt++
	err := ep.AsyncWriter.Close()
	if err != nil {
		return err
	}
	err = ep.AsyncGroup.Wait()
	if err != nil {
		return err
	}
	err = ep.AsyncReader.Close()
	if err != nil {
		return err
	}
	ep.AsyncReader = nil
	ep.AsyncWriter = nil
	ep.AsyncGroup = nil
	return err
}
View Source
var Collations []*Collation = []*Collation{
	{"utf8_general_ci", "utf8", 33, "", "Yes", 1, "PAD SPACE"},
	{"binary", "binary", 63, "YES", "Yes", 1, "NO PAD"},
	{"utf8_unicode_ci", "utf8", 192, "", "Yes", 1, "PAD SPACE"},
	{"utf8_bin", "utf8", 83, "YES", "Yes", 1, "NO PAD"},
	{"utf8mb4_general_ci", "utf8mb4", 45, "", "Yes", 1, "PAD SPACE"},
	{"utf8mb4_unicode_ci", "utf8mb4", 224, "", "Yes", 1, "PAD SPACE"},
	{"utf8mb4_bin", "utf8mb4", 46, "YES", "Yes", 1, "NO PAD"},
	{"utf8mb4_0900_bin", "utf8mb4", 309, "", "Yes", 1, "NO PAD"},
	{"utf8mb4_0900_ai_ci", "utf8mb4", 255, "", "Yes", 0, "NO PAD"},
	{"utf8mb4_de_pb_0900_ai_ci", "utf8mb4", 256, "", "Yes", 0, "NO PAD"},
	{"utf8mb4_is_0900_ai_ci", "utf8mb4", 257, "", "Yes", 0, "NO PAD"},
	{"utf8mb4_lv_0900_ai_ci", "utf8mb4", 258, "", "Yes", 0, "NO PAD"},
}
View Source
var ComputeDdlBatchWithSnapshotFunc = computeDdlBatchWithSnapshotImpl

ComputeDdlBatchWithSnapshotFunc is a function variable for ComputeDdlBatchWithSnapshot to allow stubbing in tests

View Source
var ConnIDAllocKey = "____server_conn_id"

ConnIDAllocKey is used get connection ID from HAKeeper.

DefaultCapability means default capabilities of the server

View Source
var DefaultClientConnStatus = SERVER_STATUS_AUTOCOMMIT

DefaultClientConnStatus default server status

View Source
var ExeSqlInBgSes = func(reqCtx context.Context, bh BackgroundExec, sql string) ([]ExecResult, error) {
	return executeSQLInBackgroundSession(reqCtx, bh, sql)
}

ExeSqlInBgSes for mock stub

View Source
var FinishedPacket = func(c *Conn) error {
	return c.FinishedPacket()
}
View Source
var ForeachQueriedRow = func(
	ctx context.Context,
	tx taskservice.SqlExecutor,
	query string,
	onEachRow func(context.Context, *sql.Rows) (bool, error),
) (cnt int64, err error) {
	var (
		ok   bool
		rows *sql.Rows
	)
	if rows, err = tx.QueryContext(ctx, query); err != nil {
		return
	}
	if rows.Err() != nil {
		err = rows.Err()
		return
	}
	defer func() {
		_ = rows.Close()
	}()

	for rows.Next() {
		if ok, err = onEachRow(ctx, rows); err != nil {
			return
		}
		if ok {
			cnt++
		}
	}
	return
}
View Source
var GSysVarsMgr = &GlobalSysVarsMgr{
	accountsGlobalSysVarsMap: make(map[uint32]*SystemVariables),
}
View Source
var GetBool = func(slices *ColumnSlices, rowIdx uint64, colIdx uint64) (bool, error) {
	return slices.GetBool(rowIdx, colIdx)
}
View Source
var GetBytesBased = func(slices *ColumnSlices, r uint64, i uint64) ([]byte, error) {
	return slices.GetBytesBased(r, i)
}
View Source
var GetComputationWrapper = func(execCtx *ExecCtx, db string, user string, eng engine.Engine, proc *process.Process, ses *Session) ([]ComputationWrapper, error) {
	var cws []ComputationWrapper = nil
	if preparePlan := execCtx.input.getPreparePlan(); preparePlan != nil {
		tcw := InitTxnComputationWrapper(ses, execCtx.input.stmt, proc)
		tcw.plan = preparePlan.GetDcl().GetPrepare().Plan
		tcw.binaryPrepare = execCtx.input.isBinaryProtExecute
		tcw.prepareName = execCtx.input.stmtName
		cws = append(cws, tcw)
		return cws, nil
	} else if cached := ses.getCachedPlan(execCtx.input.getHash()); cached != nil {
		for i, stmt := range cached.stmts {
			tcw := InitTxnComputationWrapper(ses, stmt, proc)
			tcw.plan = cached.plans[i]
			cws = append(cws, tcw)
		}

		return cws, nil
	}

	var stmts []tree.Statement = nil
	var cmdFieldStmt *InternalCmdFieldList
	var cmdGetSnapshotTsStmt *InternalCmdGetSnapshotTs
	var cmdGetDatabasesStmt *InternalCmdGetDatabases
	var cmdGetMoIndexesStmt *InternalCmdGetMoIndexes
	var cmdGetDdlStmt *InternalCmdGetDdl
	var cmdGetObjectStmt *InternalCmdGetObject
	var cmdObjectListStmt *InternalCmdObjectList
	var err error

	if execCtx.input.getStmt() != nil {
		stmts = append(stmts, execCtx.input.getStmt())
	} else if isCmdFieldListSql(execCtx.input.getSql()) {
		cmdFieldStmt, err = parseCmdFieldList(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdFieldStmt)
	} else if isCmdGetSnapshotTsSql(execCtx.input.getSql()) {
		cmdGetSnapshotTsStmt, err = parseCmdGetSnapshotTs(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetSnapshotTsStmt)
	} else if isCmdGetDatabasesSql(execCtx.input.getSql()) {
		cmdGetDatabasesStmt, err = parseCmdGetDatabases(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetDatabasesStmt)
	} else if isCmdGetMoIndexesSql(execCtx.input.getSql()) {
		cmdGetMoIndexesStmt, err = parseCmdGetMoIndexes(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetMoIndexesStmt)
	} else if isCmdGetDdlSql(execCtx.input.getSql()) {
		cmdGetDdlStmt, err = parseCmdGetDdl(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetDdlStmt)
	} else if isCmdGetObjectSql(execCtx.input.getSql()) {
		cmdGetObjectStmt, err = parseCmdGetObject(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetObjectStmt)
	} else if isCmdObjectListSql(execCtx.input.getSql()) {
		cmdObjectListStmt, err = parseCmdObjectList(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdObjectListStmt)
	} else if isCmdCheckSnapshotFlushedSql(execCtx.input.getSql()) {
		cmdCheckSnapshotFlushedStmt, err := parseCmdCheckSnapshotFlushed(execCtx.reqCtx, execCtx.input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdCheckSnapshotFlushedStmt)
	} else {
		stmts, err = parseSql(execCtx, ses.GetMySQLParser())
		if err != nil {
			return nil, err
		}
		v, err := ses.GetSessionSysVar("enable_remap_hint")
		if err == nil {
			if on, convErr := valueIsBoolTrue(v); convErr == nil && on {
				err = parsers.AddRewriteHints(execCtx.reqCtx, stmts, execCtx.input.getSql())
				if err != nil {
					return nil, err
				}
			}
		}
	}

	for _, stmt := range stmts {
		cws = append(cws, InitTxnComputationWrapper(ses, stmt, proc))
	}
	return cws, nil
}
View Source
var GetComputationWrapperInBack = func(execCtx *ExecCtx, db string, input *UserInput, user string, eng engine.Engine, proc *process.Process, ses FeSession) ([]ComputationWrapper, error) {
	var cw []ComputationWrapper = nil

	var stmts []tree.Statement = nil
	var cmdFieldStmt *InternalCmdFieldList
	var cmdGetSnapshotTsStmt *InternalCmdGetSnapshotTs
	var cmdGetDatabasesStmt *InternalCmdGetDatabases
	var cmdGetMoIndexesStmt *InternalCmdGetMoIndexes
	var cmdGetDdlStmt *InternalCmdGetDdl
	var cmdGetObjectStmt *InternalCmdGetObject
	var cmdObjectListStmt *InternalCmdObjectList
	var err error

	if input.getStmt() != nil {
		stmts = append(stmts, input.getStmt())
	} else if isCmdFieldListSql(input.getSql()) {
		cmdFieldStmt, err = parseCmdFieldList(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdFieldStmt)
	} else if isCmdGetSnapshotTsSql(input.getSql()) {
		cmdGetSnapshotTsStmt, err = parseCmdGetSnapshotTs(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetSnapshotTsStmt)
	} else if isCmdGetDatabasesSql(input.getSql()) {
		cmdGetDatabasesStmt, err = parseCmdGetDatabases(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetDatabasesStmt)
	} else if isCmdGetMoIndexesSql(input.getSql()) {
		cmdGetMoIndexesStmt, err = parseCmdGetMoIndexes(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetMoIndexesStmt)
	} else if isCmdGetDdlSql(input.getSql()) {
		cmdGetDdlStmt, err = parseCmdGetDdl(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetDdlStmt)
	} else if isCmdGetObjectSql(input.getSql()) {
		cmdGetObjectStmt, err = parseCmdGetObject(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdGetObjectStmt)
	} else if isCmdObjectListSql(input.getSql()) {
		cmdObjectListStmt, err = parseCmdObjectList(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdObjectListStmt)
	} else if isCmdCheckSnapshotFlushedSql(input.getSql()) {
		cmdCheckSnapshotFlushedStmt, err := parseCmdCheckSnapshotFlushed(execCtx.reqCtx, input.getSql())
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, cmdCheckSnapshotFlushedStmt)
	} else {
		stmts, err = parseSql(execCtx, ses.GetMySQLParser())
		if err != nil {
			return nil, err
		}
	}

	for _, stmt := range stmts {
		cw = append(cw, InitTxnComputationWrapper(ses, stmt, proc))
	}
	return cw, nil
}
View Source
var GetDate = func(slices *ColumnSlices, r uint64, i uint64) (types.Date, error) {
	return slices.GetDate(r, i)
}
View Source
var GetDatetime = func(slices *ColumnSlices, r uint64, i uint64) (string, error) {
	return slices.GetDatetime(r, i)
}
View Source
var GetDecimal = func(slices *ColumnSlices, r uint64, i uint64) (string, error) {
	return slices.GetDecimal(r, i)
}
View Source
var GetFloat32 = func(slices *ColumnSlices, r uint64, i uint64) (float32, error) {
	return slices.GetFloat32(r, i)
}
View Source
var GetFloat64 = func(slices *ColumnSlices, r uint64, i uint64) (float64, error) {
	return slices.GetFloat64(r, i)
}
View Source
var GetInt64 = func(slices *ColumnSlices, r uint64, i uint64) (int64, error) {
	return slices.GetInt64(r, i)
}
View Source
var GetObjectDataReader = func(ctx context.Context, ses *Session, objectName string, offset int64, size int64) ([]byte, error) {
	return readObjectFromFS(ctx, ses, objectName, offset, size)
}

GetObjectDataReader is the function to read object data from fileservice This is exported as a variable to allow stubbing in tests

View Source
var GetObjectFSProvider = func(ses *Session) (fileservice.FileService, error) {
	eng := getPu(ses.GetService()).StorageEngine
	var de *disttae.Engine
	var ok bool
	if de, ok = eng.(*disttae.Engine); !ok {
		var entireEngine *engine.EntireEngine
		if entireEngine, ok = eng.(*engine.EntireEngine); ok {
			de, ok = entireEngine.Engine.(*disttae.Engine)
		}
		if !ok {
			return nil, moerr.NewInternalErrorNoCtx("failed to get disttae engine")
		}
	}

	fs := de.FS()
	if fs == nil {
		return nil, moerr.NewInternalErrorNoCtx("fileservice is not available")
	}
	return fs, nil
}

GetObjectFSProvider is the function to get fileservice for GetObject This is exported as a variable to allow stubbing in tests

View Source
var GetObjectPermissionChecker = func(ctx context.Context, ses *Session, pubAccountName, pubName string) (uint64, error) {
	if len(pubAccountName) == 0 || len(pubName) == 0 {
		return 0, moerr.NewInternalError(ctx, "publication account name and publication name are required for GET OBJECT")
	}
	bh := ses.GetShareTxnBackgroundExec(ctx, false)
	defer bh.Close()
	currentAccount := ses.GetTenantInfo().GetTenant()
	accountID, _, err := getAccountFromPublication(ctx, bh, pubAccountName, pubName, currentAccount)
	return accountID, err
}

GetObjectPermissionChecker is the function to check publication permission for GetObject This is exported as a variable to allow stubbing in tests Returns the authorized account ID for execution

View Source
var GetStringBased = func(slices *ColumnSlices, r uint64, i uint64) (string, error) {
	return slices.GetStringBased(r, i)
}
View Source
var GetTableErrMsg = func(
	ctx context.Context,
	accountId uint32,
	ieExecutor ie.InternalExecutor,
	taskId string,
	tbl *cdc.DbTableInfo) (
	hasError bool, err error,
) {
	ctx = defines.AttachAccountId(ctx, catalog.System_Account)
	sql := cdc.CDCSQLBuilder.GetTableErrMsgSQL(uint64(accountId), taskId, tbl.SourceDbName, tbl.SourceTblName)
	res := ieExecutor.Query(ctx, sql, ie.SessionOverrideOptions{})
	if res.Error() != nil {
		return false, res.Error()
	} else if res.RowCount() < 1 {
		return false, nil
	}

	errMsg, err := res.GetString(ctx, 0, 0)
	if err != nil {
		return false, err
	}
	if errMsg == "" {
		return false, nil
	}

	metadata := cdc.ParseErrorMetadata(errMsg)
	if metadata == nil {
		return false, nil
	}

	if cdc.ShouldRetry(metadata) {

		if metadata.IsRetryable {
			logutil.Info(
				"cdc.frontend.task.retryable_table_error",
				zap.String("db", tbl.SourceDbName),
				zap.String("table", tbl.SourceTblName),
				zap.Int("retry-count", metadata.RetryCount),
				zap.Int("max-retry", cdc.MaxRetryCount),
				zap.String("message", metadata.Message),
			)
		} else {

			age := time.Since(metadata.FirstSeen)
			logutil.Info(
				"cdc.frontend.task.expired_non_retryable_error",
				zap.String("db", tbl.SourceDbName),
				zap.String("table", tbl.SourceTblName),
				zap.Duration("age", age),
				zap.String("message", metadata.Message),
			)
		}
		return false, nil
	}

	if metadata.IsRetryable {

		logutil.Warn(
			"cdc.frontend.task.max_retry_exceeded",
			zap.String("db", tbl.SourceDbName),
			zap.String("table", tbl.SourceTblName),
			zap.Int("retry-count", metadata.RetryCount),
			zap.String("message", metadata.Message),
		)
	} else {

		age := time.Since(metadata.FirstSeen)
		logutil.Info(
			"cdc.frontend.task.permanent_table_error",
			zap.String("db", tbl.SourceDbName),
			zap.String("table", tbl.SourceTblName),
			zap.Duration("age", age),
			zap.String("message", metadata.Message),
		)
	}

	hasError = true
	return
}
View Source
var GetTime = func(slices *ColumnSlices, r uint64, i uint64) (string, error) {
	return slices.GetTime(r, i)
}
View Source
var GetTimestamp = func(slices *ColumnSlices, r uint64, i uint64, timeZone *time.Location) (string, error) {
	return slices.GetTimestamp(r, i, timeZone)
}
View Source
var GetUUID = func(slices *ColumnSlices, r uint64, i uint64) (string, error) {
	return slices.GetUUID(r, i)
}
View Source
var GetUint64 = func(slices *ColumnSlices, r uint64, i uint64) (uint64, error) {
	return slices.GetUint64(r, i)
}
View Source
var IsNull = func(slices *ColumnSlices, rowIdx int, colIdx int) bool {
	return slices.IsNull(rowIdx, colIdx)
}
View Source
var (
	MaxPrepareNumberInOneSession atomic.Uint32
)
View Source
var NewBackgroundExec = func(
	reqCtx context.Context,
	upstream FeSession,
	opts ...*BackgroundExecOption,
) BackgroundExec {
	// XXXSP
	var txnOp TxnOperator

	return upstream.InitBackExec(txnOp, "", backSesOutputCallback, opts...)
}
View Source
var NewShareTxnBackgroundExec = func(ctx context.Context, ses FeSession, rawBatch bool) BackgroundExec {
	return ses.GetShareTxnBackgroundExec(ctx, rawBatch)
}
View Source
var ObjectListPermissionChecker = func(ctx context.Context, ses *Session, pubAccountName, pubName string) (uint64, error) {
	if len(pubAccountName) == 0 || len(pubName) == 0 {
		return 0, moerr.NewInternalError(ctx, "publication account name and publication name are required for OBJECT LIST")
	}
	bh := ses.GetShareTxnBackgroundExec(ctx, false)
	defer bh.Close()
	currentAccount := ses.GetTenantInfo().GetTenant()
	accountID, _, err := getAccountFromPublication(ctx, bh, pubAccountName, pubName, currentAccount)
	return accountID, err
}

ObjectListPermissionChecker is the function to check publication permission for ObjectList This is exported as a variable to allow stubbing in tests Returns the authorized account ID for execution

View Source
var PathExists = func(path string) (bool, bool, error) {
	fi, err := os.Stat(path)
	if err == nil {
		return true, !fi.IsDir(), nil
	}
	if os.IsNotExist(err) {
		return false, false, err
	}

	return false, false, err
}

path exists in the system return: true/false - exists or not. true/false - file or directory error

View Source
var ProcessObjectListFunc = processObjectListImpl

ProcessObjectListFunc is a function variable for ProcessObjectList to allow stubbing in tests

View Source
var ReadNBytesIntoBuf = func(c *Conn, buf []byte, n int) error {
	return c.ReadNBytesIntoBuf(buf, n)
}
View Source
var ReadOnePayload = func(c *Conn, payloadLength int) ([]byte, error) {
	return c.ReadOnePayload(payloadLength)
}
View Source
var RecordParseErrorStatement = func(ctx context.Context, ses *Session, proc *process.Process, envBegin time.Time,
	envStmt []string, sqlTypes []string, err error) (context.Context, error) {
	retErr := moerr.NewParseError(ctx, err.Error())

	sqlType := ""
	if len(sqlTypes) > 0 {
		sqlType = sqlTypes[0]
	} else {
		sqlType = constant.ExternSql
	}

	if len(envStmt) > 0 {
		for i, sql := range envStmt {
			if i < len(sqlTypes) {
				sqlType = sqlTypes[i]
			}
			ctx, err = RecordStatement(ctx, ses, proc, nil, envBegin, sql, sqlType, true)
			if err != nil {
				return nil, err
			}
			ses.tStmt.EndStatement(ctx, retErr, 0, 0, 0)
		}
	} else {
		ctx, err = RecordStatement(ctx, ses, proc, nil, envBegin, "", sqlType, true)
		if err != nil {
			return nil, err
		}
		ses.tStmt.EndStatement(ctx, retErr, 0, 0, 0)
	}
	ses.SetTStmt(nil)

	tenant := ses.GetTenantInfo()
	if tenant == nil {
		tenant, _ = GetTenantInfo(ctx, "internal")
	}
	incStatementErrorsCounter(tenant.GetTenant(), tenant.GetTenantID(), nil)
	return ctx, nil
}
View Source
var RecordStatement = func(ctx context.Context, ses *Session, proc *process.Process, cw ComputationWrapper, envBegin time.Time, envStmt, sqlType string, useEnv bool) (context.Context, error) {
	// set StatementID
	var stmID uuid.UUID
	var statement tree.Statement = nil
	var text string
	if cw != nil {
		copy(stmID[:], cw.GetUUID())
		statement = cw.GetAst()

		ses.ast = statement
		binExec, prepareName := cw.BinaryExecute()
		execSql := makeExecuteSql(ctx, ses, statement, binExec, prepareName)
		if len(execSql) != 0 {
			bb := strings.Builder{}
			bb.WriteString(envStmt)
			bb.WriteString(" // ")
			bb.WriteString(execSql)
			text = commonutil.Abbreviate(bb.String(), int(getPu(ses.GetService()).SV.LengthOfQueryPrinted))
		} else {

			text = commonutil.Abbreviate(envStmt, int(getPu(ses.GetService()).SV.LengthOfQueryPrinted))
		}
	} else {
		u, _ := util.FastUuid()
		stmID = uuid.UUID(u)
		text = commonutil.Abbreviate(envStmt, int(getPu(ses.GetService()).SV.LengthOfQueryPrinted))
	}
	ses.SetStmtId(stmID)
	stmtTyp := getStatementType(statement).GetStatementType()
	queryTyp := getStatementType(statement).GetQueryType()
	ses.SetStmtType(stmtTyp)
	ses.SetQueryType(queryTyp)
	ses.SetSqlSourceType(sqlType)
	ses.SetSqlOfStmt(text)
	if proc != nil {

		proc.SetStmtProfile(&ses.stmtProfile)
	}
	ses.stmtProfile.SetDivByZeroRuntimeProfile(stmtTyp, queryTyp, isIgnoreStatement(statement))

	if sqlType != constant.InternalSql {
		ses.pushQueryId(types.Uuid(stmID).String())
	}

	if !motrace.GetTracerProvider().IsEnable() {
		return ctx, nil
	}
	if sqlType == constant.InternalSql && envStmt == "" {

		return ctx, nil
	}

	tenant := ses.GetTenantInfo()
	if tenant == nil {
		tenant, _ = GetTenantInfo(ctx, "internal")
	}
	stm := motrace.NewStatementInfo()
	// set TransactionID
	var txn TxnOperator
	var err error

	if handler := ses.GetTxnHandler(); handler.InActiveTxn() {
		txn = handler.GetTxn()
		if err != nil {
			return nil, err
		}
		stm.SetTxnID(txn.Txn().ID)
	}

	copy(stm.SessionID[:], ses.GetUUID())
	copy(stm.StatementID[:], stmID[:])
	requestAt := envBegin
	if !useEnv {
		requestAt = time.Now()
	}

	stm.ConnectionId = ses.GetConnectionID()
	stm.Account = tenant.GetTenant()
	stm.AccountID = tenant.GetTenantID()
	stm.RoleId = tenant.GetDefaultRoleID()

	stm.User = tenant.GetUser()
	stm.Host = ses.respr.GetStr(PEER)
	stm.Database = ses.respr.GetStr(DBNAME)
	stm.StatementFingerprint = ""
	stm.StatementTag = ""
	stm.SqlSourceType = sqlType
	stm.RequestAt = requestAt
	stm.StatementType = getStatementType(statement).GetStatementType()
	stm.QueryType = getStatementType(statement).GetQueryType()
	stm.ConnType = transferSessionConnType2StatisticConnType(ses.connType)
	if sqlType == constant.InternalSql && isCmdFieldListSql(envStmt) {

		stm.User = ""
	}
	if ses.disableAgg {
		stm.DisableAgg()
	}

	stm.RecordStatementSql(text, envStmt)
	stm.Report(ctx)
	ses.SetTStmt(stm)

	return ctx, nil
}
View Source
var RecordStatementTxnID = func(ctx context.Context, fses FeSession) error {
	var ses *Session
	var ok bool
	if ses, ok = fses.(*Session); !ok {
		return nil
	}
	var txn TxnOperator
	var err error
	if ses == nil {
		return nil
	}

	if stm := ses.tStmt; stm != nil && stm.IsZeroTxnID() {
		if handler := ses.GetTxnHandler(); handler.InActiveTxn() {

			txn = handler.GetTxn()
			if err != nil {
				return err
			}
			stm.SetTxnID(txn.Txn().ID)
			ses.SetTxnId(txn.Txn().ID)
		}

	}

	if upSes := ses.upstream; upSes != nil && upSes.tStmt != nil && upSes.tStmt.IsZeroTxnID() {

		if handler := ses.GetTxnHandler(); handler.InActiveTxn() {
			txn = handler.GetTxn()
			if err != nil {
				return err
			}

			if stmt := upSes.tStmt; stmt.NeedSkipTxn() {

				stmt.SetSkipTxn(false)
				stmt.SetSkipTxnId(txn.Txn().ID)
			} else if txnId := txn.Txn().ID; !stmt.SkipTxnId(txnId) {
				upSes.tStmt.SetTxnID(txnId)
			}
		}
	}
	return nil
}

RecordStatementTxnID record txnID after TxnBegin or Compile(autocommit=1)

View Source
var Write = func(ep *ExportConfig, output []byte) (int, error) {
	n, err := ep.AsyncWriter.Write(output)
	if err != nil {
		err2 := ep.AsyncWriter.CloseWithError(err)
		if err2 != nil {
			return 0, err2
		}
	}
	return n, err
}

Functions

func BuildDdlMysqlResultSet

func BuildDdlMysqlResultSet(mrs *MysqlResultSet)

BuildDdlMysqlResultSet builds the MySQL result set columns for DDL query

func CDCParseGranularityTuple

func CDCParseGranularityTuple(
	ctx context.Context,
	level string,
	pattern string,
	dup map[string]struct{},
) (pt *cdc.PatternTuple, err error)

CDCParseGranularityTuple pattern example:

db1
db1:db2
db1.t1
db1.t1:db2.t2

There must be no special characters (',' '.' ':' '`') in database name & table name.

func CDCParsePitrGranularity

func CDCParsePitrGranularity(
	ctx context.Context,
	level string,
	tables string,
) (pts *cdc.PatternTuples, err error)

CDCParsePitrGranularity parses a comma-separated list of table patterns into a PatternTuples struct. The level parameter specifies whether patterns are at account/db/table level. For account level, returns a single pattern matching all DBs and tables. For db/table level, parses each pattern into source and sink components.

func CDCParseTableInfo

func CDCParseTableInfo(
	ctx context.Context,
	input string,
	level string,
) (db string, table string, err error)

CDCParseTableInfo parses a string to get account,database,table info

input format:

DbLevel: database
TableLevel: database.table

There must be no special characters (',' '.' ':' '`') in database name & table name.

func CDCPauseTaskCompleteHook

func CDCPauseTaskCompleteHook(sqlExecutorFactory func() ie.InternalExecutor) taskservice.PauseTaskCompletedHook

func CDCStrToTS

func CDCStrToTS(tsStr string) (types.TS, error)

func CDCStrToTime

func CDCStrToTime(tsStr string, tz *time.Location) (ts time.Time, err error)

func CDCTaskExecutorFactory

func CDCTaskExecutorFactory(
	logger *zap.Logger,
	sqlExecutorFactory func() ie.InternalExecutor,
	attachToTask func(context.Context, uint64, taskservice.ActiveRoutine) error,
	cnUUID string,
	ts taskservice.TaskService,
	fs fileservice.FileService,
	txnClient client.TxnClient,
	txnEngine engine.Engine,
) taskservice.TaskExecutor

func CancelCheck added in v1.2.1

func CancelCheck(Ctx context.Context) error

CancelCheck checks if the given context has been canceled. If the context is canceled, it returns the context's error.

func CheckPassword

func CheckPassword(pwd, salt, auth []byte) bool

CheckPassword checks the authentication from password. the server get the auth string from HandShakeResponse pwd is SHA1(SHA1(password)), AUTH is from client hash1 = AUTH XOR SHA1( slat + pwd) hash2 = SHA1(hash1) check(hash2, hpwd)

func CheckSnapshotFlushed

func CheckSnapshotFlushed(ctx context.Context, txn client.TxnOperator, snapshotTs int64, engine *disttae.Engine, level, databaseName, tableName string) (bool, error)

CheckSnapshotFlushed checks if a snapshot's timestamp is less than or equal to the checkpoint watermark This is an exported function that can be used without Session Parameters:

  • level: snapshot level ("account", "database", "table")
  • databaseName: database name (required for "database" and "table" levels)
  • tableName: table name (required for "table" level)
  • snapshotTs: snapshot timestamp

func CheckTableDefChange

func CheckTableDefChange(catalogCache *cache.CatalogCache, tblKey *cache.TableChangeQuery) bool

func ComputeDdlBatch

func ComputeDdlBatch(
	ctx context.Context,
	databaseName string,
	tableName string,
	eng engine.Engine,
	mp *mpool.MPool,
	txn TxnOperator,
) (*batch.Batch, error)

ComputeDdlBatch computes the DDL batch for given scope This is the core function that can be used by both frontend handlers and upstream sql helper Parameters:

  • ctx: context with account ID attached
  • databaseName: database name (empty to iterate all databases)
  • tableName: table name (empty to iterate all tables in database)
  • eng: storage engine
  • mp: memory pool
  • txn: transaction operator (should already have snapshot timestamp applied if needed)

Returns:

  • batch: the result batch with columns (dbname, tablename, tableid, tablesql)
  • err: error if failed

func ComputeDdlBatchWithSnapshot

func ComputeDdlBatchWithSnapshot(
	ctx context.Context,
	databaseName string,
	tableName string,
	eng engine.Engine,
	mp *mpool.MPool,
	txn TxnOperator,
	snapshotTs int64,
) (*batch.Batch, error)

ComputeDdlBatchWithSnapshot computes the DDL batch with snapshot applied Parameters:

  • ctx: context with account ID attached
  • databaseName: database name (empty to iterate all databases)
  • tableName: table name (empty to iterate all tables in database)
  • eng: storage engine
  • mp: memory pool
  • txn: transaction operator
  • snapshotTs: snapshot timestamp (0 means no snapshot)

Returns:

  • batch: the result batch with columns (dbname, tablename, tableid, tablesql)
  • err: error if failed

func ConstructTLSConfig added in v0.8.0

func ConstructTLSConfig(ctx context.Context, caFile, certFile, keyFile string) (*tls.Config, error)

ConstructTLSConfig creates the TLS config.

func Copy added in v1.2.1

func Copy[T any](src []T) []T

func ExecuteAndGetRowsAffected

func ExecuteAndGetRowsAffected(
	ctx context.Context,
	tx taskservice.SqlExecutor,
	query string,
	args ...interface{},
) (int64, error)

func ExecuteFuncWithRecover

func ExecuteFuncWithRecover(fun func() error) (err error, hasRecovered bool)

ExecuteFuncWithRecover executes the function and recover the panic

func FillDdlMysqlResultSet

func FillDdlMysqlResultSet(resultBatch *batch.Batch, mrs *MysqlResultSet)

FillDdlMysqlResultSet fills the MySQL result set from the DDL batch

func GenSQLForCheckUpgradeAccountPrivilegeExist added in v1.2.0

func GenSQLForCheckUpgradeAccountPrivilegeExist() string

GenSQLForCheckUpgradeAccountPrivilegeExist generates an SQL statement to check for the existence of upgrade account permissions.

func GenSQLForInsertUpgradeAccountPrivilege added in v1.2.0

func GenSQLForInsertUpgradeAccountPrivilege() string

GenSQLForInsertUpgradeAccountPrivilege generates SQL statements for inserting upgrade account permissions

func GetAccountAdminRole added in v1.0.0

func GetAccountAdminRole() string

func GetAccountAdminRoleId added in v1.0.0

func GetAccountAdminRoleId() uint32

func GetAccountIDFromPublication

func GetAccountIDFromPublication(ctx context.Context, bh BackgroundExec, pubAccountName string, pubName string, currentAccount string) (uint64, string, error)

GetAccountIDFromPublication verifies publication permission and returns the upstream account ID Parameters:

  • ctx: context
  • bh: background executor
  • pubAccountName: publication account name
  • pubName: publication name
  • currentAccount: current tenant account name

Returns:

  • accountID: the upstream account ID
  • accountName: the upstream account name
  • err: error if permission denied or publication not found

func GetAdminUserId added in v1.0.0

func GetAdminUserId() uint32

func GetDdlBatchWithoutSession

func GetDdlBatchWithoutSession(
	ctx context.Context,
	databaseName string,
	tableName string,
	eng engine.Engine,
	txn client.TxnOperator,
	mp *mpool.MPool,
	snapshot *plan2.Snapshot,
) (*batch.Batch, error)

GetDdlBatchWithoutSession gets DDL batch without requiring Session This is a version that can be used by test utilities or other components If snapshot is provided, it will be applied to the transaction

func GetDefaultRole added in v0.6.0

func GetDefaultRole() string

func GetDefaultRoleId added in v1.0.0

func GetDefaultRoleId() uint32

func GetDefaultTenant added in v0.6.0

func GetDefaultTenant() string

func GetExplainColumn

func GetExplainColumn(ctx context.Context, explainColName string) ([]*plan2.ColDef, []interface{}, error)

func GetObjectListWithoutSession

func GetObjectListWithoutSession(
	ctx context.Context,
	from, to types.TS,
	dbname, tablename string,
	eng engine.Engine,
	txn client.TxnOperator,
	mp *mpool.MPool,
) (*batch.Batch, error)

GetObjectListWithoutSession gets object list from the specified table/database without requiring Session This is a version that can be used by test utilities If dbname is empty, it will iterate over all databases If tablename is empty (but dbname is not), it will iterate over all tables in the database

func GetPassWord added in v0.8.0

func GetPassWord(pwd string) ([]byte, error)

GetPassWord is used to get hash byte password SHA1(SHA1(password))

func GetPrepareStmtID added in v0.6.0

func GetPrepareStmtID(ctx context.Context, name string) (int, error)

func GetRoutineId

func GetRoutineId() uint64

GetRoutineId gets the routine id

func GetSimpleExprValue added in v0.5.0

func GetSimpleExprValue(ctx context.Context, e tree.Expr, feSes FeSession) (interface{}, error)

only support single value and unary minus

func GetSnapshotTsByName

func GetSnapshotTsByName(ctx context.Context, bh BackgroundExec, snapshotName string) (int64, error)

GetSnapshotTsByName gets the snapshot timestamp by snapshot name Parameters:

  • ctx: context with account ID attached
  • bh: background executor
  • snapshotName: the snapshot name

Returns:

  • ts: snapshot timestamp (physical time in nanoseconds)
  • err: error if snapshot not found or query failed

func GetSysTenantId added in v1.0.0

func GetSysTenantId() uint32

func GetUserRoot added in v1.0.0

func GetUserRoot() string

func GetUserRootId added in v1.0.0

func GetUserRootId() uint32

func GetVersionCompatibility added in v0.8.0

func GetVersionCompatibility(ctx context.Context, ses *Session, dbName string) (ret string, err error)

func HashPassWord added in v0.8.0

func HashPassWord(pwd string) string

HashPassWord is uesed to hash password *SHA1(SHA1(password))

func HashPassWordWithByte added in v0.8.0

func HashPassWordWithByte(pwd []byte) string

func HashSha1 added in v0.8.0

func HashSha1(toHash []byte) []byte

HashSha1 is used to calcute a sha1 hash SHA1()

func InitFunction added in v0.7.0

func InitFunction(ses *Session, execCtx *ExecCtx, tenant *TenantInfo, cf *tree.CreateFunction) (err error)

func InitGeneralTenant added in v0.6.0

func InitGeneralTenant(ctx context.Context, bh BackgroundExec, ses *Session, ca *createAccount) (err error)

InitGeneralTenant initializes the application level tenant

func InitProcedure added in v0.8.0

func InitProcedure(ctx context.Context, ses *Session, tenant *TenantInfo, cp *tree.CreateProcedure) (err error)

func InitRole added in v0.6.0

func InitRole(ctx context.Context, ses *Session, tenant *TenantInfo, cr *tree.CreateRole) (err error)

InitRole creates the new role

func InitServerLevelVars

func InitServerLevelVars(service string)

func InitServerVersion

func InitServerVersion(v string)

func InitSysTenant added in v0.6.0

func InitSysTenant(ctx context.Context, txn executor.TxnExecutor, finalVersion string) (err error)

InitSysTenant initializes the tenant SYS before any tenants and accepting any requests during the system is booting.

func InitUser added in v0.6.0

func InitUser(ctx context.Context, ses *Session, tenant *TenantInfo, cu *createUser) (err error)

InitUser creates new user for the tenant

func IsAdministrativeStatement added in v0.6.0

func IsAdministrativeStatement(stmt tree.Statement) bool

IsAdministrativeStatement checks the statement is the administrative statement.

func IsCreateDropDatabase added in v0.8.0

func IsCreateDropDatabase(stmt tree.Statement) bool

func IsCreateDropSequence added in v0.8.0

func IsCreateDropSequence(stmt tree.Statement) bool

func IsDDL added in v0.6.0

func IsDDL(stmt tree.Statement) bool

IsDDL checks the statement is the DDL statement.

func IsDropStatement added in v0.6.0

func IsDropStatement(stmt tree.Statement) bool

IsDropStatement checks the statement is the drop statement.

func IsParameterModificationStatement added in v0.6.0

func IsParameterModificationStatement(stmt tree.Statement) bool

IsParameterModificationStatement checks the statement is the statement of parameter modification statement.

func IsPrepareStatement added in v0.6.0

func IsPrepareStatement(stmt tree.Statement) bool

IsPrepareStatement checks the statement is the Prepare statement.

func Max

func Max(a int, b int) int

func Migrate added in v1.2.0

func Migrate(ses *Session, req *query.MigrateConnToRequest) error

func MoServerIsStarted added in v1.2.1

func MoServerIsStarted(service string) bool

func NeedToBeCommittedInActiveTransaction added in v0.6.0

func NeedToBeCommittedInActiveTransaction(stmt tree.Statement) bool

NeedToBeCommittedInActiveTransaction checks the statement that need to be committed in an active transaction.

Currently, it includes the drop statement, the administration statement ,

the parameter modification statement.

func NewGraph added in v0.6.0

func NewGraph() *graph

func NewInternalExecutor added in v0.6.0

func NewInternalExecutor(
	service string,
) *internalExecutor

func NewJsonPlanHandler added in v0.8.0

func NewJsonPlanHandler(ctx context.Context, stmt *motrace.StatementInfo, ses FeSession, plan *plan2.Plan, phyPlan *models.PhyPlan, opts ...marshalPlanOptions) *jsonPlanHandler

func NewMarshalPlanHandler added in v0.8.0

func NewMarshalPlanHandler(ctx context.Context, stmt *motrace.StatementInfo, plan *plan2.Plan, phyPlan *models.PhyPlan, opts ...marshalPlanOptions) *marshalPlanHandler

func NewMarshalPlanHandlerCompositeSubStmt

func NewMarshalPlanHandlerCompositeSubStmt(ctx context.Context, plan *plan.Plan, opts ...marshalPlanOptions) *marshalPlanHandler

NewMarshalPlanHandlerCompositeSubStmt MarshalHandler for child statements of composite statements

func NewSqlCodec

func NewSqlCodec() codec.Codec

func NewSubDbRestoreRecord

func NewSubDbRestoreRecord(dbName string, account uint32, createSql string, spTs int64) *subDbRestoreRecord

func ParseLabel added in v1.0.0

func ParseLabel(labelStr string) (map[string]string, error)

ParseLabel parses the label string. The labels are separated by ",", key and value are separated by "=".

func ProcessObjectList

func ProcessObjectList(
	ctx context.Context,
	stmt *tree.ObjectList,
	eng engine.Engine,
	txnOp client.TxnOperator,
	mp *mpool.MPool,
	resolveSnapshot func(ctx context.Context, snapshotName string) (*timestamp.Timestamp, error),
	getCurrentTS func() types.TS,
	dbname string,
	tablename string,
) (*batch.Batch, error)

ProcessObjectList is the core function that processes OBJECTLIST statement It returns a batch with "table name", "db name" columns plus object list columns This function can be used by both handleObjectList and test utilities If dbname is empty, it will iterate over all databases If tablename is empty (but dbname is not), it will iterate over all tables in the database

func ReadObjectFromEngine

func ReadObjectFromEngine(ctx context.Context, eng engine.Engine, objectName string, offset int64, size int64) ([]byte, error)

ReadObjectFromEngine reads the object file from engine's fileservice and returns its content as []byte offset: 读取偏移,>=0 size: 读取大小,必须 > 0 且 <= 100MB (getObjectChunkSize) This is a version that doesn't require Session

func ResolveSnapshotWithSnapshotNameWithoutSession

func ResolveSnapshotWithSnapshotNameWithoutSession(
	ctx context.Context,
	snapshotName string,
	sqlExecutor executor.SQLExecutor,
	txnOp client.TxnOperator,
) (*timestamp.Timestamp, error)

ResolveSnapshotWithSnapshotNameWithoutSession resolves snapshot name to timestamp without requiring Session This is a version that can be used by test utilities

func RewriteError added in v1.0.0

func RewriteError(err error, username string) (uint16, string, string)

RewriteError rewrites the error info

func SetDebugHTTPAddr

func SetDebugHTTPAddr(addr string)

SetDebugHTTPAddr is called from cmd/mo-service/main.go to store the debug HTTP listen address for use by GPU offload manifest URL generation.

func SetPUForExternalUT

func SetPUForExternalUT(service string, pu *config.ParameterUnit)

func SetSessionAlloc

func SetSessionAlloc(service string, s Allocator)

func SetSpecialUser added in v0.6.0

func SetSpecialUser(username string, password []byte)

SetSpecialUser saves the user for initialization !!!NOTE: userName must not contain Colon ':'

func ShouldSwitchToSysAccount

func ShouldSwitchToSysAccount(dbName string, tableName string) bool

for system_metrics.metric and system.statement_info, it is special under the no sys account, should switch into the sys account first.

func TransformStdTimeString

func TransformStdTimeString(tsStr string) (string, error)

func Upload added in v1.2.0

func Upload(ses FeSession, execCtx *ExecCtx, localPath string, storageDir string) (string, error)

func WildcardMatch added in v0.5.0

func WildcardMatch(pattern, target string) bool

WildcardMatch implements wildcard pattern match algorithm. pattern and target are ascii characters TODO: add \_ and \%

func WithBackgroundExec

func WithBackgroundExec(
	ctx context.Context,
	ses *Session,
	fn func(context.Context, *Session, BackgroundExec) error,
) (err error)

func WithWaitActiveCost added in v1.2.0

func WithWaitActiveCost(cost time.Duration) marshalPlanOptions

Types

type AccountRoutineManager added in v0.8.0

type AccountRoutineManager struct {
	// contains filtered or unexported fields
}

func (*AccountRoutineManager) AlterRoutineStatue added in v1.0.0

func (ar *AccountRoutineManager) AlterRoutineStatue(tenantID int64, status string)

func (*AccountRoutineManager) EnKillQueue added in v1.0.0

func (ar *AccountRoutineManager) EnKillQueue(tenantID int64, version uint64)

type Allocator

type Allocator interface {
	// Alloc allocate a []byte with len(data) >= size, and the returned []byte cannot
	// be expanded in use.
	Alloc(capacity int) ([]byte, error)
	// Free the allocated memory
	Free([]byte)
}

type BackgroundExec added in v0.6.0

type BackgroundExec interface {
	Close()
	Exec(context.Context, string) error
	ExecRestore(context.Context, string, uint32, uint32) error
	ExecStmt(context.Context, tree.Statement) error
	GetExecResultSet() []interface{}
	ClearExecResultSet()
	GetExecStatsArray() statistic.StatsArray
	SetRestore(b bool)

	GetExecResultBatches() []*batch.Batch
	ClearExecResultBatches()
	Clear()
	Service() string
}

BackgroundExec executes the sql in background session without network output.

type BackgroundExecOption

type BackgroundExecOption struct {
	// contains filtered or unexported fields
}

type BaseService added in v1.0.0

type BaseService interface {
	// ID returns the ID of the service.
	ID() string
	// SQLAddress returns the SQL listen address of the service.
	SQLAddress() string
	// SessionMgr returns the session manager instance of the service.
	SessionMgr() *queryservice.SessionManager
	// CheckTenantUpgrade used to upgrade tenant metadata if the tenant is old version.
	CheckTenantUpgrade(ctx context.Context, tenantID int64) error
	// GetFinalVersion Get mo final version, which is based on the current code
	GetFinalVersion() string
	// UpgradeTenant used to upgrade tenant
	UpgradeTenant(ctx context.Context, tenantName string, retryCount uint32, isALLAccount bool) error
}

BaseService is an interface which indicates that the instance is the base CN service and should implement the following methods.

type BatchByte added in v0.8.0

type BatchByte struct {
	// contains filtered or unexported fields
}

type BinaryWriter added in v1.2.1

type BinaryWriter interface {
	MediaWriter
}

BinaryWriter write batch into fileservice

type BufferAllocator

type BufferAllocator struct {
	// contains filtered or unexported fields
}

func (*BufferAllocator) Alloc

func (ba *BufferAllocator) Alloc(size int) ([]byte, error)

func (*BufferAllocator) Free

func (ba *BufferAllocator) Free(buf []byte)

type CDCCreateTaskOptions

type CDCCreateTaskOptions struct {
	TaskName     string
	TaskId       string
	UserInfo     *CDCUserInfo
	Exclude      string
	StartTs      string
	EndTs        string
	MaxSqlLength int64
	PitrTables   string // json encoded pitr tables: cdc2.PatternTuples
	SrcUri       string // json encoded source uri: cdc2.UriInfo
	SrcUriInfo   cdc.UriInfo
	SinkUri      string // json encoded sink uri: cdc2.UriInfo
	SinkUriInfo  cdc.UriInfo
	ExtraOpts    string // json encoded extra opts: map[string]any
	SinkType     string
	NoFull       bool
	ConfigFile   string

	// control options
	UseConsole bool
}

func (*CDCCreateTaskOptions) BuildTaskDetails

func (opts *CDCCreateTaskOptions) BuildTaskDetails() (details *task.Details, err error)

func (*CDCCreateTaskOptions) BuildTaskMetadata

func (opts *CDCCreateTaskOptions) BuildTaskMetadata() task.TaskMetadata

func (*CDCCreateTaskOptions) Reset

func (opts *CDCCreateTaskOptions) Reset()

func (*CDCCreateTaskOptions) ToInsertTaskSQL

func (opts *CDCCreateTaskOptions) ToInsertTaskSQL(
	ctx context.Context,
	tx taskservice.SqlExecutor,
	service string,
) (sql string, err error)

func (*CDCCreateTaskOptions) ValidateAndFill

func (opts *CDCCreateTaskOptions) ValidateAndFill(
	ctx context.Context,
	ses *Session,
	req *CDCCreateTaskRequest,
) (err error)

type CDCCreateTaskRequest

type CDCCreateTaskRequest = tree.CreateCDC

type CDCDao

type CDCDao struct {
	// contains filtered or unexported fields
}

func NewCDCDao

func NewCDCDao(
	ses *Session,
	opts ...CDCDaoOption,
) (t CDCDao)

func (*CDCDao) BuildCreateOpts

func (t *CDCDao) BuildCreateOpts(
	ctx context.Context, req *CDCCreateTaskRequest,
) (opts CDCCreateTaskOptions, err error)

func (*CDCDao) CreateTask

func (t *CDCDao) CreateTask(
	ctx context.Context,
	req *CDCCreateTaskRequest,
) (err error)

func (*CDCDao) DeleteManyWatermark

func (t *CDCDao) DeleteManyWatermark(
	ctx context.Context,
	keys map[taskservice.CDCTaskKey]struct{},
) (deletedCnt int64, err error)

func (*CDCDao) DeleteTaskAndWatermark

func (t *CDCDao) DeleteTaskAndWatermark(
	ctx context.Context,
	accountId uint64,
	taskName string,
	keys map[taskservice.CDCTaskKey]struct{},
) (res DeleteCDCArtifactsResult, err error)

func (*CDCDao) DeleteTaskByName

func (t *CDCDao) DeleteTaskByName(
	ctx context.Context,
	accountId uint64,
	taskName string,
) (deletedCnt int64, err error)

if taskName is empty, delete all tasks belong to accountId

func (*CDCDao) GetTaskKeys

func (t *CDCDao) GetTaskKeys(
	ctx context.Context,
	accountId uint64,
	taskName string,
	keys map[taskservice.CDCTaskKey]struct{},
	ifExists bool,
) (cnt int64, err error)

func (*CDCDao) GetTaskWatermark

func (t *CDCDao) GetTaskWatermark(
	ctx context.Context,
	accountId uint64,
	taskId string,
) (res string, err error)

func (*CDCDao) MustGetBGExecutor

func (t *CDCDao) MustGetBGExecutor(ctx context.Context) BackgroundExec

func (*CDCDao) MustGetSQLExecutor

func (t *CDCDao) MustGetSQLExecutor(ctx context.Context) taskservice.SqlExecutor

func (*CDCDao) MustGetTaskService

func (t *CDCDao) MustGetTaskService() taskservice.TaskService

func (*CDCDao) PrepareUpdateTask

func (t *CDCDao) PrepareUpdateTask(
	ctx context.Context,
	accountId uint64,
	taskName string,
	targetState string,
) (affectedRows int64, err error)

update `state` only

func (*CDCDao) ShowTasks

func (t *CDCDao) ShowTasks(
	ctx context.Context,
	req *CDCShowTaskRequest,
) (err error)

type CDCDaoOption

type CDCDaoOption func(*CDCDao)

func WithBGExecutor

func WithBGExecutor(bgExecutor BackgroundExec) CDCDaoOption

func WithSQLExecutor

func WithSQLExecutor(sqlExecutor taskservice.SqlExecutor) CDCDaoOption

type CDCShowTaskRequest

type CDCShowTaskRequest = tree.ShowCDC

type CDCTaskExecutor

type CDCTaskExecutor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCDCTaskExecutor

func NewCDCTaskExecutor(
	logger *zap.Logger,
	ie ie.InternalExecutor,
	spec *task.CreateCdcDetails,
	cnUUID string,
	fileService fileservice.FileService,
	cnTxnClient client.TxnClient,
	cnEngine engine.Engine,
	cdcMp *mpool.MPool,
) *CDCTaskExecutor

func (*CDCTaskExecutor) Cancel

func (exec *CDCTaskExecutor) Cancel() error

Cancel cdc task

func (*CDCTaskExecutor) Pause

func (exec *CDCTaskExecutor) Pause() error

Pause cdc task

func (*CDCTaskExecutor) Restart

func (exec *CDCTaskExecutor) Restart() error

Restart cdc task from init watermark

func (*CDCTaskExecutor) Resume

func (exec *CDCTaskExecutor) Resume() error

Resume cdc task from last recorded watermark

func (*CDCTaskExecutor) Start

func (exec *CDCTaskExecutor) Start(rootCtx context.Context) (err error)

type CDCUserInfo

type CDCUserInfo struct {
	UserName    string
	AccountId   uint32
	AccountName string
}

type CloseExportData

type CloseExportData struct {
	// contains filtered or unexported fields
}

func NewCloseExportData

func NewCloseExportData() *CloseExportData

func (*CloseExportData) Close

func (cld *CloseExportData) Close()

func (*CloseExportData) Open

func (cld *CloseExportData) Open()

type CloseFlag

type CloseFlag struct {
	// contains filtered or unexported fields
}

func (*CloseFlag) Close

func (cf *CloseFlag) Close()

func (*CloseFlag) IsClosed

func (cf *CloseFlag) IsClosed() bool

func (*CloseFlag) IsOpened

func (cf *CloseFlag) IsOpened() bool

func (*CloseFlag) Open

func (cf *CloseFlag) Open()

type Collation added in v1.1.1

type Collation struct {
	// contains filtered or unexported fields
}

type Column

type Column interface {
	SetName(string)
	Name() string

	//data type: MYSQL_TYPE_XXXX
	SetColumnType(defines.MysqlType)
	ColumnType() defines.MysqlType

	//the max count of spaces
	SetLength(uint32)
	Length() uint32

	//unsigned / signed for digital types
	//default: signed
	//true: signed; false: unsigned
	SetSigned(bool)
	IsSigned() bool
}

type ColumnImpl

type ColumnImpl struct {
	// contains filtered or unexported fields
}

func (*ColumnImpl) ColumnType

func (ci *ColumnImpl) ColumnType() defines.MysqlType

func (*ColumnImpl) Length

func (ci *ColumnImpl) Length() uint32

func (*ColumnImpl) Name

func (ci *ColumnImpl) Name() string

func (*ColumnImpl) SetColumnType

func (ci *ColumnImpl) SetColumnType(colType defines.MysqlType)

func (*ColumnImpl) SetLength

func (ci *ColumnImpl) SetLength(l uint32)

func (*ColumnImpl) SetName

func (ci *ColumnImpl) SetName(name string)

type ColumnInfo added in v0.5.0

type ColumnInfo interface {
	GetName() string

	GetType() types.T
}

type ColumnSlices

type ColumnSlices struct {
	// contains filtered or unexported fields
}

func (*ColumnSlices) Close

func (slices *ColumnSlices) Close()

func (*ColumnSlices) ColumnCount

func (slices *ColumnSlices) ColumnCount() int

func (*ColumnSlices) GetBool

func (slices *ColumnSlices) GetBool(rowIdx uint64, colIdx uint64) (bool, error)

func (*ColumnSlices) GetBytesBased

func (slices *ColumnSlices) GetBytesBased(r uint64, i uint64) ([]byte, error)

func (*ColumnSlices) GetDate

func (slices *ColumnSlices) GetDate(r uint64, i uint64) (types.Date, error)

func (*ColumnSlices) GetDatetime

func (slices *ColumnSlices) GetDatetime(r uint64, i uint64) (string, error)

func (*ColumnSlices) GetDecimal

func (slices *ColumnSlices) GetDecimal(r uint64, i uint64) (string, error)

func (*ColumnSlices) GetFloat32

func (slices *ColumnSlices) GetFloat32(r uint64, i uint64) (float32, error)

func (*ColumnSlices) GetFloat64

func (slices *ColumnSlices) GetFloat64(r uint64, i uint64) (float64, error)

func (*ColumnSlices) GetInt64

func (slices *ColumnSlices) GetInt64(r uint64, i uint64) (int64, error)

func (*ColumnSlices) GetSliceIdx

func (slices *ColumnSlices) GetSliceIdx(colIdx uint64) int

func (*ColumnSlices) GetStringBased

func (slices *ColumnSlices) GetStringBased(r uint64, i uint64) (string, error)

func (*ColumnSlices) GetTime

func (slices *ColumnSlices) GetTime(r uint64, i uint64) (string, error)

func (*ColumnSlices) GetTimestamp

func (slices *ColumnSlices) GetTimestamp(r uint64, i uint64, timeZone *time.Location) (string, error)

func (*ColumnSlices) GetType

func (slices *ColumnSlices) GetType(colIdx uint64) *types.Type

func (*ColumnSlices) GetUUID

func (slices *ColumnSlices) GetUUID(r uint64, i uint64) (string, error)

func (*ColumnSlices) GetUint64

func (slices *ColumnSlices) GetUint64(r uint64, i uint64) (uint64, error)

func (*ColumnSlices) GetVector

func (slices *ColumnSlices) GetVector(colIdx uint64) *vector.Vector

func (*ColumnSlices) IsConst

func (slices *ColumnSlices) IsConst(colIdx uint64) bool

func (*ColumnSlices) IsNull

func (slices *ColumnSlices) IsNull(rowIdx int, colIdx int) bool

type CommandType added in v0.6.0

type CommandType uint8
const (
	COM_SLEEP               CommandType = 0x00
	COM_QUIT                CommandType = 0x01
	COM_INIT_DB             CommandType = 0x02
	COM_QUERY               CommandType = 0x03
	COM_FIELD_LIST          CommandType = 0x04
	COM_CREATE_DB           CommandType = 0x05
	COM_DROP_DB             CommandType = 0x06
	COM_REFRESH             CommandType = 0x07
	COM_SHUTDOWN            CommandType = 0x08
	COM_STATISTICS          CommandType = 0x09
	COM_PROCESS_INFO        CommandType = 0x0a
	COM_CONNECT             CommandType = 0x0b
	COM_PROCESS_KILL        CommandType = 0x0c
	COM_DEBUG               CommandType = 0x0d
	COM_PING                CommandType = 0x0e
	COM_TIME                CommandType = 0x0f
	COM_DELAYED_INSERT      CommandType = 0x10
	COM_CHANGE_USER         CommandType = 0x11
	COM_REGISTER_SLAVE      CommandType = 0x15
	COM_STMT_PREPARE        CommandType = 0x16
	COM_STMT_EXECUTE        CommandType = 0x17
	COM_STMT_SEND_LONG_DATA CommandType = 0x18
	COM_STMT_CLOSE          CommandType = 0x19
	COM_STMT_RESET          CommandType = 0x1a
	COM_SET_OPTION          CommandType = 0x1b
	COM_STMT_FETCH          CommandType = 0x1c
	COM_DAEMON              CommandType = 0x1d
	COM_BINLOG_DUMP_GTID    CommandType = 0x1e
	COM_RESET_CONNECTION    CommandType = 0x1f
)

text protocol in mysql client protocol iteration command

func (CommandType) String added in v0.6.0

func (ct CommandType) String() string

type Compile

type Compile interface {
	Run(uint64) (*util2.RunResult, error)
	GetPlan() *plan.Plan
	Release()
	SetOriginSQL(string)
}

type ComputationRunner added in v0.5.0

type ComputationRunner interface {
	// todo: remove the ts next day, that's useless.
	Run(ts uint64) (*util.RunResult, error)
}

type ComputationWrapper

type ComputationWrapper interface {
	ComputationRunner
	GetAst() tree.Statement

	GetProcess() *process.Process

	GetColumns(ctx context.Context) ([]interface{}, error)

	Compile(any any, fill func(*batch.Batch, *perfcounter.CounterSet) error) (interface{}, error)

	GetUUID() []byte

	// RecordExecPlan records the execution plan and calculates CU resources, and stores them into statementinfo
	RecordExecPlan(ctx context.Context, phyPlan *models.PhyPlan) error

	// RecordCompoundStmt calculates the CU resources of composite statements, and stores them into statementinfo
	RecordCompoundStmt(ctx context.Context, statsBytes statistic.StatsArray) error

	// StatsCompositeSubStmtResource Statistics on CU resources of sub statements in composite statements
	StatsCompositeSubStmtResource(ctx context.Context) (statsByte statistic.StatsArray)

	SetExplainBuffer(buf *bytes.Buffer)

	GetLoadTag() bool

	GetServerStatus() uint16
	Clear()
	Plan() *plan.Plan
	ResetPlanAndStmt(stmt tree.Statement)
	Free()
	ParamVals() []any
	BinaryExecute() (bool, string) //binary execute for COM_STMT_EXECUTE
}

ComputationWrapper is the wrapper of the computation

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewIOSession

func NewIOSession(conn net.Conn, pu *config.ParameterUnit, service string) (_ *Conn, err error)

NewIOSession create a new io session

func (*Conn) AllocNewBlock

func (c *Conn) AllocNewBlock(allocLength int) (err error)

AllocNewBlock allocates memory and push it into the dynamic buffer

func (*Conn) Append

func (c *Conn) Append(elems ...byte) (err error)

Append Add bytes to buffer

func (*Conn) AppendPart

func (c *Conn) AppendPart(elems []byte) error

AppendPart is the base method of adding bytes to buffer

func (*Conn) BeginPacket

func (c *Conn) BeginPacket() error

BeginPacket Reserve Header in the buffer

func (*Conn) CheckAllowedPacketSize

func (c *Conn) CheckAllowedPacketSize(totalLength int) error

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) CountFlushPackage

func (c *Conn) CountFlushPackage(n int64)

func (*Conn) CountOutputBytes

func (c *Conn) CountOutputBytes(n int)

func (*Conn) Disconnect

func (c *Conn) Disconnect() error

Disconnect closes the underlying network connection without full cleanup. This is used to forcefully disconnect the client (e.g., on timeout during LOAD DATA).

func (*Conn) FinishedPacket

func (c *Conn) FinishedPacket() error

FinishedPacket Fill in the header and flush if buffer full

func (*Conn) Flush

func (c *Conn) Flush() error

Flush Send buffer to the network

func (*Conn) FlushIfFull

func (c *Conn) FlushIfFull() error

func (*Conn) FreeLoadLocal

func (c *Conn) FreeLoadLocal()

func (*Conn) GetPayloadLength

func (c *Conn) GetPayloadLength() (int, bool)

GetPayloadLength try to get packet header from read buf return:

the packet length
the header is ready or not

func (*Conn) ID

func (c *Conn) ID() uint64

func (*Conn) RawConn

func (c *Conn) RawConn() net.Conn

func (*Conn) Read

func (c *Conn) Read() (_ []byte, err error)

Read reads the complete packet including process the > 16MB packet. return the payload packet format:

|------packet------------------------------------------------------------------| |---3-bytes-payload length---+---1 byte sequence_id---+----------payload-------| if the length pf packet is more that 16MB. there are multiple packets for the same packet.

func (*Conn) ReadFromConn

func (c *Conn) ReadFromConn(buf []byte) (int, error)

ReadFromConn is the base method for receiving from network, calling net.Conn.Read(). The maximum read length is len(buf)

func (*Conn) ReadFromConnWithTimeout

func (c *Conn) ReadFromConnWithTimeout(buf []byte, timeout time.Duration) (int, error)

ReadFromConnWithTimeout reads from the network with a specific timeout. This is used for LOAD DATA LOCAL operations where we need timeout detection.

func (*Conn) ReadIntoReadBuf

func (c *Conn) ReadIntoReadBuf() error

func (*Conn) ReadLoadLocalPacket

func (c *Conn) ReadLoadLocalPacket() (_ []byte, err error)

ReadLoadLocalPacket just for processLoadLocal, reuse memory, and not merge 16MB packets

func (*Conn) ReadNBytesIntoBuf

func (c *Conn) ReadNBytesIntoBuf(buf []byte, n int) error

ReadNBytesIntoBuf reads specified bytes from the network

func (*Conn) ReadNBytesIntoBufWithTimeout

func (c *Conn) ReadNBytesIntoBufWithTimeout(buf []byte, n int, timeout time.Duration) error

ReadNBytesIntoBufWithTimeout reads specified bytes from the network with a timeout. This is used for LOAD DATA LOCAL operations.

func (*Conn) ReadOnePayload

func (c *Conn) ReadOnePayload(payloadLength int) (payload []byte, err error)

ReadOnePayload allocates memory for a payload and reads it

func (*Conn) RemoteAddress

func (c *Conn) RemoteAddress() string

func (*Conn) Reset

func (c *Conn) Reset()

Reset does not release fix buffer but release dynamical buffer and load data local buffer

func (*Conn) SetSession

func (c *Conn) SetSession(ses *Session)

func (*Conn) SetTimeout

func (c *Conn) SetTimeout(d time.Duration)

SetTimeout updates the read timeout used by ReadFromConn.

func (*Conn) UseConn

func (c *Conn) UseConn(conn net.Conn)

func (*Conn) Write

func (c *Conn) Write(payload []byte) error

Write Only OK, EOF, ERROR needs to be sent immediately

func (*Conn) WriteToConn

func (c *Conn) WriteToConn(buf []byte) error

WriteToConn is the base method for write data to network, calling net.Conn.Write().

type ConnType added in v1.0.0

type ConnType int
const (
	ConnTypeUnset    ConnType = 0
	ConnTypeInternal ConnType = 1
	ConnTypeExternal ConnType = 2
)

type CsvWriter added in v1.2.1

type CsvWriter interface {
	MediaWriter
}

CsvWriter write batch into csv file

type DeleteCDCArtifactsResult

type DeleteCDCArtifactsResult struct {
	TaskRows       int64
	WatermarkRows  int64
	LocalTxnOpened bool
}

type ExecCtx added in v1.2.0

type ExecCtx struct {
	// contains filtered or unexported fields
}

func (*ExecCtx) Close added in v1.2.3

func (execCtx *ExecCtx) Close()

type ExecResult added in v0.6.0

type ExecResult interface {
	GetRowCount() uint64

	GetColumnCount() uint64

	GetString(ctx context.Context, rindex, cindex uint64) (string, error)

	GetUint64(ctx context.Context, rindex, cindex uint64) (uint64, error)

	GetInt64(ctx context.Context, rindex, cindex uint64) (int64, error)

	ColumnIsNull(ctx context.Context, rindex, cindex uint64) (bool, error)
}

ExecResult is the result interface of the execution

type ExecutorState

type ExecutorState int

ExecutorState represents the state of a CDCTaskExecutor

const (
	// StateIdle is the initial state after creation
	StateIdle ExecutorState = iota
	// StateStarting is the state when Start() is in progress
	StateStarting
	// StateRunning is the state when the executor is actively running
	StateRunning
	// StatePausing is the state when Pause() is in progress
	StatePausing
	// StatePaused is the state when the executor is paused
	StatePaused
	// StateRestarting is the state when Restart() is in progress
	StateRestarting
	// StateCancelling is the state when Cancel() is in progress
	StateCancelling
	// StateCancelled is the state after Cancel() completes
	StateCancelled
	// StateFailed is the state when Start() or other operations fail
	StateFailed
)

func (ExecutorState) String

func (s ExecutorState) String() string

String returns the string representation of ExecutorState

type ExecutorStateMachine

type ExecutorStateMachine struct {
	// contains filtered or unexported fields
}

ExecutorStateMachine manages state transitions for CDCTaskExecutor

func NewExecutorStateMachine

func NewExecutorStateMachine() *ExecutorStateMachine

NewExecutorStateMachine creates a new state machine in Idle state

func (*ExecutorStateMachine) CanTransition

func (sm *ExecutorStateMachine) CanTransition(t Transition) bool

CanTransition checks if a transition is valid from current state

func (*ExecutorStateMachine) GetErrorMessage

func (sm *ExecutorStateMachine) GetErrorMessage() string

GetErrorMessage returns the error message if in Failed state

func (*ExecutorStateMachine) IsActive

func (sm *ExecutorStateMachine) IsActive() bool

IsActive returns true if the executor is in an active state (not idle, cancelled, or failed)

func (*ExecutorStateMachine) IsRunning

func (sm *ExecutorStateMachine) IsRunning() bool

IsRunning returns true if the executor is in a running state

func (*ExecutorStateMachine) IsState

func (sm *ExecutorStateMachine) IsState(state ExecutorState) bool

IsState checks if current state matches the given state

func (*ExecutorStateMachine) MustTransition

func (sm *ExecutorStateMachine) MustTransition(t Transition)

MustTransition attempts to transition and panics on error Use this only when the transition is guaranteed to be valid

func (*ExecutorStateMachine) SetFailed

func (sm *ExecutorStateMachine) SetFailed(errMsg string) error

SetFailed transitions to Failed state and stores error message

func (*ExecutorStateMachine) State

func (sm *ExecutorStateMachine) State() ExecutorState

State returns the current state

func (*ExecutorStateMachine) String

func (sm *ExecutorStateMachine) String() string

String returns the string representation of the state machine

func (*ExecutorStateMachine) Transition

func (sm *ExecutorStateMachine) Transition(t Transition) error

Transition attempts to transition to a new state Returns error if transition is not allowed

type ExportConfig added in v1.0.0

type ExportConfig struct {

	// curFileSize
	CurFileSize uint64
	Rows        uint64
	FileCnt     uint
	ColumnFlag  []bool
	Symbol      [][]byte
	// default flush size
	DefaultBufSize int64

	FileService fileservice.FileService
	Ctx         context.Context
	AsyncReader *io.PipeReader
	AsyncWriter *io.PipeWriter
	AsyncGroup  *errgroup.Group
	// contains filtered or unexported fields
}

func (*ExportConfig) Close added in v1.2.1

func (ec *ExportConfig) Close()

func (*ExportConfig) Write added in v1.2.1

func (ec *ExportConfig) Write(execCtx *ExecCtx, crs *perfcounter.CounterSet, bat *batch.Batch) error

type FeSession added in v1.2.0

type FeSession interface {
	GetService() string
	GetTimeZone() *time.Location
	GetStatsCache() *plan2.StatsCache
	GetUserName() string
	GetSql() string
	GetAccountId() uint32
	GetTenantInfo() *TenantInfo
	GetConfig(ctx context.Context, varName, dbName, tblName string) (any, error)
	GetBackgroundExec(ctx context.Context, opts ...*BackgroundExecOption) BackgroundExec
	GetRawBatchBackgroundExec(ctx context.Context) BackgroundExec
	GetGlobalSysVars() *SystemVariables
	GetGlobalSysVar(name string) (interface{}, error)
	GetSessionSysVars() *SystemVariables
	GetSessionSysVar(name string) (interface{}, error)
	GetUserDefinedVar(name string) (*UserDefinedVar, error)
	SetUserDefinedVar(name string, value interface{}, sql string) error
	GetDebugString() string
	GetFromRealUser() bool

	GetTenantName() string
	SetTxnId(i []byte)
	GetTxnId() uuid.UUID
	GetStmtId() uuid.UUID
	GetSqlOfStmt() string

	GetResponser() Responser
	GetTxnHandler() *TxnHandler
	GetDatabaseName() string
	SetDatabaseName(db string)
	GetMysqlResultSet() *MysqlResultSet
	SetNewResponse(category int, affectedRows uint64, cmd int, d interface{}, isLastStmt bool) *Response
	GetTxnCompileCtx() *TxnCompilerContext
	GetCmd() CommandType
	IsBackgroundSession() bool
	GetPrepareStmt(ctx context.Context, name string) (*PrepareStmt, error)
	CountPayload(i int)
	RemovePrepareStmt(name string)
	SetShowStmtType(statement ShowStatementType)
	SetSql(sql string)
	GetMemPool() *mpool.MPool
	GetProc() *process.Process
	GetLastInsertID() uint64
	GetSqlHelper() *SqlHelper
	GetBuffer() *buffer.Buffer
	GetStmtProfile() *process.StmtProfile
	CopySeqToProc(proc *process.Process)

	SetMysqlResultSet(mrs *MysqlResultSet)
	GetConnectionID() uint32
	IsDerivedStmt() bool
	SetAccountId(uint32)
	SetPlan(plan *plan.Plan)
	SetData([][]interface{})
	GetIsInternal() bool

	GetUpstream() FeSession

	GetSqlCount() uint64

	GetStmtInfo() *motrace.StatementInfo
	GetTxnInfo() string
	GetUUID() []byte
	SendRows() int64
	SetTStmt(stmt *motrace.StatementInfo)
	GetUUIDString() string
	DisableTrace() bool
	Close()
	Clear()

	EnterFPrint(idx int)
	ExitFPrint(idx int)
	SetStaticTxnInfo(string)
	GetStaticTxnInfo() string
	GetShareTxnBackgroundExec(ctx context.Context, newRawBatch bool) BackgroundExec
	GetMySQLParser() *mysql.MySQLParser
	InitBackExec(txnOp TxnOperator, db string, callBack outputCallBackFunc, opts ...*BackgroundExecOption) BackgroundExec
	GetTempTable(dbName, alias string) (string, bool)
	AddTempTable(dbName, alias, realName string)
	RemoveTempTable(dbName, alias string)
	RemoveTempTableByRealName(realName string)
	SessionLogger
	// contains filtered or unexported methods
}

type FeTxnOption added in v1.2.0

type FeTxnOption struct {
	// contains filtered or unexported fields
}

func (*FeTxnOption) Close added in v1.2.3

func (opt *FeTxnOption) Close()

type GlobalSysVarsMgr added in v1.2.1

type GlobalSysVarsMgr struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*GlobalSysVarsMgr) Get added in v1.2.1

func (m *GlobalSysVarsMgr) Get(accountId uint32, ses *Session, ctx context.Context, bh BackgroundExec) (*SystemVariables, error)

Get return sys vars of accountId

func (*GlobalSysVarsMgr) Put added in v1.2.1

func (m *GlobalSysVarsMgr) Put(accountId uint32, vars *SystemVariables)

type IOPackage

type IOPackage interface {
	// IsLittleEndian the byte order
	//true - littleEndian; false - littleEndian
	IsLittleEndian() bool

	// WriteUint8 writes an uint8 into the buffer at the position
	// returns position + 1
	WriteUint8([]byte, int, uint8) int

	// WriteUint16 writes an uint16 into the buffer at the position
	// returns position + 2
	WriteUint16([]byte, int, uint16) int

	// WriteUint32 writes an uint32 into the buffer at the position
	// returns position + 4
	WriteUint32([]byte, int, uint32) int

	// WriteUint64 writes an uint64 into the buffer at the position
	// returns position + 8
	WriteUint64([]byte, int, uint64) int

	// AppendUint8 appends an uint8 to the buffer
	// returns the buffer
	AppendUint8([]byte, uint8) []byte

	// AppendUint16 appends an uint16 to the buffer
	// returns the buffer
	AppendUint16([]byte, uint16) []byte

	// AppendUint32 appends an uint32 to the buffer
	// returns the buffer
	AppendUint32([]byte, uint32) []byte

	// AppendUint64 appends an uint64 to the buffer
	// returns the buffer
	AppendUint64([]byte, uint64) []byte

	// ReadUint8 reads an uint8 from the buffer at the position
	// returns uint8 value ; pos+1 ; true - decoded successfully or false - failed
	ReadUint8([]byte, int) (uint8, int, bool)

	// ReadUint16 reads an uint16 from the buffer at the position
	// returns uint16 value ; pos+2 ; true - decoded successfully or false - failed
	ReadUint16([]byte, int) (uint16, int, bool)

	// ReadUint32 reads an uint32 from the buffer at the position
	// returns uint32 value ; pos+4 ; true - decoded successfully or false - failed
	ReadUint32([]byte, int) (uint32, int, bool)

	// ReadUint64 reads an uint64 from the buffer at the position
	// returns uint64 value ; pos+8 ; true - decoded successfully or false - failed
	ReadUint64([]byte, int) (uint64, int, bool)
}

type IOPackageImpl

type IOPackageImpl struct {
	// contains filtered or unexported fields
}

IOPackageImpl implements the IOPackage for the basic interaction in the connection

func NewIOPackage

func NewIOPackage(littleEndian bool) *IOPackageImpl

func (*IOPackageImpl) AppendUint8

func (bio *IOPackageImpl) AppendUint8(data []byte, value uint8) []byte

func (*IOPackageImpl) AppendUint16

func (bio *IOPackageImpl) AppendUint16(data []byte, value uint16) []byte

func (*IOPackageImpl) AppendUint32

func (bio *IOPackageImpl) AppendUint32(data []byte, value uint32) []byte

func (*IOPackageImpl) AppendUint64

func (bio *IOPackageImpl) AppendUint64(data []byte, value uint64) []byte

func (*IOPackageImpl) IsLittleEndian

func (bio *IOPackageImpl) IsLittleEndian() bool

func (*IOPackageImpl) ReadUint8

func (bio *IOPackageImpl) ReadUint8(data []byte, pos int) (uint8, int, bool)

func (*IOPackageImpl) ReadUint16

func (bio *IOPackageImpl) ReadUint16(data []byte, pos int) (uint16, int, bool)

func (*IOPackageImpl) ReadUint32

func (bio *IOPackageImpl) ReadUint32(data []byte, pos int) (uint32, int, bool)

func (*IOPackageImpl) ReadUint64

func (bio *IOPackageImpl) ReadUint64(data []byte, pos int) (uint64, int, bool)

func (*IOPackageImpl) WriteUint8

func (bio *IOPackageImpl) WriteUint8(data []byte, pos int, value uint8) int

func (*IOPackageImpl) WriteUint16

func (bio *IOPackageImpl) WriteUint16(data []byte, pos int, value uint16) int

func (*IOPackageImpl) WriteUint32

func (bio *IOPackageImpl) WriteUint32(data []byte, pos int, value uint32) int

func (*IOPackageImpl) WriteUint64

func (bio *IOPackageImpl) WriteUint64(data []byte, pos int, value uint64) int

type InternalCmdCheckSnapshotFlushed

type InternalCmdCheckSnapshotFlushed struct {
	// contains filtered or unexported fields
}

InternalCmdCheckSnapshotFlushed the internal command to check if snapshot is flushed by publication permission Parameters: snapshotName, subscriptionAccountName, publicationName Returns: result (bool)

func (*InternalCmdCheckSnapshotFlushed) Format

func (ic *InternalCmdCheckSnapshotFlushed) Format(ctx *tree.FmtCtx)

func (*InternalCmdCheckSnapshotFlushed) Free

Free implements tree.Statement.

func (*InternalCmdCheckSnapshotFlushed) GetQueryType

func (ic *InternalCmdCheckSnapshotFlushed) GetQueryType() string

func (*InternalCmdCheckSnapshotFlushed) GetStatementType

func (ic *InternalCmdCheckSnapshotFlushed) GetStatementType() string

func (*InternalCmdCheckSnapshotFlushed) StmtKind

func (*InternalCmdCheckSnapshotFlushed) String

type InternalCmdFieldList added in v0.6.0

type InternalCmdFieldList struct {
	// contains filtered or unexported fields
}

InternalCmdFieldList the CMD_FIELD_LIST statement

func (*InternalCmdFieldList) Format added in v0.6.0

func (icfl *InternalCmdFieldList) Format(ctx *tree.FmtCtx)

func (*InternalCmdFieldList) Free added in v1.2.0

func (icfl *InternalCmdFieldList) Free()

Free implements tree.Statement.

func (*InternalCmdFieldList) GetQueryType added in v0.7.0

func (icfl *InternalCmdFieldList) GetQueryType() string

func (*InternalCmdFieldList) GetStatementType added in v0.7.0

func (icfl *InternalCmdFieldList) GetStatementType() string

func (*InternalCmdFieldList) StmtKind added in v1.2.0

func (icfl *InternalCmdFieldList) StmtKind() tree.StmtKind

func (*InternalCmdFieldList) String added in v0.6.0

func (icfl *InternalCmdFieldList) String() string

type InternalCmdGetDatabases

type InternalCmdGetDatabases struct {
	// contains filtered or unexported fields
}

InternalCmdGetDatabases the internal command to get databases by publication permission Parameters: snapshotName, accountName, publicationName, level, dbName, tableName Returns: list of database names covered by the snapshot

func (*InternalCmdGetDatabases) Format

func (ic *InternalCmdGetDatabases) Format(ctx *tree.FmtCtx)

func (*InternalCmdGetDatabases) Free

func (ic *InternalCmdGetDatabases) Free()

Free implements tree.Statement.

func (*InternalCmdGetDatabases) GetQueryType

func (ic *InternalCmdGetDatabases) GetQueryType() string

func (*InternalCmdGetDatabases) GetStatementType

func (ic *InternalCmdGetDatabases) GetStatementType() string

func (*InternalCmdGetDatabases) StmtKind

func (ic *InternalCmdGetDatabases) StmtKind() tree.StmtKind

func (*InternalCmdGetDatabases) String

func (ic *InternalCmdGetDatabases) String() string

type InternalCmdGetDdl

type InternalCmdGetDdl struct {
	// contains filtered or unexported fields
}

InternalCmdGetDdl the internal command to get DDL by publication permission Parameters: snapshotName, subscriptionAccountName, publicationName, level, dbName, tableName Returns: list of DDL records (dbname, tablename, tableid, tablesql)

func (*InternalCmdGetDdl) Format

func (ic *InternalCmdGetDdl) Format(ctx *tree.FmtCtx)

func (*InternalCmdGetDdl) Free

func (ic *InternalCmdGetDdl) Free()

Free implements tree.Statement.

func (*InternalCmdGetDdl) GetQueryType

func (ic *InternalCmdGetDdl) GetQueryType() string

func (*InternalCmdGetDdl) GetStatementType

func (ic *InternalCmdGetDdl) GetStatementType() string

func (*InternalCmdGetDdl) StmtKind

func (ic *InternalCmdGetDdl) StmtKind() tree.StmtKind

func (*InternalCmdGetDdl) String

func (ic *InternalCmdGetDdl) String() string

type InternalCmdGetMoIndexes

type InternalCmdGetMoIndexes struct {
	// contains filtered or unexported fields
}

InternalCmdGetMoIndexes the internal command to get mo_indexes by publication permission Parameters: tableId, subscriptionAccountName, publicationName, snapshotName Returns: list of index records from mo_indexes table

func (*InternalCmdGetMoIndexes) Format

func (ic *InternalCmdGetMoIndexes) Format(ctx *tree.FmtCtx)

func (*InternalCmdGetMoIndexes) Free

func (ic *InternalCmdGetMoIndexes) Free()

Free implements tree.Statement.

func (*InternalCmdGetMoIndexes) GetQueryType

func (ic *InternalCmdGetMoIndexes) GetQueryType() string

func (*InternalCmdGetMoIndexes) GetStatementType

func (ic *InternalCmdGetMoIndexes) GetStatementType() string

func (*InternalCmdGetMoIndexes) StmtKind

func (ic *InternalCmdGetMoIndexes) StmtKind() tree.StmtKind

func (*InternalCmdGetMoIndexes) String

func (ic *InternalCmdGetMoIndexes) String() string

type InternalCmdGetObject

type InternalCmdGetObject struct {
	// contains filtered or unexported fields
}

InternalCmdGetObject the internal command to get object data by publication permission Parameters: subscriptionAccountName, publicationName, objectName, chunkIndex Returns: data chunk from the object file

func (*InternalCmdGetObject) Format

func (ic *InternalCmdGetObject) Format(ctx *tree.FmtCtx)

func (*InternalCmdGetObject) Free

func (ic *InternalCmdGetObject) Free()

Free implements tree.Statement.

func (*InternalCmdGetObject) GetQueryType

func (ic *InternalCmdGetObject) GetQueryType() string

func (*InternalCmdGetObject) GetStatementType

func (ic *InternalCmdGetObject) GetStatementType() string

func (*InternalCmdGetObject) StmtKind

func (ic *InternalCmdGetObject) StmtKind() tree.StmtKind

func (*InternalCmdGetObject) String

func (ic *InternalCmdGetObject) String() string

type InternalCmdGetSnapshotTs

type InternalCmdGetSnapshotTs struct {
	// contains filtered or unexported fields
}

InternalCmdGetSnapshotTs the internal command to get snapshot ts by publication permission

func (*InternalCmdGetSnapshotTs) Format

func (ic *InternalCmdGetSnapshotTs) Format(ctx *tree.FmtCtx)

func (*InternalCmdGetSnapshotTs) Free

func (ic *InternalCmdGetSnapshotTs) Free()

Free implements tree.Statement.

func (*InternalCmdGetSnapshotTs) GetQueryType

func (ic *InternalCmdGetSnapshotTs) GetQueryType() string

func (*InternalCmdGetSnapshotTs) GetStatementType

func (ic *InternalCmdGetSnapshotTs) GetStatementType() string

func (*InternalCmdGetSnapshotTs) StmtKind

func (ic *InternalCmdGetSnapshotTs) StmtKind() tree.StmtKind

func (*InternalCmdGetSnapshotTs) String

func (ic *InternalCmdGetSnapshotTs) String() string

type InternalCmdObjectList

type InternalCmdObjectList struct {
	// contains filtered or unexported fields
}

InternalCmdObjectList the internal command to get object list by publication permission Parameters: snapshotName, againstSnapshotName, subscriptionAccountName, publicationName The handler will use the snapshot's level to determine dbName and tableName scope Returns: object list records

func (*InternalCmdObjectList) Format

func (ic *InternalCmdObjectList) Format(ctx *tree.FmtCtx)

func (*InternalCmdObjectList) Free

func (ic *InternalCmdObjectList) Free()

Free implements tree.Statement.

func (*InternalCmdObjectList) GetQueryType

func (ic *InternalCmdObjectList) GetQueryType() string

func (*InternalCmdObjectList) GetStatementType

func (ic *InternalCmdObjectList) GetStatementType() string

func (*InternalCmdObjectList) StmtKind

func (ic *InternalCmdObjectList) StmtKind() tree.StmtKind

func (*InternalCmdObjectList) String

func (ic *InternalCmdObjectList) String() string

type Interpreter added in v0.8.0

type Interpreter struct {
	// contains filtered or unexported fields
}

func (*Interpreter) EvalCond added in v0.8.0

func (interpreter *Interpreter) EvalCond(cond string) (int, error)

Evaluate condition by sending it to bh with a select

func (*Interpreter) ExecuteSp added in v0.8.0

func (interpreter *Interpreter) ExecuteSp(stmt tree.Statement, dbName string) (err error)

func (*Interpreter) ExecuteStarlark

func (interpreter *Interpreter) ExecuteStarlark(spBody string, dbName string, bg bool) error

func (*Interpreter) FlushParam added in v0.8.0

func (interpreter *Interpreter) FlushParam() error

func (*Interpreter) GetExprString added in v0.8.0

func (interpreter *Interpreter) GetExprString(input tree.Expr) string

func (*Interpreter) GetResult added in v0.8.0

func (interpreter *Interpreter) GetResult() []ExecResult

func (*Interpreter) GetSimpleExprValueWithSpVar added in v0.8.0

func (interpreter *Interpreter) GetSimpleExprValueWithSpVar(e tree.Expr) (interface{}, error)

func (*Interpreter) GetSpVar added in v0.8.0

func (interpreter *Interpreter) GetSpVar(varName string) (interface{}, error)

func (*Interpreter) GetStatementString added in v0.8.0

func (interpreter *Interpreter) GetStatementString(input tree.Statement) string

func (*Interpreter) MatchExpr added in v0.8.0

func (interpreter *Interpreter) MatchExpr(expr tree.Expr) (tree.Expr, error)

Currently we support only binary, unary and comparison expression.

func (*Interpreter) SetSpVar added in v0.8.0

func (interpreter *Interpreter) SetSpVar(name string, value interface{}) error

Return error if variable is not declared yet. PARAM is an exception!

type KillRecord added in v0.8.0

type KillRecord struct {
	// contains filtered or unexported fields
}

func NewKillRecord added in v0.8.0

func NewKillRecord(killtime time.Time, version uint64) KillRecord

type LeakCheckAllocator

type LeakCheckAllocator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLeakCheckAllocator

func NewLeakCheckAllocator() *LeakCheckAllocator

func (*LeakCheckAllocator) Alloc

func (lca *LeakCheckAllocator) Alloc(capacity int) ([]byte, error)

func (*LeakCheckAllocator) CheckBalance

func (lca *LeakCheckAllocator) CheckBalance() bool

func (*LeakCheckAllocator) Free

func (lca *LeakCheckAllocator) Free(bytes []byte)

type MOServer

type MOServer struct {
	// contains filtered or unexported fields
}

MOServer MatrixOne Server

func NewMOServer

func NewMOServer(
	ctx context.Context,
	addr string,
	pu *config.ParameterUnit,
	aicm *defines.AutoIncrCacheManager,
	baseService BaseService,
) *MOServer

func (*MOServer) GetRoutineManager added in v0.7.0

func (mo *MOServer) GetRoutineManager() *RoutineManager

func (*MOServer) IsRunning

func (mo *MOServer) IsRunning() bool

func (*MOServer) Start

func (mo *MOServer) Start() error

func (*MOServer) Stop

func (mo *MOServer) Stop() error

type MediaReader added in v1.2.1

type MediaReader interface {
}

type MediaWriter added in v1.2.1

type MediaWriter interface {
	Write(*ExecCtx, *perfcounter.CounterSet, *batch.Batch) error
	Close()
}

type MemBlock

type MemBlock struct {
	// contains filtered or unexported fields
}

func (*MemBlock) Adjust

func (block *MemBlock) Adjust()

Adjust clean up the packet that have been consumed and move the data forward that has not been consumed

func (*MemBlock) AvailableData

func (block *MemBlock) AvailableData() []byte

AvailableData return the slice of data[readIndex : writeIndex]

func (*MemBlock) AvailableDataAfterHead

func (block *MemBlock) AvailableDataAfterHead() []byte

func (*MemBlock) AvailableDataLen

func (block *MemBlock) AvailableDataLen() int

AvailableDataLen get unconsumed byte from the read buf

func (*MemBlock) AvailableSpace

func (block *MemBlock) AvailableSpace() []byte

func (*MemBlock) AvailableSpaceLen

func (block *MemBlock) AvailableSpaceLen() int

func (*MemBlock) BufferLen

func (block *MemBlock) BufferLen() int

func (*MemBlock) CopyDataAfterHeadOutTo

func (block *MemBlock) CopyDataAfterHeadOutTo(output []byte)

CopyDataAfterHeadOutTo copy the data in read buf to output buffer

func (*MemBlock) CopyDataIn

func (block *MemBlock) CopyDataIn(input []byte)

func (*MemBlock) Head

func (block *MemBlock) Head() []byte

func (*MemBlock) IncReadIndex

func (block *MemBlock) IncReadIndex(n int)

IncReadIndex increase the read index of read buffer

func (*MemBlock) IncWriteIndex

func (block *MemBlock) IncWriteIndex(len int)

func (*MemBlock) IsFull

func (block *MemBlock) IsFull() bool

IsFull check read buf full or not

func (*MemBlock) ReserveHead

func (block *MemBlock) ReserveHead() []byte

func (*MemBlock) ResetIndices

func (block *MemBlock) ResetIndices()

ResetIndices set read and write index = 0

type MemWriter added in v1.2.1

type MemWriter interface {
	MediaWriter
}

MemWriter write batch into memory pool

type MysqlColumn

type MysqlColumn struct {
	ColumnImpl
	// contains filtered or unexported fields
}

func (*MysqlColumn) Charset

func (mc *MysqlColumn) Charset() uint16

func (*MysqlColumn) Decimal

func (mc *MysqlColumn) Decimal() uint8

func (*MysqlColumn) DefaultValue

func (mc *MysqlColumn) DefaultValue() []byte

func (*MysqlColumn) Flag

func (mc *MysqlColumn) Flag() uint16

func (*MysqlColumn) GetAutoIncr added in v0.6.0

func (mc *MysqlColumn) GetAutoIncr() bool

func (*MysqlColumn) IsSigned

func (mc *MysqlColumn) IsSigned() bool

func (*MysqlColumn) OrgName

func (mc *MysqlColumn) OrgName() string

func (*MysqlColumn) OrgTable

func (mc *MysqlColumn) OrgTable() string

func (*MysqlColumn) Schema

func (mc *MysqlColumn) Schema() string

func (*MysqlColumn) SetAutoIncr added in v0.6.0

func (mc *MysqlColumn) SetAutoIncr(s bool)

func (*MysqlColumn) SetCharset

func (mc *MysqlColumn) SetCharset(charset uint16)

func (*MysqlColumn) SetDecimal

func (mc *MysqlColumn) SetDecimal(decimal int32)

func (*MysqlColumn) SetDefaultValue

func (mc *MysqlColumn) SetDefaultValue(defaultValue []byte)

func (*MysqlColumn) SetFlag

func (mc *MysqlColumn) SetFlag(flag uint16)

func (*MysqlColumn) SetOrgName

func (mc *MysqlColumn) SetOrgName(orgName string)

func (*MysqlColumn) SetOrgTable

func (mc *MysqlColumn) SetOrgTable(orgTable string)

func (*MysqlColumn) SetSchema

func (mc *MysqlColumn) SetSchema(schema string)

func (*MysqlColumn) SetSigned

func (mc *MysqlColumn) SetSigned(s bool)

func (*MysqlColumn) SetTable

func (mc *MysqlColumn) SetTable(table string)

func (*MysqlColumn) Table

func (mc *MysqlColumn) Table() string

type MysqlExecutionResult

type MysqlExecutionResult struct {
	// contains filtered or unexported fields
}

the result of the execution

func NewMysqlExecutionResult

func NewMysqlExecutionResult(status uint16, insertid, rows uint64, warnings uint16, mrs *MysqlResultSet) *MysqlExecutionResult

func (*MysqlExecutionResult) AffectedRows

func (mer *MysqlExecutionResult) AffectedRows() uint64

func (*MysqlExecutionResult) InsertID

func (mer *MysqlExecutionResult) InsertID() uint64

func (*MysqlExecutionResult) Mrs

func (*MysqlExecutionResult) SetAffectedRows

func (mer *MysqlExecutionResult) SetAffectedRows(affectedRows uint64)

func (*MysqlExecutionResult) SetInsertID

func (mer *MysqlExecutionResult) SetInsertID(insertID uint64)

func (*MysqlExecutionResult) SetMrs

func (mer *MysqlExecutionResult) SetMrs(mrs *MysqlResultSet)

func (*MysqlExecutionResult) SetStatus

func (mer *MysqlExecutionResult) SetStatus(status uint16)

func (*MysqlExecutionResult) SetWarnings

func (mer *MysqlExecutionResult) SetWarnings(warnings uint16)

func (*MysqlExecutionResult) Status

func (mer *MysqlExecutionResult) Status() uint16

func (*MysqlExecutionResult) Warnings

func (mer *MysqlExecutionResult) Warnings() uint16

type MysqlHelper

type MysqlHelper interface {
	MakeColumnDefData(context.Context, []*plan.ColDef) ([][]byte, error)
}

type MysqlPayloadWriter added in v1.2.1

type MysqlPayloadWriter interface {
	OpenRow() error
	CloseRow() error
	OpenPayload() error
	FillPayload() error
	ClosePayload(bool) error
}

MysqlPayloadWriter make final payload for the packet

type MysqlProtocolImpl

type MysqlProtocolImpl struct {
	SV *config.FrontendParameters
	// contains filtered or unexported fields
}

func NewMysqlClientProtocol

func NewMysqlClientProtocol(sid string, connectionID uint32, tcp *Conn, maxBytesToFlush int, SV *config.FrontendParameters) *MysqlProtocolImpl

func (*MysqlProtocolImpl) AddFlushBytes added in v1.0.0

func (ds *MysqlProtocolImpl) AddFlushBytes(b uint64)

func (*MysqlProtocolImpl) AddSequenceId added in v0.6.0

func (mp *MysqlProtocolImpl) AddSequenceId(a uint8)

func (*MysqlProtocolImpl) Authenticate added in v0.8.0

func (mp *MysqlProtocolImpl) Authenticate(ctx context.Context) error

func (*MysqlProtocolImpl) CalculateOutTrafficBytes added in v1.0.0

func (mp *MysqlProtocolImpl) CalculateOutTrafficBytes(reset bool) (bytes int64, packets int64)

CalculateOutTrafficBytes calculate the bytes of the last out traffic, the number of mysql packets return 0 value, if the connection is closed.

packet cnt has 3 part: 1st part: flush op cnt. 2nd part: upload part, calculation = payload / 16KiB

3rd part [mo 2.0] 3.1: response part, calculation = sendByte / (16KiB - 66B)

  • use net.Listener raw api.
  • discard ioCopyBufferSize logic.

3.2: output csv

  • fill with ExportDataDefaultFlushSize size, do once flush.

[mo 1.2, 1.1.*] 3rd part: response part, calculation = sendByte / 4KiB

  • ioCopyBufferSize currently is 4096 Byte, which is the option for goetty_buf.ByteBuf, set by goetty_buf.WithIOCopyBufferSize(...). goetty_buf.ByteBuf.WriteTo(...) will call by io.CopyBuffer(...) if do Conn.Flush().
  • If ioCopyBufferSize is changed, you should see the calling of goetty.NewApplicationWithListenAddress(...) in NewMOServer()

func (*MysqlProtocolImpl) Close added in v1.2.1

func (mp *MysqlProtocolImpl) Close()

func (*MysqlProtocolImpl) ConnectionID added in v1.2.1

func (mp *MysqlProtocolImpl) ConnectionID() uint32

func (*MysqlProtocolImpl) Disconnect

func (mp *MysqlProtocolImpl) Disconnect() error

Disconnect closes the underlying network connection to forcefully disconnect the client.

func (*MysqlProtocolImpl) Free

func (mp *MysqlProtocolImpl) Free(buf []byte)

func (*MysqlProtocolImpl) FreeLoadLocal

func (mp *MysqlProtocolImpl) FreeLoadLocal()

func (*MysqlProtocolImpl) GetAuthResponse

func (mp *MysqlProtocolImpl) GetAuthResponse() []byte

func (*MysqlProtocolImpl) GetAuthString

func (mp *MysqlProtocolImpl) GetAuthString() []byte

func (*MysqlProtocolImpl) GetBool added in v1.2.1

func (mp *MysqlProtocolImpl) GetBool(id PropertyID) bool

func (*MysqlProtocolImpl) GetCapability added in v0.6.0

func (mp *MysqlProtocolImpl) GetCapability() uint32

func (*MysqlProtocolImpl) GetConnectAttrs added in v0.8.0

func (mp *MysqlProtocolImpl) GetConnectAttrs() map[string]string

func (*MysqlProtocolImpl) GetDatabaseName

func (mp *MysqlProtocolImpl) GetDatabaseName() string

func (*MysqlProtocolImpl) GetDebugString added in v1.2.1

func (mp *MysqlProtocolImpl) GetDebugString() string

func (*MysqlProtocolImpl) GetSalt added in v1.2.1

func (mp *MysqlProtocolImpl) GetSalt() []byte

func (*MysqlProtocolImpl) GetSequenceId added in v0.6.0

func (mp *MysqlProtocolImpl) GetSequenceId() uint8

func (*MysqlProtocolImpl) GetSession added in v0.6.0

func (mp *MysqlProtocolImpl) GetSession() *Session

func (*MysqlProtocolImpl) GetStr added in v1.2.1

func (mp *MysqlProtocolImpl) GetStr(id PropertyID) string

func (*MysqlProtocolImpl) GetTcpConnection added in v1.2.1

func (mp *MysqlProtocolImpl) GetTcpConnection() *Conn

func (*MysqlProtocolImpl) GetU8 added in v1.2.1

func (mp *MysqlProtocolImpl) GetU8(id PropertyID) uint8

func (*MysqlProtocolImpl) GetU32 added in v1.2.1

func (mp *MysqlProtocolImpl) GetU32(id PropertyID) uint32

func (*MysqlProtocolImpl) GetUserName

func (mp *MysqlProtocolImpl) GetUserName() string

func (*MysqlProtocolImpl) HandleHandshake added in v0.7.0

func (mp *MysqlProtocolImpl) HandleHandshake(ctx context.Context, payload []byte) (bool, error)

func (*MysqlProtocolImpl) IsEstablished added in v1.2.1

func (mp *MysqlProtocolImpl) IsEstablished() bool

func (*MysqlProtocolImpl) IsTlsEstablished added in v1.2.1

func (mp *MysqlProtocolImpl) IsTlsEstablished() bool

func (*MysqlProtocolImpl) MakeColumnDefData

func (mp *MysqlProtocolImpl) MakeColumnDefData(ctx context.Context, columns []*planPb.ColDef) ([][]byte, error)

func (*MysqlProtocolImpl) MakeEOFPayload added in v0.8.0

func (mp *MysqlProtocolImpl) MakeEOFPayload(warnings, status uint16) []byte

MakeEOFPayload exposes (*MysqlProtocolImpl).makeEOFPayload() function.

func (*MysqlProtocolImpl) MakeErrPayload added in v0.8.0

func (mp *MysqlProtocolImpl) MakeErrPayload(errCode uint16, sqlState, errorMessage string) []byte

MakeErrPayload exposes (*MysqlProtocolImpl).makeErrPayload() function.

func (*MysqlProtocolImpl) MakeHandshakePayload added in v0.8.0

func (mp *MysqlProtocolImpl) MakeHandshakePayload() []byte

MakeHandshakePayload exposes (*MysqlProtocolImpl).makeHandshakeV10Payload() function.

func (*MysqlProtocolImpl) MakeOKPayload added in v0.8.0

func (mp *MysqlProtocolImpl) MakeOKPayload(affectedRows, lastInsertId uint64, statusFlags, warnings uint16, message string) []byte

MakeOKPayload exposes (*MysqlProtocolImpl).makeOKPayload() function.

func (*MysqlProtocolImpl) ParseExecuteData added in v0.6.0

func (mp *MysqlProtocolImpl) ParseExecuteData(ctx context.Context, proc *process.Process, stmt *PrepareStmt, data []byte, pos int) error

func (*MysqlProtocolImpl) ParseSendLongData added in v0.8.0

func (mp *MysqlProtocolImpl) ParseSendLongData(ctx context.Context, proc *process.Process, stmt *PrepareStmt, data []byte, pos int) error

func (*MysqlProtocolImpl) Peer added in v1.2.1

func (mp *MysqlProtocolImpl) Peer() string

func (*MysqlProtocolImpl) Read added in v1.2.1

func (mp *MysqlProtocolImpl) Read() ([]byte, error)

func (*MysqlProtocolImpl) ReadIntLenEnc added in v0.8.1

func (mp *MysqlProtocolImpl) ReadIntLenEnc(data []byte, pos int) (uint64, int, bool)

func (*MysqlProtocolImpl) ReadLoadLocalPacket

func (mp *MysqlProtocolImpl) ReadLoadLocalPacket() ([]byte, error)

func (*MysqlProtocolImpl) Reset

func (mp *MysqlProtocolImpl) Reset(ses *Session)

Reset implements the MysqlWriter interface.

func (*MysqlProtocolImpl) ResetStatistics added in v0.7.0

func (mp *MysqlProtocolImpl) ResetStatistics()

func (*MysqlProtocolImpl) SendColumnCountPacket

func (mp *MysqlProtocolImpl) SendColumnCountPacket(count uint64) error

SendColumnCountPacket makes the column count packet

func (*MysqlProtocolImpl) SendColumnDefinitionPacket

func (mp *MysqlProtocolImpl) SendColumnDefinitionPacket(ctx context.Context, column Column, cmd int) ([]byte, error)

SendColumnDefinitionPacket the server send the column definition to the client

func (*MysqlProtocolImpl) SendEOFPacketIf

func (mp *MysqlProtocolImpl) SendEOFPacketIf(warnings, status uint16) error

func (*MysqlProtocolImpl) SendPrepareResponse added in v0.6.0

func (mp *MysqlProtocolImpl) SendPrepareResponse(ctx context.Context, stmt *PrepareStmt) error

func (*MysqlProtocolImpl) SendResponse

func (mp *MysqlProtocolImpl) SendResponse(ctx context.Context, resp *Response) error

func (*MysqlProtocolImpl) SendResultSetTextBatchRow

func (mp *MysqlProtocolImpl) SendResultSetTextBatchRow(mrs *MysqlResultSet, cnt uint64) error

the server send group row of the result set as an independent packet thread safe

func (*MysqlProtocolImpl) SendResultSetTextRow

func (mp *MysqlProtocolImpl) SendResultSetTextRow(mrs *MysqlResultSet, r uint64) error

the server send every row of the result set as an independent packet thread safe

func (*MysqlProtocolImpl) SetBool added in v1.2.1

func (mp *MysqlProtocolImpl) SetBool(id PropertyID, val bool)

func (*MysqlProtocolImpl) SetCapability added in v1.1.1

func (mp *MysqlProtocolImpl) SetCapability(cap uint32)

func (*MysqlProtocolImpl) SetDatabaseName

func (mp *MysqlProtocolImpl) SetDatabaseName(s string)

func (*MysqlProtocolImpl) SetEstablished added in v1.2.1

func (mp *MysqlProtocolImpl) SetEstablished()

func (*MysqlProtocolImpl) SetSalt added in v1.2.1

func (mp *MysqlProtocolImpl) SetSalt(s []byte)

SetSalt updates the salt value. This happens with proxy mode enabled.

func (*MysqlProtocolImpl) SetSequenceID added in v0.6.0

func (mp *MysqlProtocolImpl) SetSequenceID(value uint8)

func (*MysqlProtocolImpl) SetSession added in v0.6.0

func (mp *MysqlProtocolImpl) SetSession(ses *Session)

func (*MysqlProtocolImpl) SetStr added in v1.2.1

func (mp *MysqlProtocolImpl) SetStr(id PropertyID, val string)

func (*MysqlProtocolImpl) SetTlsEstablished added in v1.2.1

func (mp *MysqlProtocolImpl) SetTlsEstablished()

func (*MysqlProtocolImpl) SetU8 added in v1.2.1

func (mp *MysqlProtocolImpl) SetU8(id PropertyID, val uint8)

func (*MysqlProtocolImpl) SetU32 added in v1.2.1

func (mp *MysqlProtocolImpl) SetU32(id PropertyID, v uint32)

func (*MysqlProtocolImpl) SetUserName

func (mp *MysqlProtocolImpl) SetUserName(s string)

func (*MysqlProtocolImpl) String

func (ds *MysqlProtocolImpl) String() string

func (*MysqlProtocolImpl) UpdateCtx added in v1.2.1

func (mp *MysqlProtocolImpl) UpdateCtx(ctx context.Context)

func (*MysqlProtocolImpl) UseConn

func (mp *MysqlProtocolImpl) UseConn(conn net.Conn)

func (*MysqlProtocolImpl) Write added in v1.2.1

func (mp *MysqlProtocolImpl) Write(execCtx *ExecCtx, crs *perfcounter.CounterSet, bat *batch.Batch) error

func (*MysqlProtocolImpl) WriteBinaryRow added in v1.2.1

func (mp *MysqlProtocolImpl) WriteBinaryRow() error

func (*MysqlProtocolImpl) WriteColumnDef added in v1.2.1

func (mp *MysqlProtocolImpl) WriteColumnDef(ctx context.Context, column Column, i int) error

func (*MysqlProtocolImpl) WriteColumnDefBytes

func (mp *MysqlProtocolImpl) WriteColumnDefBytes(payload []byte) error

func (*MysqlProtocolImpl) WriteEOF added in v1.2.1

func (mp *MysqlProtocolImpl) WriteEOF(warnings, status uint16) error

func (*MysqlProtocolImpl) WriteEOFIF added in v1.2.1

func (mp *MysqlProtocolImpl) WriteEOFIF(warnings uint16, status uint16) error

func (*MysqlProtocolImpl) WriteEOFIFAndNoFlush

func (mp *MysqlProtocolImpl) WriteEOFIFAndNoFlush(warnings uint16, status uint16) error

func (*MysqlProtocolImpl) WriteEOFOrOK added in v1.2.1

func (mp *MysqlProtocolImpl) WriteEOFOrOK(warnings uint16, status uint16) error

func (*MysqlProtocolImpl) WriteERR added in v1.2.1

func (mp *MysqlProtocolImpl) WriteERR(errorCode uint16, sqlState, errorMessage string) error

func (*MysqlProtocolImpl) WriteHandshake added in v1.2.1

func (mp *MysqlProtocolImpl) WriteHandshake() error

func (*MysqlProtocolImpl) WriteLengthEncodedNumber added in v1.2.1

func (mp *MysqlProtocolImpl) WriteLengthEncodedNumber(u uint64) error

func (*MysqlProtocolImpl) WriteLocalInfileRequest added in v1.2.1

func (mp *MysqlProtocolImpl) WriteLocalInfileRequest(filename string) error

func (*MysqlProtocolImpl) WriteOK added in v1.2.1

func (mp *MysqlProtocolImpl) WriteOK(affectedRows, lastInsertId uint64, status, warnings uint16, message string) error

func (*MysqlProtocolImpl) WriteOKtWithEOF added in v1.2.1

func (mp *MysqlProtocolImpl) WriteOKtWithEOF(affectedRows, lastInsertId uint64, status, warnings uint16, message string) error

func (*MysqlProtocolImpl) WritePacket added in v0.8.0

func (mp *MysqlProtocolImpl) WritePacket(payload []byte) error

WritePacket exposes (*MysqlProtocolImpl).writePackets() function.

func (*MysqlProtocolImpl) WritePrepareResponse added in v1.2.1

func (mp *MysqlProtocolImpl) WritePrepareResponse(ctx context.Context, stmt *PrepareStmt) error

func (*MysqlProtocolImpl) WriteResponse added in v1.2.1

func (mp *MysqlProtocolImpl) WriteResponse(ctx context.Context, resp *Response) error

func (*MysqlProtocolImpl) WriteResultSetRow added in v1.2.1

func (mp *MysqlProtocolImpl) WriteResultSetRow(mrs *MysqlResultSet, cnt uint64) error

func (*MysqlProtocolImpl) WriteResultSetRow2

func (mp *MysqlProtocolImpl) WriteResultSetRow2(mrs *MysqlResultSet, colSlices *ColumnSlices, cnt uint64) error

func (*MysqlProtocolImpl) WriteRow added in v1.2.1

func (mp *MysqlProtocolImpl) WriteRow() error

func (*MysqlProtocolImpl) WriteTextRow added in v1.2.1

func (mp *MysqlProtocolImpl) WriteTextRow() error

type MysqlReader added in v1.2.1

type MysqlReader interface {
	MediaReader
	Property
	Read() ([]byte, error)
	ReadLoadLocalPacket() ([]byte, error)
	FreeLoadLocal()
	Free(buf []byte)
	HandleHandshake(ctx context.Context, payload []byte) (bool, error)
	Authenticate(ctx context.Context) error
	ParseSendLongData(ctx context.Context, proc *process.Process, stmt *PrepareStmt, data []byte, pos int) error
	ParseExecuteData(ctx context.Context, proc *process.Process, stmt *PrepareStmt, data []byte, pos int) error
	// Disconnect closes the underlying network connection to forcefully disconnect the client.
	Disconnect() error
}

MysqlReader read packet using mysql format

type MysqlResp added in v1.2.1

type MysqlResp struct {
	// contains filtered or unexported fields
}

func NewMysqlResp added in v1.2.1

func NewMysqlResp(mysqlWr MysqlRrWr) *MysqlResp

func (*MysqlResp) Close added in v1.2.1

func (resper *MysqlResp) Close()

func (*MysqlResp) GetBool added in v1.2.1

func (resper *MysqlResp) GetBool(PropertyID) bool

func (*MysqlResp) GetStr added in v1.2.1

func (resper *MysqlResp) GetStr(id PropertyID) string

func (*MysqlResp) GetU8 added in v1.2.1

func (resper *MysqlResp) GetU8(PropertyID) uint8

func (*MysqlResp) GetU32 added in v1.2.1

func (resper *MysqlResp) GetU32(id PropertyID) uint32

func (*MysqlResp) MysqlRrWr added in v1.2.1

func (resper *MysqlResp) MysqlRrWr() MysqlRrWr

func (*MysqlResp) ResetStatistics added in v1.2.1

func (resper *MysqlResp) ResetStatistics()

func (*MysqlResp) RespPostMeta added in v1.2.1

func (resper *MysqlResp) RespPostMeta(execCtx *ExecCtx, meta any) (err error)

func (*MysqlResp) RespPreMeta added in v1.2.1

func (resper *MysqlResp) RespPreMeta(execCtx *ExecCtx, meta any) (err error)

func (*MysqlResp) RespResult added in v1.2.1

func (resper *MysqlResp) RespResult(execCtx *ExecCtx, crs *perfcounter.CounterSet, bat *batch.Batch) (err error)

func (*MysqlResp) SetBool added in v1.2.1

func (resper *MysqlResp) SetBool(PropertyID, bool)

func (*MysqlResp) SetStr added in v1.2.1

func (resper *MysqlResp) SetStr(id PropertyID, val string)

func (*MysqlResp) SetU8 added in v1.2.1

func (resper *MysqlResp) SetU8(PropertyID, uint8)

func (*MysqlResp) SetU32 added in v1.2.1

func (resper *MysqlResp) SetU32(id PropertyID, v uint32)

type MysqlResultSet

type MysqlResultSet struct {
	//column information
	Columns []Column

	//data
	Data [][]interface{}
}

Discussion: for some MatrixOne types and Type.Scale value are needed for stringification, I think we need to add a field MoTypes []types.Type in this struct, what's your opinion on this matter?@Daviszhen

func GetCDCShowOutputResultSet

func GetCDCShowOutputResultSet() *MysqlResultSet

func (*MysqlResultSet) AddColumn

func (mrs *MysqlResultSet) AddColumn(column Column) uint64

func (*MysqlResultSet) AddRow

func (mrs *MysqlResultSet) AddRow(row []interface{}) uint64

func (*MysqlResultSet) ColumnIsNull

func (mrs *MysqlResultSet) ColumnIsNull(ctx context.Context, rindex, cindex uint64) (bool, error)

the value in position (rindex,cindex) is null or not return true - null ; false - not null

func (*MysqlResultSet) GetColumn

func (mrs *MysqlResultSet) GetColumn(ctx context.Context, index uint64) (Column, error)

func (*MysqlResultSet) GetColumnCount

func (mrs *MysqlResultSet) GetColumnCount() uint64

func (*MysqlResultSet) GetFloat64

func (mrs *MysqlResultSet) GetFloat64(ctx context.Context, rindex, cindex uint64) (float64, error)

convert the value into Float64

func (*MysqlResultSet) GetInt64

func (mrs *MysqlResultSet) GetInt64(ctx context.Context, rindex, cindex uint64) (int64, error)

convert the value into int64

func (*MysqlResultSet) GetRow

func (mrs *MysqlResultSet) GetRow(ctx context.Context, index uint64) ([]interface{}, error)

func (*MysqlResultSet) GetRowCount

func (mrs *MysqlResultSet) GetRowCount() uint64

func (*MysqlResultSet) GetString

func (mrs *MysqlResultSet) GetString(ctx context.Context, rindex, cindex uint64) (string, error)

convert the value into string

func (*MysqlResultSet) GetUint64

func (mrs *MysqlResultSet) GetUint64(ctx context.Context, rindex, cindex uint64) (uint64, error)

convert the value into uint64

func (*MysqlResultSet) GetValue

func (mrs *MysqlResultSet) GetValue(ctx context.Context, rindex uint64, cindex uint64) (interface{}, error)

type MysqlRrWr added in v1.2.1

type MysqlRrWr interface {
	MysqlReader
	MysqlWriter
	MysqlHelper
}

type MysqlWriter added in v1.2.1

type MysqlWriter interface {
	MediaWriter
	Property
	WriteHandshake() error
	WriteOK(affectedRows, lastInsertId uint64, status, warnings uint16, message string) error
	WriteOKtWithEOF(affectedRows, lastInsertId uint64, status, warnings uint16, message string) error
	WriteEOF(warnings, status uint16) error
	WriteEOFIF(warnings uint16, status uint16) error
	WriteEOFIFAndNoFlush(warnings uint16, status uint16) error
	WriteEOFOrOK(warnings uint16, status uint16) error
	WriteERR(errorCode uint16, sqlState, errorMessage string) error
	WriteLengthEncodedNumber(uint64) error
	WriteColumnDef(context.Context, Column, int) error
	WriteColumnDefBytes([]byte) error
	WriteRow() error
	WriteTextRow() error
	WriteBinaryRow() error
	WriteResultSetRow(mrs *MysqlResultSet, count uint64) error
	WriteResultSetRow2(mrs *MysqlResultSet, colSlices *ColumnSlices, count uint64) error
	WriteResponse(context.Context, *Response) error
	WritePrepareResponse(ctx context.Context, stmt *PrepareStmt) error
	WriteLocalInfileRequest(filepath string) error

	CalculateOutTrafficBytes(b bool) (int64, int64)
	ResetStatistics()
	UpdateCtx(ctx context.Context)
	// Reset sets the session and reset some fields and stats.
	Reset(ses *Session)
}

MysqlWriter write batch & control packets using mysql protocol format

type NullResp added in v1.2.1

type NullResp struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*NullResp) Close added in v1.2.1

func (resper *NullResp) Close()

func (*NullResp) GetBool added in v1.2.1

func (resper *NullResp) GetBool(PropertyID) bool

func (*NullResp) GetStr added in v1.2.1

func (resper *NullResp) GetStr(id PropertyID) string

func (*NullResp) GetU8 added in v1.2.1

func (resper *NullResp) GetU8(PropertyID) uint8

func (*NullResp) GetU32 added in v1.2.1

func (resper *NullResp) GetU32(id PropertyID) uint32

func (*NullResp) MysqlRrWr added in v1.2.1

func (resper *NullResp) MysqlRrWr() MysqlRrWr

func (*NullResp) ResetStatistics added in v1.2.1

func (resper *NullResp) ResetStatistics()

func (*NullResp) RespPostMeta added in v1.2.1

func (resper *NullResp) RespPostMeta(execCtx *ExecCtx, a any) error

func (*NullResp) RespPreMeta added in v1.2.1

func (resper *NullResp) RespPreMeta(ctx *ExecCtx, a any) error

func (*NullResp) RespResult added in v1.2.1

func (resper *NullResp) RespResult(ctx *ExecCtx, crs *perfcounter.CounterSet, b *batch.Batch) error

func (*NullResp) SetBool added in v1.2.1

func (resper *NullResp) SetBool(PropertyID, bool)

func (*NullResp) SetStr added in v1.2.1

func (resper *NullResp) SetStr(id PropertyID, val string)

func (*NullResp) SetU8 added in v1.2.1

func (resper *NullResp) SetU8(PropertyID, uint8)

func (*NullResp) SetU32 added in v1.2.1

func (resper *NullResp) SetU32(PropertyID, uint32)

type Packet

type Packet struct {
	Length     int32
	SequenceID int8
	Payload    []byte
}

type ParquetWriter

type ParquetWriter struct {
	// contains filtered or unexported fields
}

ParquetWriter handles writing data to Parquet format

func NewParquetWriter

func NewParquetWriter(ctx context.Context, mrs *MysqlResultSet) (*ParquetWriter, error)

NewParquetWriter creates a new ParquetWriter

func (*ParquetWriter) Close

func (pw *ParquetWriter) Close() ([]byte, error)

Close closes the parquet writer and returns the complete parquet data

func (*ParquetWriter) Reset

func (pw *ParquetWriter) Reset()

Reset resets the writer for a new file

func (*ParquetWriter) Size

func (pw *ParquetWriter) Size() int

Size returns the current buffer size in bytes

func (*ParquetWriter) WriteBatch

func (pw *ParquetWriter) WriteBatch(bat *batch.Batch, mp *mpool.MPool, timeZone *time.Location) error

WriteBatch writes a batch of data to the parquet writer

type PitrConfig

type PitrConfig struct {
	Level  string
	Length int64
	Unit   string
	Exists bool
}

PitrConfig represents the PITR configuration for a specific level

func NewPitrConfig

func NewPitrConfig(level string) *PitrConfig

NewPitrConfig creates a new PitrConfig instance

func (*PitrConfig) IsValid

func (pc *PitrConfig) IsValid(minLength int64) bool

IsValid checks if the PITR configuration meets the minimum requirements

type PrepareStmt added in v0.6.0

type PrepareStmt struct {
	Name           string
	Sql            string
	PreparePlan    *plan.Plan
	PrepareStmt    tree.Statement
	ParamTypes     []byte
	ColDefData     [][]byte
	IsCloudNonuser bool

	Ts timestamp.Timestamp
	// contains filtered or unexported fields
}

func (*PrepareStmt) Close added in v0.8.0

func (prepareStmt *PrepareStmt) Close()

type PrivilegeScope added in v0.6.0

type PrivilegeScope uint8
const (
	PrivilegeScopeSys      PrivilegeScope = 1
	PrivilegeScopeAccount  PrivilegeScope = 2
	PrivilegeScopeUser     PrivilegeScope = 4
	PrivilegeScopeRole     PrivilegeScope = 8
	PrivilegeScopeDatabase PrivilegeScope = 16
	PrivilegeScopeTable    PrivilegeScope = 32
	PrivilegeScopeRoutine  PrivilegeScope = 64
)

func (PrivilegeScope) String added in v0.6.0

func (ps PrivilegeScope) String() string

type PrivilegeType added in v0.6.0

type PrivilegeType int
const (
	PrivilegeTypeCreateAccount PrivilegeType = iota
	PrivilegeTypeDropAccount
	PrivilegeTypeAlterAccount
	PrivilegeTypeCreateUser
	PrivilegeTypeDropUser
	PrivilegeTypeAlterUser
	PrivilegeTypeCreateRole
	PrivilegeTypeDropRole
	PrivilegeTypeAlterRole
	PrivilegeTypeCreateDatabase
	PrivilegeTypeDropDatabase
	PrivilegeTypeShowDatabases
	PrivilegeTypeConnect
	PrivilegeTypeManageGrants
	PrivilegeTypeAccountAll
	PrivilegeTypeAccountOwnership
	PrivilegeTypeUserOwnership
	PrivilegeTypeRoleOwnership
	PrivilegeTypeShowTables
	PrivilegeTypeCreateObject // includes: table, view, stream, sequence, function, dblink,etc
	PrivilegeTypeCreateTable
	PrivilegeTypeCreateView
	PrivilegeTypeDropObject
	PrivilegeTypeDropTable
	PrivilegeTypeDropView
	PrivilegeTypeAlterObject
	PrivilegeTypeAlterTable
	PrivilegeTypeAlterView
	PrivilegeTypeDatabaseAll
	PrivilegeTypeDatabaseOwnership
	PrivilegeTypeSelect
	PrivilegeTypeInsert
	PrivilegeTypeUpdate
	PrivilegeTypeTruncate
	PrivilegeTypeDelete
	PrivilegeTypeReference
	PrivilegeTypeIndex // include create/alter/drop index
	PrivilegeTypeTableAll
	PrivilegeTypeTableOwnership
	PrivilegeTypeExecute
	PrivilegeTypeCanGrantRoleToOthersInCreateUser // used in checking the privilege of CreateUser with the default role
	PrivilegeTypeValues
	PrivilegeTypeUpgradeAccount
)

func (PrivilegeType) Scope added in v0.6.0

func (pt PrivilegeType) Scope() PrivilegeScope

func (PrivilegeType) String added in v0.6.0

func (pt PrivilegeType) String() string

type Property added in v1.2.1

type Property interface {
	GetStr(PropertyID) string
	SetStr(PropertyID, string)
	SetU32(PropertyID, uint32)
	GetU32(PropertyID) uint32
	SetU8(PropertyID, uint8)
	GetU8(PropertyID) uint8
	SetBool(PropertyID, bool)
	GetBool(PropertyID) bool
}

type PropertyID added in v1.2.1

type PropertyID int
const (
	USERNAME PropertyID = iota + 1
	DBNAME
	//Connection id
	CONNID
	//Peer address
	PEER
	//Seqeunce id
	SEQUENCEID
	//capability bits
	CAPABILITY
	ESTABLISHED
	TLS_ESTABLISHED

	// AuthString is the property authString in MysqlProtocolImpl.
	AuthString
)

type QueryResult added in v1.2.1

type QueryResult struct {
}

func (*QueryResult) Close added in v1.2.1

func (result *QueryResult) Close()

func (*QueryResult) Write added in v1.2.1

func (result *QueryResult) Write(execCtx *ExecCtx, crs *perfcounter.CounterSet, bat *batch.Batch) error

type Request

type Request struct {
	// contains filtered or unexported fields
}

func ToRequest added in v1.2.1

func ToRequest(payload []byte) *Request

func (*Request) GetCmd

func (req *Request) GetCmd() CommandType

func (*Request) GetData

func (req *Request) GetData() interface{}

func (*Request) SetCmd

func (req *Request) SetCmd(cmd CommandType)

func (*Request) SetData

func (req *Request) SetData(data interface{})

type Response

type Response struct {
	// contains filtered or unexported fields
}

func ExecRequest added in v1.2.0

func ExecRequest(ses *Session, execCtx *ExecCtx, req *Request) (resp *Response, err error)

ExecRequest the server execute the commands from the client following the mysql's routine

func NewGeneralErrorResponse

func NewGeneralErrorResponse(cmd CommandType, status uint16, err error) *Response

func NewGeneralOkResponse

func NewGeneralOkResponse(cmd CommandType, status uint16) *Response

func NewOkResponse

func NewOkResponse(affectedRows, lastInsertId uint64, warnings, status uint16, cmd int, d interface{}) *Response

func NewResponse

func NewResponse(category int, affectedRows, lastInsertId uint64, warnings, status uint16, cmd int, d interface{}) *Response

func (*Response) GetCategory

func (resp *Response) GetCategory() int

func (*Response) GetData

func (resp *Response) GetData() interface{}

func (*Response) GetStatus

func (resp *Response) GetStatus() uint16

func (*Response) SetCategory

func (resp *Response) SetCategory(category int)

func (*Response) SetData

func (resp *Response) SetData(data interface{})

func (*Response) SetStatus

func (resp *Response) SetStatus(status uint16)

type Responser added in v1.2.1

type Responser interface {
	Property
	RespPreMeta(*ExecCtx, any) error
	RespResult(*ExecCtx, *perfcounter.CounterSet, *batch.Batch) error
	RespPostMeta(*ExecCtx, any) error
	MysqlRrWr() MysqlRrWr
	Close()
	ResetStatistics()
}

type ResultSet

type ResultSet interface {
	//Add a column definition
	//return the index of column (start from 0)
	AddColumn(Column) uint64

	//the Count of the Column
	GetColumnCount() uint64

	//get the i th column
	GetColumn(context.Context, uint64) (Column, error)

	//Add a data row
	//return the index of row (start from 0)
	AddRow([]interface{}) uint64

	//the count of the data row
	GetRowCount() uint64

	//get the i th data row
	GetRow(context.Context, uint64) ([]interface{}, error)

	//get the data of row i, column j
	GetValue(context.Context, uint64, uint64) (interface{}, error)
}

type Routine

type Routine struct {
	// contains filtered or unexported fields
}

Routine handles requests. Read requests from the IOSession layer, use the executor to handle requests, and response them.

func NewRoutine

func NewRoutine(ctx context.Context, protocol MysqlRrWr, parameters *config.FrontendParameters) *Routine

type RoutineManager

type RoutineManager struct {
	// contains filtered or unexported fields
}

func NewRoutineManager

func NewRoutineManager(ctx context.Context, service string) (*RoutineManager, error)

func (*RoutineManager) Closed

func (rm *RoutineManager) Closed(rs *Conn)

When the io is closed, the Closed will be called.

func (*RoutineManager) Created

func (rm *RoutineManager) Created(rs *Conn) error

func (*RoutineManager) GetAccountRoutineManager added in v1.0.0

func (rm *RoutineManager) GetAccountRoutineManager() *AccountRoutineManager

func (*RoutineManager) Handler

func (rm *RoutineManager) Handler(rs *Conn, msg []byte) error

func (*RoutineManager) KillRoutineConnections added in v0.8.0

func (rm *RoutineManager) KillRoutineConnections()

func (*RoutineManager) MigrateConnectionFrom added in v1.1.2

func (rm *RoutineManager) MigrateConnectionFrom(req *query.MigrateConnFromRequest, resp *query.MigrateConnFromResponse) error

func (*RoutineManager) MigrateConnectionTo added in v1.1.2

func (rm *RoutineManager) MigrateConnectionTo(ctx context.Context, req *query.MigrateConnToRequest) error

func (*RoutineManager) ResetSession

type Scope added in v0.5.0

type Scope int
const (
	ScopeGlobal  Scope = iota //it is only in global
	ScopeSession              //it is only in session
	ScopeBoth                 //it is both in global and session
)

func (Scope) String added in v0.5.0

func (s Scope) String() string

type Server added in v1.2.3

type Server interface {
	GetRoutineManager() *RoutineManager
	Start() error
	Stop() error
}

Server interface is for mock MOServer

type ServerLevelVariables

type ServerLevelVariables struct {
	RtMgr atomic.Value
	Pu    atomic.Value
	Aicm  atomic.Value
	// contains filtered or unexported fields
}

ServerLevelVariables holds the variables are shared in single frontend mo server instance. these variables should be initialized at the server startup.

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(
	connCtx context.Context,
	service string,
	proto MysqlRrWr,
	mp *mpool.MPool,
) *Session

func (*Session) AddSeqValues added in v0.8.0

func (ses *Session) AddSeqValues(proc *process.Process)

func (*Session) AddTempTable

func (ses *Session) AddTempTable(dbName, alias, realName string)

AddTempTable adds the temporary table to the session

func (*Session) AppendData added in v0.6.0

func (ses *Session) AppendData(row []interface{})

func (*Session) AppendResultBatch added in v0.8.0

func (ses *Session) AppendResultBatch(bat *batch.Batch) error

func (*Session) AuthenticateUser added in v0.6.0

func (ses *Session) AuthenticateUser(ctx context.Context, userInput string, dbName string, authResponse []byte, salt []byte, checkPassword func(pwd []byte, salt []byte, auth []byte) bool) ([]byte, error)

AuthenticateUser Verify the user's password, and if the login information contains the database name, verify if the database exists

func (*Session) Clear added in v1.2.0

func (ses *Session) Clear()

func (*Session) ClearAllMysqlResultSet added in v0.6.0

func (ses *Session) ClearAllMysqlResultSet()

func (*Session) ClearDDLOwnerRoleID

func (ses *Session) ClearDDLOwnerRoleID()

func (*Session) ClearExportParam added in v1.0.0

func (ses *Session) ClearExportParam()

func (*Session) ClearResultBatches added in v0.8.0

func (ses *Session) ClearResultBatches()

ClearResultBatches does not call Batch.Clear().

func (*Session) ClearStmtProfile added in v1.0.0

func (ses *Session) ClearStmtProfile()

func (*Session) Close added in v0.8.0

func (ses *Session) Close()

func (*Session) CopySeqToProc added in v0.8.0

func (ses *Session) CopySeqToProc(proc *process.Process)

func (*Session) CountFlushPackage

func (ses *Session) CountFlushPackage(delta int64)

CountFlushPackage count the raw conn flush op.

func (*Session) CountOutputBytes

func (ses *Session) CountOutputBytes(delta int)

func (*Session) CountPayload added in v1.1.2

func (ses *Session) CountPayload(length int)

func (*Session) DatabaseNameIsEmpty added in v0.5.0

func (ses *Session) DatabaseNameIsEmpty() bool

func (*Session) Debug added in v1.2.1

func (ses *Session) Debug(ctx context.Context, msg string, fields ...zap.Field)

func (*Session) Debugf added in v1.2.1

func (ses *Session) Debugf(ctx context.Context, format string, args ...any)

func (*Session) DeleteSeqValues added in v0.8.0

func (ses *Session) DeleteSeqValues(proc *process.Process)

func (*Session) DisableTrace added in v1.2.0

func (ses *Session) DisableTrace() bool

func (*Session) EnterFPrint added in v1.2.1

func (ses *Session) EnterFPrint(idx int)

func (*Session) Error added in v1.2.1

func (ses *Session) Error(ctx context.Context, msg string, fields ...zap.Field)

func (*Session) Errorf added in v1.2.1

func (ses *Session) Errorf(ctx context.Context, format string, args ...any)

func (*Session) ExitFPrint added in v1.2.1

func (ses *Session) ExitFPrint(idx int)

func (*Session) Fatal added in v1.2.1

func (ses *Session) Fatal(ctx context.Context, msg string, fields ...zap.Field)

func (*Session) Fatalf added in v1.2.1

func (ses *Session) Fatalf(ctx context.Context, format string, args ...any)

func (*Session) GenNewStmtId added in v0.6.0

func (ses *Session) GenNewStmtId() uint32

func (*Session) GetAccountId added in v1.2.0

func (ses *Session) GetAccountId() uint32

func (*Session) GetAllMysqlResultSet added in v0.6.0

func (ses *Session) GetAllMysqlResultSet() []*MysqlResultSet

func (*Session) GetBackgroundExec added in v0.6.0

func (ses *Session) GetBackgroundExec(ctx context.Context, opts ...*BackgroundExecOption) BackgroundExec

GetBackgroundExec generates a background executor

func (*Session) GetBuffer added in v1.0.0

func (ses *Session) GetBuffer() *buffer.Buffer

func (*Session) GetCmd added in v0.6.0

func (ses *Session) GetCmd() CommandType

func (*Session) GetConfig

func (ses *Session) GetConfig(ctx context.Context, varName, dbName, tblName string) (any, error)

GetUserDefinedVar gets value of the config

func (*Session) GetConnectionID added in v0.5.1

func (ses *Session) GetConnectionID() uint32

func (*Session) GetCreateVersion

func (ses *Session) GetCreateVersion() string

func (*Session) GetDDLOwnerRoleID

func (ses *Session) GetDDLOwnerRoleID() uint32

func (*Session) GetData added in v0.6.0

func (ses *Session) GetData() [][]interface{}

func (*Session) GetDatabaseName added in v0.5.0

func (ses *Session) GetDatabaseName() string

func (*Session) GetDebugString added in v0.8.0

func (ses *Session) GetDebugString() string

func (*Session) GetErrInfo added in v0.6.0

func (ses *Session) GetErrInfo() *errInfo

func (*Session) GetExportConfig added in v1.0.0

func (ses *Session) GetExportConfig() *ExportConfig

func (*Session) GetFlushPacketCnt

func (ses *Session) GetFlushPacketCnt() int64

func (*Session) GetFromRealUser added in v0.6.0

func (ses *Session) GetFromRealUser() bool

func (*Session) GetGlobalSysVar added in v1.2.1

func (ses *Session) GetGlobalSysVar(name string) (interface{}, error)

func (*Session) GetGlobalSysVars added in v0.6.0

func (ses *Session) GetGlobalSysVars() *SystemVariables

func (*Session) GetIncBlockIdx added in v0.7.0

func (ses *Session) GetIncBlockIdx() int

func (*Session) GetIsInternal added in v0.6.0

func (ses *Session) GetIsInternal() bool

func (*Session) GetLastInsertID added in v0.7.0

func (ses *Session) GetLastInsertID() uint64

func (*Session) GetLastStmtId added in v0.6.0

func (ses *Session) GetLastStmtId() uint32

func (*Session) GetLogLevel added in v1.2.1

func (ses *Session) GetLogLevel() zapcore.Level

func (*Session) GetLogger added in v1.2.1

func (ses *Session) GetLogger() SessionLogger

func (*Session) GetMemPool added in v0.6.0

func (ses *Session) GetMemPool() *mpool.MPool

func (*Session) GetMySQLParser

func (ses *Session) GetMySQLParser() *mysql.MySQLParser

func (*Session) GetMysqlResultSet added in v0.6.0

func (ses *Session) GetMysqlResultSet() *MysqlResultSet

func (*Session) GetOutputBytes

func (ses *Session) GetOutputBytes() int

func (*Session) GetOutputCallback added in v0.6.0

func (ses *Session) GetOutputCallback(execCtx *ExecCtx) func(*batch.Batch, *perfcounter.CounterSet) error

func (*Session) GetPrepareStmt added in v0.6.0

func (ses *Session) GetPrepareStmt(ctx context.Context, name string) (*PrepareStmt, error)

func (*Session) GetPrepareStmts added in v1.1.2

func (ses *Session) GetPrepareStmts() []*PrepareStmt

func (*Session) GetPrivilege added in v0.6.0

func (ses *Session) GetPrivilege() *privilege

func (*Session) GetPrivilegeCache added in v0.6.0

func (ses *Session) GetPrivilegeCache() *privilegeCache

func (*Session) GetProc added in v1.2.0

func (ses *Session) GetProc() *process.Process

func (*Session) GetQueryEnd added in v1.0.1

func (ses *Session) GetQueryEnd() time.Time

func (*Session) GetQueryInExecute added in v1.0.0

func (ses *Session) GetQueryInExecute() bool

func (*Session) GetQueryInProgress added in v1.0.1

func (ses *Session) GetQueryInProgress() bool

func (*Session) GetQueryStart added in v1.0.0

func (ses *Session) GetQueryStart() time.Time

func (*Session) GetQueryType added in v1.0.0

func (ses *Session) GetQueryType() string

func (*Session) GetRawBatchBackgroundExec added in v0.8.0

func (ses *Session) GetRawBatchBackgroundExec(ctx context.Context) BackgroundExec

func (*Session) GetResponser added in v1.2.1

func (ses *Session) GetResponser() Responser

func (*Session) GetResultBatches added in v0.8.0

func (ses *Session) GetResultBatches() []*batch.Batch

func (*Session) GetSeqLastValue added in v0.8.0

func (ses *Session) GetSeqLastValue() string

func (*Session) GetService

func (ses *Session) GetService() string

func (*Session) GetSessId added in v1.2.1

func (ses *Session) GetSessId() uuid.UUID

func (*Session) GetSessionStart added in v1.0.0

func (ses *Session) GetSessionStart() time.Time

func (*Session) GetSessionSysVar added in v1.2.1

func (ses *Session) GetSessionSysVar(name string) (interface{}, error)

func (*Session) GetSessionSysVars added in v1.2.1

func (ses *Session) GetSessionSysVars() *SystemVariables

func (*Session) GetShareTxnBackgroundExec added in v0.8.0

func (ses *Session) GetShareTxnBackgroundExec(ctx context.Context, newRawBatch bool) BackgroundExec

GetShareTxnBackgroundExec returns a background executor running the sql in a shared transaction. newRawBatch denotes we need the raw batch instead of mysql result set.

func (*Session) GetShowStmtType added in v0.6.0

func (ses *Session) GetShowStmtType() ShowStatementType

func (*Session) GetSql added in v0.5.0

func (ses *Session) GetSql() string

func (*Session) GetSqlCount added in v1.2.0

func (ses *Session) GetSqlCount() uint64

func (*Session) GetSqlHelper added in v0.8.0

func (ses *Session) GetSqlHelper() *SqlHelper

func (*Session) GetSqlModeNoAutoValueOnZero

func (ses *Session) GetSqlModeNoAutoValueOnZero() (bool, bool)

func (*Session) GetSqlOfStmt added in v1.0.0

func (ses *Session) GetSqlOfStmt() string

func (*Session) GetSqlSourceType added in v1.0.0

func (ses *Session) GetSqlSourceType() string

func (*Session) GetStaticTxnInfo added in v1.2.1

func (ses *Session) GetStaticTxnInfo() string

func (*Session) GetStatsCache added in v1.2.0

func (ses *Session) GetStatsCache() *plan2.StatsCache

func (*Session) GetStmtId added in v1.0.0

func (ses *Session) GetStmtId() uuid.UUID

func (*Session) GetStmtInfo added in v1.2.0

func (ses *Session) GetStmtInfo() *motrace.StatementInfo

func (*Session) GetStmtProfile added in v1.2.0

func (ses *Session) GetStmtProfile() *process.StmtProfile

func (*Session) GetStmtType added in v1.0.0

func (ses *Session) GetStmtType() string

func (*Session) GetTempTable

func (ses *Session) GetTempTable(dbName, alias string) (string, bool)

GetTempTable gets the real name of the temporary table

func (*Session) GetTenantInfo added in v0.6.0

func (ses *Session) GetTenantInfo() *TenantInfo

func (*Session) GetTenantName added in v0.6.0

func (ses *Session) GetTenantName() string

func (*Session) GetTenantNameWithStmt added in v1.0.0

func (ses *Session) GetTenantNameWithStmt(stmt tree.Statement) string

GetTenantName return tenant name according to GetTenantInfo and stmt.

With stmt = nil, should be only called in TxnHandler.NewTxn, TxnHandler.CommitTxn, TxnHandler.RollbackTxn

func (*Session) GetTimeZone added in v0.6.0

func (ses *Session) GetTimeZone() *time.Location

func (*Session) GetTxnCompileCtx added in v0.5.0

func (ses *Session) GetTxnCompileCtx() *TxnCompilerContext

func (*Session) GetTxnHandler added in v0.5.0

func (ses *Session) GetTxnHandler() *TxnHandler

func (*Session) GetTxnId added in v1.0.0

func (ses *Session) GetTxnId() uuid.UUID

func (*Session) GetTxnInfo added in v1.1.0

func (ses *Session) GetTxnInfo() string

func (*Session) GetUUID added in v0.6.0

func (ses *Session) GetUUID() []byte

func (*Session) GetUUIDString added in v0.6.0

func (ses *Session) GetUUIDString() string

func (*Session) GetUpstream added in v1.2.0

func (ses *Session) GetUpstream() FeSession

func (*Session) GetUserDefinedVar added in v0.5.0

func (ses *Session) GetUserDefinedVar(name string) (*UserDefinedVar, error)

GetUserDefinedVar gets value of the user defined variable

func (*Session) GetUserName added in v0.5.0

func (ses *Session) GetUserName() string

func (*Session) Info added in v1.2.1

func (ses *Session) Info(ctx context.Context, msg string, fields ...zap.Field)

func (*Session) Infof added in v1.2.1

func (ses *Session) Infof(ctx context.Context, format string, args ...any)

func (*Session) InheritSequenceData added in v0.8.0

func (ses *Session) InheritSequenceData(other *Session)

func (*Session) InitBackExec

func (ses *Session) InitBackExec(txnOp TxnOperator, db string, callBack outputCallBackFunc, opts ...*BackgroundExecOption) BackgroundExec

func (*Session) InitExportConfig added in v1.0.0

func (ses *Session) InitExportConfig(ep *tree.ExportParam)

func (*Session) InitSystemVariables added in v1.2.1

func (ses *Session) InitSystemVariables(ctx context.Context, bh BackgroundExec) (err error)

func (*Session) InvalidatePrivilegeCache added in v0.6.0

func (ses *Session) InvalidatePrivilegeCache()

func (*Session) IsBackgroundSession added in v0.7.0

func (ses *Session) IsBackgroundSession() bool

func (*Session) IsDerivedStmt added in v1.0.0

func (ses *Session) IsDerivedStmt() bool

func (*Session) IsRestore

func (ses *Session) IsRestore() bool

func (*Session) IsRestoreFail

func (ses *Session) IsRestoreFail() bool

func (*Session) LogDebug

func (ses *Session) LogDebug() bool

func (*Session) MaybeUpgradeTenant added in v1.2.0

func (ses *Session) MaybeUpgradeTenant(ctx context.Context, curVersion string, tenantID int64) error

func (*Session) RemovePrepareStmt added in v0.6.0

func (ses *Session) RemovePrepareStmt(name string)

func (*Session) RemoveTempTable

func (ses *Session) RemoveTempTable(dbName, alias string)

RemoveTempTable removes the temporary table alias

func (*Session) RemoveTempTableByRealName

func (ses *Session) RemoveTempTableByRealName(realName string)

RemoveTempTableByRealName removes the temporary table alias by its real name

func (*Session) ReplaceDerivedStmt added in v1.0.0

func (ses *Session) ReplaceDerivedStmt(b bool) bool

ReplaceDerivedStmt sets the derivedStmt and returns the previous value. if b is true, executing a derived statement.

func (*Session) ReplaceResponser added in v1.2.1

func (ses *Session) ReplaceResponser(resper Responser) Responser

func (*Session) ReserveConn

func (ses *Session) ReserveConn()

func (*Session) ReserveConnAndClose

func (ses *Session) ReserveConnAndClose()

ReserveConnAndClose closes the session with the connection is reserved.

func (*Session) Reset

func (ses *Session) Reset()

Reset release resources like buffer,memory,handles,etc.

	It also reserves some necessary resources that are carefully designed.
 	does not close txn handler here.

func (*Session) ResetBlockIdx added in v0.7.0

func (ses *Session) ResetBlockIdx()

func (*Session) ResetPacketCounter added in v1.1.2

func (ses *Session) ResetPacketCounter()

func (*Session) SaveResultSet added in v0.8.0

func (ses *Session) SaveResultSet()

func (*Session) SendRows added in v1.2.0

func (ses *Session) SendRows() int64

func (*Session) SetAccountId added in v1.2.0

func (ses *Session) SetAccountId(u uint32)

func (*Session) SetCmd added in v0.6.0

func (ses *Session) SetCmd(cmd CommandType)

func (*Session) SetConnectionID

func (ses *Session) SetConnectionID(v uint32)

func (*Session) SetCreateVersion

func (ses *Session) SetCreateVersion(version string)

func (*Session) SetDDLOwnerRoleID

func (ses *Session) SetDDLOwnerRoleID(roleID uint32)

func (*Session) SetData added in v0.6.0

func (ses *Session) SetData(data [][]interface{})

func (*Session) SetDatabaseName added in v0.5.0

func (ses *Session) SetDatabaseName(db string)

func (*Session) SetFromRealUser added in v0.6.0

func (ses *Session) SetFromRealUser(b bool)

func (*Session) SetGlobalSysVar added in v1.2.1

func (ses *Session) SetGlobalSysVar(ctx context.Context, name string, val interface{}) (err error)

func (*Session) SetLastInsertID added in v0.7.0

func (ses *Session) SetLastInsertID(num uint64)

func (*Session) SetLastStmtID added in v1.1.2

func (ses *Session) SetLastStmtID(id uint32)

func (*Session) SetMemPool added in v0.6.0

func (ses *Session) SetMemPool(mp *mpool.MPool)

func (*Session) SetMysqlResultSet added in v0.6.0

func (ses *Session) SetMysqlResultSet(mrs *MysqlResultSet)

func (*Session) SetMysqlResultSetOfBackgroundTask added in v0.8.0

func (ses *Session) SetMysqlResultSetOfBackgroundTask(mrs *MysqlResultSet)

func (*Session) SetNewResponse added in v0.8.1

func (ses *Session) SetNewResponse(category int, affectedRows uint64, cmd int, d interface{}, isLastStmt bool) *Response

func (*Session) SetOutputCallback added in v0.6.0

func (ses *Session) SetOutputCallback(callback outputCallBackFunc)

func (*Session) SetPlan added in v1.2.0

func (ses *Session) SetPlan(plan *plan.Plan)

func (*Session) SetPrepareStmt added in v0.6.0

func (ses *Session) SetPrepareStmt(ctx context.Context, name string, prepareStmt *PrepareStmt) error

func (*Session) SetPrivilege added in v0.6.0

func (ses *Session) SetPrivilege(priv *privilege)

func (*Session) SetQueryEnd added in v1.0.1

func (ses *Session) SetQueryEnd(t time.Time)

func (*Session) SetQueryInExecute added in v1.0.0

func (ses *Session) SetQueryInExecute(b bool)

func (*Session) SetQueryInProgress added in v1.0.1

func (ses *Session) SetQueryInProgress(b bool)

func (*Session) SetQueryStart added in v1.0.0

func (ses *Session) SetQueryStart(t time.Time)

func (*Session) SetQueryType added in v1.0.0

func (ses *Session) SetQueryType(qt string)

func (*Session) SetRestore

func (ses *Session) SetRestore(b bool)

func (*Session) SetRestoreFail

func (ses *Session) SetRestoreFail(b bool)

func (*Session) SetSeqLastValue added in v0.8.0

func (ses *Session) SetSeqLastValue(proc *process.Process)

func (*Session) SetSessionRoutineStatus added in v1.0.0

func (ses *Session) SetSessionRoutineStatus(status string) error

func (*Session) SetSessionSysVar added in v1.2.1

func (ses *Session) SetSessionSysVar(ctx context.Context, name string, val interface{}) (err error)

func (*Session) SetShowStmtType added in v0.6.0

func (ses *Session) SetShowStmtType(sst ShowStatementType)

func (*Session) SetSql added in v0.5.0

func (ses *Session) SetSql(sql string)

func (*Session) SetSqlOfStmt added in v1.0.0

func (ses *Session) SetSqlOfStmt(sot string)

func (*Session) SetSqlSourceType added in v1.0.0

func (ses *Session) SetSqlSourceType(st string)

func (*Session) SetStaticTxnInfo added in v1.2.1

func (ses *Session) SetStaticTxnInfo(info string)

func (*Session) SetStmtId added in v1.0.0

func (ses *Session) SetStmtId(id uuid.UUID)

func (*Session) SetStmtType added in v1.0.0

func (ses *Session) SetStmtType(st string)

func (*Session) SetTStmt added in v1.0.0

func (ses *Session) SetTStmt(stmt *motrace.StatementInfo)

SetTStmt do set the Session.tStmt 1. init-set at RecordStatement, which means the statement is started. 2. reset nil, means the statement is finished.

  • case 1: logStatementStringStatus()
  • case 2: RecordParseErrorStatement()

func (*Session) SetTenantInfo added in v0.6.0

func (ses *Session) SetTenantInfo(ti *TenantInfo)

func (*Session) SetTimeZone added in v0.6.0

func (ses *Session) SetTimeZone(loc *time.Location)

func (*Session) SetTxnId added in v1.0.0

func (ses *Session) SetTxnId(id []byte)

func (*Session) SetUserDefinedVar added in v0.5.0

func (ses *Session) SetUserDefinedVar(name string, value interface{}, sql string) error

SetUserDefinedVar sets the user defined variable to the value in session

func (*Session) SetUserName added in v0.5.0

func (ses *Session) SetUserName(uname string)

func (*Session) StatusSession added in v1.0.0

func (ses *Session) StatusSession() *status.Session

StatusSession implements the queryservice.Session interface.

func (*Session) UpdateDebugString added in v0.8.0

func (ses *Session) UpdateDebugString()

func (*Session) UpgradeTenant added in v1.2.0

func (ses *Session) UpgradeTenant(ctx context.Context, tenantName string, retryCount uint32, isALLAccount bool) error

func (*Session) Warn added in v1.2.1

func (ses *Session) Warn(ctx context.Context, msg string, fields ...zap.Field)

func (*Session) Warnf added in v1.2.1

func (ses *Session) Warnf(ctx context.Context, format string, args ...any)

type SessionAllocator added in v1.0.0

type SessionAllocator struct {
	// contains filtered or unexported fields
}

func NewSessionAllocator added in v1.0.0

func NewSessionAllocator(pu *config.ParameterUnit) *SessionAllocator

func (*SessionAllocator) Alloc added in v1.0.0

func (s *SessionAllocator) Alloc(capacity int) ([]byte, error)

func (SessionAllocator) Free added in v1.0.0

func (s SessionAllocator) Free(bs []byte)

type SessionConn

type SessionConn interface {
	ID() uint64
	RawConn() net.Conn
	UseConn(net.Conn)
	Disconnect() error
	Close() error
	Read() ([]byte, error)
	Append(...byte) error
	BeginPacket() error
	FinishedPacket() error
	Flush() error
	Write([]byte) error
	RemoteAddress() string
}

type SessionLogger added in v1.2.1

type SessionLogger interface {
	SessionLoggerGetter
	Info(ctx context.Context, msg string, fields ...zap.Field)
	Error(ctx context.Context, msg string, fields ...zap.Field)
	Warn(ctx context.Context, msg string, fields ...zap.Field)
	Fatal(ctx context.Context, msg string, fields ...zap.Field)
	Debug(ctx context.Context, msg string, fields ...zap.Field)
	Infof(ctx context.Context, msg string, args ...any)
	Errorf(ctx context.Context, msg string, args ...any)
	Warnf(ctx context.Context, msg string, args ...any)
	Fatalf(ctx context.Context, msg string, args ...any)
	Debugf(ctx context.Context, msg string, args ...any)
	LogDebug() bool
	GetLogger() SessionLogger
}

type SessionLoggerGetter added in v1.2.1

type SessionLoggerGetter interface {
	GetSessId() uuid.UUID
	GetStmtId() uuid.UUID
	GetTxnId() uuid.UUID
	GetLogLevel() zapcore.Level
}

type ShowStatementType added in v0.5.0

type ShowStatementType int
const (
	NotShowStatement ShowStatementType = 0
	ShowTableStatus  ShowStatementType = 1
)

type SnapshotCoveredScope

type SnapshotCoveredScope struct {
	DatabaseName string
	TableName    string
	Level        string
}

SnapshotCoveredScope represents the scope of databases/tables covered by a snapshot

func GetSnapshotCoveredScope

func GetSnapshotCoveredScope(ctx context.Context, bh BackgroundExec, snapshotName string) (*SnapshotCoveredScope, int64, error)

GetSnapshotCoveredScope gets the database/table scope covered by a snapshot Parameters:

  • ctx: context with account ID attached
  • bh: background executor
  • snapshotName: the snapshot name

Returns:

  • scope: the covered scope containing database name, table name and level
  • snapshotTs: snapshot timestamp
  • err: error if snapshot not found or query failed

type SnapshotInfo

type SnapshotInfo struct {
	SnapshotId   string
	SnapshotName string
	Ts           int64
	Level        string
	AccountName  string
	DatabaseName string
	TableName    string
	ObjId        uint64
}

SnapshotInfo represents the exported snapshot information This can be used by external packages without exposing internal snapshotRecord

func GetSnapshotInfoByName

func GetSnapshotInfoByName(ctx context.Context, sqlExecutor executor.SQLExecutor, txnOp client.TxnOperator, snapshotName string) (*SnapshotInfo, error)

GetSnapshotInfoByName gets snapshot info by name using executor This is an exported function that can be used without Session

type SpStatus added in v0.8.0

type SpStatus int
const (
	SpOk        SpStatus = 0
	SpNotOk     SpStatus = 1
	SpBranchHit SpStatus = 2
	SpLeaveLoop SpStatus = 3
	SpIterLoop  SpStatus = 4
)

type SqlHelper added in v0.8.0

type SqlHelper struct {
	// contains filtered or unexported fields
}

func (*SqlHelper) ExecSql added in v0.8.0

func (sh *SqlHelper) ExecSql(sql string) (ret [][]interface{}, err error)

Made for sequence func. nextval, setval.

func (*SqlHelper) ExecSqlWithCtx

func (sh *SqlHelper) ExecSqlWithCtx(ctx context.Context, sql string) ([][]interface{}, error)

func (*SqlHelper) GetCompilerContext added in v0.8.0

func (sh *SqlHelper) GetCompilerContext() any

func (*SqlHelper) GetSubscriptionMeta added in v1.2.0

func (sh *SqlHelper) GetSubscriptionMeta(dbName string) (*plan.SubscriptionMeta, error)

type SystemVariable added in v0.5.0

type SystemVariable struct {
	Name string

	// scope of the system variable includes Global,Session,Both
	Scope Scope

	// can be changed during runtime
	Dynamic bool

	//can be set for single query by SET_VAR()
	SetVarHintApplies bool

	Type SystemVariableType

	Default interface{}

	UpdateSessVar func(context.Context, *Session, *SystemVariables, string, interface{}) error
}

func (SystemVariable) GetDefault added in v0.5.0

func (sv SystemVariable) GetDefault() interface{}

func (SystemVariable) GetDynamic added in v0.5.0

func (sv SystemVariable) GetDynamic() bool

func (SystemVariable) GetName added in v0.5.0

func (sv SystemVariable) GetName() string

func (SystemVariable) GetScope added in v0.5.0

func (sv SystemVariable) GetScope() Scope

func (SystemVariable) GetSetVarHintApplies added in v0.5.0

func (sv SystemVariable) GetSetVarHintApplies() bool

func (SystemVariable) GetType added in v0.5.0

func (sv SystemVariable) GetType() SystemVariableType

type SystemVariableBoolType added in v0.5.0

type SystemVariableBoolType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableBoolType added in v0.5.0

func InitSystemVariableBoolType(name string) SystemVariableBoolType

func (SystemVariableBoolType) Convert added in v0.5.0

func (svbt SystemVariableBoolType) Convert(value interface{}) (interface{}, error)

func (SystemVariableBoolType) ConvertFromString added in v0.8.0

func (svbt SystemVariableBoolType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableBoolType) IsTrue added in v0.6.0

func (svbt SystemVariableBoolType) IsTrue(v interface{}) bool

func (SystemVariableBoolType) MysqlType added in v0.5.0

func (svbt SystemVariableBoolType) MysqlType() defines.MysqlType

func (SystemVariableBoolType) String added in v0.5.0

func (svbt SystemVariableBoolType) String() string

func (SystemVariableBoolType) Type added in v0.5.0

func (svbt SystemVariableBoolType) Type() types.T

func (SystemVariableBoolType) Zero added in v0.5.0

func (svbt SystemVariableBoolType) Zero() interface{}

type SystemVariableDoubleType added in v0.5.0

type SystemVariableDoubleType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableDoubleType added in v1.2.0

func InitSystemVariableDoubleType(name string, minimum, maximum float64) SystemVariableDoubleType

func (SystemVariableDoubleType) Convert added in v0.5.0

func (svdt SystemVariableDoubleType) Convert(value interface{}) (interface{}, error)

func (SystemVariableDoubleType) ConvertFromString added in v0.8.0

func (svdt SystemVariableDoubleType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableDoubleType) MysqlType added in v0.5.0

func (svdt SystemVariableDoubleType) MysqlType() defines.MysqlType

func (SystemVariableDoubleType) String added in v0.5.0

func (svdt SystemVariableDoubleType) String() string

func (SystemVariableDoubleType) Type added in v0.5.0

func (svdt SystemVariableDoubleType) Type() types.T

func (SystemVariableDoubleType) Zero added in v0.5.0

func (svdt SystemVariableDoubleType) Zero() interface{}

type SystemVariableEnumType added in v0.5.0

type SystemVariableEnumType struct {
	// contains filtered or unexported fields
}

func InitSystemSystemEnumType added in v0.5.0

func InitSystemSystemEnumType(name string, values ...string) SystemVariableEnumType

func (SystemVariableEnumType) Convert added in v0.5.0

func (svet SystemVariableEnumType) Convert(value interface{}) (interface{}, error)

func (SystemVariableEnumType) ConvertFromString added in v0.8.0

func (svet SystemVariableEnumType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableEnumType) MysqlType added in v0.5.0

func (svet SystemVariableEnumType) MysqlType() defines.MysqlType

func (SystemVariableEnumType) String added in v0.5.0

func (svet SystemVariableEnumType) String() string

func (SystemVariableEnumType) Type added in v0.5.0

func (svet SystemVariableEnumType) Type() types.T

func (SystemVariableEnumType) Zero added in v0.5.0

func (svet SystemVariableEnumType) Zero() interface{}

type SystemVariableIntType added in v0.5.0

type SystemVariableIntType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableIntType added in v0.5.0

func InitSystemVariableIntType(name string, minimum, maximum int64, maybeMinusOne bool) SystemVariableIntType

func (SystemVariableIntType) Convert added in v0.5.0

func (svit SystemVariableIntType) Convert(value interface{}) (interface{}, error)

func (SystemVariableIntType) ConvertFromString added in v0.8.0

func (svit SystemVariableIntType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableIntType) MysqlType added in v0.5.0

func (svit SystemVariableIntType) MysqlType() defines.MysqlType

func (SystemVariableIntType) String added in v0.5.0

func (svit SystemVariableIntType) String() string

func (SystemVariableIntType) Type added in v0.5.0

func (svit SystemVariableIntType) Type() types.T

func (SystemVariableIntType) Zero added in v0.5.0

func (svit SystemVariableIntType) Zero() interface{}

type SystemVariableNullType added in v0.5.0

type SystemVariableNullType struct {
}

func (SystemVariableNullType) Convert added in v0.5.0

func (svnt SystemVariableNullType) Convert(value interface{}) (interface{}, error)

func (SystemVariableNullType) ConvertFromString added in v0.8.0

func (svnt SystemVariableNullType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableNullType) MysqlType added in v0.5.0

func (svnt SystemVariableNullType) MysqlType() defines.MysqlType

func (SystemVariableNullType) String added in v0.5.0

func (svnt SystemVariableNullType) String() string

func (SystemVariableNullType) Type added in v0.5.0

func (svnt SystemVariableNullType) Type() types.T

func (SystemVariableNullType) Zero added in v0.5.0

func (svnt SystemVariableNullType) Zero() interface{}

type SystemVariableSetType added in v0.5.0

type SystemVariableSetType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableSetType added in v0.5.0

func InitSystemVariableSetType(name string, values ...string) SystemVariableSetType

func (SystemVariableSetType) Convert added in v0.5.0

func (svst SystemVariableSetType) Convert(value interface{}) (interface{}, error)

func (SystemVariableSetType) ConvertFromString added in v0.8.0

func (svst SystemVariableSetType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableSetType) MysqlType added in v0.5.0

func (svst SystemVariableSetType) MysqlType() defines.MysqlType

func (SystemVariableSetType) String added in v0.5.0

func (svst SystemVariableSetType) String() string

func (SystemVariableSetType) Type added in v0.5.0

func (svst SystemVariableSetType) Type() types.T

func (SystemVariableSetType) Values added in v0.5.0

func (svst SystemVariableSetType) Values() []string

func (SystemVariableSetType) Zero added in v0.5.0

func (svst SystemVariableSetType) Zero() interface{}

type SystemVariableStringType added in v0.5.0

type SystemVariableStringType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableStringType added in v0.5.0

func InitSystemVariableStringType(name string) SystemVariableStringType

func (SystemVariableStringType) Convert added in v0.5.0

func (svst SystemVariableStringType) Convert(value interface{}) (interface{}, error)

func (SystemVariableStringType) ConvertFromString added in v0.8.0

func (svst SystemVariableStringType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableStringType) MysqlType added in v0.5.0

func (svst SystemVariableStringType) MysqlType() defines.MysqlType

func (SystemVariableStringType) String added in v0.5.0

func (svst SystemVariableStringType) String() string

func (SystemVariableStringType) Type added in v0.5.0

func (svst SystemVariableStringType) Type() types.T

func (SystemVariableStringType) Zero added in v0.5.0

func (svst SystemVariableStringType) Zero() interface{}

type SystemVariableType added in v0.5.0

type SystemVariableType interface {
	fmt.Stringer

	// Convert the value to another value of the type
	Convert(value interface{}) (interface{}, error)

	// Type gets the type in the computation engine
	Type() types.T

	// MysqlType gets the mysql type
	MysqlType() defines.MysqlType

	// Zero gets the zero value for the type
	Zero() interface{}

	// Convert the value from string to another value of the type
	ConvertFromString(value string) (interface{}, error)
}

type SystemVariableUintType added in v0.5.0

type SystemVariableUintType struct {
	// contains filtered or unexported fields
}

func InitSystemVariableUintType added in v0.5.0

func InitSystemVariableUintType(name string, minimum, maximum uint64) SystemVariableUintType

func (SystemVariableUintType) Convert added in v0.5.0

func (svut SystemVariableUintType) Convert(value interface{}) (interface{}, error)

func (SystemVariableUintType) ConvertFromString added in v0.8.0

func (svut SystemVariableUintType) ConvertFromString(value string) (interface{}, error)

func (SystemVariableUintType) MysqlType added in v0.5.0

func (svut SystemVariableUintType) MysqlType() defines.MysqlType

func (SystemVariableUintType) String added in v0.5.0

func (svut SystemVariableUintType) String() string

func (SystemVariableUintType) Type added in v0.5.0

func (svut SystemVariableUintType) Type() types.T

func (SystemVariableUintType) Zero added in v0.5.0

func (svut SystemVariableUintType) Zero() interface{}

type SystemVariables added in v1.2.1

type SystemVariables struct {
	// contains filtered or unexported fields
}

SystemVariables is account level

func (*SystemVariables) Clone added in v1.2.1

func (sv *SystemVariables) Clone() *SystemVariables

Clone returns a copy of sv

func (*SystemVariables) Get added in v1.2.1

func (sv *SystemVariables) Get(name string) interface{}

func (*SystemVariables) Set added in v1.2.1

func (sv *SystemVariables) Set(name string, value interface{})

type TS added in v1.1.0

type TS string
const (
	// Created
	TSCreatedStart TS = "TSCreatedStart"
	TSCreatedEnd   TS = "TSCreatedEnd"

	// Handler
	TSEstablishStart  TS = "TSEstablishStart"
	TSEstablishEnd    TS = "TSEstablishEnd"
	TSUpgradeTLSStart TS = "TSUpgradeTLSStart"
	TSUpgradeTLSEnd   TS = "TSUpgradeTLSEnd"

	// mysql protocol
	TSAuthenticateStart  TS = "TSAuthenticateStart"
	TSAuthenticateEnd    TS = "TSAuthenticateEnd"
	TSSendErrPacketStart TS = "TSSendErrPacketStart"
	TSSendErrPacketEnd   TS = "TSSendErrPacketEnd"
	TSSendOKPacketStart  TS = "TSSendOKPacketStart"
	TSSendOKPacketEnd    TS = "TSSendOKPacketEnd"

	// session
	TSCheckTenantStart      TS = "TSCheckTenantStart"
	TSCheckTenantEnd        TS = "TSCheckTenantEnd"
	TSCheckUserStart        TS = "TSCheckUserStart"
	TSCheckUserEnd          TS = "TSCheckUserEnd"
	TSCheckRoleStart        TS = "TSCheckRoleStart"
	TSCheckRoleEnd          TS = "TSCheckRoleEnd"
	TSCheckDbNameStart      TS = "TSCheckDbNameStart"
	TSCheckDbNameEnd        TS = "TSCheckDbNameEnd"
	TSInitGlobalSysVarStart TS = "TSInitGlobalSysVarStart"
	TSInitGlobalSysVarEnd   TS = "TSInitGlobalSysVarEnd"
)

type TableIDInfo

type TableIDInfo struct {
	TableID   uint64
	DbID      uint64
	DbName    string
	TableName string
}

TableIDInfo contains table ID and database ID information

type TableInfo added in v0.5.0

type TableInfo interface {
	GetColumns()
}

type TenantInfo added in v0.6.0

type TenantInfo struct {
	Tenant      string
	User        string
	DefaultRole string

	TenantID      uint32
	UserID        uint32
	DefaultRoleID uint32
	// contains filtered or unexported fields
}

func GetBackgroundTenant added in v1.2.0

func GetBackgroundTenant() *TenantInfo

func GetTenantInfo added in v0.6.0

func GetTenantInfo(ctx context.Context, userInput string) (*TenantInfo, error)

GetTenantInfo extract tenant info from the input of the user. * The format of the user 1. tenant:user:role 2. tenant:user 3. user

a new format: 1. tenant#user#role 2. tenant#user

func (*TenantInfo) Copy

func (ti *TenantInfo) Copy() *TenantInfo

func (*TenantInfo) GetDefaultRole added in v0.6.0

func (ti *TenantInfo) GetDefaultRole() string

func (*TenantInfo) GetDefaultRoleID added in v0.6.0

func (ti *TenantInfo) GetDefaultRoleID() uint32

func (*TenantInfo) GetTenant added in v0.6.0

func (ti *TenantInfo) GetTenant() string

func (*TenantInfo) GetTenantID added in v0.6.0

func (ti *TenantInfo) GetTenantID() uint32

func (*TenantInfo) GetUseSecondaryRole added in v0.6.0

func (ti *TenantInfo) GetUseSecondaryRole() bool

func (*TenantInfo) GetUser added in v0.6.0

func (ti *TenantInfo) GetUser() string

func (*TenantInfo) GetUserID added in v0.6.0

func (ti *TenantInfo) GetUserID() uint32

func (*TenantInfo) GetVersion added in v0.7.0

func (ti *TenantInfo) GetVersion() string

func (*TenantInfo) HasDefaultRole added in v0.6.0

func (ti *TenantInfo) HasDefaultRole() bool

func (*TenantInfo) IsAccountAdminRole added in v0.6.0

func (ti *TenantInfo) IsAccountAdminRole() bool

func (*TenantInfo) IsAdminRole added in v0.6.0

func (ti *TenantInfo) IsAdminRole() bool

func (*TenantInfo) IsDefaultRole added in v0.6.0

func (ti *TenantInfo) IsDefaultRole() bool

func (*TenantInfo) IsMoAdminRole added in v0.6.0

func (ti *TenantInfo) IsMoAdminRole() bool

func (*TenantInfo) IsNameOfAdminRoles added in v0.6.0

func (ti *TenantInfo) IsNameOfAdminRoles(name string) bool

func (*TenantInfo) IsSysTenant added in v0.6.0

func (ti *TenantInfo) IsSysTenant() bool

func (*TenantInfo) SetDefaultRole added in v0.6.0

func (ti *TenantInfo) SetDefaultRole(r string)

func (*TenantInfo) SetDefaultRoleID added in v0.6.0

func (ti *TenantInfo) SetDefaultRoleID(id uint32)

func (*TenantInfo) SetTenantID added in v0.6.0

func (ti *TenantInfo) SetTenantID(id uint32)

func (*TenantInfo) SetUseSecondaryRole added in v0.6.0

func (ti *TenantInfo) SetUseSecondaryRole(v bool)

func (*TenantInfo) SetUser added in v0.8.0

func (ti *TenantInfo) SetUser(user string)

func (*TenantInfo) SetUserID added in v0.6.0

func (ti *TenantInfo) SetUserID(id uint32)

func (*TenantInfo) SetVersion added in v0.7.0

func (ti *TenantInfo) SetVersion(version string)

func (*TenantInfo) String added in v0.6.0

func (ti *TenantInfo) String() string

type Transition

type Transition int

Transition represents a state transition action

const (
	// TransitionStart represents the Start action
	TransitionStart Transition = iota
	// TransitionStartSuccess represents successful Start completion
	TransitionStartSuccess
	// TransitionStartFail represents failed Start
	TransitionStartFail
	// TransitionPause represents the Pause action
	TransitionPause
	// TransitionPauseComplete represents Pause completion
	TransitionPauseComplete
	// TransitionResume represents the Resume action
	TransitionResume
	// TransitionRestart represents the Restart action
	TransitionRestart
	// TransitionRestartBegin represents Restart beginning new Start
	TransitionRestartBegin
	// TransitionCancel represents the Cancel action
	TransitionCancel
	// TransitionCancelComplete represents Cancel completion
	TransitionCancelComplete
)

func (Transition) String

func (t Transition) String() string

String returns the string representation of Transition

type TxnClient added in v0.6.0

type TxnClient = client.TxnClient

type TxnCompilerContext added in v0.5.0

type TxnCompilerContext struct {
	// contains filtered or unexported fields
}

func InitTxnCompilerContext added in v0.5.0

func InitTxnCompilerContext(db string) *TxnCompilerContext

func (*TxnCompilerContext) BuildTableDefByMoColumns

func (tcc *TxnCompilerContext) BuildTableDefByMoColumns(dbName, table string) (*plan.TableDef, error)

func (*TxnCompilerContext) CheckSubscriptionValid added in v0.8.0

func (tcc *TxnCompilerContext) CheckSubscriptionValid(subName, accName, pubName string) error

func (*TxnCompilerContext) CheckTimeStampValid added in v1.2.0

func (tcc *TxnCompilerContext) CheckTimeStampValid(ts int64) (bool, error)

func (*TxnCompilerContext) Close

func (tcc *TxnCompilerContext) Close()

func (*TxnCompilerContext) DatabaseExists added in v0.5.0

func (tcc *TxnCompilerContext) DatabaseExists(name string, snapshot *plan2.Snapshot) bool

func (*TxnCompilerContext) DefaultDatabase added in v0.5.0

func (tcc *TxnCompilerContext) DefaultDatabase() string

func (*TxnCompilerContext) GetAccountId added in v0.6.0

func (tcc *TxnCompilerContext) GetAccountId() (uint32, error)

func (*TxnCompilerContext) GetAccountName

func (tcc *TxnCompilerContext) GetAccountName() string

func (*TxnCompilerContext) GetBuildingAlterView added in v0.7.0

func (tcc *TxnCompilerContext) GetBuildingAlterView() (bool, string, string)

func (*TxnCompilerContext) GetConfig

func (tcc *TxnCompilerContext) GetConfig(varName string, dbName string, tblName string) (string, error)

func (*TxnCompilerContext) GetContext added in v0.7.0

func (tcc *TxnCompilerContext) GetContext() context.Context

func (*TxnCompilerContext) GetDatabase added in v1.2.3

func (tcc *TxnCompilerContext) GetDatabase() string

func (*TxnCompilerContext) GetDatabaseId added in v0.8.0

func (tcc *TxnCompilerContext) GetDatabaseId(dbName string, snapshot *plan2.Snapshot) (uint64, error)

func (*TxnCompilerContext) GetLowerCaseTableNames added in v1.2.1

func (tcc *TxnCompilerContext) GetLowerCaseTableNames() int64

func (*TxnCompilerContext) GetProcess added in v0.7.0

func (tcc *TxnCompilerContext) GetProcess() *process.Process

func (*TxnCompilerContext) GetQueryResultMeta added in v0.7.0

func (tcc *TxnCompilerContext) GetQueryResultMeta(uuid string) ([]*plan.ColDef, string, error)

func (*TxnCompilerContext) GetQueryingSubscription added in v0.8.0

func (tcc *TxnCompilerContext) GetQueryingSubscription() *plan.SubscriptionMeta

func (*TxnCompilerContext) GetRootSql added in v0.6.0

func (tcc *TxnCompilerContext) GetRootSql() string

func (*TxnCompilerContext) GetSession added in v0.6.0

func (tcc *TxnCompilerContext) GetSession() FeSession

func (*TxnCompilerContext) GetSnapshot added in v1.2.0

func (tcc *TxnCompilerContext) GetSnapshot() *plan2.Snapshot

func (*TxnCompilerContext) GetStatsCache added in v0.8.0

func (tcc *TxnCompilerContext) GetStatsCache() *plan2.StatsCache

func (*TxnCompilerContext) GetSubscriptionMeta added in v0.8.0

func (tcc *TxnCompilerContext) GetSubscriptionMeta(dbName string, snapshot *plan2.Snapshot) (*plan.SubscriptionMeta, error)

func (*TxnCompilerContext) GetTxnHandler added in v0.6.0

func (tcc *TxnCompilerContext) GetTxnHandler() *TxnHandler

func (*TxnCompilerContext) GetUserName added in v0.6.0

func (tcc *TxnCompilerContext) GetUserName() string

func (*TxnCompilerContext) GetViews added in v1.2.0

func (tcc *TxnCompilerContext) GetViews() []string

func (*TxnCompilerContext) InitExecuteStmtParam

func (tcc *TxnCompilerContext) InitExecuteStmtParam(execPlan *plan.Execute) (*plan.Plan, tree.Statement, error)

func (*TxnCompilerContext) IsPublishing added in v0.8.0

func (tcc *TxnCompilerContext) IsPublishing(dbName string) (bool, error)

func (*TxnCompilerContext) Resolve added in v0.5.0

func (tcc *TxnCompilerContext) Resolve(dbName string, tableName string, snapshot *plan2.Snapshot) (*plan2.ObjectRef, *plan2.TableDef, error)

func (*TxnCompilerContext) ResolveAccountIds added in v0.7.0

func (tcc *TxnCompilerContext) ResolveAccountIds(accountNames []string) (accountIds []uint32, err error)

func (*TxnCompilerContext) ResolveById added in v0.7.0

func (tcc *TxnCompilerContext) ResolveById(tableId uint64, snapshot *plan2.Snapshot) (*plan2.ObjectRef, *plan2.TableDef, error)

func (*TxnCompilerContext) ResolveIndexTableByRef

func (tcc *TxnCompilerContext) ResolveIndexTableByRef(
	ref *plan.ObjectRef,
	tblName string,
	snapshot *plan2.Snapshot,
) (*plan2.ObjectRef, *plan2.TableDef, error)

func (*TxnCompilerContext) ResolveSnapshotWithSnapshotName added in v1.2.0

func (tcc *TxnCompilerContext) ResolveSnapshotWithSnapshotName(snapshotName string) (*plan2.Snapshot, error)

func (*TxnCompilerContext) ResolveSubscriptionTableById added in v1.2.0

func (tcc *TxnCompilerContext) ResolveSubscriptionTableById(tableId uint64, subMeta *plan.SubscriptionMeta) (*plan2.ObjectRef, *plan2.TableDef, error)

func (*TxnCompilerContext) ResolveUdf added in v0.8.0

func (tcc *TxnCompilerContext) ResolveUdf(name string, args []*plan.Expr) (udf *function.Udf, err error)

func (*TxnCompilerContext) ResolveVariable added in v0.5.0

func (tcc *TxnCompilerContext) ResolveVariable(varName string, isSystemVar, isGlobalVar bool) (varValue interface{}, err error)

func (*TxnCompilerContext) SetBuildingAlterView added in v0.7.0

func (tcc *TxnCompilerContext) SetBuildingAlterView(yesOrNo bool, dbName, viewName string)

func (*TxnCompilerContext) SetContext

func (tcc *TxnCompilerContext) SetContext(ctx context.Context)

func (*TxnCompilerContext) SetDatabase added in v0.5.0

func (tcc *TxnCompilerContext) SetDatabase(db string)

func (*TxnCompilerContext) SetExecCtx added in v1.2.0

func (tcc *TxnCompilerContext) SetExecCtx(execCtx *ExecCtx)

func (*TxnCompilerContext) SetQueryingSubscription added in v0.8.0

func (tcc *TxnCompilerContext) SetQueryingSubscription(meta *plan.SubscriptionMeta)

func (*TxnCompilerContext) SetSnapshot added in v1.2.0

func (tcc *TxnCompilerContext) SetSnapshot(snapshot *plan2.Snapshot)

func (*TxnCompilerContext) SetViews added in v1.2.0

func (tcc *TxnCompilerContext) SetViews(views []string)

func (*TxnCompilerContext) Stats added in v0.7.0

func (tcc *TxnCompilerContext) Stats(obj *plan2.ObjectRef, snapshot *plan2.Snapshot) (*pb.StatsInfo, error)

type TxnComputationWrapper added in v0.5.0

type TxnComputationWrapper struct {
	// contains filtered or unexported fields
}

func InitTxnComputationWrapper added in v0.5.0

func InitTxnComputationWrapper(
	ses FeSession,
	stmt tree.Statement,
	proc *process.Process,
) *TxnComputationWrapper

func (*TxnComputationWrapper) BinaryExecute

func (cwft *TxnComputationWrapper) BinaryExecute() (bool, string)

func (*TxnComputationWrapper) Clear added in v1.2.0

func (cwft *TxnComputationWrapper) Clear()

func (*TxnComputationWrapper) Compile added in v0.5.0

func (cwft *TxnComputationWrapper) Compile(any any, fill func(*batch.Batch, *perfcounter.CounterSet) error) (interface{}, error)

Compile build logical plan and then build physical plan `Compile` object

func (*TxnComputationWrapper) Free added in v1.1.0

func (cwft *TxnComputationWrapper) Free()

func (*TxnComputationWrapper) GetAst added in v0.5.0

func (cwft *TxnComputationWrapper) GetAst() tree.Statement

func (*TxnComputationWrapper) GetColumns added in v0.5.0

func (cwft *TxnComputationWrapper) GetColumns(ctx context.Context) ([]interface{}, error)

func (*TxnComputationWrapper) GetLoadTag added in v0.6.0

func (cwft *TxnComputationWrapper) GetLoadTag() bool

func (*TxnComputationWrapper) GetProcess added in v0.6.0

func (cwft *TxnComputationWrapper) GetProcess() *process.Process

func (*TxnComputationWrapper) GetServerStatus added in v0.8.1

func (cwft *TxnComputationWrapper) GetServerStatus() uint16

func (*TxnComputationWrapper) GetUUID added in v0.6.0

func (cwft *TxnComputationWrapper) GetUUID() []byte

func (*TxnComputationWrapper) ParamVals added in v1.2.1

func (cwft *TxnComputationWrapper) ParamVals() []any

func (*TxnComputationWrapper) Plan added in v1.2.0

func (cwft *TxnComputationWrapper) Plan() *plan.Plan

func (*TxnComputationWrapper) RecordCompoundStmt

func (cwft *TxnComputationWrapper) RecordCompoundStmt(ctx context.Context, statsBytes statistic.StatsArray) error

RecordCompoundStmt Check if it is a compound statement, What is a compound statement?

func (*TxnComputationWrapper) RecordExecPlan added in v0.6.0

func (cwft *TxnComputationWrapper) RecordExecPlan(ctx context.Context, phyPlan *models.PhyPlan) error

func (*TxnComputationWrapper) ResetPlanAndStmt added in v1.2.0

func (cwft *TxnComputationWrapper) ResetPlanAndStmt(stmt tree.Statement)

func (*TxnComputationWrapper) Run added in v0.5.0

func (cwft *TxnComputationWrapper) Run(ts uint64) (*util2.RunResult, error)

func (*TxnComputationWrapper) SetExplainBuffer

func (cwft *TxnComputationWrapper) SetExplainBuffer(buf *bytes.Buffer)

func (*TxnComputationWrapper) StatsCompositeSubStmtResource

func (cwft *TxnComputationWrapper) StatsCompositeSubStmtResource(ctx context.Context) (statsByte statistic.StatsArray)

type TxnHandler added in v0.5.0

type TxnHandler struct {
	// contains filtered or unexported fields
}

func InitTxnHandler added in v0.5.0

func InitTxnHandler(service string, storage engine.Engine, connCtx context.Context, txnOp TxnOperator) *TxnHandler

func (*TxnHandler) Close added in v1.2.0

func (th *TxnHandler) Close()

func (*TxnHandler) Commit added in v1.2.0

func (th *TxnHandler) Commit(execCtx *ExecCtx) error

Commit commits the txn. option bits decide the actual commit behaviour

func (*TxnHandler) Create added in v1.2.0

func (th *TxnHandler) Create(execCtx *ExecCtx) error

Create starts a new txn. option bits decide the actual behaviour

func (*TxnHandler) GetConnCtx added in v1.2.0

func (th *TxnHandler) GetConnCtx() context.Context

func (*TxnHandler) GetOptionBits added in v1.2.0

func (th *TxnHandler) GetOptionBits() uint32

func (*TxnHandler) GetServerStatus added in v1.2.0

func (th *TxnHandler) GetServerStatus() uint16

func (*TxnHandler) GetStorage added in v0.5.0

func (th *TxnHandler) GetStorage() engine.Engine

func (*TxnHandler) GetTxn added in v0.5.0

func (th *TxnHandler) GetTxn() TxnOperator

func (*TxnHandler) GetTxnCtx added in v1.2.0

func (th *TxnHandler) GetTxnCtx() context.Context

func (*TxnHandler) InActiveTxn added in v1.2.0

func (th *TxnHandler) InActiveTxn() bool

func (*TxnHandler) InMultiStmtTransactionMode added in v1.2.0

func (th *TxnHandler) InMultiStmtTransactionMode() bool

func (*TxnHandler) IsShareTxn added in v0.8.0

func (th *TxnHandler) IsShareTxn() bool

func (*TxnHandler) OptionBitsIsSet added in v1.2.0

func (th *TxnHandler) OptionBitsIsSet(bit uint32) bool

func (*TxnHandler) Rollback added in v0.5.0

func (th *TxnHandler) Rollback(execCtx *ExecCtx) error

Rollback rolls back the txn the option bits decide the actual behavior

func (*TxnHandler) SetAutocommit added in v1.2.0

func (th *TxnHandler) SetAutocommit(execCtx *ExecCtx, old, on bool) error

SetAutocommit sets the value of the system variable 'autocommit'.

It commits the active transaction if the old value is false and the new value is true.

func (*TxnHandler) SetOptionBits added in v1.2.0

func (th *TxnHandler) SetOptionBits(bits uint32)

func (*TxnHandler) SetServerStatus added in v1.2.0

func (th *TxnHandler) SetServerStatus(status uint16)

func (*TxnHandler) SetShareTxn

func (th *TxnHandler) SetShareTxn(txnOp TxnOperator)

SetShareTxn updates the shared transaction operator. This is used to reuse a TxnHandler with a new transaction without recreating the entire object.

type TxnOperator added in v0.6.0

type TxnOperator = client.TxnOperator

type TxnOption added in v0.6.0

type TxnOption = client.TxnOption

type UserDefinedVar added in v1.0.2

type UserDefinedVar struct {
	Value interface{}
	Sql   string
}

type UserInput added in v0.8.0

type UserInput struct {
	// contains filtered or unexported fields
}

UserInput normally, just use the sql. for some special statement, like 'set_var', we need to use the stmt. if the stmt is not nil, we neglect the sql.

Directories

Path Synopsis
Package mock_frontend is a generated GoMock package.
Package mock_frontend is a generated GoMock package.
mock_file
Package mock_file is a generated GoMock package.
Package mock_file is a generated GoMock package.
mock_incr
Package mock_incr is a generated GoMock package.
Package mock_incr is a generated GoMock package.
mock_lock
Package mock_lock is a generated GoMock package.
Package mock_lock is a generated GoMock package.
mock_moserver
Package mock_moserver is a generated GoMock package.
Package mock_moserver is a generated GoMock package.
mock_query
Package mock_query is a generated GoMock package.
Package mock_query is a generated GoMock package.
mock_shard
Package mock_shard is a generated GoMock package.
Package mock_shard is a generated GoMock package.
mock_task
Package mock_task is a generated GoMock package.
Package mock_task is a generated GoMock package.

Jump to

Keyboard shortcuts

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