package
9.0.0-alpha+incompatible
Repository: https://github.com/pingcap/tidb.git
Documentation: pkg.go.dev
# README
dbutil library
dbutil is a library that contains a collection of auxiliary functions related to MySQL and TiDB.
# Packages
Package dbutiltest is a package for some common used methods for db related testing.
# Functions
AnalyzeValuesFromBuckets analyze upperBound or lowerBound to string for each column.
CloseDB closes the mysql fd.
ColumnName returns `column`.
DecodeTimeInBucket decodes Time from a packed uint64 value.
DeleteRows delete rows in several times.
ExecSQLWithRetry executes sql with retry.
ExecuteSQLs executes some sqls in one transaction.
FindAllColumnWithIndex returns columns with index, order is pk, uk and normal index.
FindAllIndex returns all index, order is pk, uk, and normal index.
FindColumnByName finds column by name.
FindSuitableColumnWithIndex returns first column of a suitable index.
FormatTimeZoneOffset is to format offset of timezone.
GetBucketsInfo SHOW STATS_BUCKETS in TiDB.
GetCRC32Checksum returns checksum code of some data by given condition.
GetCreateTableSQL returns the create table statement.
GetDBConfigFromEnv returns DBConfig from environment.
GetDBVersion returns the database's version.
GetMinMaxValue return min and max value of given column by specified limitRange condition.
GetParserForDB discovers ANSI_QUOTES in db's session variables and returns a proper parser.
GetRandomValues returns some random value.
GetRowCount returns row count of the table.
GetSchemas returns name of all schemas.
GetSessionVariable gets server's session variable, although argument is QueryExecutor, (session) system variables may be set through DSN.
GetSQLMode returns sql_mode.
GetTables returns name of all tables in the specified schema.
GetTidbLatestTSO returns tidb's current TSO.
GetTimeZoneOffset is to get offset of timezone.
GetViews returns names of all views in the specified schema.
IsFloatType returns true if tp is float type.
IsNumberType returns true if tp is number type.
IsRetryableError checks whether the SQL statement can be retry directly when encountering this error.
IsTiDB returns true if this database is tidb.
IsTimeTypeAndNeedDecode returns true if tp is time type and encoded in tidb buckets.
OpenDB opens a mysql connection FD.
ReplacePlaceholder will use args to replace '?', used for log.
ScanRow scans rows into a map.
ScanRowsToInterfaces scans rows to interface array.
SelectUniqueOrderKey returns some columns for order by condition.
ShowBinlogFormat queries variable 'binlog_format' and returns its value.
ShowBinlogRowImage queries variable 'binlog_row_image' and returns its values.
ShowGrants queries privileges for a mysql user.
ShowIndex returns result of executing `show index`.
ShowLogBin queries variable 'log_bin' and returns its value.
ShowMySQLVariable queries MySQL variable and returns its value.
ShowServerID queries variable 'server_id' and returns its value.
ShowVersion queries variable 'version' and returns its value.
TableName returns `schema`.`table`.
# Constants
DefaultDeleteRowsNum is the default rows num for delete one time.
DefaultRetryTime is the default retry time to execute sql.
DefaultTimeout is the default timeout for execute sql.
SlowLogThreshold defines the duration to log debug log of sql when exec time greater than.
# Variables
ErrNoData means no data in table.
ErrVersionNotFound means can't get the database's version.
Retryable1105Msgs list the error messages of some retryable error with `1105` code (`ErrUnknown`).
# Structs
Bucket saves the bucket information from TiDB.
ColumnData saves column's data.
DBConfig is database configuration.
IndexInfo contains information of table index.
# Interfaces
DBExecutor is a interface for execute read and write statements from a database.
QueryExecutor is a interface for execute Query from a database.