Documentation
¶
Overview ¶
Package config defines the YAML-backed configuration for the transformation engine: directories, rule toggles, and charset/collation mappings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoRandomConfig ¶ added in v1.3.0
type AutoRandomConfig struct {
// Tables lists table names to convert, or "*" for every eligible table;
// empty disables the conversion.
Tables []string `yaml:"tables"`
// ShardBits is AUTO_RANDOM's S (1-15).
ShardBits int `yaml:"shard_bits"`
// RangeBits is AUTO_RANDOM's R (32-64). The default 54 keeps every ID
// below 2^53, so it stays exact in JavaScript and below PHP_INT_MAX; 64
// is TiDB's own default and produces IDs up to 2^63-1.
RangeBits int `yaml:"range_bits"`
}
AutoRandomConfig selects tables for AUTO_RANDOM conversion. https://docs.pingcap.com/tidb/stable/auto-random
type CharsetMapping ¶
type CharsetMapping struct {
TargetCharset string `yaml:"target_charset"`
TargetCollation string `yaml:"target_collation"`
}
CharsetMapping defines target charset and collation for a source charset
type Config ¶
type Config struct {
// InputDir specifies the directory to read SQL files from
InputDir string `yaml:"input_dir"`
// OutputDir specifies the directory to write transformed SQL files
OutputDir string `yaml:"output_dir"`
// EnabledRules is a list of rule names to enable
EnabledRules []string `yaml:"enabled_rules"`
// DisabledRules is a list of rule names to disable
DisabledRules []string `yaml:"disabled_rules"`
// FormattingOptions controls output formatting
FormattingOptions FormattingConfig `yaml:"formatting"`
// CharsetMappings defines how to convert character sets
CharsetMappings map[string]CharsetMapping `yaml:"charset_mappings"`
// CollationMappings defines how to convert collations
CollationMappings map[string]string `yaml:"collation_mappings"`
// AllowedDefaultFunctions lists function names the FunctionDefault rule
// keeps in DEFAULT clauses; anything else is stripped.
// https://docs.pingcap.com/tidb/stable/data-type-default-values
AllowedDefaultFunctions []string `yaml:"allowed_default_functions"`
// ZeroDateDefaults controls DEFAULT '0000-00-00...' on date/time columns,
// which TiDB rejects under its default sql_mode (NO_ZERO_DATE,
// NO_ZERO_IN_DATE): "keep" (default) leaves them and warns, "drop"
// removes the DEFAULT clause.
ZeroDateDefaults string `yaml:"zero_date_defaults"`
// AutoRandom converts BIGINT AUTO_INCREMENT primary keys of the listed
// tables to AUTO_RANDOM to avoid write hotspots. Opt-in.
AutoRandom AutoRandomConfig `yaml:"auto_random"`
// ShardRowIDBits adds SHARD_ROW_ID_BITS to tables without a clustered
// primary key (no PRIMARY KEY, or NONCLUSTERED); 0 disables it.
ShardRowIDBits uint64 `yaml:"shard_row_id_bits"`
// PreSplitRegions adds PRE_SPLIT_REGIONS next to SHARD_ROW_ID_BITS; 0
// leaves it out.
PreSplitRegions uint64 `yaml:"pre_split_regions"`
// Removed in v1.2.0 (never implemented); still accepted so existing
// config files load. They have no effect.
LegacyStrictMode *bool `yaml:"strict_mode,omitempty"`
LegacyPreserveComments *bool `yaml:"preserve_comments,omitempty"`
}
Config holds configuration for the transformation engine
func LoadConfig ¶
LoadConfig reads configuration from a YAML file. If path is empty, returns DefaultConfig. Unknown keys and out-of-range values are errors: a typo would otherwise silently fall back to a default.
func (*Config) IsRuleEnabled ¶
IsRuleEnabled checks if a rule is enabled based on configuration
type FormattingConfig ¶
type FormattingConfig struct {
// IndentSize specifies the number of spaces for indentation
IndentSize int `yaml:"indent_size"`
// UppercaseKeywords determines if SQL keywords should be uppercase
UppercaseKeywords bool `yaml:"uppercase_keywords"`
// BackquoteIdentifiers determines if identifiers should be backtick-quoted.
// Disabling it emits bare names, which breaks DDL for reserved words.
BackquoteIdentifiers bool `yaml:"backquote_identifiers"`
// SingleQuoteStrings determines if strings should use single quotes
SingleQuoteStrings bool `yaml:"single_quote_strings"`
}
FormattingConfig controls SQL output formatting