postgres

package
v0.0.0-...-b087e1e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCockroachDBPlugin

func NewCockroachDBPlugin() *engine.Plugin

NewCockroachDBPlugin creates a CockroachDB plugin with PostgreSQL compatibility and CockroachDB-specific overrides for unsupported catalog functions.

func NewPostgresPlugin

func NewPostgresPlugin() *engine.Plugin

func NewQuestDBPlugin

func NewQuestDBPlugin() *engine.Plugin

NewQuestDBPlugin creates a QuestDB plugin that reuses the PostgreSQL runtime while overriding the incompatible catalog and metadata paths.

func NewYugabyteDBPlugin

func NewYugabyteDBPlugin() *engine.Plugin

NewYugabyteDBPlugin creates a YugabyteDB plugin that reuses the PostgreSQL connection and query runtime with YugabyteDB-specific metadata hooks.

Types

type CockroachDBPlugin

type CockroachDBPlugin struct {
	PostgresPlugin
}

CockroachDBPlugin extends PostgresPlugin with CockroachDB-specific overrides. CockroachDB is PostgreSQL wire-compatible but lacks some pg_catalog functions.

func (*CockroachDBPlugin) GetSSLStatus

func (p *CockroachDBPlugin) GetSSLStatus(config *engine.PluginConfig) (*engine.SSLStatus, error)

GetSSLStatus determines SSL status for CockroachDB connections. CockroachDB does not have pg_stat_ssl, so we query the session's ssl variable via SHOW ssl (returns "on"/"off" as a string).

func (*CockroachDBPlugin) GetStorageUnitExistsQuery

func (p *CockroachDBPlugin) GetStorageUnitExistsQuery() string

GetStorageUnitExistsQuery returns a CockroachDB-compatible table existence check. CockroachDB does not support to_regclass().

func (*CockroachDBPlugin) GetTableInfoQuery

func (p *CockroachDBPlugin) GetTableInfoQuery() string

GetTableInfoQuery returns a CockroachDB-compatible table info query. CockroachDB does not support pg_size_pretty() or pg_total_relation_size(), so we query only the table name and type from information_schema.

func (*CockroachDBPlugin) GetTableNameAndAttributes

func (p *CockroachDBPlugin) GetTableNameAndAttributes(rows *sql.Rows) (string, []engine.Record)

GetTableNameAndAttributes parses CockroachDB table info rows.

func (*CockroachDBPlugin) IsGeometryType

func (p *CockroachDBPlugin) IsGeometryType(columnType string) bool

IsGeometryType returns false for CockroachDB since it has limited geometry support compared to PostGIS and does not use the same binary encoding.

type PostgresPlugin

type PostgresPlugin struct {
	gorm_plugin.GormPlugin
}

func (*PostgresPlugin) DB

func (p *PostgresPlugin) DB(config *engine.PluginConfig) (*gorm.DB, error)

func (*PostgresPlugin) FormatGeometryValue

func (p *PostgresPlugin) FormatGeometryValue(rawBytes []byte, columnType string) string

FormatGeometryValue formats PostgreSQL geometry data for display. PostGIS columns use EWKB format which we decode to WKT. Native PostgreSQL geometric types (point, line, etc.) return text representation.

func (*PostgresPlugin) GetAllSchemasQuery

func (p *PostgresPlugin) GetAllSchemasQuery() string

func (*PostgresPlugin) GetColumnConstraints

func (p *PostgresPlugin) GetColumnConstraints(config *engine.PluginConfig, schema string, storageUnit string) (map[string]map[string]any, error)

GetColumnConstraints retrieves column constraints for PostgreSQL tables

func (*PostgresPlugin) GetCreateTableQuery

func (p *PostgresPlugin) GetCreateTableQuery(db *gorm.DB, schema string, storageUnit string, columns []engine.Record) string

func (*PostgresPlugin) GetDatabases

func (p *PostgresPlugin) GetDatabases(config *engine.PluginConfig) ([]string, error)

func (*PostgresPlugin) GetForeignKeyRelationships

func (p *PostgresPlugin) GetForeignKeyRelationships(config *engine.PluginConfig, schema string, storageUnit string) (map[string]*engine.ForeignKeyRelationship, error)

func (*PostgresPlugin) GetGraphQueryDB

func (p *PostgresPlugin) GetGraphQueryDB(db *gorm.DB, schema string) *gorm.DB

func (*PostgresPlugin) GetLastInsertID

func (p *PostgresPlugin) GetLastInsertID(db *gorm.DB) (int64, error)

GetLastInsertID returns the most recently auto-generated ID using PostgreSQL's lastval().

func (*PostgresPlugin) GetPlaceholder

func (p *PostgresPlugin) GetPlaceholder(index int) string

func (*PostgresPlugin) GetPrimaryKeyColQuery

func (p *PostgresPlugin) GetPrimaryKeyColQuery() string

func (*PostgresPlugin) GetSSLStatus

func (p *PostgresPlugin) GetSSLStatus(config *engine.PluginConfig) (*engine.SSLStatus, error)

GetSSLStatus queries PostgreSQL to get the actual SSL status of the connection. Uses pg_stat_ssl system view. Results are cached.

func (*PostgresPlugin) GetStorageUnitExistsQuery

func (p *PostgresPlugin) GetStorageUnitExistsQuery() string

func (*PostgresPlugin) GetSupportedOperators

func (p *PostgresPlugin) GetSupportedOperators() map[string]string

func (*PostgresPlugin) GetTableInfoQuery

func (p *PostgresPlugin) GetTableInfoQuery() string

func (*PostgresPlugin) GetTableNameAndAttributes

func (p *PostgresPlugin) GetTableNameAndAttributes(rows *sql.Rows) (string, []engine.Record)

func (*PostgresPlugin) IsArrayType

func (p *PostgresPlugin) IsArrayType(columnType string) bool

IsArrayType returns true for PostgreSQL array types which use an underscore prefix (e.g., _int4 for int[], _text for text[]).

func (*PostgresPlugin) MarkGeneratedColumns

func (p *PostgresPlugin) MarkGeneratedColumns(config *engine.PluginConfig, schema string, storageUnit string, columns []engine.Column) error

MarkGeneratedColumns detects PostgreSQL generated columns (GENERATED ALWAYS AS) and marks them as IsComputed.

func (*PostgresPlugin) NormalizeType

func (p *PostgresPlugin) NormalizeType(typeName string) string

NormalizeType converts PostgreSQL type aliases to their canonical form.

func (*PostgresPlugin) RawExecute

func (p *PostgresPlugin) RawExecute(config *engine.PluginConfig, query string, params ...any) (*engine.GetRowsResult, error)

type QuestDBPlugin

type QuestDBPlugin struct {
	PostgresPlugin
}

QuestDBPlugin extends PostgresPlugin with QuestDB-specific catalog behavior. QuestDB uses the PostgreSQL wire protocol in our product, but its table metadata path is schema-less in practice and does not support the PostgreSQL relation size functions used by the base plugin.

func (*QuestDBPlugin) GetColumnTypes

func (p *QuestDBPlugin) GetColumnTypes(db *gorm.DB, schema, tableName string) (map[string]gorm_plugin.ColumnTypeInfo, error)

GetColumnTypes returns QuestDB column types via information_schema.columns.

func (*QuestDBPlugin) GetColumnsForTable

func (p *QuestDBPlugin) GetColumnsForTable(config *engine.PluginConfig, schema string, storageUnit string) ([]engine.Column, error)

GetColumnsForTable returns QuestDB columns via information_schema.columns.

func (*QuestDBPlugin) GetForeignKeyRelationships

func (p *QuestDBPlugin) GetForeignKeyRelationships(_ *engine.PluginConfig, _, _ string) (map[string]*engine.ForeignKeyRelationship, error)

GetForeignKeyRelationships returns an empty relationship set because the QuestDB fixtures and source model treat QuestDB tables as lacking foreign-key graph metadata.

func (*QuestDBPlugin) GetPrimaryKeyColQuery

func (p *QuestDBPlugin) GetPrimaryKeyColQuery() string

GetPrimaryKeyColQuery returns a primary key query that tolerates schema-less QuestDB source references.

func (*QuestDBPlugin) GetSSLStatus

func (p *QuestDBPlugin) GetSSLStatus(config *engine.PluginConfig) (*engine.SSLStatus, error)

GetSSLStatus derives QuestDB SSL status from connection configuration. QuestDB speaks the PostgreSQL wire protocol but does not expose pg_stat_ssl, so the generic PostgreSQL runtime query fails.

func (*QuestDBPlugin) GetStorageUnitExistsQuery

func (p *QuestDBPlugin) GetStorageUnitExistsQuery() string

GetStorageUnitExistsQuery returns a QuestDB-compatible table existence check.

func (*QuestDBPlugin) GetTableInfoQuery

func (p *QuestDBPlugin) GetTableInfoQuery() string

GetTableInfoQuery returns a QuestDB-compatible table info query.

func (*QuestDBPlugin) GetTableNameAndAttributes

func (p *QuestDBPlugin) GetTableNameAndAttributes(rows *sql.Rows) (string, []engine.Record)

GetTableNameAndAttributes parses QuestDB table info rows.

func (*QuestDBPlugin) MarkGeneratedColumns

func (p *QuestDBPlugin) MarkGeneratedColumns(config *engine.PluginConfig, schema string, storageUnit string, columns []engine.Column) error

MarkGeneratedColumns is a no-op for QuestDB. The inherited PostgreSQL probe queries information_schema.columns.is_generated, which QuestDB does not expose.

type YugabyteDBPlugin

type YugabyteDBPlugin struct {
	PostgresPlugin
}

YugabyteDBPlugin reuses the PostgreSQL runtime while using YugabyteDB-safe catalog queries for metadata paths that differ from upstream PostgreSQL.

func (*YugabyteDBPlugin) GetPrimaryKeyColQuery

func (p *YugabyteDBPlugin) GetPrimaryKeyColQuery() string

GetPrimaryKeyColQuery returns primary key columns through information_schema.

func (*YugabyteDBPlugin) GetTableInfoQuery

func (p *YugabyteDBPlugin) GetTableInfoQuery() string

GetTableInfoQuery returns a YugabyteDB-compatible table info query.

func (*YugabyteDBPlugin) GetTableNameAndAttributes

func (p *YugabyteDBPlugin) GetTableNameAndAttributes(rows *sql.Rows) (string, []engine.Record)

GetTableNameAndAttributes parses YugabyteDB table info rows.

Jump to

Keyboard shortcuts

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