postgres

package
v0.0.0-...-2d490e1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertData

func ConvertData(conv *internal.Conv, srcTable string, srcCols []string, vals []string) (string, []string, []interface{}, error)

ConvertData maps the source DB data in vals into Spanner data, based on the Spanner and source DB schemas. Note that since entries in vals may be empty, we also return the list of columns (empty cols are dropped).

func ConvertSQLRow

func ConvertSQLRow(conv *internal.Conv, srcTable string, srcCols []string, srcSchema schema.Table, spTable string, spCols []string, spSchema ddl.CreateTable, srcVals []interface{}) ([]string, []interface{}, error)

ConvertSQLRow performs data conversion for a single row of data returned from a 'SELECT *' query. ConvertSQLRow assumes that srcCols, spCols and srcVals all have the same length. Note that ConvertSQLRow returns cols as well as converted values. This is because cols can change when we add a column (synthetic primary key) or because we drop columns (handling of NULL values).

func PrNodeType

func PrNodeType(n nodes.Node) string

PrNodeType strips off "pg_query." prefix from nodes.Nodes type.

func ProcessDataRow

func ProcessDataRow(conv *internal.Conv, srcTable string, srcCols, vals []string)

ProcessDataRow converts a row of data and writes it out to Spanner. srcTable and srcCols are the source table and columns respectively, and vals contains string data to be converted to appropriate types to send to Spanner. ProcessDataRow is only called in DataMode.

func ProcessInfoSchema

func ProcessInfoSchema(conv *internal.Conv, db *sql.DB) error

ProcessInfoSchema performs schema conversion for source database 'db'. We assume that the source database supports information schema tables. These tables are a broadly supported ANSI standard, and we use them to obtain source database's schema information.

func ProcessPgDump

func ProcessPgDump(conv *internal.Conv, r *internal.Reader) error

ProcessPgDump reads pg_dump data from r and does schema or data conversion, depending on whether conv is configured for schema mode or data mode. In schema mode, ProcessPgDump incrementally builds a schema (updating conv). In data mode, ProcessPgDump uses this schema to convert PostgreSQL data and writes it to Spanner, using the data sink specified in conv.

func ProcessSQLData

func ProcessSQLData(conv *internal.Conv, db *sql.DB)

ProcessSQLData performs data conversion for source database 'db'. For each table, we extract data using a "SELECT *" query, convert the data to Spanner data (based on the source and Spanner schemas), and write it to Spanner. If we can't get/process data for a table, we skip that table and process the remaining tables.

Note that the database/sql library has a somewhat complex model for returning data from rows.Scan. Scalar values can be returned using the native value used by the underlying driver (by passing *interface{} to rows.Scan), or they can be converted to specific go types. Array values are always returned as []byte, a string encoding of the array values. This string encoding is database/driver specific. For example, for PostgreSQL, array values are returned in the form "{v1,v2,..,vn}", where each v1,v2,...,vn is a PostgreSQL encoding of the respective array value.

We choose to do all type conversions explicitly ourselves so that we can generate more targeted error messages: hence we pass *interface{} parameters to row.Scan.

func SetRowStats

func SetRowStats(conv *internal.Conv, db *sql.DB)

SetRowStats populates conv with the number of rows in each table.

Types

This section is empty.

Jump to

Keyboard shortcuts

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