Documentation ¶
Index ¶
- Constants
- func BuildSchemaMetadata(rows *sql.Rows) (_ *schema.Metadata, err error)
- func CreateIntrospectionTables(ctx context.Context, workspaceResources *modconfig.ModResources, ...) error
- func CreatePreparedStatements(ctx context.Context, resourceMaps *modconfig.ModResources, ...) (err error, warnings []string)
- func ExecuteQuery(ctx context.Context, queryString string, client Client) (*queryresult.ResultStreamer, error)
- func GetPreparedStatementsSQL(resourceMaps *modconfig.ModResources) map[string]string
- func PgEscapeName(name string) string
- func PgEscapeSearchPath(searchPath []string) []string
- func PgEscapeString(str string) string
- func WaitForConnection(ctx context.Context, db *sql.DB) (err error)
- type AcquireSessionResult
- type Client
- type ColumnTag
- type DatabaseSession
- type EnsureSessionStateCallback
- type InitResult
Constants ¶
const TagColumn = "column"
TagColumn is the tag used to specify the column name and type in the introspection tables
Variables ¶
This section is empty.
Functions ¶
func CreateIntrospectionTables ¶
func CreateIntrospectionTables(ctx context.Context, workspaceResources *modconfig.ModResources, session *DatabaseSession) error
func CreatePreparedStatements ¶
func CreatePreparedStatements(ctx context.Context, resourceMaps *modconfig.ModResources, session *DatabaseSession) (err error, warnings []string)
func ExecuteQuery ¶
func ExecuteQuery(ctx context.Context, queryString string, client Client) (*queryresult.ResultStreamer, error)
ExecuteQuery executes a single query. If shutdownAfterCompletion is true, shutdown the client after completion
func GetPreparedStatementsSQL ¶
func GetPreparedStatementsSQL(resourceMaps *modconfig.ModResources) map[string]string
func PgEscapeName ¶
PgEscapeName escapes strings which will be usaed for Podsdtgres object identifiers (table names, column names, schema names)
func PgEscapeSearchPath ¶
PgEscapeSearchPath applies postgres escaping to search path and remove whitespace
func PgEscapeString ¶
PgEscapeString escapes strings which are to be inserted use a custom escape tag to avoid chance of clash with the escaped text https://medium.com/@lnishada/postgres-dollar-quoting-6d23e4f186ec
Types ¶
type AcquireSessionResult ¶
type AcquireSessionResult struct { Session *DatabaseSession Error error Warnings []string }
type Client ¶
type Client interface { Close(ctx context.Context) error ForeignSchemaNames() []string LoadForeignSchemaNames(ctx context.Context) error ConnectionMap() *steampipeconfig.ConnectionDataMap GetCurrentSearchPath(context.Context) ([]string, error) GetCurrentSearchPathForDbConnection(context.Context, *sql.Conn) ([]string, error) SetRequiredSessionSearchPath(context.Context) error GetRequiredSessionSearchPath() []string ContructSearchPath(context.Context, []string, []string) ([]string, error) AcquireSession(context.Context) *AcquireSessionResult ExecuteSync(context.Context, string) (*queryresult.SyncQueryResult, error) Execute(context.Context, string) (*queryresult.Result, error) ExecuteSyncInSession(context.Context, *DatabaseSession, string) (*queryresult.SyncQueryResult, error) ExecuteInSession(context.Context, *DatabaseSession, string, func()) (*queryresult.Result, error) CacheOn(context.Context) error CacheOff(context.Context) error CacheClear(context.Context) error SetEnsureSessionDataFunc(EnsureSessionStateCallback) RefreshSessions(ctx context.Context) *AcquireSessionResult GetSchemaFromDB(context.Context) (*schema.Metadata, error) // remote client will have empty implementation RefreshConnectionAndSearchPaths(context.Context) *steampipeconfig.RefreshConnectionResult }
type DatabaseSession ¶
type DatabaseSession struct { BackendPid uint32 `json:"backend_pid"` LifeCycle *utils.LifecycleTimer `json:"lifecycle"` UsedCount int `json:"used"` LastUsed time.Time `json:"last_used"` SearchPath []string `json:"-"` Initialized bool `json:"-"` // this gets rewritten, since the database/sql gives back a new instance everytime Connection *sql.Conn `json:"-"` // the id of the last scan metadata retrieved ScanMetadataMaxId int64 `json:"-"` }
DatabaseSession wraps over the raw database/sql.Conn and also allows for retaining useful instrumentation
func NewDBSession ¶
func NewDBSession(backendPid uint32) *DatabaseSession
func (*DatabaseSession) Close ¶
func (s *DatabaseSession) Close(waitForCleanup bool) error
func (*DatabaseSession) UpdateUsage ¶
func (s *DatabaseSession) UpdateUsage()
UpdateUsage updates the UsedCount of the DatabaseSession and also the lastUsed time
type EnsureSessionStateCallback ¶
type EnsureSessionStateCallback = func(context.Context, *DatabaseSession) (err error, warnings []string)
type InitResult ¶
func (*InitResult) AddMessage ¶
func (r *InitResult) AddMessage(message string)
func (*InitResult) AddWarnings ¶
func (r *InitResult) AddWarnings(warnings ...string)
func (*InitResult) DisplayMessages ¶
func (r *InitResult) DisplayMessages()
func (*InitResult) HasMessages ¶
func (r *InitResult) HasMessages() bool