Documentation ¶
Overview ¶
Package informationschema provides metadata readers that query tables from the information_schema schema. It tries to be database agnostic, but there is a set of options to configure what tables and columns to expect.
Index ¶
- Constants
- func New(opts ...metadata.ReaderOption) func(drivers.DB, ...metadata.ReaderOption) metadata.Reader
- func WithCheckConstraints(con bool) metadata.ReaderOption
- func WithColumnPrivileges(c bool) metadata.ReaderOption
- func WithConstraints(con bool) metadata.ReaderOption
- func WithCurrentSchema(expr string) metadata.ReaderOption
- func WithCustomClauses(cols map[ClauseName]string) metadata.ReaderOption
- func WithDataTypeFormatter(f func(metadata.Column) string) metadata.ReaderOption
- func WithFunctions(fun bool) metadata.ReaderOption
- func WithIndexes(ind bool) metadata.ReaderOption
- func WithPlaceholder(pf func(int) string) metadata.ReaderOption
- func WithSequences(seq bool) metadata.ReaderOption
- func WithSystemSchemas(schemas []string) metadata.ReaderOption
- func WithTablePrivileges(t bool) metadata.ReaderOption
- func WithUsagePrivileges(u bool) metadata.ReaderOption
- type ClauseName
- type InformationSchema
- func (s InformationSchema) Columns(f metadata.Filter) (*metadata.ColumnSet, error)
- func (s InformationSchema) ConstraintColumns(f metadata.Filter) (*metadata.ConstraintColumnSet, error)
- func (s InformationSchema) Constraints(f metadata.Filter) (*metadata.ConstraintSet, error)
- func (s InformationSchema) FunctionColumns(f metadata.Filter) (*metadata.FunctionColumnSet, error)
- func (s InformationSchema) Functions(f metadata.Filter) (*metadata.FunctionSet, error)
- func (s InformationSchema) IndexColumns(f metadata.Filter) (*metadata.IndexColumnSet, error)
- func (s InformationSchema) Indexes(f metadata.Filter) (*metadata.IndexSet, error)
- func (s InformationSchema) PrivilegeSummaries(f metadata.Filter) (*metadata.PrivilegeSummarySet, error)
- func (s InformationSchema) Schemas(f metadata.Filter) (*metadata.SchemaSet, error)
- func (s InformationSchema) Sequences(f metadata.Filter) (*metadata.SequenceSet, error)
- func (s *InformationSchema) SetLimit(l int)
- func (s InformationSchema) Tables(f metadata.Filter) (*metadata.TableSet, error)
- type Logger
Constants ¶
const ( ColumnsDataType = ClauseName("columns.data_type") ColumnsColumnSize = ClauseName("columns.column_size") ColumnsNumericScale = ClauseName("columns.numeric_scale") ColumnsNumericPrecRadix = ClauseName("columns.numeric_precision_radix") ColumnsCharOctetLength = ClauseName("columns.character_octet_length") FunctionColumnsColumnSize = ClauseName("function_columns.column_size") FunctionColumnsNumericScale = ClauseName("function_columns.numeric_scale") FunctionColumnsNumericPrecRadix = ClauseName("function_columns.numeric_precision_radix") FunctionColumnsCharOctetLength = ClauseName("function_columns.character_octet_length") FunctionsSecurityType = ClauseName("functions.security_type") ConstraintIsDeferrable = ClauseName("constraint_columns.is_deferrable") ConstraintInitiallyDeferred = ClauseName("constraint_columns.initially_deferred") ConstraintJoinCond = ClauseName("constraint_join.fk") SequenceColumnsIncrement = ClauseName("sequence_columns.increment") PrivilegesGrantor = ClauseName("privileges.grantor") )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...metadata.ReaderOption) func(drivers.DB, ...metadata.ReaderOption) metadata.Reader
New InformationSchema reader
func WithCheckConstraints ¶
func WithCheckConstraints(con bool) metadata.ReaderOption
WithCheckConstraints when the `statistics` table exists
func WithColumnPrivileges ¶
func WithColumnPrivileges(c bool) metadata.ReaderOption
WithColumnPrivileges when the `column_privileges` table exists
func WithConstraints ¶
func WithConstraints(con bool) metadata.ReaderOption
WithConstraints when the `statistics` table exists
func WithCurrentSchema ¶
func WithCurrentSchema(expr string) metadata.ReaderOption
WithCurrentSchema expression to filter by when OnlyVisible filter is true
func WithCustomClauses ¶
func WithCustomClauses(cols map[ClauseName]string) metadata.ReaderOption
WithCustomClauses to use different expressions for some columns
func WithDataTypeFormatter ¶
func WithDataTypeFormatter(f func(metadata.Column) string) metadata.ReaderOption
WithDataTypeFormatter function to build updated string represenation of data type from Column
func WithFunctions ¶
func WithFunctions(fun bool) metadata.ReaderOption
WithFunctions when the `routines` and `parameters` tables exists
func WithIndexes ¶
func WithIndexes(ind bool) metadata.ReaderOption
WithIndexes when the `statistics` table exists
func WithPlaceholder ¶
func WithPlaceholder(pf func(int) string) metadata.ReaderOption
WithPlaceholder generator function, that usually returns either `?` or `$n`, where `n` is the argument.
func WithSequences ¶
func WithSequences(seq bool) metadata.ReaderOption
WithSequences when the `sequences` table exists
func WithSystemSchemas ¶
func WithSystemSchemas(schemas []string) metadata.ReaderOption
WithSystemSchemas that are ignored unless WithSystem filter is true
func WithTablePrivileges ¶
func WithTablePrivileges(t bool) metadata.ReaderOption
WithTablePrivileges when the `table_privileges` table exists
func WithUsagePrivileges ¶
func WithUsagePrivileges(u bool) metadata.ReaderOption
WithUsagePrivileges when the `usage_privileges` table exists
Types ¶
type ClauseName ¶
type ClauseName string
type InformationSchema ¶
type InformationSchema struct { metadata.LoggingReader // contains filtered or unexported fields }
InformationSchema metadata reader
func (InformationSchema) Columns ¶
Columns from selected catalog (or all, if empty), matching schemas and tables
func (InformationSchema) ConstraintColumns ¶
func (s InformationSchema) ConstraintColumns(f metadata.Filter) (*metadata.ConstraintColumnSet, error)
ConstraintColumns from selected catalog (or all, if empty), matching schemas and constraints
func (InformationSchema) Constraints ¶
func (s InformationSchema) Constraints(f metadata.Filter) (*metadata.ConstraintSet, error)
Constraintes from selected catalog (or all, if empty), matching schemas and names
func (InformationSchema) FunctionColumns ¶
func (s InformationSchema) FunctionColumns(f metadata.Filter) (*metadata.FunctionColumnSet, error)
FunctionColumns (arguments) from selected catalog (or all, if empty), matching schemas and functions
func (InformationSchema) Functions ¶
func (s InformationSchema) Functions(f metadata.Filter) (*metadata.FunctionSet, error)
Functions from selected catalog (or all, if empty), matching schemas, names and types
func (InformationSchema) IndexColumns ¶
func (s InformationSchema) IndexColumns(f metadata.Filter) (*metadata.IndexColumnSet, error)
IndexColumns from selected catalog (or all, if empty), matching schemas and indexes
func (InformationSchema) Indexes ¶
Indexes from selected catalog (or all, if empty), matching schemas and names
func (InformationSchema) PrivilegeSummaries ¶
func (s InformationSchema) PrivilegeSummaries(f metadata.Filter) (*metadata.PrivilegeSummarySet, error)
PrivilegeSummaries of privileges on tables, views and sequences from selected catalog (or all, if empty), matching schemas and names
func (InformationSchema) Schemas ¶
Schemas from selected catalog (or all, if empty), matching schemas and tables
func (InformationSchema) Sequences ¶
func (s InformationSchema) Sequences(f metadata.Filter) (*metadata.SequenceSet, error)
Sequences from selected catalog (or all, if empty), matching schemas and names
func (*InformationSchema) SetLimit ¶
func (s *InformationSchema) SetLimit(l int)