fetch

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: PostgreSQL Imports: 23 Imported by: 0

Documentation

Overview

Package fetch queries source database for objects and data

Index

Constants

This section is empty.

Variables

View Source
var CopyRate = monitoring.NewRate(" rows")
View Source
var CopyThroughput = monitoring.NewIRate("B")
View Source
var TableCount int

Functions

func CollectAndAssociateContext

func CollectAndAssociateContext[P associer[C, P], C any](ctx context.Context, n string, parents []P, rowto rowToFunc[C]) ([]P, int, error)

CollectAndAssociateContext queries child objects

Returns parents with associated components and the count of components.

If a component does not match an existing parent, skip to next component and search starting from last associated parent. Fails after 8 unassociated components.

Use this to query table columns, keys, etc.

func CollectMapContext

func CollectMapContext(ctx context.Context, n string) (map[string]any, error)

func CollectObjectsContext

func CollectObjectsContext[T any](ctx context.Context, n string, rowto rowToFunc[T]) ([]T, error)

CollectObjectsContext accumulates rows

func CopyTables

func CopyTables(p *dispatch.Plan, tables []catalog.Table, srcModel any)

CopyTables instanciates COPY operations for a list of tables

func CopyTask

func CopyTask(source, target catalog.Table, reqs []string) dispatch.Task

CopyTask instanciates a COPY operation for a table

Task weight is source table row count. Generates a COPY statement for each batch of rows. Use SetupExecute to configure query output.

func FilterSchemas

func FilterSchemas(patterns ...string)

FilterSchemas restricts queries to a list of schemas

All subsequent queries must accept a %s fmt parameter for schemas name substitutions. e.g. WHERE OWNER IN (%s)

func ForEachContext

func ForEachContext(ctx context.Context, n string, f func(*sql.Rows) error) (int, error)

func ForEachItemAssociateContext

func ForEachItemAssociateContext[P associer[C, P], C any](ctx context.Context, parents []P, query func(P) (string, []any), rowto rowToFunc[C]) ([]P, int, error)

ForEachItemAssociateContext execute a query for each item

Use it to inspect extra information for item with per-item query like `SHOW CREATE`.

func QueryRowContext

func QueryRowContext(ctx context.Context, n string) *sql.Row

QueryRowContext executes a query that is expected to return a single row

Panics if connexion to database is not already established.

func Render

func Render(name string, o any) string

Render execute an SQL template

func RestartIdentities

func RestartIdentities(tables []catalog.Table) dispatch.Task

RestartIdentities fetches identities start from source and generates ALTER COLUMN.

Returns nil if no tables have identity column.

Requires source connection in context from database.WithConnection.

func RestartSequences

func RestartSequences(seqs []catalog.Sequence) dispatch.Task

RestartSequences fetches sequences start from source and generates ALTER SEQUENCE.

Returns nil if no sequences are given. Group sequence restart by schema.

Requires catalog.FilterSchemas to be set with schemas containing sequences. Requires source connection in context from database.WithConnection.

func SQL

func SQL(name string, fmtArgs ...any) (string, []any)

SQL reads embedded query

panics if query is not found

Removes lines ending with `-- pg_migrate:skip` pragma. Uncomment line with `-- pg_migrate:uncomment` pragma. Inject fmtArgs if provided else inject schemas list if FilterSchemas() was called.

func Setup

func Setup(sqlFiles fs.FS, f func(int) string, funcs template.FuncMap)

Setup initialize catalog inspection for a specific RDMS

Not calling Setup() before inspecting is a bug.

func Value

func Value(path, from, to string) valueFactory

Value instanciates converters for a single column value.

If data does not requires conversion, copy to a new memory segment so that initial data can be freed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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