frontend

package
v1.2.3-hotfix-20240916 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0 Imports: 112 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaveQueryResult    = "save_query_result"
	QueryResultMaxsize = "query_result_maxsize"
	QueryResultTimeout = "query_result_timeout"
)
View Source
const (
	DefaultReadBufferSize  int = 512
	DefaultWriteBufferSize int = 512
)
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
)

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 (
	// 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 (
	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 (
	PubDbName = "mo_pubs"
)

Variables

View Source
var (
	// the sqls creating many tables for the tenant.
	// Wrap them in a transaction
	MoCatalogMoUserDDL = `` /* 384-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
			)`, catalog.MO_CATALOG, catalog.MO_SNAPSHOTS)

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

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

	MoCatalogMoStagesDDL = `` /* 265-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`
)
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) unique 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)
)

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

View Source
var Close = func(ep *ExportConfig) error {
	if !ep.UseFileService {
		ep.FileCnt++
		return ep.File.Close()
	} else {
		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 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 EndOfLine = func(ep *ExportConfig) (int, error) {
	if ep.UseFileService {
		n, err := ep.AsyncWriter.Write(ep.LineBuffer.Bytes())
		if err != nil {
			err2 := ep.AsyncWriter.CloseWithError(err)
			if err2 != nil {
				return 0, err2
			}
		}
		ep.LineBuffer.Reset()
		return n, err
	}
	return 0, nil
}
View Source
var ExeSqlInBgSes = func(reqCtx context.Context, upstream *Session, sql string) ([]ExecResult, error) {
	return executeSQLInBackgroundSession(reqCtx, upstream, sql)
}

ExeSqlInBgSes for mock stub

View Source
var Flush = func(ep *ExportConfig) error {
	if !ep.UseFileService {
		return ep.Writer.Flush()
	}
	return nil
}
View Source
var GSysVarsMgr = &GlobalSysVarsMgr{
	accountsGlobalSysVarsMap: make(map[uint32]*SystemVariables),
}
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 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 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 {
		stmts, err = parseSql(execCtx)
		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 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 {
		stmts, err = parseSql(execCtx)
		if err != nil {
			return nil, err
		}
	}

	for _, stmt := range stmts {
		cw = append(cw, InitTxnComputationWrapper(ses, stmt, proc))
	}
	return cw, nil
}
View Source
var GetRawBatchBackgroundExec = func(ctx context.Context, ses *Session) BackgroundExec {
	return ses.GetRawBatchBackgroundExec(ctx)
}
View Source
var MaxPrepareNumberInOneSession int = 100000
View Source
var NewBackgroundExec = func(
	reqCtx context.Context,
	upstream FeSession) BackgroundExec {
	backSes := newBackSession(upstream, nil, "", fakeDataSetFetcher2)
	if up, ok := upstream.(*Session); ok {
		backSes.upstream = up
	}
	bh := &backExec{
		backSes: backSes,
	}

	return bh
}
View Source
var OpenFile = os.OpenFile
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 Read = func(ep *ExportConfig) (int, error) {
	if !ep.UseFileService {
		ep.OutputStr = make([]byte, ep.LineSize)
		return ep.File.Read(ep.OutputStr)
	} else {
		ep.OutputStr = make([]byte, ep.LineSize)
		copy(ep.OutputStr, ep.LineBuffer.Bytes())
		ep.LineBuffer.Reset()
		return int(ep.LineSize), nil
	}
}
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)
	}

	tenant := ses.GetTenantInfo()
	if tenant == nil {
		tenant, _ = GetTenantInfo(ctx, "internal")
	}
	incStatementErrorsCounter(tenant.GetTenant(), 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

		execSql := makeExecuteSql(ctx, ses, statement)
		if len(execSql) != 0 {
			bb := strings.Builder{}
			bb.WriteString(envStmt)
			bb.WriteString(" // ")
			bb.WriteString(execSql)
			text = SubStringFromBegin(bb.String(), int(getGlobalPu().SV.LengthOfQueryPrinted))
		} else {

			text = SubStringFromBegin(envStmt, int(getGlobalPu().SV.LengthOfQueryPrinted))
		}
	} else {
		stmID, _ = uuid.NewV7()
		text = SubStringFromBegin(envStmt, int(getGlobalPu().SV.LengthOfQueryPrinted))
	}
	ses.SetStmtId(stmID)
	ses.SetStmtType(getStatementType(statement).GetStatementType())
	ses.SetQueryType(getStatementType(statement).GetQueryType())
	ses.SetSqlSourceType(sqlType)
	ses.SetSqlOfStmt(text)

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

	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.Account = tenant.GetTenant()
	stm.RoleId = proc.SessionInfo.RoleId
	stm.User = tenant.GetUser()
	stm.Host = ses.respr.GetStr(PEER)
	stm.Database = ses.respr.GetStr(DBNAME)
	stm.Statement = text
	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 stm.IsMoLogger() && stm.StatementType == "Load" && len(stm.Statement) > 128 {
		stm.Statement = envStmt[:40] + "..." + envStmt[len(envStmt)-70:]
	}
	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 Seek = func(ep *ExportConfig) (int64, error) {
	if !ep.UseFileService {
		return ep.File.Seek(int64(ep.CurFileSize-ep.LineSize), io.SeekStart)
	}
	return 0, nil
}
View Source
var Truncate = func(ep *ExportConfig) error {
	if !ep.UseFileService {
		return ep.File.Truncate(int64(ep.CurFileSize - ep.LineSize))
	} else {
		return nil
	}
}
View Source
var Write = func(ep *ExportConfig, output []byte) (int, error) {
	if !ep.UseFileService {
		return ep.Writer.Write(output)
	} else {
		return ep.LineBuffer.Write(output)
	}
}

Functions

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 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 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 GetAdminUserId added in v1.0.0

func GetAdminUserId() uint32

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 GetExplainColumns added in v0.5.0

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

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, ses *Session) (interface{}, error)

only support single value and unary minus

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, 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 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 Min

func Min(a int, b int) int

func MoServerIsStarted added in v1.2.1

func MoServerIsStarted() 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() *internalExecutor

func NewJsonPlanHandler added in v0.8.0

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

func NewMarshalPlanHandler added in v0.8.0

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

func NewSqlCodec

func NewSqlCodec() codec.Codec

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 RewriteError added in v1.0.0

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

RewriteError rewrites the error info

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 SubStringFromBegin

func SubStringFromBegin(str string, length int) string

length: -1, complete string. 0, empty string >0 , length of characters at the header of the string.

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 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 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()

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

BackgroundExec executes the sql in background session without network output.

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 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 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_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_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 ComputationRunner added in v0.5.0

type ComputationRunner interface {
	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) error) (interface{}, error)

	GetUUID() []byte

	RecordExecPlan(ctx context.Context) error

	GetLoadTag() bool

	GetServerStatus() uint16
	Clear()
	Plan() *plan.Plan
	ResetPlanAndStmt(stmt tree.Statement)
	Free()
	ParamVals() []any
}

ComputationWrapper is the wrapper of the computation

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 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

	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)
}

ExecResult is the result interface of the execution

type ExportConfig added in v1.0.0

type ExportConfig struct {

	// file handler
	File *os.File
	// bufio.writer
	Writer *bufio.Writer
	// curFileSize
	CurFileSize uint64
	Rows        uint64
	FileCnt     uint
	ColumnFlag  []bool
	Symbol      [][]byte
	// default flush size
	DefaultBufSize int64
	OutputStr      []byte
	LineSize       uint64

	//file service & buffer for the line
	UseFileService bool

	FileService fileservice.FileService
	LineBuffer  *bytes.Buffer
	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, bat *batch.Batch) error

type FeSession added in v1.2.0

type FeSession interface {
	GetTimeZone() *time.Location
	GetStatsCache() *plan2.StatsCache
	GetUserName() string
	GetSql() string
	GetAccountId() uint32
	GetTenantInfo() *TenantInfo
	GetBackgroundExec(ctx context.Context) 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)
	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()

	GetFPrints() footPrints
	ResetFPrints()
	EnterFPrint(idx int)
	ExitFPrint(idx int)
	SetStaticTxnInfo(string)
	GetStaticTxnInfo() string
	GetShareTxnBackgroundExec(ctx context.Context, newRawBatch bool) BackgroundExec
	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) (*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) 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) AppendUint8

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

func (*IOPackageImpl) IsLittleEndian

func (bio *IOPackageImpl) IsLittleEndian() 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) ReadUint8

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

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

func (*IOPackageImpl) WriteUint8

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

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 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) 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 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) 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, *batch.Batch) error
	Close()
}

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 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(connectionID uint32, tcp goetty.IOSession, 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. return -1 value, if the session is nil unexpected.

packet cnt has 3 part: 1st part: flush op cnt. 2nd part: upload part, calculation = payload / 16KiB 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 baseIO.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) DisableAutoFlush added in v1.2.0

func (mp *MysqlProtocolImpl) DisableAutoFlush()

func (*MysqlProtocolImpl) EnableAutoFlush added in v1.2.0

func (mp *MysqlProtocolImpl) EnableAutoFlush()

func (*MysqlProtocolImpl) Flush added in v1.2.0

func (mp *MysqlProtocolImpl) Flush() error

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) GetStats

func (mp *MysqlProtocolImpl) GetStats() string

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() goetty.IOSession

func (*MysqlProtocolImpl) GetU32 added in v1.2.1

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

func (*MysqlProtocolImpl) GetU8 added in v1.2.1

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

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) 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(options goetty.ReadOptions) (interface{}, error)

func (*MysqlProtocolImpl) ReadIntLenEnc added in v0.8.1

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

func (*MysqlProtocolImpl) ResetStatistics added in v0.7.0

func (mp *MysqlProtocolImpl) ResetStatistics()

func (*MysqlProtocolImpl) ResetStats

func (ds *MysqlProtocolImpl) ResetStats()

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) 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) SetU32 added in v1.2.1

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

func (*MysqlProtocolImpl) SetU8 added in v1.2.1

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

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) Write added in v1.2.1

func (mp *MysqlProtocolImpl) Write(execCtx *ExecCtx, 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) 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) 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) 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(options goetty.ReadOptions) (interface{}, error)
	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
}

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) GetU32 added in v1.2.1

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

func (*MysqlResp) GetU8 added in v1.2.1

func (resper *MysqlResp) GetU8(PropertyID) uint8

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, 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) SetU32 added in v1.2.1

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

func (*MysqlResp) SetU8 added in v1.2.1

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

type MysqlResultSet

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

	//column name --> column index
	Name2Index map[string]uint64

	//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 (*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)

func (*MysqlResultSet) GetValueByName

func (mrs *MysqlResultSet) GetValueByName(ctx context.Context, rindex uint64, colName string) (interface{}, error)

type MysqlRrWr added in v1.2.1

type MysqlRrWr interface {
	MysqlReader
	MysqlWriter
}

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
	WriteEOFOrOK(warnings uint16, status uint16) error
	WriteERR(errorCode uint16, sqlState, errorMessage string) error
	WriteLengthEncodedNumber(uint64) error
	WriteColumnDef(context.Context, Column, int) error
	WriteRow() error
	WriteTextRow() error
	WriteBinaryRow() error
	WriteResultSetRow(mrs *MysqlResultSet, 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)
}

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) GetU32 added in v1.2.1

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

func (*NullResp) GetU8 added in v1.2.1

func (resper *NullResp) GetU8(PropertyID) uint8

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, 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) SetU32 added in v1.2.1

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

func (*NullResp) SetU8 added in v1.2.1

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

type Packet

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

type PrepareStmt added in v0.6.0

type PrepareStmt struct {
	Name           string
	Sql            string
	PreparePlan    *plan.Plan
	PrepareStmt    tree.Statement
	ParamTypes     []byte
	IsInsertValues bool
	InsertBat      *batch.Batch
	// 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
)

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, 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, *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)

	//get the data of row i, column
	GetValueByName(context.Context, uint64, string) (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, rs goetty.IOSession) *Routine

type RoutineManager

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

func NewRoutineManager

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

func (*RoutineManager) Closed

func (rm *RoutineManager) Closed(rs goetty.IOSession)

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

func (*RoutineManager) Created

func (rm *RoutineManager) Created(rs goetty.IOSession)

func (*RoutineManager) GetAccountRoutineManager added in v1.0.0

func (rm *RoutineManager) GetAccountRoutineManager() *AccountRoutineManager

func (*RoutineManager) Handler

func (rm *RoutineManager) Handler(rs goetty.IOSession, msg interface{}, received uint64) 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

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 Session

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

func NewSession

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

func (*Session) AddSeqValues added in v0.8.0

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

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) 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) CountPacket added in v1.1.2

func (ses *Session) CountPacket(delta int64)

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) 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) GetConnectionID added in v0.5.1

func (ses *Session) GetConnectionID() 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) GetFPrints added in v1.2.1

func (ses *Session) GetFPrints() footPrints

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) GetMysqlResultSet added in v0.6.0

func (ses *Session) GetMysqlResultSet() *MysqlResultSet

func (*Session) GetOutputCallback added in v0.6.0

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

func (*Session) GetPacketCnt added in v1.1.2

func (ses *Session) GetPacketCnt() int64

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) 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) 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) 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) 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) (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) 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) 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) ResetBlockIdx added in v0.7.0

func (ses *Session) ResetBlockIdx()

func (*Session) ResetFPrints added in v1.2.1

func (ses *Session) ResetFPrints()

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) 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) 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 at logStatementStringStatus, which means the statement is finished.

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 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)
	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 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) 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 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) 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 Timeout

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

func NewTimeout

func NewTimeout(tg time.Duration, autoUpdateWhenChecked bool) *Timeout

func (*Timeout) UpdateTime

func (t *Timeout) UpdateTime(tn time.Time)

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) 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) 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) GetBuildingAlterView added in v0.7.0

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

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) GetPrimaryKeyDef added in v0.5.0

func (tcc *TxnCompilerContext) GetPrimaryKeyDef(dbName string, tableName string, snapshot plan2.Snapshot) []*plan2.ColDef

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) IsPublishing added in v0.8.0

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

func (*TxnCompilerContext) ReplacePlan added in v1.2.0

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

func (*TxnCompilerContext) Resolve added in v0.5.0

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

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)

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, pubmeta *plan.SubscriptionMeta) (*plan2.ObjectRef, *plan2.TableDef)

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) 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)

func (*TxnCompilerContext) UpdateStatsInCache added in v1.2.0

func (tcc *TxnCompilerContext) UpdateStatsInCache(tid uint64, s *pb.StatsInfo)

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) 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) error) (interface{}, error)

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) GetClock added in v0.7.0

func (cwft *TxnComputationWrapper) GetClock() clock.Clock

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) RecordExecPlan added in v0.6.0

func (cwft *TxnComputationWrapper) RecordExecPlan(ctx context.Context) 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)

type TxnHandler added in v0.5.0

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

func InitTxnHandler added in v0.5.0

func InitTxnHandler(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) CreateTempEngine added in v1.2.0

func (th *TxnHandler) CreateTempEngine()

func (*TxnHandler) CreateTempStorage added in v1.2.0

func (th *TxnHandler) CreateTempStorage(ck clock.Clock) error

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) GetTempEngine added in v1.2.0

func (th *TxnHandler) GetTempEngine() *memoryengine.Engine

func (*TxnHandler) GetTempStorage added in v1.2.0

func (th *TxnHandler) GetTempStorage() *memorystorage.Storage

func (*TxnHandler) GetTempTNService added in v1.2.0

func (th *TxnHandler) GetTempTNService() *metadata.TNService

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) HasTempEngine added in v1.2.0

func (th *TxnHandler) HasTempEngine() bool

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)

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_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.

Jump to

Keyboard shortcuts

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