Documentation ¶
Index ¶
- Constants
- Variables
- func GetDisksByPaths(disks []Disk, dataPaths []string) map[string]string
- type ClickHouse
- func (ch *ClickHouse) ApplyMacros(ctx context.Context, s string) (string, error)
- func (ch *ClickHouse) ApplyMutation(ctx context.Context, tableMetadata metadata.TableMetadata, ...) error
- func (ch *ClickHouse) AttachDataParts(table metadata.TableMetadata, disks []Disk) error
- func (ch *ClickHouse) AttachTable(ctx context.Context, table metadata.TableMetadata) error
- func (ch *ClickHouse) CalculateMaxFileSize(ctx context.Context, cfg *config.Config) (int64, error)
- func (ch *ClickHouse) CanShardOperation(ctx context.Context) error
- func (ch *ClickHouse) CheckReplicationInProgress(table metadata.TableMetadata) (bool, error)
- func (ch *ClickHouse) CheckSettingsExists(ctx context.Context, settings map[string]bool) (map[string]bool, error)
- func (ch *ClickHouse) CheckSystemPartsColumns(ctx context.Context, table *Table) error
- func (ch *ClickHouse) Close()
- func (ch *ClickHouse) Connect() error
- func (ch *ClickHouse) CreateDatabase(database string, cluster string) error
- func (ch *ClickHouse) CreateDatabaseFromQuery(ctx context.Context, query, cluster string, args ...interface{}) error
- func (ch *ClickHouse) CreateDatabaseWithEngine(database, engine, cluster string) error
- func (ch *ClickHouse) CreateTable(table Table, query string, dropTable, ignoreDependencies bool, ...) error
- func (ch *ClickHouse) CreateUserDefinedFunction(name string, query string, cluster string) error
- func (ch *ClickHouse) DropTable(table Table, query string, onCluster string, ignoreDependencies bool, ...) error
- func (ch *ClickHouse) FreezeTable(ctx context.Context, table *Table, name string) error
- func (ch *ClickHouse) FreezeTableOldWay(ctx context.Context, table *Table, name string) error
- func (ch *ClickHouse) GetAccessManagementPath(ctx context.Context, disks []Disk) (string, error)
- func (ch *ClickHouse) GetBackupTablesLegacy(backupName string, disks []Disk) ([]metadata.TableMetadata, error)
- func (ch *ClickHouse) GetConn() driver.Conn
- func (ch *ClickHouse) GetDatabases(ctx context.Context, cfg *config.Config, tablePattern string) ([]Database, error)
- func (ch *ClickHouse) GetDefaultPath(disks []Disk) (string, error)
- func (ch *ClickHouse) GetDisks(ctx context.Context, enrich bool) ([]Disk, error)
- func (ch *ClickHouse) GetEmbeddedBackupPath(disks []Disk) (string, error)
- func (ch *ClickHouse) GetInProgressMutations(ctx context.Context, database string, table string) ([]metadata.MutationMetadata, error)
- func (ch *ClickHouse) GetPreprocessedConfigPath(ctx context.Context) (string, error)
- func (ch *ClickHouse) GetPreprocessedXMLSettings(ctx context.Context, settingsXPath map[string]string, fileName string) (map[string]string, error)
- func (ch *ClickHouse) GetTables(ctx context.Context, tablePattern string) ([]Table, error)
- func (ch *ClickHouse) GetUserDefinedFunctions(ctx context.Context) ([]Function, error)
- func (ch *ClickHouse) GetVersion(ctx context.Context) (int, error)
- func (ch *ClickHouse) GetVersionDescribe(ctx context.Context) string
- func (ch *ClickHouse) IsAtomic(database string) (bool, error)
- func (ch *ClickHouse) IsClickhouseShadow(path string) bool
- func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string
- func (ch *ClickHouse) ParseXML(ctx context.Context, configName string) (configFile string, doc *xmlquery.Node, err error)
- func (ch *ClickHouse) Query(query string, args ...interface{}) error
- func (ch *ClickHouse) QueryContext(ctx context.Context, query string, args ...interface{}) error
- func (ch *ClickHouse) Select(dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectSingleRow(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) SelectSingleRowNoCtx(dest interface{}, query string, args ...interface{}) error
- func (ch *ClickHouse) ShowCreateTable(ctx context.Context, database, name string) string
- func (ch *ClickHouse) StructSelect(dest interface{}, query string, args ...interface{}) error
- type Database
- type Disk
- type Function
- type IsSystemTablesFieldPresent
- type Macro
- type ShardBackupType
- type SystemBackups
- type Table
Constants ¶
const ( ShardBackupFull = "full" ShardBackupNone = "none" ShardBackupSchema = "schema-only" )
Variables ¶
var (
ErrShardOperationVers = errors.New("sharded operations are only supported for " +
"clickhouse-server >= v21.x")
)
Functions ¶
Types ¶
type ClickHouse ¶
type ClickHouse struct { Config *config.ClickHouseConfig Log *apexLog.Entry IsOpen bool // contains filtered or unexported fields }
ClickHouse - provide
func (*ClickHouse) ApplyMacros ¶
func (*ClickHouse) ApplyMutation ¶
func (ch *ClickHouse) ApplyMutation(ctx context.Context, tableMetadata metadata.TableMetadata, mutation metadata.MutationMetadata) error
func (*ClickHouse) AttachDataParts ¶
func (ch *ClickHouse) AttachDataParts(table metadata.TableMetadata, disks []Disk) error
AttachDataParts - execute ALTER TABLE ... ATTACH PART command for specific table
func (*ClickHouse) AttachTable ¶
func (ch *ClickHouse) AttachTable(ctx context.Context, table metadata.TableMetadata) error
AttachTable - execute ATTACH TABLE command for specific table
func (*ClickHouse) CalculateMaxFileSize ¶
func (*ClickHouse) CanShardOperation ¶
func (ch *ClickHouse) CanShardOperation(ctx context.Context) error
func (*ClickHouse) CheckReplicationInProgress ¶
func (ch *ClickHouse) CheckReplicationInProgress(table metadata.TableMetadata) (bool, error)
CheckReplicationInProgress allow to avoid concurrent ATTACH PART https://github.com/Altinity/clickhouse-backup/issues/474
func (*ClickHouse) CheckSettingsExists ¶
func (*ClickHouse) CheckSystemPartsColumns ¶
func (ch *ClickHouse) CheckSystemPartsColumns(ctx context.Context, table *Table) error
CheckSystemPartsColumns check data parts types consistency https://github.com/Altinity/clickhouse-backup/issues/529#issuecomment-1554460504
func (*ClickHouse) Connect ¶
func (ch *ClickHouse) Connect() error
Connect - establish connection to ClickHouse
func (*ClickHouse) CreateDatabase ¶
func (ch *ClickHouse) CreateDatabase(database string, cluster string) error
CreateDatabase - create ClickHouse database
func (*ClickHouse) CreateDatabaseFromQuery ¶
func (ch *ClickHouse) CreateDatabaseFromQuery(ctx context.Context, query, cluster string, args ...interface{}) error
func (*ClickHouse) CreateDatabaseWithEngine ¶
func (ch *ClickHouse) CreateDatabaseWithEngine(database, engine, cluster string) error
func (*ClickHouse) CreateTable ¶
func (ch *ClickHouse) CreateTable(table Table, query string, dropTable, ignoreDependencies bool, onCluster string, version int, defaultDataPath string) error
CreateTable - create ClickHouse table
func (*ClickHouse) CreateUserDefinedFunction ¶
func (ch *ClickHouse) CreateUserDefinedFunction(name string, query string, cluster string) error
func (*ClickHouse) DropTable ¶
func (ch *ClickHouse) DropTable(table Table, query string, onCluster string, ignoreDependencies bool, version int, defaultDataPath string) error
DropTable - drop ClickHouse table
func (*ClickHouse) FreezeTable ¶
FreezeTable - freeze all partitions for table This way available for ClickHouse since v19.1
func (*ClickHouse) FreezeTableOldWay ¶
FreezeTableOldWay - freeze all partitions in table one by one This way using for ClickHouse below v19.1
func (*ClickHouse) GetAccessManagementPath ¶
GetAccessManagementPath extract path from following sources system.user_directories, access_control_path from /var/lib/clickhouse/preprocessed_configs/config.xml, system.disks
func (*ClickHouse) GetBackupTablesLegacy ¶
func (ch *ClickHouse) GetBackupTablesLegacy(backupName string, disks []Disk) ([]metadata.TableMetadata, error)
GetBackupTablesLegacy - return list of backups of tables that can be restored
func (*ClickHouse) GetConn ¶
func (ch *ClickHouse) GetConn() driver.Conn
GetConn - return current connection
func (*ClickHouse) GetDatabases ¶
func (ch *ClickHouse) GetDatabases(ctx context.Context, cfg *config.Config, tablePattern string) ([]Database, error)
GetDatabases - return slice of all non system databases for backup
func (*ClickHouse) GetDefaultPath ¶
func (ch *ClickHouse) GetDefaultPath(disks []Disk) (string, error)
func (*ClickHouse) GetEmbeddedBackupPath ¶
func (ch *ClickHouse) GetEmbeddedBackupPath(disks []Disk) (string, error)
func (*ClickHouse) GetInProgressMutations ¶
func (ch *ClickHouse) GetInProgressMutations(ctx context.Context, database string, table string) ([]metadata.MutationMetadata, error)
func (*ClickHouse) GetPreprocessedConfigPath ¶
func (ch *ClickHouse) GetPreprocessedConfigPath(ctx context.Context) (string, error)
func (*ClickHouse) GetPreprocessedXMLSettings ¶
func (ch *ClickHouse) GetPreprocessedXMLSettings(ctx context.Context, settingsXPath map[string]string, fileName string) (map[string]string, error)
GetPreprocessedXMLSettings - @todo think about from_end and from_zookeeper corner cases
func (*ClickHouse) GetTables ¶
GetTables - return slice of all tables suitable for backup, MySQL and PostgresSQL database engine shall be skipped
func (*ClickHouse) GetUserDefinedFunctions ¶
func (ch *ClickHouse) GetUserDefinedFunctions(ctx context.Context) ([]Function, error)
func (*ClickHouse) GetVersion ¶
func (ch *ClickHouse) GetVersion(ctx context.Context) (int, error)
GetVersion - returned ClickHouse version in number format Example value: 19001005
func (*ClickHouse) GetVersionDescribe ¶
func (ch *ClickHouse) GetVersionDescribe(ctx context.Context) string
func (*ClickHouse) IsClickhouseShadow ¶
func (ch *ClickHouse) IsClickhouseShadow(path string) bool
func (*ClickHouse) LogQuery ¶
func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string
func (*ClickHouse) Query ¶
func (ch *ClickHouse) Query(query string, args ...interface{}) error
func (*ClickHouse) QueryContext ¶
func (ch *ClickHouse) QueryContext(ctx context.Context, query string, args ...interface{}) error
func (*ClickHouse) Select ¶
func (ch *ClickHouse) Select(dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectContext ¶
func (ch *ClickHouse) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectSingleRow ¶
func (ch *ClickHouse) SelectSingleRow(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) SelectSingleRowNoCtx ¶
func (ch *ClickHouse) SelectSingleRowNoCtx(dest interface{}, query string, args ...interface{}) error
func (*ClickHouse) ShowCreateTable ¶
func (ch *ClickHouse) ShowCreateTable(ctx context.Context, database, name string) string
func (*ClickHouse) StructSelect ¶
func (ch *ClickHouse) StructSelect(dest interface{}, query string, args ...interface{}) error
type Database ¶
type Database struct { Name string `ch:"name"` Engine string `ch:"engine"` Query string `ch:"query"` }
Database - Clickhouse system.databases struct
type IsSystemTablesFieldPresent ¶
type IsSystemTablesFieldPresent struct { IsDataPathPresent uint64 `ch:"is_data_path_present"` IsDataPathsPresent uint64 `ch:"is_data_paths_present"` IsUUIDPresent uint64 `ch:"is_uuid_present"` IsCreateTableQueryPresent uint64 `ch:"is_create_table_query_present"` IsTotalBytesPresent uint64 `ch:"is_total_bytes_present"` }
IsSystemTablesFieldPresent - ClickHouse `system.tables` varius field flags
type ShardBackupType ¶
type ShardBackupType string
type SystemBackups ¶
type SystemBackups struct { Id string `ch:"id"` UUID string `ch:"uuid"` BackupName string `ch:"backup_name"` Name string `ch:"name"` Status string `ch:"status"` StatusChangedTime time.Time `ch:"status_changed_time"` Error string `ch:"error"` Internal bool `ch:"internal"` StartTime time.Time `ch:"start_time"` EndTime time.Time `ch:"end_time"` CompressedSize uint64 `ch:"compressed_size"` UncompressedSize uint64 `ch:"uncompressed_size"` NumFiles uint64 `ch:"num_files"` }
SystemBackups - info from system.backups
type Table ¶
type Table struct { // common fields for all `clickhouse-server` versions Database string `ch:"database"` Name string `ch:"name"` Engine string `ch:"engine"` // fields depends on `clickhouse-server` version DataPath string `ch:"data_path"` // For legacy support DataPaths []string `ch:"data_paths"` UUID string `ch:"uuid"` CreateTableQuery string `ch:"create_table_query"` TotalBytes uint64 `ch:"total_bytes"` Skip bool BackupType ShardBackupType }
Table - ClickHouse table struct