burrow: github.com/hyperledger/burrow/vent/sqldb/adapters Index | Files

package adapters

import "github.com/hyperledger/burrow/vent/sqldb/adapters"

Index

Package Files

db_adapter.go postgres_adapter.go sqlite_adapter_nosqlite.go

func Cleanf Uses

func Cleanf(format string, args ...interface{}) string

type DBAdapter Uses

type DBAdapter interface {
    Open(dbURL string) (*sqlx.DB, error)
    // TODO: incrementally refactor DBAdapter to be responsible for actually _doing_ the queries,
    // TODO: legacy stringly queries:
    // TypeMapping maps generic SQL column types to db adapter dependent column types
    TypeMapping(sqlColumnType types.SQLColumnType) (string, error)
    // ErrorEquals compares generic SQL errors to db adapter dependent errors
    ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool
    // SecureColumnName returns columns with proper delimiters to ensure well formed column names
    SecureName(name string) string
    // CreateTableQuery builds a CREATE TABLE query to create a new table
    CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)
    // FindTableQuery builds a SELECT query to check if a table exists
    FindTableQuery() string
    // TableDefinitionQuery builds a SELECT query to get a table structure from the Dictionary table
    TableDefinitionQuery() string
    // AlterColumnQuery builds an ALTER COLUMN query to alter a table structure (only adding columns is supported)
    AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)
    // SelectRowQuery builds a SELECT query to get row values
    SelectRowQuery(tableName, fields, indexValue string) string
    // SelectLogQuery builds a SELECT query to get all tables involved in a given block transaction
    SelectLogQuery() string
    // InsertLogQuery builds an INSERT query to store data in Log table
    InsertLogQuery() string
    // UpsertQuery builds an INSERT... ON CONFLICT (or similar) query to upsert data in event tables based on PK
    UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)
    // DeleteQuery builds a DELETE FROM event tables query based on PK
    DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)
    // RestoreDBQuery builds a list of sql clauses needed to restore the db to a point in time
    RestoreDBQuery() string
    // CleanDBQueries returns necessary queries to clean the database
    CleanDBQueries() types.SQLCleanDBQuery
    // DropTableQuery builds a DROP TABLE query to delete a table
    DropTableQuery(tableName string) string
    // Get the schema qualified name of the given table
    SchemaName(tableName string) string
}

DBAdapter implements database dependent interface

type DBNotifyTriggerAdapter Uses

type DBNotifyTriggerAdapter interface {
    // Create a SQL function that notifies on channel with the payload of columns - the payload containing the value
    // of each column will be sent once whenever any of the columns changes. Expected to replace existing function.
    CreateNotifyFunctionQuery(function, channel string, columns ...string) string
    // Create a trigger that fires the named function after any operation on a row in table. Expected to replace existing
    // trigger.
    CreateTriggerQuery(triggerName, tableName, functionName string) string
}

type PostgresAdapter Uses

type PostgresAdapter struct {
    Schema string
    types.SQLNames
    Log *logging.Logger
}

PostgresAdapter implements DBAdapter for Postgres

func NewPostgresAdapter Uses

func NewPostgresAdapter(schema string, sqlNames types.SQLNames, log *logging.Logger) *PostgresAdapter

NewPostgresAdapter constructs a new db adapter

func (*PostgresAdapter) AlterColumnQuery Uses

func (pa *PostgresAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)

AlterColumnQuery returns a query for adding a new column to a table

func (*PostgresAdapter) CleanDBQueries Uses

func (pa *PostgresAdapter) CleanDBQueries() types.SQLCleanDBQuery

func (*PostgresAdapter) CreateNotifyFunctionQuery Uses

func (pa *PostgresAdapter) CreateNotifyFunctionQuery(function, channel string, columns ...string) string

func (*PostgresAdapter) CreateTableQuery Uses

func (pa *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)

CreateTableQuery builds query for creating a new table

func (*PostgresAdapter) CreateTriggerQuery Uses

func (pa *PostgresAdapter) CreateTriggerQuery(triggerName, tableName, functionName string) string

func (*PostgresAdapter) DeleteQuery Uses

func (pa *PostgresAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)

func (*PostgresAdapter) DropTableQuery Uses

func (pa *PostgresAdapter) DropTableQuery(tableName string) string

func (*PostgresAdapter) ErrorEquals Uses

func (pa *PostgresAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool

ErrorEquals verify if an error is of a given SQL type

func (*PostgresAdapter) FindTableQuery Uses

func (pa *PostgresAdapter) FindTableQuery() string

FindTableQuery returns a query that checks if a table exists

func (*PostgresAdapter) InsertLogQuery Uses

func (pa *PostgresAdapter) InsertLogQuery() string

InsertLogQuery returns a query to insert a row in log table

func (*PostgresAdapter) Open Uses

func (pa *PostgresAdapter) Open(dbURL string) (*sqlx.DB, error)

func (*PostgresAdapter) RestoreDBQuery Uses

func (pa *PostgresAdapter) RestoreDBQuery() string

func (*PostgresAdapter) SchemaName Uses

func (pa *PostgresAdapter) SchemaName(tableName string) string

func (*PostgresAdapter) SecureName Uses

func (pa *PostgresAdapter) SecureName(name string) string

SecureColumnName return columns between appropriate security containers

func (*PostgresAdapter) SelectLogQuery Uses

func (pa *PostgresAdapter) SelectLogQuery() string

SelectLogQuery returns a query for selecting all tables involved in a block trn

func (*PostgresAdapter) SelectRowQuery Uses

func (pa *PostgresAdapter) SelectRowQuery(tableName, fields, indexValue string) string

SelectRowQuery returns a query for selecting row values

func (*PostgresAdapter) TableDefinitionQuery Uses

func (pa *PostgresAdapter) TableDefinitionQuery() string

TableDefinitionQuery returns a query with table structure

func (*PostgresAdapter) TypeMapping Uses

func (pa *PostgresAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)

TypeMapping convert generic dataTypes to database dependent dataTypes

func (*PostgresAdapter) UpsertQuery Uses

func (pa *PostgresAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)

type SQLiteAdapter Uses

type SQLiteAdapter struct {
    Log *logging.Logger
}

This is a no-op version of SQLiteAdapter

func NewSQLiteAdapter Uses

func NewSQLiteAdapter(names types.SQLNames, log *logging.Logger) *SQLiteAdapter

func (*SQLiteAdapter) AlterColumnQuery Uses

func (*SQLiteAdapter) AlterColumnQuery(tableName, columnName string, sqlColumnType types.SQLColumnType, length, order int) (string, string)

func (*SQLiteAdapter) CleanDBQueries Uses

func (*SQLiteAdapter) CleanDBQueries() types.SQLCleanDBQuery

func (*SQLiteAdapter) CreateTableQuery Uses

func (*SQLiteAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string)

func (*SQLiteAdapter) DeleteQuery Uses

func (*SQLiteAdapter) DeleteQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, error)

func (*SQLiteAdapter) DropTableQuery Uses

func (*SQLiteAdapter) DropTableQuery(tableName string) string

func (*SQLiteAdapter) ErrorEquals Uses

func (*SQLiteAdapter) ErrorEquals(err error, sqlErrorType types.SQLErrorType) bool

func (*SQLiteAdapter) FindTableQuery Uses

func (*SQLiteAdapter) FindTableQuery() string

func (*SQLiteAdapter) InsertLogQuery Uses

func (*SQLiteAdapter) InsertLogQuery() string

func (*SQLiteAdapter) Open Uses

func (*SQLiteAdapter) Open(dbURL string) (*sqlx.DB, error)

func (*SQLiteAdapter) RestoreDBQuery Uses

func (*SQLiteAdapter) RestoreDBQuery() string

func (*SQLiteAdapter) SchemaName Uses

func (*SQLiteAdapter) SchemaName(tableName string) string

func (*SQLiteAdapter) SecureName Uses

func (*SQLiteAdapter) SecureName(name string) string

func (*SQLiteAdapter) SelectLogQuery Uses

func (*SQLiteAdapter) SelectLogQuery() string

func (*SQLiteAdapter) SelectRowQuery Uses

func (*SQLiteAdapter) SelectRowQuery(tableName, fields, indexValue string) string

func (*SQLiteAdapter) TableDefinitionQuery Uses

func (*SQLiteAdapter) TableDefinitionQuery() string

func (*SQLiteAdapter) TypeMapping Uses

func (*SQLiteAdapter) TypeMapping(sqlColumnType types.SQLColumnType) (string, error)

func (*SQLiteAdapter) UpsertQuery Uses

func (*SQLiteAdapter) UpsertQuery(table *types.SQLTable, row types.EventDataRow) (types.UpsertDeleteQuery, interface{}, error)

Package adapters imports 7 packages (graph) and is imported by 1 packages. Updated 2019-08-24. Refresh now. Tools for package owners.