Documentation ¶
Overview ¶
Package mysql provides methods to parse SQL and estimate MySQL data sizes.
Index ¶
Constants ¶
const ( InnoDB = Engine("InnoDB") MyISAM = Engine("MyISAM") )
List of supported engines.
const ( Command = "mysql" DefaultPerN = 100 DefaultPrecision = 2 )
Default values used to configure the estimator.
const ( UnknownRowFormat = RowFormat("") CompactRowFormat = RowFormat("compact") CompressedRowFormat = RowFormat("compressed") DynamicRowFormat = RowFormat("dynamic") RedundantRowFormat = RowFormat("redundant") StaticRowFormat = RowFormat("static") )
List of known row formats
const DefaultCharset = "utf8mb4"
DefaultCharset is the default charset used as fail over in any charset is provided.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
Column is a table's column.
type Configurator ¶
Configurator is implemented by any method exposing cursor to adjust the estimator.
func SetBatchMode ¶
func SetBatchMode(enabled bool) Configurator
SetBatchMode defines if the batch mode must be used to export the report in CSV format.
func SetPerN ¶
func SetPerN(i uint64) Configurator
SetPerN defines the number of data to take account in the estimation.
func SetPrecision ¶
func SetPrecision(i uint64) Configurator
SetPrecision defines the decimal precision used to print data size.
func SetVerbose ¶
func SetVerbose(verbose bool) Configurator
SetVerbose defines the verbose mode to use to print the report.
type DataType ¶
type DataType string
DataType represents a MySQL data type.
const ( Bit DataType = "bit" TinyInt DataType = "tinyint" SmallInt DataType = "smallint" MediumInt DataType = "mediumint" Int DataType = "int" Integer DataType = "integer" BigInt DataType = "bigint" Float DataType = "float" Double DataType = "double" Decimal DataType = "decimal" Numeric DataType = "numeric" Real DataType = "real" Year DataType = "year" Date DataType = "date" Time DataType = "time" Timestamp DataType = "timestamp" DateTime DataType = "datetime" Char DataType = "char" Binary DataType = "binary" VarChar DataType = "varchar" VarBinary DataType = "varbinary" TinyBlob DataType = "tinyblob" TinyText DataType = "tinytext" Blob DataType = "blob" Text DataType = "test" MediumBlob DataType = "mediumblob" MediumText DataType = "mediumtext" LongBlob DataType = "longblob" LongText DataType = "longtext" JSON DataType = "json" Enum DataType = "enum" Set DataType = "set" )
List of supported MySQL data types.
func ToDataType ¶
ToDataType returns a MySQL DataType based on the given data name.
func (DataType) Size ¶
Size returns the required storage of the data type for this requested size in bytes and charset. It implements the ds.Data interface. todo To improve (decimal, numeric, etc.) See https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html
type Database ¶
Database represents a database.
type Engine ¶
type Engine string
Engine is an engine.
func ToEngine ¶
ToEngine returns a MySQL engine based on the given engine name. By default the default MySQL engine is used if no one is provided.
func (Engine) Fields ¶
Fields returns the columns with their sizes updated with engine and row format constrains.
func (Engine) RowFormat ¶
RowFormat defines the row format to use based on columns or the current value. sql: SELECT row_format FROM information_schema.tables WHERE table_schema="dbName" AND table_name="tbName";
type Estimator ¶
type Estimator struct {
// contains filtered or unexported fields
}
Estimator represents an MySQL data estimator.
func Estimate ¶
func Estimate(opts ...Configurator) (*Estimator, error)
Estimate tries to instantiate a new estimator based on this configuration.
type Storage ¶
type Storage []Database
Storage represents a storage. It can contain many MySQL database.