Documentation
¶
Overview ¶
Package dtsx provides functionality for reading and writing DTSX (SQL Server Integration Services) XML files.
Index ¶
- func EvaluateExpression(expr string, pkg *Package) (interface{}, error)
- func GetConnectionName(cm *schema.ConnectionManagerType) string
- func GetConnectionString(cm *schema.ConnectionManagerType) string
- func GetExecutableName(exec *schema.AnyNonPackageExecutableType) string
- func GetProperty(s interface{}, name string) interface{}
- func GetSqlStatementSource(s *schema.SqlTaskDataType) string
- func GetSqlStatementSourceFromBase(s *schema.SqlTaskBaseAttributeGroup) string
- func GetVariableName(v *schema.VariableType) string
- func GetVariableValue(v *schema.VariableType) string
- func Marshal(pkg *Package) ([]byte, error)
- func RunPackage(dtexecPath, dtsxPath string, opts *RunOptions) (string, error)
- type BinaryOp
- type Cast
- type Conditional
- type DependencyGraph
- type Expr
- type ExpressionDetails
- type ExpressionInfo
- type FunctionCall
- type Literal
- type Package
- func (p *Package) BuildDependencyGraph() *DependencyGraph
- func (p *Package) GetConnections() *QueryResult
- func (p *Package) GetExpressions() *QueryResult
- func (p *Package) GetOptimizationSuggestions() []ValidationError
- func (p *Package) GetUnusedVariables() []string
- func (p *Package) GetVariableByName(name string) (*schema.VariableType, error)
- func (p *Package) GetVariables() *QueryResult
- func (p *Package) QueryExecutables(filter func(*schema.AnyNonPackageExecutableType) bool) []*schema.AnyNonPackageExecutableType
- func (p *Package) Validate() []ValidationError
- type PackageBuilder
- func (pb *PackageBuilder) AddConnection(name, connectionType, connectionString string) *PackageBuilder
- func (pb *PackageBuilder) AddConnectionExpression(connectionName, propertyName, expression string) *PackageBuilder
- func (pb *PackageBuilder) AddVariable(namespace, name, value string) *PackageBuilder
- func (pb *PackageBuilder) AddVariableWithType(namespace, name, value string, dataType string) *PackageBuilder
- func (pb *PackageBuilder) Build() *Package
- type PackageParser
- func (p *PackageParser) EvaluateExpression(expr string) (interface{}, error)
- func (p *PackageParser) GetConnectionManager(id string) (*schema.ConnectionManagerType, error)
- func (p *PackageParser) GetExecutable(refId string) (*schema.AnyNonPackageExecutableType, error)
- func (p *PackageParser) GetSQLStatements() []*SQLStatement
- func (p *PackageParser) GetVariableValue(name string) (interface{}, error)
- type PackageValidator
- type PrecedenceAnalyzer
- func (p *PrecedenceAnalyzer) GetAllExecutionOrders() (map[string]int, error)
- func (p *PrecedenceAnalyzer) GetExecutableChain(refId string) ([]string, error)
- func (p *PrecedenceAnalyzer) GetExecutionFlowDescription() string
- func (p *PrecedenceAnalyzer) GetExecutionOrder(refId string) (int, error)
- func (p *PrecedenceAnalyzer) ValidateConstraints() []error
- type QueryResult
- type RunOptions
- type SQLStatement
- type Token
- type UnaryOp
- type ValidationError
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateExpression ¶
EvaluateExpression evaluates an SSIS expression in the context of a package
func GetConnectionName ¶
func GetConnectionName(cm *schema.ConnectionManagerType) string
GetConnectionName returns the name of a connection manager
func GetConnectionString ¶
func GetConnectionString(cm *schema.ConnectionManagerType) string
GetConnectionString returns the connection string of a connection manager
func GetExecutableName ¶
func GetExecutableName(exec *schema.AnyNonPackageExecutableType) string
GetExecutableName returns the name of an executable
func GetProperty ¶
func GetProperty(s interface{}, name string) interface{}
GetProperty returns the value of the specified property by name for any struct
func GetSqlStatementSource ¶
func GetSqlStatementSource(s *schema.SqlTaskDataType) string
GetSqlStatementSource returns the SQL statement source from SqlTaskDataType
func GetSqlStatementSourceFromBase ¶
func GetSqlStatementSourceFromBase(s *schema.SqlTaskBaseAttributeGroup) string
GetSqlStatementSourceFromBase returns the SQL statement source from SqlTaskBaseAttributeGroup
func GetVariableName ¶
func GetVariableName(v *schema.VariableType) string
GetVariableName returns the full name (namespace::name) of a variable
func GetVariableValue ¶
func GetVariableValue(v *schema.VariableType) string
GetVariableValue returns the value of a variable
func RunPackage ¶
func RunPackage(dtexecPath, dtsxPath string, opts *RunOptions) (string, error)
RunPackage executes a DTSX package using dtexec.exe. It takes the path to dtexec.exe, the path to the DTSX file, and optional RunOptions. Returns the combined stdout/stderr output and any error that occurred.
Types ¶
type Conditional ¶
Conditional represents a ternary conditional expression
func (*Conditional) Eval ¶
func (c *Conditional) Eval(vars map[string]interface{}) (interface{}, error)
type DependencyGraph ¶
type DependencyGraph struct {
// VariableDependencies: variable name -> list of expressions/locations that use it
VariableDependencies map[string][]string
// ConnectionDependencies: connection name -> list of tasks/locations that use it
ConnectionDependencies map[string][]string
// TaskDependencies: task ID -> list of variables/connections it depends on
TaskDependencies map[string][]string
// ExpressionDependencies: expression -> list of variables it references
ExpressionDependencies map[string][]string
}
DependencyGraph represents relationships between package elements
func (*DependencyGraph) GetConnectionImpact ¶
func (dg *DependencyGraph) GetConnectionImpact(connName string) []string
GetConnectionImpact returns all tasks affected by a connection change
func (*DependencyGraph) GetVariableImpact ¶
func (dg *DependencyGraph) GetVariableImpact(varName string) []string
GetVariableImpact returns all locations affected by a variable change
type ExpressionDetails ¶
type ExpressionDetails struct {
Expression string
Location string
Name string
Context string
EvaluatedValue string
EvaluationError string
Dependencies []string
}
ExpressionDetails provides comprehensive information about an expression
func GetExpressionDetails ¶
func GetExpressionDetails(exprInfo *ExpressionInfo, pkg *Package) *ExpressionDetails
GetExpressionDetails returns detailed information about an expression including evaluation result and dependencies
type ExpressionInfo ¶
type ExpressionInfo struct {
Expression string
Location string // e.g., "Package", "Executable", "PrecedenceConstraint", etc.
Name string // property name if applicable
Context string // additional context like executable type, variable name, etc.
}
ExpressionInfo contains information about an expression found in the package
type FunctionCall ¶
FunctionCall represents a function call
func (*FunctionCall) Eval ¶
func (f *FunctionCall) Eval(vars map[string]interface{}) (interface{}, error)
type Package ¶
type Package struct {
XMLName xml.Name `xml:"Executable"`
RefIdAttr *string `xml:"refId,attr"`
CreationDateAttr *string `xml:"CreationDate,attr"`
CreationNameAttr *string `xml:"CreationName,attr"`
CreatorComputerNameAttr *string `xml:"CreatorComputerName,attr"`
CreatorNameAttr *string `xml:"CreatorName,attr"`
DescriptionAttr *string `xml:"Description,attr"`
DTSIDAttr *string `xml:"DTSID,attr"`
EnableConfigAttr *string `xml:"EnableConfig,attr"`
ExecutableTypeAttr *string `xml:"ExecutableType,attr"`
LastModifiedProductVersionAttr *string `xml:"LastModifiedProductVersion,attr"`
LocaleIDAttr *string `xml:"LocaleID,attr"`
ObjectNameAttr *string `xml:"ObjectName,attr"`
PackageTypeAttr *string `xml:"PackageType,attr"`
VersionBuildAttr *string `xml:"VersionBuild,attr"`
VersionGUIDAttr *string `xml:"VersionGUID,attr"`
*schema.ExecutableTypePackage
}
Package represents a DTSX package structure
func IsDTSXPackage ¶
IsDTSXPackage validates if the given filename is a valid DTSX package. It checks if the file exists, is readable, and contains valid DTSX XML structure. Returns the unmarshaled Package and true if the file is a valid DTSX package, nil and false otherwise.
func UnmarshalFromFile ¶
UnmarshalFromFile reads a DTSX file and returns a Package
func UnmarshalFromReader ¶
UnmarshalFromReader parses DTSX XML from an io.Reader and returns a Package
func (*Package) BuildDependencyGraph ¶
func (p *Package) BuildDependencyGraph() *DependencyGraph
BuildDependencyGraph analyzes the package and builds a dependency graph
func (*Package) GetConnections ¶
func (p *Package) GetConnections() *QueryResult
GetConnections returns all connection managers in the package
func (*Package) GetExpressions ¶
func (p *Package) GetExpressions() *QueryResult
GetExpressions returns all expressions found in the package
func (*Package) GetOptimizationSuggestions ¶
func (p *Package) GetOptimizationSuggestions() []ValidationError
GetOptimizationSuggestions returns performance and best practice suggestions
func (*Package) GetUnusedVariables ¶
GetUnusedVariables returns variables that are not referenced anywhere
func (*Package) GetVariableByName ¶
func (p *Package) GetVariableByName(name string) (*schema.VariableType, error)
GetVariableByName finds a variable by name (ObjectName property)
func (*Package) GetVariables ¶
func (p *Package) GetVariables() *QueryResult
GetVariables returns all variables in the package
func (*Package) QueryExecutables ¶
func (p *Package) QueryExecutables(filter func(*schema.AnyNonPackageExecutableType) bool) []*schema.AnyNonPackageExecutableType
QueryExecutables finds executables matching a filter function
func (*Package) Validate ¶
func (p *Package) Validate() []ValidationError
Validate performs comprehensive validation on the package
type PackageBuilder ¶
type PackageBuilder struct {
// contains filtered or unexported fields
}
PackageBuilder provides a fluent API for constructing DTSX packages
func NewPackageBuilder ¶
func NewPackageBuilder() *PackageBuilder
NewPackageBuilder creates a new package builder
func (*PackageBuilder) AddConnection ¶
func (pb *PackageBuilder) AddConnection(name, connectionType, connectionString string) *PackageBuilder
AddConnection adds a connection manager to the package
func (*PackageBuilder) AddConnectionExpression ¶
func (pb *PackageBuilder) AddConnectionExpression(connectionName, propertyName, expression string) *PackageBuilder
AddConnectionExpression adds a property expression to an existing connection manager
func (*PackageBuilder) AddVariable ¶
func (pb *PackageBuilder) AddVariable(namespace, name, value string) *PackageBuilder
AddVariable adds a variable to the package
func (*PackageBuilder) AddVariableWithType ¶
func (pb *PackageBuilder) AddVariableWithType(namespace, name, value string, dataType string) *PackageBuilder
AddVariableWithType adds a variable to the package with a specific data type
func (*PackageBuilder) Build ¶
func (pb *PackageBuilder) Build() *Package
Build returns the constructed package
type PackageParser ¶
type PackageParser struct {
// contains filtered or unexported fields
}
PackageParser provides centralized parsing and analysis functionality for DTSX packages
func NewPackageParser ¶
func NewPackageParser(pkg *Package) *PackageParser
NewPackageParser creates a new PackageParser for the given package
func (*PackageParser) EvaluateExpression ¶
func (p *PackageParser) EvaluateExpression(expr string) (interface{}, error)
EvaluateExpression evaluates an expression with caching
func (*PackageParser) GetConnectionManager ¶
func (p *PackageParser) GetConnectionManager(id string) (*schema.ConnectionManagerType, error)
GetConnectionManager returns a connection manager by refId or name
func (*PackageParser) GetExecutable ¶
func (p *PackageParser) GetExecutable(refId string) (*schema.AnyNonPackageExecutableType, error)
GetExecutable returns an executable by refId
func (*PackageParser) GetSQLStatements ¶
func (p *PackageParser) GetSQLStatements() []*SQLStatement
GetSQLStatements extracts SQL statements from all executables
func (*PackageParser) GetVariableValue ¶
func (p *PackageParser) GetVariableValue(name string) (interface{}, error)
GetVariableValue returns the value of a variable by name
type PackageValidator ¶
type PackageValidator struct {
// contains filtered or unexported fields
}
PackageValidator provides validation functions for DTSX packages
func NewPackageValidator ¶
func NewPackageValidator(pkg *Package) *PackageValidator
NewPackageValidator creates a new validator for the package
func (*PackageValidator) Validate ¶
func (v *PackageValidator) Validate() []*ValidationError
Validate performs comprehensive validation of the package
type PrecedenceAnalyzer ¶
type PrecedenceAnalyzer struct {
// contains filtered or unexported fields
}
PrecedenceAnalyzer handles execution order calculation with support for complex precedence constraints
func NewPrecedenceAnalyzer ¶
func NewPrecedenceAnalyzer(pkg *Package) *PrecedenceAnalyzer
NewPrecedenceAnalyzer creates a new analyzer for the given package
func (*PrecedenceAnalyzer) GetAllExecutionOrders ¶
func (p *PrecedenceAnalyzer) GetAllExecutionOrders() (map[string]int, error)
GetAllExecutionOrders returns execution orders for all executables
func (*PrecedenceAnalyzer) GetExecutableChain ¶
func (p *PrecedenceAnalyzer) GetExecutableChain(refId string) ([]string, error)
GetExecutableChain returns the execution chain for an executable (all predecessors)
func (*PrecedenceAnalyzer) GetExecutionFlowDescription ¶
func (p *PrecedenceAnalyzer) GetExecutionFlowDescription() string
GetExecutionFlowDescription returns a textual description of the execution flow
func (*PrecedenceAnalyzer) GetExecutionOrder ¶
func (p *PrecedenceAnalyzer) GetExecutionOrder(refId string) (int, error)
GetExecutionOrder returns the execution order for an executable
func (*PrecedenceAnalyzer) ValidateConstraints ¶
func (p *PrecedenceAnalyzer) ValidateConstraints() []error
ValidateConstraints checks for constraint violations and circular dependencies
type QueryResult ¶
type QueryResult struct {
Count int
Results interface{}
}
QueryResult wraps query results with metadata
type RunOptions ¶
type RunOptions struct {
// Package parameters (format: "[$Package::|$Project::|$ServerOption::]ParamName[(DataType)];Value")
Parameters []string
// Environment variables (format: "Name=Value")
EnvironmentVars []string
// Connection manager overrides (format: "id_or_name;connection_string")
Connections []string
// Configuration file path
ConfigFile string
// Property overrides using /Set (format: "propertyPath;value")
PropertySets []string
// Decryption password for encrypted packages
DecryptPassword string
// SQL Server name (for /SQL or /DTS packages)
Server string
// SQL Server username (for SQL authentication)
User string
// SQL Server password (for SQL authentication)
Password string
// Enable checkpointing (on/off)
Checkpointing string
// Checkpoint file path
CheckpointFile string
// Restart mode (deny/force/ifPossible)
Restart string
// Maximum concurrent executables (-1 for auto)
MaxConcurrent int
// Validate only without executing
Validate bool
// Treat warnings as errors
WarnAsError bool
// Verify build number (format: "major;minor;build")
VerifyBuild string
// Verify package ID (GUID)
VerifyPackageID string
// Verify version ID (GUID)
VerifyVersionID string
// Verify digital signature
VerifySigned bool
// Reporting level (N=none, E=errors, W=warnings, I=info, C=custom, P=progress, V=verbose)
ReportingLevel string
// Console log options (format: "displayoptions;list_options;src_name_or_guid")
ConsoleLog []string
// Log provider configuration (format: "classid_or_progid;configstring")
Loggers []string
// Enable verbose logging to file
VerboseLog string
// Dump on error codes (semicolon-separated error codes)
DumpOnCodes string
// Dump on any error
DumpOnError bool
// Run in 32-bit mode (x86)
X86 bool
}
RunOptions contains options for executing a DTSX package with dtexec.exe
type SQLStatement ¶
type SQLStatement struct {
TaskName string
TaskType string
SQL string
RefId string
Connections []string
}
SQLStatement represents a SQL statement found in the package
type ValidationError ¶
type ValidationError struct {
Severity string // "error", "warning", "info"
Message string
Path string // Location in the package, e.g., "Variables.User::MyVar"
}
ValidationError represents a validation issue in a DTSX package