pg

package
v0.0.0-...-c42b739 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: BSD-3-Clause Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectVersion = errors.New("only postgres 9.1 is supported")

ErrIncorrectVersion is returned when a non supported postgres is found.

Functions

func DetectPgVersion

func DetectPgVersion(versionFilePath string) (versionNumber string, err error)

DetectPgVersion attempts to determine what version of postgres a data directory is based on.

func IsPgVersionSupported

func IsPgVersionSupported(versionFilePath string) error

IsPgVersionSupported returns an error if the postgres version is not supported currently.

func LDouble

func LDouble(bs []byte) (f float64)

LDouble reads a little-endian float64 from the head of a slice

func LInt16

func LInt16(bs []byte) (i int16)

LInt16 reads a little-endian int16 from the head of a slice

func LInt32

func LInt32(bs []byte) (i int32)

LInt32 reads a little-endian int32 from the head of a slice

func LInt64

func LInt64(bs []byte) (i int64)

LInt64 reads a little-endian int64 from the head of a slice

func LInt8

func LInt8(bs []byte) (i int8)

LInt8 reads a little-endian int8 from the head of a slice

func LSingle

func LSingle(bs []byte) (f float32)

LSingle reads a little-endian float32 from the head of a slice

func LUint

func LUint(bs []byte) uint64

LUint reads a little-endian uint64 from the head of a slice

Types

type DatabaseDetails

type DatabaseDetails struct {
	Name string
	Conn *sql.DB
}

DatabaseDetails represents a connection

type Schema

type Schema struct {
	Database  string
	Namespace string
	Table     string
	Fields    []*SchemaField
}

Schema is the full representation of a Table

func NewSchema

func NewSchema(database, ns, table string, db *sql.DB) (*Schema, error)

NewSchema will create a new schema by querying the database

func (*Schema) GetTextColumnQuery

func (s *Schema) GetTextColumnQuery(sizeLimit int) (names []string, err error)

GetTextColumnQuery will create a list of column names casted to return text

func (*Schema) String

func (s *Schema) String() string

type SchemaField

type SchemaField struct {
	Column   string
	DataType string
	Size     uint32
}

SchemaField represents a Column

func (SchemaField) String

func (sf SchemaField) String() string

type SchemaReader

type SchemaReader struct {
	// contains filtered or unexported fields
}

SchemaReader is used to determine the schema from a database via queries.

func NewSchemaReader

func NewSchemaReader(creds []string, driverName string, fieldSizeLimit uint32) (*SchemaReader, error)

NewSchemaReader takes a list of connections, the golang db driver name and a field size limit and returns a schema reader.

func (*SchemaReader) ConvertRelNamesToIds

func (sr *SchemaReader) ConvertRelNamesToIds(names []string) map[uint32]string

ConvertRelNamesToIds takes a table name in the form db.ns.name and gets the postgres id for that relation.

func (*SchemaReader) GetDatabaseName

func (sr *SchemaReader) GetDatabaseName(databaseID uint32) string

GetDatabaseName takes a postgres database id and returns the name of it.

func (*SchemaReader) GetFieldValues

func (sr *SchemaReader) GetFieldValues(databaseID uint32, relationID uint32, block uint32, offset uint16) (map[SchemaField]string, error)

GetFieldValues takes database id, a table id, and a tuple and returns the fields for that table

func (*SchemaReader) GetNamespaceAndTable

func (sr *SchemaReader) GetNamespaceAndTable(databaseID uint32, relationID uint32) (string, string)

GetNamespaceAndTable takes a database id and a relation id and returns the namespace and table names

func (*SchemaReader) HaveConnectionToDb

func (sr *SchemaReader) HaveConnectionToDb(databaseID uint32) bool

HaveConnectionToDb returns true if the db id in question has a connection defined.

func (*SchemaReader) LatestReplayLocation

func (sr *SchemaReader) LatestReplayLocation() uint64

LatestReplayLocation finds the last replicated WAL entry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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