context

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TableSearchQuery - SQL query for getting table by name and schema
	TableSearchQuery = `` /* 899-byte string literal not displayed */

	TableGetChildPatsQuery = `` /* 1059-byte string literal not displayed */

	// TableColumnsQuery - SQL query for getting all columns of table
	TableColumnsQuery = template.Must(template.New("TableColumnsQuery").Parse(`
		SELECT 
		    a.attname 										as name,
		    a.atttypid::TEXT::INT                          	as typeoid,
		  	pg_catalog.format_type(a.atttypid, a.atttypmod) as typename,
		  	a.attnotnull 									as notnull,
		  	a.atttypmod 									as att_len,
		  	a.attnum 										as num,
		  	t.typlen 										as type_len
			{{ if ge .Version 120000 }}
		  	,a.attgenerated != ''	    				    as attgenerated
			{{ end }}
		FROM pg_catalog.pg_attribute a
			JOIN pg_catalog.pg_type t ON a.atttypid = t.oid
		WHERE a.attrelid = $1 AND a.attnum > 0 AND NOT a.attisdropped
		ORDER BY a.attnum
	`))

	CustomTypesWithTypeChainQuery = `` /* 2128-byte string literal not displayed */

	// TableConstraintsCommonQuery - SQL query for searching the common constraints (pk, fk, trigger, check, exclude)
	// Purpose - find all constraints assigned to the discovering table (excluding Domain constraints)
	TableConstraintsCommonQuery = `` /* 1236-byte string literal not displayed */

	// TablePrimaryKeyReferencesConstraintsQuery - SQL query for collecting all the PK references
	TablePrimaryKeyReferencesConstraintsQuery = template.Must(
		template.New("TablePrimaryKeyReferencesConstraintsQuery").Parse(`
		SELECT pc.oid::TEXT::INT,
			   pn.nspname                                    AS "schema",
			   pc.conname                                    AS "name",
			   c.oid::TEXT::INT                              AS on_table_oid,
			   cn.nspname                                    AS on_table_schema,
			   c.relname                                     AS on_table_name,
			   pc.conkey                                     AS on_table_constrained_columns,
			   pg_catalog.pg_get_constraintdef(pc.oid, true) AS condef
		FROM pg_catalog.pg_constraint pc
				 JOIN pg_catalog.pg_namespace pn on pc.connamespace = pn.oid
				 JOIN pg_catalog.pg_class c ON pc.confrelid = c.oid
				 JOIN pg_catalog.pg_namespace cn ON c.relnamespace = cn.oid
	{{ if ge .Version 120000 }}
		WHERE confrelid IN (SELECT pg_catalog.pg_partition_ancestors($1)
							UNION ALL
							VALUES ($1::regclass))
	{{ else }}
		WHERE confrelid = $1::regclass
	{{ end }}
		  AND contype = 'f'
		  AND conparentid = 0
		ORDER BY conname;
	`))

	// DomainConstraintsQuery - SQL query for getting domain check constraint
	DomainConstraintsQuery = `` /* 593-byte string literal not displayed */

	LargeObjectsTableOidQuery = `` /* 191-byte string literal not displayed */

	LargeObjectsListQuery = `` /* 217-byte string literal not displayed */

	LargeObjectGetDefaultAclQuery = `` /* 165-byte string literal not displayed */

	LargeObjectGetAclQuery = `` /* 130-byte string literal not displayed */

	LargeObjectDescribeAclItemQuery = `` /* 331-byte string literal not displayed */

	PrimaryKeyColumnsQuery = `` /* 235-byte string literal not displayed */

)

Functions

This section is empty.

Types

type RuntimeContext

type RuntimeContext struct {
	// Types - list of custom types that are used in DB schema
	Types []*toolkit.Type
	// DataSectionObjects - list of objects to dump in data-section. There are sequences, Tables and large objects
	DataSectionObjects []entries.Entry
	// DataSectionObjectsToValidate - list of objects to validate in data-section
	DataSectionObjectsToValidate []entries.Entry
	// Warnings - list of occurred ValidationWarning during validation and config building
	Warnings toolkit.ValidationWarnings
	// Registry - registry of all the registered transformers definition
	Registry *transformersUtils.TransformerRegistry
	// TypeMap - map of registered types including custom types. It's common for the whole runtime
	TypeMap *pgtype.Map
	// DatabaseSchema - list of Tables with columns - required for schema diff checking
	DatabaseSchema toolkit.DatabaseSchema
	// Graph - graph of Tables with dependencies
	Graph *subset.Graph
}

RuntimeContext - describes current runtime behaviour according to the config and schema objects

func NewRuntimeContext

func NewRuntimeContext(
	ctx context.Context, tx pgx.Tx, cfg *domains.Dump,
	r *transformersUtils.TransformerRegistry,
	vr []*domains.VirtualReference, version int,
) (*RuntimeContext, error)

NewRuntimeContext - creating new runtime context. TODO: Recheck it is working properly. In a few cases (stages such as parameters building, schema validation) if

warnings are fatal procedure must be terminated immediately due to lack of objects required on the next step

func (*RuntimeContext) IsFatal

func (rc *RuntimeContext) IsFatal() bool

Jump to

Keyboard shortcuts

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