mysql

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright © 2020 Marvin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	MYSQLDatabaseMaxIdleConn     = 1024
	MYSQLDatabaseMaxConn         = 4096
	MYSQLDatabaseConnMaxLifeTime = 300 * time.Second
	MYSQLDatabaseConnMaxIdleTime = 200 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Ctx         context.Context
	DBConn      *sql.DB
	CallTimeout int64 // unit: seconds, sql execute timeout
}

func NewDatabase

func NewDatabase(ctx context.Context, datasource *datasource.Datasource, callTimeout int64) (*Database, error)

func (*Database) BeginTxn added in v0.0.15

func (d *Database) BeginTxn(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*Database) Close

func (d *Database) Close() error

func (*Database) CommitTxn added in v0.0.15

func (d *Database) CommitTxn(txn *sql.Tx) error

func (*Database) ExecContext

func (d *Database) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*Database) FilterDatabaseIncompatibleTable

func (d *Database) FilterDatabaseIncompatibleTable(sourceSchema string, exporters []string) (*structure.TableObjects, error)

func (*Database) FilterDatabaseSequence added in v0.0.9

func (d *Database) FilterDatabaseSequence(sourceSchema string, includeSequenceS, excludeSequenceS []string) (*structure.SequenceObjects, error)

func (*Database) FilterDatabaseTable

func (d *Database) FilterDatabaseTable(sourceSchema string, includeTableS, excludeTableS []string) (*structure.TableObjects, error)

func (*Database) GeDatabaseInstance

func (d *Database) GeDatabaseInstance() ([]map[string]string, error)

func (*Database) GeneralQuery

func (d *Database) GeneralQuery(query string, args ...any) ([]string, []map[string]string, error)

func (*Database) GetDatabaseCharset

func (d *Database) GetDatabaseCharset() (string, error)

func (*Database) GetDatabaseClusteredTable

func (d *Database) GetDatabaseClusteredTable(schemaName string) ([]string, error)

func (*Database) GetDatabaseCollation

func (d *Database) GetDatabaseCollation() (string, error)

func (*Database) GetDatabaseCompositeTypeTable added in v0.0.6

func (d *Database) GetDatabaseCompositeTypeTable(schemaName string) ([]string, error)

func (*Database) GetDatabaseConsistentPos

func (d *Database) GetDatabaseConsistentPos(ctx context.Context, tx *sql.Tx) (string, error)

func (*Database) GetDatabaseExternalTable added in v0.0.6

func (d *Database) GetDatabaseExternalTable(schemaName string) ([]string, error)

func (*Database) GetDatabaseGlobalName

func (d *Database) GetDatabaseGlobalName() (string, error)

func (*Database) GetDatabaseMaterializedView

func (d *Database) GetDatabaseMaterializedView(schemaName string) ([]string, error)

func (*Database) GetDatabaseNormalView added in v0.0.6

func (d *Database) GetDatabaseNormalView(schemaName string) ([]string, error)

func (*Database) GetDatabaseParameters

func (d *Database) GetDatabaseParameters() (string, string, string, string, error)

func (*Database) GetDatabasePartitionTable

func (d *Database) GetDatabasePartitionTable(schemaName string) ([]string, error)

func (*Database) GetDatabasePlatformName

func (d *Database) GetDatabasePlatformName() (string, string, string, error)

func (*Database) GetDatabaseRole

func (d *Database) GetDatabaseRole() (string, error)

func (*Database) GetDatabaseSchema

func (d *Database) GetDatabaseSchema() ([]string, error)

func (*Database) GetDatabaseSchemaCodeObject

func (d *Database) GetDatabaseSchemaCodeObject(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaCollation

func (d *Database) GetDatabaseSchemaCollation(schemaName string) (string, error)

func (*Database) GetDatabaseSchemaColumnDataDefaultCounts

func (d *Database) GetDatabaseSchemaColumnDataDefaultCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaColumnTypeCounts

func (d *Database) GetDatabaseSchemaColumnTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaConstraintTypeCounts

func (d *Database) GetDatabaseSchemaConstraintTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaIndexTypeCounts

func (d *Database) GetDatabaseSchemaIndexTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaMaterializedViewObject

func (d *Database) GetDatabaseSchemaMaterializedViewObject(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaNameALL

func (d *Database) GetDatabaseSchemaNameALL() ([]string, error)

func (*Database) GetDatabaseSchemaNameSingle

func (d *Database) GetDatabaseSchemaNameSingle(schemaNameS string) (string, error)

func (*Database) GetDatabaseSchemaObjectTypeCounts

func (d *Database) GetDatabaseSchemaObjectTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaPartitionTableCountsOverLimit

func (d *Database) GetDatabaseSchemaPartitionTableCountsOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaPartitionTableType

func (d *Database) GetDatabaseSchemaPartitionTableType(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaPartitionTypeCounts

func (d *Database) GetDatabaseSchemaPartitionTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaSubPartitionTypeCounts

func (d *Database) GetDatabaseSchemaSubPartitionTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaSynonymObject

func (d *Database) GetDatabaseSchemaSynonymObject(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableAvgRowLengthOverLimitMB

func (d *Database) GetDatabaseSchemaTableAvgRowLengthOverLimitMB(schemaName []string, limitMB int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableAvgRowLengthTOP

func (d *Database) GetDatabaseSchemaTableAvgRowLengthTOP(schemaName []string, top int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableColumnCountsOverLimit

func (d *Database) GetDatabaseSchemaTableColumnCountsOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableColumnNameLengthOverLimit

func (d *Database) GetDatabaseSchemaTableColumnNameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableIndexCountsOverLimit

func (d *Database) GetDatabaseSchemaTableIndexCountsOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableIndexLengthOverLimit

func (d *Database) GetDatabaseSchemaTableIndexLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableIndexNameLengthOverLimit

func (d *Database) GetDatabaseSchemaTableIndexNameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableIndexOverview

func (d *Database) GetDatabaseSchemaTableIndexOverview(schemaNameS []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableNameLengthOverLimit

func (d *Database) GetDatabaseSchemaTableNameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableRowsTOP

func (d *Database) GetDatabaseSchemaTableRowsTOP(schemaName []string, top int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableSequenceNameLengthOverLimit

func (d *Database) GetDatabaseSchemaTableSequenceNameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableSpecialDatatype

func (d *Database) GetDatabaseSchemaTableSpecialDatatype(schemaName []string, specialDatatype string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableTypeCounts

func (d *Database) GetDatabaseSchemaTableTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTableViewNameLengthOverLimit

func (d *Database) GetDatabaseSchemaTableViewNameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaTemporaryTableTypeCounts

func (d *Database) GetDatabaseSchemaTemporaryTableTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSchemaViewTypeCounts

func (d *Database) GetDatabaseSchemaViewTypeCounts(schemaName []string) ([]map[string]string, error)

func (*Database) GetDatabaseSequenceName added in v0.0.9

func (d *Database) GetDatabaseSequenceName(schemaName string, seqName string) ([]map[string]string, error)

func (*Database) GetDatabaseSequences added in v0.0.9

func (d *Database) GetDatabaseSequences(schemaName string) ([]string, error)

func (*Database) GetDatabaseServerMemorySize

func (d *Database) GetDatabaseServerMemorySize() (string, error)

func (*Database) GetDatabaseServerNumCPU

func (d *Database) GetDatabaseServerNumCPU() (string, error)

func (*Database) GetDatabaseSessionMaxActiveCount

func (d *Database) GetDatabaseSessionMaxActiveCount() ([]map[string]string, error)

func (*Database) GetDatabaseSize

func (d *Database) GetDatabaseSize() (string, error)

func (*Database) GetDatabaseSoftVersion

func (d *Database) GetDatabaseSoftVersion() (string, error)

func (*Database) GetDatabaseTable

func (d *Database) GetDatabaseTable(schemaName string) ([]string, error)

func (*Database) GetDatabaseTableCharset

func (d *Database) GetDatabaseTableCharset(schemaName, tableName string) (string, error)

func (*Database) GetDatabaseTableCheckKey

func (d *Database) GetDatabaseTableCheckKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableChunkTask

func (d *Database) GetDatabaseTableChunkTask(taskName, schemaName, tableName string, chunkSize uint64, callTimeout uint64, batchSize int, dataChan chan []map[string]string) error

func (*Database) GetDatabaseTableCollation

func (d *Database) GetDatabaseTableCollation(schemaName, tableName string) (string, error)

func (*Database) GetDatabaseTableColumnComment

func (d *Database) GetDatabaseTableColumnComment(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableColumnInfo

func (d *Database) GetDatabaseTableColumnInfo(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableColumnNameSqlDimensions

func (d *Database) GetDatabaseTableColumnNameSqlDimensions(sqlStr string) ([]string, map[string]string, map[string]string, error)

func (*Database) GetDatabaseTableColumnNameTableDimensions

func (d *Database) GetDatabaseTableColumnNameTableDimensions(schemaName, tableName string) ([]string, error)

func (*Database) GetDatabaseTableColumnProperties added in v0.0.7

func (d *Database) GetDatabaseTableColumnProperties(schemaNameS, tableNameS string, columnNameS []string) ([]map[string]string, error)

func (*Database) GetDatabaseTableComment

func (d *Database) GetDatabaseTableComment(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableCompareCrc added in v0.0.15

func (d *Database) GetDatabaseTableCompareCrc(querySQL string, callTimeout int, dbCharsetS, dbCharsetT, separator string, queryArgs []interface{}) ([]string, uint32, map[string]int64, error)

func (*Database) GetDatabaseTableCompareRow added in v0.0.15

func (d *Database) GetDatabaseTableCompareRow(query string, args ...any) ([]string, []map[string]string, error)

func (*Database) GetDatabaseTableConstraintIndexColumn added in v0.0.7

func (d *Database) GetDatabaseTableConstraintIndexColumn(schemaNameS, tableNameS string) (map[string]string, error)

func (*Database) GetDatabaseTableCsvData

func (d *Database) GetDatabaseTableCsvData(querySQL string, queryArgs []interface{}, callTimeout int, taskFlow, dbCharsetS, dbCharsetT, columnDetailO string, escapeBackslash bool, nullValue, separator, delimiter string, dataChan chan []string) error

func (*Database) GetDatabaseTableForeignKey

func (d *Database) GetDatabaseTableForeignKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableHighestSelectivityIndex added in v0.0.7

func (d *Database) GetDatabaseTableHighestSelectivityIndex(schemaNameS, tableNameS string, compareCondField string, ignoreCondFields []string) (*structure.Selectivity, error)

func (*Database) GetDatabaseTableNonStmtData added in v0.0.15

func (d *Database) GetDatabaseTableNonStmtData(taskFlow, querySQL string, queryArgs []interface{}, batchSize, callTimeout int, dbCharsetS, dbCharsetT, columnDetailS string, dataChan chan []interface{}) error

func (*Database) GetDatabaseTableNormalIndex

func (d *Database) GetDatabaseTableNormalIndex(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableOriginStruct

func (d *Database) GetDatabaseTableOriginStruct(schemaName, tableName, tableType string) (string, error)

func (*Database) GetDatabaseTablePartitionExpress

func (d *Database) GetDatabaseTablePartitionExpress(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTablePrimaryKey

func (d *Database) GetDatabaseTablePrimaryKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableRandomValues added in v0.0.7

func (d *Database) GetDatabaseTableRandomValues(schemaNameS, tableNameS string, columns []string, conditions string, condArgs []interface{}, limit int, collations []string) ([][]string, error)

func (*Database) GetDatabaseTableRows

func (d *Database) GetDatabaseTableRows(schemaName, tableName string) (uint64, error)

func (*Database) GetDatabaseTableSize

func (d *Database) GetDatabaseTableSize(schemaName, tableName string) (float64, error)

func (*Database) GetDatabaseTableStatisticsBucket added in v0.0.7

func (d *Database) GetDatabaseTableStatisticsBucket(schemaNameS, tableNameS string, consColumns map[string]string) (map[string][]structure.Bucket, map[string]string, error)

func (*Database) GetDatabaseTableStatisticsHistogram added in v0.0.7

func (d *Database) GetDatabaseTableStatisticsHistogram(schemaNameS, tableNameS string, consColumns map[string]string) (map[string]structure.Histogram, error)

func (*Database) GetDatabaseTableStmtData added in v0.0.15

func (d *Database) GetDatabaseTableStmtData(querySQL string, queryArgs []interface{}, batchSize, callTimeout int, dbCharsetS, dbCharsetT, columnDetailS string, dataChan chan []interface{}) error

func (*Database) GetDatabaseTableType

func (d *Database) GetDatabaseTableType(schemaName string) (map[string]string, error)

func (*Database) GetDatabaseTableUniqueIndex

func (d *Database) GetDatabaseTableUniqueIndex(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTableUniqueKey

func (d *Database) GetDatabaseTableUniqueKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Database) GetDatabaseTemporaryTable

func (d *Database) GetDatabaseTemporaryTable(schemaName string) ([]string, error)

func (*Database) GetDatabaseUsernameLengthOverLimit

func (d *Database) GetDatabaseUsernameLengthOverLimit(schemaName []string, limit int) ([]map[string]string, error)

func (*Database) GetDatabaseVersion

func (d *Database) GetDatabaseVersion() (string, error)

func (*Database) PingDatabaseConnection

func (d *Database) PingDatabaseConnection() error

func (*Database) PrepareContext

func (d *Database) PrepareContext(ctx context.Context, sqlStr string) (*sql.Stmt, error)

func (*Database) QueryContext

func (d *Database) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*Database) Transaction added in v0.0.15

func (d *Database) Transaction(ctx context.Context, opts *sql.TxOptions, fns []func(ctx context.Context, tx *sql.Tx) error) error

Jump to

Keyboard shortcuts

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