clickhouse

package
v2.4.30 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShardBackupFull   = "full"
	ShardBackupNone   = "none"
	ShardBackupSchema = "schema-only"
)

Variables

View Source
var (
	ErrShardOperationVers = errors.New("sharded operations are only supported for " +
		"clickhouse-server >= v21.x")
)

Functions

func GetDisksByPaths

func GetDisksByPaths(disks []Disk, dataPaths []string) map[string]string

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 (ch *ClickHouse) ApplyMacros(ctx context.Context, s string) (string, error)

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, dstTable Table) error

AttachDataParts - execute ALTER TABLE ... ATTACH PART command for specific table

func (*ClickHouse) AttachTable

func (ch *ClickHouse) AttachTable(ctx context.Context, table metadata.TableMetadata, dstTable Table) error

AttachTable - execute ATTACH TABLE command for specific table

func (*ClickHouse) CalculateMaxFileSize

func (ch *ClickHouse) CalculateMaxFileSize(ctx context.Context, cfg *config.Config) (int64, error)

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 (ch *ClickHouse) CheckSettingsExists(ctx context.Context, settings map[string]bool) (map[string]bool, error)

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) CheckTypesConsistency added in v2.4.24

func (ch *ClickHouse) CheckTypesConsistency(table *Table, partColumnsDataTypes []ColumnDataTypes) error

func (*ClickHouse) Close

func (ch *ClickHouse) Close()

Close - closing connection to ClickHouse

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) ExtractStoragePolicy added in v2.4.26

func (ch *ClickHouse) ExtractStoragePolicy(query string) string

func (*ClickHouse) FreezeTable

func (ch *ClickHouse) FreezeTable(ctx context.Context, table *Table, name string) error

FreezeTable - freeze all partitions for table This way available for ClickHouse since v19.1

func (*ClickHouse) FreezeTableOldWay

func (ch *ClickHouse) FreezeTableOldWay(ctx context.Context, table *Table, name string) error

FreezeTableOldWay - freeze all partitions in table one by one This way using for ClickHouse below v19.1

func (*ClickHouse) GetAccessManagementPath

func (ch *ClickHouse) GetAccessManagementPath(ctx context.Context, disks []Disk) (string, error)

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

func (ch *ClickHouse) GetDisks(ctx context.Context, enrich bool) ([]Disk, error)

GetDisks - return data from system.disks table

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

func (ch *ClickHouse) GetTables(ctx context.Context, tablePattern string) ([]Table, error)

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

func (ch *ClickHouse) IsAtomic(database string) (bool, error)

func (*ClickHouse) IsClickhouseShadow

func (ch *ClickHouse) IsClickhouseShadow(path string) bool

func (*ClickHouse) LogQuery

func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string

func (*ClickHouse) ParseXML

func (ch *ClickHouse) ParseXML(ctx context.Context, configName string) (configFile string, doc *xmlquery.Node, err error)

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 ColumnDataTypes added in v2.4.24

type ColumnDataTypes struct {
	Column string   `ch:"column"`
	Types  []string `ch:"uniq_types"`
}

ColumnDataTypes - info from system.parts_columns

type Database

type Database struct {
	Name   string `ch:"name"`
	Engine string `ch:"engine"`
	Query  string `ch:"query"`
}

Database - Clickhouse system.databases struct

type Disk

type Disk struct {
	Name            string   `ch:"name"`
	Path            string   `ch:"path"`
	Type            string   `ch:"type"`
	FreeSpace       uint64   `ch:"free_space"`
	StoragePolicies []string `ch:"storage_policies"`
	IsBackup        bool
}

type Function

type Function struct {
	Name        string `ch:"name"`
	CreateQuery string `ch:"create_query"`
}

Function - Clickhouse system.functions 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 Macro

type Macro struct {
	Macro        string `ch:"macro"`
	Substitution string `ch:"substitution"`
}

Macro - info from system.macros

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

Jump to

Keyboard shortcuts

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