catalog

package
v0.0.0-...-0f831a3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeWarning     = "01000" // generic warning
	CodeWarningSkip = "00000" // IF NOT EXISTS / IF EXISTS skipped
)

SQLSTATE warning codes matching PostgreSQL.

View Source
const (
	CodeDuplicateSchema              = "42P06"
	CodeDuplicateTable               = "42P07"
	CodeDuplicateColumn              = "42701"
	CodeDuplicateObject              = "42710"
	CodeUndefinedSchema              = "3F000"
	CodeUndefinedTable               = "42P01"
	CodeUndefinedColumn              = "42703"
	CodeUndefinedObject              = "42704"
	CodeSchemaNotEmpty               = "2BP01"
	CodeDependentObjects             = "2BP01"
	CodeWrongObjectType              = "42809"
	CodeInvalidParameterValue        = "22023"
	CodeInvalidFK                    = "42830"
	CodeInvalidTableDefinition       = "42P16"
	CodeDuplicatePKey                = "42P16" // same SQLSTATE as InvalidTableDefinition
	CodeDatatypeMismatch             = "42804"
	CodeUndefinedFunction            = "42883"
	CodeAmbiguousColumn              = "42702"
	CodeAmbiguousFunction            = "42725"
	CodeInvalidColumnDefinition      = "42611"
	CodeTooManyColumns               = "54011"
	CodeFeatureNotSupported          = "0A000"
	CodeDuplicateFunction            = "42723"
	CodeInvalidObjectDefinition      = "42P17"
	CodeSyntaxError                  = "42601"
	CodeInvalidFunctionDefinition    = "42P13"
	CodeCheckViolation               = "23514"
	CodeNotNullViolation             = "23502"
	CodeForeignKeyViolation          = "23503"
	CodeUniqueViolation              = "23505"
	CodeIndeterminateCollation       = "42P22"
	CodeObjectNotInPrerequisiteState = "55000"
	CodeInvalidGrantOperation        = "0LP01"
	CodeProgramLimitExceeded         = "54000"
	CodeReservedName                 = "42939"
)

SQLSTATE error codes matching PostgreSQL.

View Source
const (
	PrioritySchema     = 0
	PriorityExtension  = 1
	PriorityType       = 2 // Enum/Domain/Range/Composite
	PrioritySequence   = 3
	PriorityFunction   = 4
	PriorityTable      = 5
	PriorityColumn     = 6 // uses parent table OID
	PriorityConstraint = 7 // non-FK
	PriorityView       = 8
	PriorityIndex      = 9
	PriorityTrigger    = 10
	PriorityPolicy     = 11
	PriorityMetadata   = 12 // Comment/Grant/Revoke
	PriorityFKDeferred = 99 // FK constraint (PhasePost)
)

Priority constants for tie-breaking within a phase during topological sort. Lower values are executed earlier.

View Source
const (
	InvalidOid          uint32 = 0
	PGCatalogNamespace  uint32 = 11
	PGToastNamespace    uint32 = 99
	PublicNamespace     uint32 = 2200
	FirstNormalObjectId uint32 = 16384
)

Well-known namespace OIDs matching PostgreSQL.

View Source
const (
	BOOLOID                     uint32 = 16
	BYTEAOID                    uint32 = 17
	CHAROID                     uint32 = 18
	NAMEOID                     uint32 = 19
	INT8OID                     uint32 = 20
	INT2OID                     uint32 = 21
	INT2VECTOROID               uint32 = 22
	INT4OID                     uint32 = 23
	REGPROCOID                  uint32 = 24
	TEXTOID                     uint32 = 25
	OIDOID                      uint32 = 26
	TIDOID                      uint32 = 27
	XIDOID                      uint32 = 28
	CIDOID                      uint32 = 29
	OIDVECTOROID                uint32 = 30
	PGDDLCOMMANDOID             uint32 = 32
	PGTYPEOID                   uint32 = 71
	PGATTRIBUTEOID              uint32 = 75
	PGPROCOID                   uint32 = 81
	PGCLASSOID                  uint32 = 83
	JSONOID                     uint32 = 114
	XMLOID                      uint32 = 142
	XMLARRAYOID                 uint32 = 143
	PGNODETREEOID               uint32 = 194
	JSONARRAYOID                uint32 = 199
	PGTYPEARRAYOID              uint32 = 210
	TABLEAMHANDLEROID           uint32 = 269
	PGATTRIBUTEARRAYOID         uint32 = 270
	XID8ARRAYOID                uint32 = 271
	PGPROCARRAYOID              uint32 = 272
	PGCLASSARRAYOID             uint32 = 273
	INDEXAMHANDLEROID           uint32 = 325
	POINTOID                    uint32 = 600
	LSEGOID                     uint32 = 601
	PATHOID                     uint32 = 602
	BOXOID                      uint32 = 603
	POLYGONOID                  uint32 = 604
	LINEOID                     uint32 = 628
	LINEARRAYOID                uint32 = 629
	CIDROID                     uint32 = 650
	CIDRARRAYOID                uint32 = 651
	FLOAT4OID                   uint32 = 700
	FLOAT8OID                   uint32 = 701
	UNKNOWNOID                  uint32 = 705
	CIRCLEOID                   uint32 = 718
	CIRCLEARRAYOID              uint32 = 719
	MACADDR8OID                 uint32 = 774
	MACADDR8ARRAYOID            uint32 = 775
	MONEYOID                    uint32 = 790
	MONEYARRAYOID               uint32 = 791
	MACADDROID                  uint32 = 829
	INETOID                     uint32 = 869
	BOOLARRAYOID                uint32 = 1000
	BYTEAARRAYOID               uint32 = 1001
	CHARARRAYOID                uint32 = 1002
	NAMEARRAYOID                uint32 = 1003
	INT2ARRAYOID                uint32 = 1005
	INT2VECTORARRAYOID          uint32 = 1006
	INT4ARRAYOID                uint32 = 1007
	REGPROCARRAYOID             uint32 = 1008
	TEXTARRAYOID                uint32 = 1009
	TIDARRAYOID                 uint32 = 1010
	XIDARRAYOID                 uint32 = 1011
	CIDARRAYOID                 uint32 = 1012
	OIDVECTORARRAYOID           uint32 = 1013
	BPCHARARRAYOID              uint32 = 1014
	VARCHARARRAYOID             uint32 = 1015
	INT8ARRAYOID                uint32 = 1016
	POINTARRAYOID               uint32 = 1017
	LSEGARRAYOID                uint32 = 1018
	PATHARRAYOID                uint32 = 1019
	BOXARRAYOID                 uint32 = 1020
	FLOAT4ARRAYOID              uint32 = 1021
	FLOAT8ARRAYOID              uint32 = 1022
	POLYGONARRAYOID             uint32 = 1027
	OIDARRAYOID                 uint32 = 1028
	ACLITEMOID                  uint32 = 1033
	ACLITEMARRAYOID             uint32 = 1034
	MACADDRARRAYOID             uint32 = 1040
	INETARRAYOID                uint32 = 1041
	BPCHAROID                   uint32 = 1042
	VARCHAROID                  uint32 = 1043
	DATEOID                     uint32 = 1082
	TIMEOID                     uint32 = 1083
	TIMESTAMPOID                uint32 = 1114
	TIMESTAMPARRAYOID           uint32 = 1115
	DATEARRAYOID                uint32 = 1182
	TIMEARRAYOID                uint32 = 1183
	TIMESTAMPTZOID              uint32 = 1184
	TIMESTAMPTZARRAYOID         uint32 = 1185
	INTERVALOID                 uint32 = 1186
	INTERVALARRAYOID            uint32 = 1187
	NUMERICARRAYOID             uint32 = 1231
	CSTRINGARRAYOID             uint32 = 1263
	TIMETZOID                   uint32 = 1266
	TIMETZARRAYOID              uint32 = 1270
	BITOID                      uint32 = 1560
	BITARRAYOID                 uint32 = 1561
	VARBITOID                   uint32 = 1562
	VARBITARRAYOID              uint32 = 1563
	NUMERICOID                  uint32 = 1700
	REFCURSOROID                uint32 = 1790
	REFCURSORARRAYOID           uint32 = 2201
	REGPROCEDUREOID             uint32 = 2202
	REGOPEROID                  uint32 = 2203
	REGOPERATOROID              uint32 = 2204
	REGCLASSOID                 uint32 = 2205
	REGTYPEOID                  uint32 = 2206
	REGPROCEDUREARRAYOID        uint32 = 2207
	REGOPERARRAYOID             uint32 = 2208
	REGOPERATORARRAYOID         uint32 = 2209
	REGCLASSARRAYOID            uint32 = 2210
	REGTYPEARRAYOID             uint32 = 2211
	RECORDOID                   uint32 = 2249
	CSTRINGOID                  uint32 = 2275
	ANYOID                      uint32 = 2276
	ANYARRAYOID                 uint32 = 2277
	VOIDOID                     uint32 = 2278
	TRIGGEROID                  uint32 = 2279
	LANGUAGEHANDLEROID          uint32 = 2280
	INTERNALOID                 uint32 = 2281
	ANYELEMENTOID               uint32 = 2283
	RECORDARRAYOID              uint32 = 2287
	ANYNONARRAYOID              uint32 = 2776
	TXIDSNAPSHOTARRAYOID        uint32 = 2949
	UUIDOID                     uint32 = 2950
	UUIDARRAYOID                uint32 = 2951
	TXIDSNAPSHOTOID             uint32 = 2970
	FDWHANDLEROID               uint32 = 3115
	PGLSNOID                    uint32 = 3220
	PGLSNARRAYOID               uint32 = 3221
	TSMHANDLEROID               uint32 = 3310
	PGNDISTINCTOID              uint32 = 3361
	PGDEPENDENCIESOID           uint32 = 3402
	ANYENUMOID                  uint32 = 3500
	TSVECTOROID                 uint32 = 3614
	TSQUERYOID                  uint32 = 3615
	GTSVECTOROID                uint32 = 3642
	TSVECTORARRAYOID            uint32 = 3643
	GTSVECTORARRAYOID           uint32 = 3644
	TSQUERYARRAYOID             uint32 = 3645
	REGCONFIGOID                uint32 = 3734
	REGCONFIGARRAYOID           uint32 = 3735
	REGDICTIONARYOID            uint32 = 3769
	REGDICTIONARYARRAYOID       uint32 = 3770
	JSONBOID                    uint32 = 3802
	JSONBARRAYOID               uint32 = 3807
	ANYRANGEOID                 uint32 = 3831
	EVENTTRIGGEROID             uint32 = 3838
	INT4RANGEOID                uint32 = 3904
	INT4RANGEARRAYOID           uint32 = 3905
	NUMRANGEOID                 uint32 = 3906
	NUMRANGEARRAYOID            uint32 = 3907
	TSRANGEOID                  uint32 = 3908
	TSRANGEARRAYOID             uint32 = 3909
	TSTZRANGEOID                uint32 = 3910
	TSTZRANGEARRAYOID           uint32 = 3911
	DATERANGEOID                uint32 = 3912
	DATERANGEARRAYOID           uint32 = 3913
	INT8RANGEOID                uint32 = 3926
	INT8RANGEARRAYOID           uint32 = 3927
	JSONPATHOID                 uint32 = 4072
	JSONPATHARRAYOID            uint32 = 4073
	REGNAMESPACEOID             uint32 = 4089
	REGNAMESPACEARRAYOID        uint32 = 4090
	REGROLEOID                  uint32 = 4096
	REGROLEARRAYOID             uint32 = 4097
	REGCOLLATIONOID             uint32 = 4191
	REGCOLLATIONARRAYOID        uint32 = 4192
	INT4MULTIRANGEOID           uint32 = 4451
	NUMMULTIRANGEOID            uint32 = 4532
	TSMULTIRANGEOID             uint32 = 4533
	TSTZMULTIRANGEOID           uint32 = 4534
	DATEMULTIRANGEOID           uint32 = 4535
	INT8MULTIRANGEOID           uint32 = 4536
	ANYMULTIRANGEOID            uint32 = 4537
	ANYCOMPATIBLEMULTIRANGEOID  uint32 = 4538
	PGBRINBLOOMSUMMARYOID       uint32 = 4600
	PGBRINMINMAXMULTISUMMARYOID uint32 = 4601
	PGMCVLISTOID                uint32 = 5017
	PGSNAPSHOTOID               uint32 = 5038
	PGSNAPSHOTARRAYOID          uint32 = 5039
	XID8OID                     uint32 = 5069
	ANYCOMPATIBLEOID            uint32 = 5077
	ANYCOMPATIBLEARRAYOID       uint32 = 5078
	ANYCOMPATIBLENONARRAYOID    uint32 = 5079
	ANYCOMPATIBLERANGEOID       uint32 = 5080
	INT4MULTIRANGEARRAYOID      uint32 = 6150
	NUMMULTIRANGEARRAYOID       uint32 = 6151
	TSMULTIRANGEARRAYOID        uint32 = 6152
	TSTZMULTIRANGEARRAYOID      uint32 = 6153
	DATEMULTIRANGEARRAYOID      uint32 = 6155
	INT8MULTIRANGEARRAYOID      uint32 = 6157
)

Type OID constants.

View Source
const (
	DEFAULT_COLLATION_OID uint32 = 100 // "default" collation
	C_COLLATION_OID       uint32 = 950 // "C" collation
)

Collation OID constants.

pg: src/include/catalog/pg_collation_d.h

View Source
const (
	BooleanNotEqualOperator                     uint32 = 85
	BooleanEqualOperator                        uint32 = 91
	Int4EqualOperator                           uint32 = 96
	Int4LessOperator                            uint32 = 97
	TextEqualOperator                           uint32 = 98
	NameEqualTextOperator                       uint32 = 254
	NameLessTextOperator                        uint32 = 255
	NameGreaterEqualTextOperator                uint32 = 257
	TIDEqualOperator                            uint32 = 387
	Int8LessOperator                            uint32 = 412
	OID_NAME_REGEXEQ_OP                         uint32 = 639
	OID_TEXT_REGEXEQ_OP                         uint32 = 641
	TextLessOperator                            uint32 = 664
	TextGreaterEqualOperator                    uint32 = 667
	Float8LessOperator                          uint32 = 672
	OID_INET_SUB_OP                             uint32 = 931
	OID_INET_SUBEQ_OP                           uint32 = 932
	OID_INET_SUP_OP                             uint32 = 933
	OID_INET_SUPEQ_OP                           uint32 = 934
	BpcharEqualOperator                         uint32 = 1054
	OID_BPCHAR_REGEXEQ_OP                       uint32 = 1055
	BpcharLessOperator                          uint32 = 1058
	BpcharGreaterEqualOperator                  uint32 = 1061
	ARRAY_EQ_OP                                 uint32 = 1070
	ARRAY_LT_OP                                 uint32 = 1072
	ARRAY_GT_OP                                 uint32 = 1073
	OID_NAME_LIKE_OP                            uint32 = 1207
	OID_TEXT_LIKE_OP                            uint32 = 1209
	OID_BPCHAR_LIKE_OP                          uint32 = 1211
	OID_NAME_ICREGEXEQ_OP                       uint32 = 1226
	OID_TEXT_ICREGEXEQ_OP                       uint32 = 1228
	OID_BPCHAR_ICREGEXEQ_OP                     uint32 = 1234
	OID_NAME_ICLIKE_OP                          uint32 = 1625
	OID_TEXT_ICLIKE_OP                          uint32 = 1627
	OID_BPCHAR_ICLIKE_OP                        uint32 = 1629
	ByteaEqualOperator                          uint32 = 1955
	ByteaLessOperator                           uint32 = 1957
	ByteaGreaterEqualOperator                   uint32 = 1960
	OID_BYTEA_LIKE_OP                           uint32 = 2016
	TextPatternLessOperator                     uint32 = 2314
	TextPatternGreaterEqualOperator             uint32 = 2317
	BpcharPatternLessOperator                   uint32 = 2326
	BpcharPatternGreaterEqualOperator           uint32 = 2329
	OID_ARRAY_OVERLAP_OP                        uint32 = 2750
	OID_ARRAY_CONTAINS_OP                       uint32 = 2751
	OID_ARRAY_CONTAINED_OP                      uint32 = 2752
	TIDLessOperator                             uint32 = 2799
	TIDGreaterOperator                          uint32 = 2800
	TIDLessEqOperator                           uint32 = 2801
	TIDGreaterEqOperator                        uint32 = 2802
	OID_MULTIRANGE_LESS_OP                      uint32 = 2862
	OID_MULTIRANGE_LESS_EQUAL_OP                uint32 = 2863
	OID_MULTIRANGE_GREATER_EQUAL_OP             uint32 = 2864
	OID_MULTIRANGE_GREATER_OP                   uint32 = 2865
	OID_RANGE_OVERLAPS_MULTIRANGE_OP            uint32 = 2866
	OID_MULTIRANGE_OVERLAPS_RANGE_OP            uint32 = 2867
	OID_MULTIRANGE_OVERLAPS_MULTIRANGE_OP       uint32 = 2868
	OID_MULTIRANGE_CONTAINS_ELEM_OP             uint32 = 2869
	OID_MULTIRANGE_CONTAINS_RANGE_OP            uint32 = 2870
	OID_MULTIRANGE_CONTAINS_MULTIRANGE_OP       uint32 = 2871
	OID_MULTIRANGE_ELEM_CONTAINED_OP            uint32 = 2872
	OID_MULTIRANGE_RANGE_CONTAINED_OP           uint32 = 2873
	OID_MULTIRANGE_MULTIRANGE_CONTAINED_OP      uint32 = 2874
	OID_RANGE_OVERLAPS_LEFT_MULTIRANGE_OP       uint32 = 2875
	OID_MULTIRANGE_OVERLAPS_LEFT_RANGE_OP       uint32 = 2876
	OID_MULTIRANGE_OVERLAPS_LEFT_MULTIRANGE_OP  uint32 = 2877
	RECORD_EQ_OP                                uint32 = 2988
	RECORD_LT_OP                                uint32 = 2990
	RECORD_GT_OP                                uint32 = 2991
	OID_INET_OVERLAP_OP                         uint32 = 3552
	OID_RANGE_OVERLAPS_RIGHT_MULTIRANGE_OP      uint32 = 3585
	TextPrefixOperator                          uint32 = 3877
	OID_RANGE_LESS_OP                           uint32 = 3884
	OID_RANGE_LESS_EQUAL_OP                     uint32 = 3885
	OID_RANGE_GREATER_EQUAL_OP                  uint32 = 3886
	OID_RANGE_GREATER_OP                        uint32 = 3887
	OID_RANGE_OVERLAP_OP                        uint32 = 3888
	OID_RANGE_CONTAINS_ELEM_OP                  uint32 = 3889
	OID_RANGE_CONTAINS_OP                       uint32 = 3890
	OID_RANGE_ELEM_CONTAINED_OP                 uint32 = 3891
	OID_RANGE_CONTAINED_OP                      uint32 = 3892
	OID_RANGE_LEFT_OP                           uint32 = 3893
	OID_RANGE_RIGHT_OP                          uint32 = 3894
	OID_RANGE_OVERLAPS_LEFT_OP                  uint32 = 3895
	OID_RANGE_OVERLAPS_RIGHT_OP                 uint32 = 3896
	OID_MULTIRANGE_OVERLAPS_RIGHT_RANGE_OP      uint32 = 4035
	OID_MULTIRANGE_OVERLAPS_RIGHT_MULTIRANGE_OP uint32 = 4142
	OID_RANGE_ADJACENT_MULTIRANGE_OP            uint32 = 4179
	OID_MULTIRANGE_ADJACENT_RANGE_OP            uint32 = 4180
	OID_MULTIRANGE_ADJACENT_MULTIRANGE_OP       uint32 = 4198
	OID_RANGE_LEFT_MULTIRANGE_OP                uint32 = 4395
	OID_MULTIRANGE_LEFT_RANGE_OP                uint32 = 4396
	OID_MULTIRANGE_LEFT_MULTIRANGE_OP           uint32 = 4397
	OID_RANGE_RIGHT_MULTIRANGE_OP               uint32 = 4398
	OID_MULTIRANGE_RIGHT_RANGE_OP               uint32 = 4399
	OID_MULTIRANGE_RIGHT_MULTIRANGE_OP          uint32 = 4400
	OID_RANGE_CONTAINS_MULTIRANGE_OP            uint32 = 4539
	OID_RANGE_MULTIRANGE_CONTAINED_OP           uint32 = 4540
)

Operator OID constants.

View Source
const (
	RowCompareLT int = 1 // <
	RowCompareLE int = 2 // <=
	RowCompareEQ int = 3 // =
	RowCompareGE int = 4 // >=
	RowCompareGT int = 5 // >
	RowCompareNE int = 6 // <>
)

RowCompare type constants matching PG's RowCompareType.

View Source
const (
	XmlOpConcat    = 0 // XMLCONCAT(args)
	XmlOpElement   = 1 // XMLELEMENT(name, args)
	XmlOpForest    = 2 // XMLFOREST(args)
	XmlOpParse     = 3 // XMLPARSE(DOCUMENT|CONTENT expr)
	XmlOpPI        = 4 // XMLPI(name [, args])
	XmlOpRoot      = 5 // XMLROOT(xml, version, standalone)
	XmlOpSerialize = 6 // XMLSERIALIZE(DOCUMENT|CONTENT expr AS type)
	XmlOpDocument  = 7 // expr IS DOCUMENT
)

XmlExprOp identifies the type of XML expression.

View Source
const (
	XmlOptionDocument = 1
	XmlOptionContent  = 2
)

XmlOptionType identifies DOCUMENT vs CONTENT.

View Source
const (
	RelationRelationID   uint32 = 1259 // pg_class
	TypeRelationID       uint32 = 1247 // pg_type
	ConstraintRelationID uint32 = 2606 // pg_constraint
	ProcedureRelationID  uint32 = 1255 // pg_proc
	TriggerRelationID    uint32 = 2620 // pg_trigger
	NamespaceRelationID  uint32 = 2615 // pg_namespace
	IndexRelationID      uint32 = 2610 // pg_index (catalog, not the index itself)
	AttrDefaultRelID     uint32 = 2604 // pg_attrdef
	SequenceRelationID   uint32 = 2224 // pg_sequence_rel (class of seq relations is pg_class)
)
View Source
const (
	TYPTYPE_BASE       = 'b'
	TYPTYPE_COMPOSITE  = 'c'
	TYPTYPE_DOMAIN     = 'd'
	TYPTYPE_ENUM       = 'e'
	TYPTYPE_PSEUDO     = 'p'
	TYPTYPE_RANGE      = 'r'
	TYPTYPE_MULTIRANGE = 'm'
)

Type kind constants (from pg_type.h TYPTYPE_*)

View Source
const (
	PROKIND_FUNCTION  = 'f'
	PROKIND_PROCEDURE = 'p'
	PROKIND_AGGREGATE = 'a'
	PROKIND_WINDOW    = 'w'
)

Function kind constants (from pg_proc.h PROKIND_*)

View Source
const INDEX_MAX_KEYS = 32

INDEX_MAX_KEYS is the maximum number of columns in an index.

pg: src/include/pg_config_manual.h — INDEX_MAX_KEYS

View Source
const MaxHeapAttributeNumber = 1600

MaxHeapAttributeNumber is the maximum number of columns allowed in a table.

pg: src/include/access/htup_details.h — MaxHeapAttributeNumber

View Source
const PARTITION_MAX_KEYS = 32

PARTITION_MAX_KEYS is the maximum number of partition key columns.

pg: src/include/pg_config_manual.h — PARTITION_MAX_KEYS

Variables

View Source
var BuiltinCasts = [...]BuiltinCast{}/* 229 elements not displayed */

BuiltinCasts contains all 229 built-in PostgreSQL casts.

View Source
var BuiltinOperators = [...]BuiltinOperator{}/* 799 elements not displayed */

BuiltinOperators contains all 799 built-in PostgreSQL operators.

View Source
var BuiltinProcs = [...]BuiltinProc{}/* 3314 elements not displayed */

BuiltinProcs contains all 3314 built-in PostgreSQL functions.

View Source
var BuiltinTypes = [...]BuiltinType{}/* 193 elements not displayed */

BuiltinTypes contains all 193 built-in PostgreSQL types.

Functions

func FormatCreateTable

func FormatCreateTable(c *Catalog, schemaName string, rel *Relation) string

FormatCreateTable generates a full CREATE TABLE DDL statement for a relation. Exported so that section 1.7 (partitions) can reuse it.

func RegisterExtensionSQL

func RegisterExtensionSQL(name, sql string)

RegisterExtensionSQL allows external code to register extension DDL scripts. Once registered, CREATE EXTENSION <name> will execute the provided SQL.

Types

type AccessMethod

type AccessMethod struct {
	OID     uint32
	Name    string
	Type    byte   // 'i' = index, 't' = table
	Handler uint32 // handler function OID (informational only)
}

AccessMethod represents a registered index/table access method.

pg: src/backend/commands/amcmds.c — CreateAccessMethod

type AggExpr

type AggExpr struct {
	AggFuncOID  uint32
	AggName     string // for deparse
	ResultType  uint32
	Collation   uint32 // result collation
	Args        []AnalyzedExpr
	AggStar     bool // count(*)
	AggDistinct bool
}

AggExpr represents an aggregate function call.

pg: src/include/nodes/primnodes.h — Aggref

type AlternativeSubPlanExpr

type AlternativeSubPlanExpr struct{}

AlternativeSubPlanExpr is a plan-internal stub (never in user DDL).

type AnalyzedExpr

type AnalyzedExpr interface {
	// contains filtered or unexported methods
}

AnalyzedExpr is the interface for post-analysis expression nodes.

pg: src/include/nodes/primnodes.h — Expr (base node) pg: src/backend/nodes/nodeFuncs.c — exprType, exprTypmod, exprCollation

type ArrayCoerceExprQ

type ArrayCoerceExprQ struct {
	Arg        AnalyzedExpr
	ResultType uint32
	ElemExpr   AnalyzedExpr // per-element coercion expression
	Format     byte         // 'e'=explicit, 'i'=implicit
}

ArrayCoerceExprQ represents array element type coercion.

pg: src/include/nodes/primnodes.h — ArrayCoerceExpr

type ArrayExprQ

type ArrayExprQ struct {
	ElementType uint32 // element type OID
	ArrayType   uint32 // array type OID
	Elements    []AnalyzedExpr
}

ArrayExprQ represents an ARRAY[...] constructor.

pg: src/include/nodes/primnodes.h — ArrayExpr

type BoolExprQ

type BoolExprQ struct {
	Op   BoolOpType
	Args []AnalyzedExpr
}

BoolExprQ represents an analyzed boolean expression (AND/OR/NOT).

pg: src/include/nodes/primnodes.h — BoolExpr

type BoolOpType

type BoolOpType int

BoolOpType identifies a boolean operator.

const (
	BoolAnd BoolOpType = iota
	BoolOr
	BoolNot
)

type BoolTestType

type BoolTestType int

BoolTestType identifies the kind of boolean test.

const (
	BoolIsTrue BoolTestType = iota
	BoolIsNotTrue
	BoolIsFalse
	BoolIsNotFalse
	BoolIsUnknown
	BoolIsNotUnknown
)

type BooleanTestExpr

type BooleanTestExpr struct {
	Arg      AnalyzedExpr
	TestType BoolTestType
}

BooleanTestExpr represents IS [NOT] TRUE/FALSE/UNKNOWN.

pg: src/include/nodes/primnodes.h — BooleanTest

type BuiltinCast

type BuiltinCast struct {
	Source  uint32
	Target  uint32
	Func    uint32
	Context byte // 'i'=implicit, 'a'=assignment, 'e'=explicit
	Method  byte // 'f'=function, 'b'=binary coercible, 'i'=I/O
}

BuiltinCast represents a built-in PostgreSQL type cast.

type BuiltinOperator

type BuiltinOperator struct {
	OID      uint32
	Name     string
	Kind     byte // 'b'=binary, 'l'=prefix
	CanMerge bool
	CanHash  bool
	Left     uint32 // 0 for prefix operators
	Right    uint32
	Result   uint32
	Com      uint32 // commutator OID
	Negate   uint32 // negator OID
	Code     uint32 // implementing function OID
	Rest     uint32 // restriction selectivity estimator
	Join     uint32 // join selectivity estimator
}

BuiltinOperator represents a built-in PostgreSQL operator.

type BuiltinProc

type BuiltinProc struct {
	OID          uint32
	Name         string
	Lang         uint32
	Cost         float32
	Rows         float32
	Variadic     uint32
	Support      uint32
	Kind         byte // 'f'=function, 'a'=aggregate, 'w'=window, 'p'=procedure
	SecDef       bool
	LeakProof    bool
	IsStrict     bool
	RetSet       bool
	Volatile     byte // 'i'=immutable, 's'=stable, 'v'=volatile
	Parallel     byte // 's'=safe, 'r'=restricted, 'u'=unsafe
	NArgs        int16
	NArgDefaults int16
	RetType      uint32
	ArgTypes     []uint32
	AllArgTypes  []uint32 // nil if IN only
	ArgModes     []byte   // nil if all IN; values are 'i','o','b','v','t'
	ArgNames     []string // nil if no names
}

BuiltinProc represents a built-in PostgreSQL function/procedure.

type BuiltinType

type BuiltinType struct {
	OID         uint32
	TypeName    string
	Namespace   uint32
	Len         int16
	ByVal       bool
	Type        byte // 'b'=base, 'c'=composite, 'd'=domain, 'e'=enum, 'p'=pseudo, 'r'=range, 'm'=multirange
	Category    byte // type category for parser
	IsPreferred bool
	IsDefined   bool
	Delim       byte
	RelID       uint32
	Subscript   uint32 // typsubscript function OID
	Elem        uint32 // element type for arrays
	Array       uint32 // array type OID
	Input       uint32 // input function OID
	Output      uint32 // output function OID
	Receive     uint32 // binary receive function OID
	Send        uint32 // binary send function OID
	ModIn       uint32 // typmod input function OID
	ModOut      uint32 // typmod output function OID
	Analyze     uint32 // analyze function OID
	Align       byte   // 'c', 's', 'i', 'd'
	Storage     byte   // 'p', 'e', 'x', 'm'
	NotNull     bool
	BaseType    uint32 // for domains
	TypeMod     int32
	NDims       int32
	Collation   uint32
}

BuiltinType represents a built-in PostgreSQL type.

type CaseExprQ

type CaseExprQ struct {
	Arg        AnalyzedExpr // nil for searched CASE
	When       []*CaseWhenQ
	Default    AnalyzedExpr // nil if no ELSE
	ResultType uint32
	Collation  uint32 // result collation
}

CaseExprQ represents an analyzed CASE expression. Named CaseExprQ to avoid collision with the raw CaseExpr in pgparser nodes.

pg: src/include/nodes/primnodes.h — CaseExpr

type CaseTestExprQ

type CaseTestExprQ struct {
	TypeOID uint32
	TypeMod int32
}

CaseTestExprQ represents the internal CASE test placeholder.

pg: src/include/nodes/primnodes.h — CaseTestExpr

type CaseWhenQ

type CaseWhenQ struct {
	Condition AnalyzedExpr
	Result    AnalyzedExpr
}

CaseWhenQ represents a WHEN clause in a CASE expression.

pg: src/include/nodes/primnodes.h — CaseWhen

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is the in-memory PostgreSQL catalog.

func LoadSDL

func LoadSDL(sql string) (*Catalog, error)

LoadSDL parses a declarative schema definition (SDL) and loads it into a new Catalog. SDL only accepts CREATE/COMMENT/GRANT statements — DML and destructive DDL (DROP, ALTER TABLE ADD/DROP COLUMN, TRUNCATE, etc.) are rejected with a clear error.

The pipeline: parse → validate → collectDeclared → extractDeps → topoSort → execute.

func LoadSQL

func LoadSQL(sql string) (*Catalog, error)

LoadSQL parses SQL and executes all statements into a new Catalog. Returns the catalog and the first error encountered (if any). On error, the catalog reflects all statements that succeeded before the failure.

func New

func New() *Catalog

New creates a fully initialized Catalog with all built-in data indexed.

func (*Catalog) AddConstraint

func (c *Catalog) AddConstraint(schemaName, tableName string, def ConstraintDef) error

AddConstraint adds a constraint to an existing relation, bypassing DDL text.

func (*Catalog) AllProcNames

func (c *Catalog) AllProcNames() []string

AllProcNames returns all unique procedure/function names, sorted.

func (*Catalog) AlterDomainStmt

func (c *Catalog) AlterDomainStmt(stmt *nodes.AlterDomainStmt) error

AlterDomainStmt alters an existing domain from a parsed ALTER DOMAIN statement.

pg: src/backend/commands/typecmds.c — AlterDomainStmt

func (*Catalog) AlterEnumStmt

func (c *Catalog) AlterEnumStmt(stmt *nodes.AlterEnumStmt) error

AlterEnumStmt handles ALTER TYPE ... ADD VALUE and ALTER TYPE ... RENAME VALUE.

pg: src/backend/commands/typecmds.c — AlterEnum

func (*Catalog) AlterFunction

func (c *Catalog) AlterFunction(stmt *nodes.AlterFunctionStmt) error

AlterFunction alters a function's attributes.

pg: src/backend/commands/functioncmds.c — AlterFunction

func (*Catalog) AlterIndexStmt

func (c *Catalog) AlterIndexStmt(stmt *nodes.AlterTableStmt) error

AlterIndexStmt applies ALTER INDEX commands.

pg: src/backend/commands/tablecmds.c — AlterTable dispatch for OBJECT_INDEX

func (*Catalog) AlterOpFamily

func (c *Catalog) AlterOpFamily(stmt *nodes.AlterOpFamilyStmt) error

AlterOpFamily adds or drops members from an operator family.

pg: src/backend/commands/opclasscmds.c — AlterOpFamily

func (*Catalog) AlterPolicy

func (c *Catalog) AlterPolicy(stmt *nodes.AlterPolicyStmt) error

AlterPolicy modifies an existing row-level security policy.

pg: src/backend/commands/policy.c — AlterPolicy

func (*Catalog) AlterSequenceStmt

func (c *Catalog) AlterSequenceStmt(stmt *nodes.AlterSeqStmt) error

AlterSequenceStmt alters an existing sequence from a parsed ALTER SEQUENCE statement.

pg: src/backend/commands/sequence.c — AlterSequence

func (*Catalog) AlterTableStmt

func (c *Catalog) AlterTableStmt(stmt *nodes.AlterTableStmt) error

AlterTableStmt applies ALTER TABLE commands from a pgparser AST. Commands are sorted into passes before execution (DROP first, then TYPE, then ADD, then attribute changes), mirroring PG's multi-pass approach.

pg: src/backend/commands/tablecmds.c — AlterTable

func (*Catalog) AnalyzeDomainExpr

func (c *Catalog) AnalyzeDomainExpr(expr nodes.Node, domainBaseTypeOID uint32, domainBaseTypMod int32) (AnalyzedExpr, error)

AnalyzeDomainExpr analyzes a raw expression node in the context of a domain type. The "VALUE" keyword is intercepted in transformColumnRef and replaced with CoerceToDomainValueExpr.

pg: src/backend/commands/typecmds.c — domainAddCheckConstraint

func (*Catalog) AnalyzeExprNoContext

func (c *Catalog) AnalyzeExprNoContext(expr nodes.Node) (AnalyzedExpr, error)

AnalyzeExprNoContext analyzes a raw expression node without any range table context. Used for function parameter default expressions.

pg: src/backend/parser/parse_expr.c — transformExpr (no pstate relations)

func (*Catalog) AnalyzeSelectStmt

func (c *Catalog) AnalyzeSelectStmt(stmt *nodes.SelectStmt) (*Query, error)

AnalyzeSelectStmt transforms a raw SelectStmt AST node into a semantically analyzed Query. The catalog must already contain the schema (tables, types, functions) referenced by the query — load it via Exec() beforehand.

The returned Query contains resolved column references (VarExpr), type information, and provenance tracking (TargetEntry.ResOrigTbl/ResOrigCol) that can be used to extract column lineage.

pg: src/backend/parser/analyze.c — transformSelectStmt

func (*Catalog) AnalyzeStandaloneExpr

func (c *Catalog) AnalyzeStandaloneExpr(expr nodes.Node, rel *Relation) (AnalyzedExpr, error)

AnalyzeStandaloneExpr analyzes a raw expression node in the context of a relation's columns. Used for CHECK constraints, column defaults, and policy expressions.

pg: src/backend/parser/parse_expr.c — transformExpr (standalone context)

func (*Catalog) AnalyzeTriggerWhenExpr

func (c *Catalog) AnalyzeTriggerWhenExpr(expr nodes.Node, rel *Relation) (AnalyzedExpr, error)

AnalyzeTriggerWhenExpr analyzes a trigger WHEN clause in the context of OLD (varno=1) and NEW (varno=2) pseudo-relations.

pg: src/backend/commands/trigger.c — CreateTrigger (WHEN clause setup)

func (*Catalog) CanCoerce

func (c *Catalog) CanCoerce(source, target uint32, context byte) bool

CanCoerce returns true if source can be coerced to target in the given context.

func (*Catalog) Clone

func (c *Catalog) Clone() *Catalog

Clone creates a deep copy of the Catalog.

Builtin immutable data (casts, operators, builtin procs, builtin types) is shared by reference. All user-created objects are deep-copied so modifications to the clone do not affect the original, and vice versa.

func (*Catalog) CommentObject

func (c *Catalog) CommentObject(stmt *nodes.CommentStmt) error

CommentObject sets or removes a comment on a catalog object from a pgparser AST.

pg: src/backend/commands/comment.c — CommentObject

func (*Catalog) ConstraintsOf

func (c *Catalog) ConstraintsOf(relOID uint32) []*Constraint

ConstraintsOf returns all constraints on the given relation.

func (*Catalog) CreateAccessMethod

func (c *Catalog) CreateAccessMethod(stmt *nodes.CreateAmStmt) error

CreateAccessMethod registers a new access method.

pg: src/backend/commands/amcmds.c — CreateAccessMethod

func (*Catalog) CreateCast

func (c *Catalog) CreateCast(stmt *nodes.CreateCastStmt) error

CreateCast registers a user-defined cast.

pg: src/backend/commands/functioncmds.c — CreateCast

func (*Catalog) CreateExtension

func (c *Catalog) CreateExtension(stmt *nodes.CreateExtensionStmt) error

CreateExtension loads and executes a bundled extension DDL script.

pg: src/backend/commands/extension.c — CreateExtension

func (*Catalog) CreateFunctionStmt

func (c *Catalog) CreateFunctionStmt(stmt *nodes.CreateFunctionStmt) error

CreateFunctionStmt creates a user-defined function or procedure from a pgparser AST.

pg: src/backend/commands/functioncmds.c — CreateFunction

func (*Catalog) CreateOpFamily

func (c *Catalog) CreateOpFamily(stmt *nodes.CreateOpFamilyStmt) error

CreateOpFamily registers a new operator family.

pg: src/backend/commands/opclasscmds.c — CreateOpFamily

func (*Catalog) CreatePolicy

func (c *Catalog) CreatePolicy(stmt *nodes.CreatePolicyStmt) error

CreatePolicy creates a new row-level security policy on a table.

pg: src/backend/commands/policy.c — CreatePolicy

func (*Catalog) CreateSchemaCommand

func (c *Catalog) CreateSchemaCommand(stmt *nodes.CreateSchemaStmt) error

CreateSchemaCommand creates a new schema in the catalog.

pg: src/backend/commands/schemacmds.c — CreateSchemaCommand

func (*Catalog) CreateTriggerStmt

func (c *Catalog) CreateTriggerStmt(stmt *nodes.CreateTrigStmt) error

CreateTriggerStmt creates a new trigger on a relation from a pgparser AST.

pg: src/backend/commands/trigger.c — CreateTrigger

func (*Catalog) CurrentUser

func (c *Catalog) CurrentUser() string

CurrentUser returns the effective current user name.

func (*Catalog) DefineAggregate

func (c *Catalog) DefineAggregate(stmt *nodes.DefineStmt) error

DefineAggregate creates a user-defined aggregate function.

pg: src/backend/commands/aggregatecmds.c — DefineAggregate

func (*Catalog) DefineCompositeType

func (c *Catalog) DefineCompositeType(stmt *nodes.CompositeTypeStmt) error

DefineCompositeType creates a new composite type from a parsed CREATE TYPE ... AS statement.

pg: src/backend/commands/typecmds.c — DefineCompositeType

func (*Catalog) DefineDomain

func (c *Catalog) DefineDomain(stmt *nodes.CreateDomainStmt) error

DefineDomain creates a new domain type from a parsed CREATE DOMAIN statement.

pg: src/backend/commands/typecmds.c — DefineDomain

func (*Catalog) DefineEnum

func (c *Catalog) DefineEnum(stmt *nodes.CreateEnumStmt) error

DefineEnum creates a new enum type from a parsed CREATE TYPE ... AS ENUM statement.

pg: src/backend/commands/typecmds.c — DefineEnum

func (*Catalog) DefineIndex

func (c *Catalog) DefineIndex(stmt *nodes.IndexStmt) error

DefineIndex creates a new index on a relation.

pg: src/backend/commands/indexcmds.c — DefineIndex

func (*Catalog) DefineOpClass

func (c *Catalog) DefineOpClass(stmt *nodes.CreateOpClassStmt) error

DefineOpClass registers a new operator class.

pg: src/backend/commands/opclasscmds.c — DefineOpClass

func (*Catalog) DefineOperator

func (c *Catalog) DefineOperator(stmt *nodes.DefineStmt) error

DefineOperator creates a user-defined operator.

pg: src/backend/commands/operatorcmds.c — DefineOperator

func (*Catalog) DefineRange

func (c *Catalog) DefineRange(stmt *nodes.CreateRangeStmt) error

DefineRange creates a new range type from a parsed CREATE TYPE ... AS RANGE statement.

pg: src/backend/commands/typecmds.c — DefineRange

func (*Catalog) DefineRelation

func (c *Catalog) DefineRelation(stmt *nodes.CreateStmt, relkind byte) error

DefineRelation creates a new relation (table).

pg: src/backend/commands/tablecmds.c — DefineRelation

func (*Catalog) DefineSequence

func (c *Catalog) DefineSequence(stmt *nodes.CreateSeqStmt) error

DefineSequence creates a new sequence from a parsed CREATE SEQUENCE statement.

pg: src/backend/commands/sequence.c — DefineSequence

func (*Catalog) DefineType

func (c *Catalog) DefineType(stmt *nodes.DefineStmt) error

DefineType creates a new base type.

Two-phase protocol:

  1. Shell type (no parameters): creates an undefined shell entry.
  2. Full definition (with parameters): requires existing shell type, parses params, looks up I/O functions, registers the complete type + array type.

pg: src/backend/commands/typecmds.c — DefineType

func (*Catalog) DefineView

func (c *Catalog) DefineView(stmt *nodes.ViewStmt) error

DefineView creates a new view in the catalog.

pg: src/backend/commands/view.c — DefineView

func (*Catalog) DeparseExpr

func (c *Catalog) DeparseExpr(expr AnalyzedExpr, rtable []*RangeTableEntry, prettyParen bool) string

DeparseExpr deparses an analyzed expression to SQL text, matching pg_get_expr() / pg_get_constraintdef() output format.

pg: src/backend/utils/adt/ruleutils.c — deparse_expression_pretty

func (*Catalog) DomainInfo

func (c *Catalog) DomainInfo(typeOID uint32) *DomainType

DomainInfo returns the domain metadata for the given type OID, or nil.

func (*Catalog) DrainWarnings

func (c *Catalog) DrainWarnings() []Warning

DrainWarnings returns all accumulated warnings and clears the buffer.

func (*Catalog) EnumValues

func (c *Catalog) EnumValues(typeOID uint32) []string

EnumValues returns the labels of an enum type, or nil if not an enum.

func (*Catalog) Exec

func (c *Catalog) Exec(sql string, opts *ExecOptions) ([]ExecResult, error)

Exec parses and executes one or more SQL statements against the catalog. DDL statements modify catalog state. DML, transaction control, and other non-utility statements are skipped (Skipped=true in the result).

pg: src/backend/tcop/postgres.c — exec_simple_query

func (*Catalog) ExecAlterObjectSchemaStmt

func (c *Catalog) ExecAlterObjectSchemaStmt(stmt *nodes.AlterObjectSchemaStmt) error

ExecAlterObjectSchemaStmt moves an object to a different schema (SET SCHEMA).

pg: src/backend/commands/alter.c — ExecAlterObjectSchemaStmt

func (*Catalog) ExecCreateTableAs

func (c *Catalog) ExecCreateTableAs(stmt *nodes.CreateTableAsStmt) error

ExecCreateTableAs creates a table or materialized view from a query (CREATE TABLE ... AS SELECT or CREATE MATERIALIZED VIEW ... AS SELECT).

pg: src/backend/commands/createas.c — ExecCreateTableAs

func (*Catalog) ExecGrantStmt

func (c *Catalog) ExecGrantStmt(stmt *nodes.GrantStmt) error

ExecGrantStmt processes GRANT and REVOKE statements. For pgddl, grants are stored for catalog completeness but do not affect DDL semantics.

pg: src/backend/catalog/aclchk.c — ExecGrantStmt_oids

func (*Catalog) ExecRefreshMatView

func (c *Catalog) ExecRefreshMatView(stmt *nodes.RefreshMatViewStmt) error

ExecRefreshMatView refreshes a materialized view. For pgddl, this is a no-op (no physical data to refresh) — just verifies the matview exists.

pg: src/backend/commands/matview.c — ExecRefreshMatView

func (*Catalog) ExecRenameStmt

func (c *Catalog) ExecRenameStmt(stmt *nodes.RenameStmt) error

ExecRenameStmt handles RENAME operations from a pgparser AST.

pg: src/backend/commands/alter.c — ExecRenameStmt

func (*Catalog) ExecuteTruncate

func (c *Catalog) ExecuteTruncate(stmt *nodes.TruncateStmt) error

ExecuteTruncate handles TRUNCATE TABLE. For pgddl (no physical data), this validates the targets and optionally resets owned sequence values for RESTART IDENTITY.

pg: src/backend/commands/tablecmds.c — ExecuteTruncate

func (*Catalog) FindCoercionPathway

func (c *Catalog) FindCoercionPathway(source, target uint32, context byte) (CoercionPathway, uint32)

FindCoercionPathway returns the coercion pathway from source to target for the given context ('i'=implicit, 'a'=assignment, 'e'=explicit). The second return value is the cast function OID (0 for relabel/none).

func (*Catalog) FormatType

func (c *Catalog) FormatType(typeOID uint32, typmod int32) string

FormatType formats a type OID and typmod into a human-readable type name.

func (*Catalog) GetComment

func (c *Catalog) GetComment(objType byte, objOID uint32, subID int16) (string, bool)

GetComment returns the comment for the given object, if any.

func (*Catalog) GetDomainConstraintByOID

func (c *Catalog) GetDomainConstraintByOID(oid uint32) string

GetDomainConstraintByOID returns the name of a domain constraint by its OID, or empty string if not found.

(pgddl helper — PG uses SearchSysCache1(CONSTROID, ...))

func (*Catalog) GetIndexByOID

func (c *Catalog) GetIndexByOID(oid uint32) *Index

GetIndexByOID returns the index with the given OID, or nil.

func (*Catalog) GetMatViewDefinition

func (c *Catalog) GetMatViewDefinition(schema, name string, pretty ...bool) (string, error)

GetMatViewDefinition returns the SQL definition of a materialized view, matching pg_get_viewdef() output format (PG's pg_get_viewdef works on matviews too).

When pretty is false, matches pg_get_viewdef(oid) (PRETTYFLAG_INDENT only). When pretty is true, matches pg_get_viewdef(oid, true) (PRETTYFLAG_INDENT | PRETTYFLAG_PAREN).

pg: src/backend/utils/adt/ruleutils.c — pg_get_viewdef_worker

func (*Catalog) GetRelation

func (c *Catalog) GetRelation(schema, name string) *Relation

GetRelation returns the relation in the given schema, or nil. If schema is empty, the search path is used.

func (*Catalog) GetRelationByOID

func (c *Catalog) GetRelationByOID(oid uint32) *Relation

GetRelationByOID returns the relation with the given OID, or nil.

func (*Catalog) GetSchema

func (c *Catalog) GetSchema(name string) *Schema

GetSchema returns the schema with the given name, or nil.

func (*Catalog) GetSequenceByOID

func (c *Catalog) GetSequenceByOID(oid uint32) *Sequence

GetSequenceByOID returns the sequence with the given OID, or nil.

func (*Catalog) GetUserProcByOID

func (c *Catalog) GetUserProcByOID(oid uint32) *UserProc

GetUserProcByOID returns the user-defined function/procedure with the given OID, or nil.

func (*Catalog) GetViewDefinition

func (c *Catalog) GetViewDefinition(schema, name string, pretty ...bool) (string, error)

GetViewDefinition returns the SQL definition of a view, matching pg_get_viewdef() output format.

When pretty is false, matches pg_get_viewdef(oid) (PRETTYFLAG_INDENT only). When pretty is true, matches pg_get_viewdef(oid, true) (PRETTYFLAG_INDENT | PRETTYFLAG_PAREN).

pg: src/backend/utils/adt/ruleutils.c — pg_get_viewdef_worker

func (*Catalog) IndexesOf

func (c *Catalog) IndexesOf(relOID uint32) []*Index

IndexesOf returns all indexes on the given relation.

func (*Catalog) IsBinaryCoercible

func (c *Catalog) IsBinaryCoercible(source, target uint32) bool

IsBinaryCoercible returns true if source can be cast to target as a no-op relabel.

pg: src/backend/parser/parse_coerce.c — IsBinaryCoercibleWithCast

func (*Catalog) LookupAccessMethod

func (c *Catalog) LookupAccessMethod(name string) *AccessMethod

LookupAccessMethod returns the access method with the given name, or nil.

func (*Catalog) LookupCast

func (c *Catalog) LookupCast(source, target uint32) *BuiltinCast

LookupCast returns the cast from source to target, or nil.

func (*Catalog) LookupOperatorExact

func (c *Catalog) LookupOperatorExact(name string, left, right uint32) []*BuiltinOperator

LookupOperatorExact returns the operators matching the exact signature.

func (*Catalog) LookupProcByName

func (c *Catalog) LookupProcByName(name string) []*BuiltinProc

LookupProcByName returns all procs with the given name.

func (*Catalog) LookupProcByOID

func (c *Catalog) LookupProcByOID(oid uint32) *BuiltinProc

LookupProcByOID returns the proc with the given OID, or nil.

func (*Catalog) ProcessUtility

func (c *Catalog) ProcessUtility(stmt nodes.Node) error

ProcessUtility dispatches a utility (DDL) statement to the appropriate handler.

pg: src/backend/tcop/utility.c — standard_ProcessUtility

func (*Catalog) QueryPgAttrdef

func (c *Catalog) QueryPgAttrdef(relOID uint32) []PgAttrdefRow

QueryPgAttrdef returns pg_attrdef rows for a relation by OID.

(pgddl helper — PG uses SearchSysCache with pg_attrdef)

func (*Catalog) QueryPgAttribute

func (c *Catalog) QueryPgAttribute(relOID uint32) []PgAttributeRow

QueryPgAttribute returns pg_attribute rows for a relation by OID.

(pgddl helper — PG uses ScanPgRelation/SearchSysCache with pg_attribute)

func (*Catalog) QueryPgClass

func (c *Catalog) QueryPgClass(schemaName string) []PgClassRow

QueryPgClass returns pg_class rows for all objects in the given schema.

(pgddl helper — PG uses ScanPgRelation/SearchSysCache with pg_class)

func (*Catalog) QueryPgConstraint

func (c *Catalog) QueryPgConstraint(relOID uint32) []PgConstraintRow

QueryPgConstraint returns pg_constraint rows for a relation by OID.

(pgddl helper — PG uses SearchSysCache with pg_constraint)

func (*Catalog) QueryPgDepend

func (c *Catalog) QueryPgDepend() []PgDependRow

QueryPgDepend returns all pg_depend rows.

(pgddl helper — PG uses SearchSysCache with pg_depend)

func (*Catalog) QueryPgDescription

func (c *Catalog) QueryPgDescription() []PgDescriptionRow

QueryPgDescription returns all pg_description rows.

(pgddl helper — PG uses SearchSysCache with pg_description)

func (*Catalog) QueryPgDomainConstraints

func (c *Catalog) QueryPgDomainConstraints(schemaName string) []PgDomainConstraintRow

QueryPgDomainConstraints returns domain CHECK constraints for a given schema.

(pgddl helper — PG uses pg_constraint with contypid != 0)

func (*Catalog) QueryPgEnum

func (c *Catalog) QueryPgEnum(typeOID uint32) []PgEnumRow

QueryPgEnum returns pg_enum rows for an enum type by OID.

(pgddl helper — PG uses SearchSysCache with pg_enum)

func (*Catalog) QueryPgIndex

func (c *Catalog) QueryPgIndex(relOID uint32) []PgIndexRow

QueryPgIndex returns pg_index rows for a relation by OID.

(pgddl helper — PG uses SearchSysCache with pg_index)

func (*Catalog) QueryPgInherits

func (c *Catalog) QueryPgInherits() []PgInheritsRow

QueryPgInherits returns all pg_inherits rows.

(pgddl helper — PG uses SearchSysCache with pg_inherits)

func (*Catalog) QueryPgNamespace

func (c *Catalog) QueryPgNamespace() []PgNamespaceRow

QueryPgNamespace returns all user-created schemas as pg_namespace rows.

(pgddl helper — PG uses ScanPgRelation/SearchSysCache with pg_namespace)

func (*Catalog) QueryPgPolicy

func (c *Catalog) QueryPgPolicy(relOID uint32) []PgPolicyRow

QueryPgPolicy returns pg_policy rows for the given relation OID. If relOID is 0, returns all policies.

pg: src/include/catalog/pg_policy.h

func (*Catalog) QueryPgProc

func (c *Catalog) QueryPgProc(schemaName string) []PgProcRow

QueryPgProc returns pg_proc rows for user-created functions in a schema.

(pgddl helper — PG uses SearchSysCache with pg_proc)

func (*Catalog) QueryPgSequence

func (c *Catalog) QueryPgSequence(schemaName string) []PgSequenceRow

QueryPgSequence returns pg_sequence rows for all sequences in a schema.

(pgddl helper — PG uses SearchSysCache with pg_sequence)

func (*Catalog) QueryPgTrigger

func (c *Catalog) QueryPgTrigger(relOID uint32) []PgTriggerRow

QueryPgTrigger returns pg_trigger rows for a relation by OID.

(pgddl helper — PG uses SearchSysCache with pg_trigger)

func (*Catalog) QueryPgType

func (c *Catalog) QueryPgType(schemaName string) []PgTypeRow

QueryPgType returns pg_type rows for user-created types in a schema.

(pgddl helper — PG uses SearchSysCache with pg_type)

func (*Catalog) RangeInfo

func (c *Catalog) RangeInfo(typeOID uint32) *RangeType

RangeInfo returns the range metadata for the given type OID, or nil.

func (*Catalog) RelationIsVisible

func (c *Catalog) RelationIsVisible(relOID uint32) bool

RelationIsVisible checks whether a relation is visible in the current search path. A relation is visible if its schema is in the search path and no relation with the same name appears in an earlier search path entry.

pg: src/backend/catalog/namespace.c — RelationIsVisibleExt

func (*Catalog) RemoveObjects

func (c *Catalog) RemoveObjects(stmt *nodes.DropStmt) error

RemoveObjects dispatches DROP statements for non-relation object types. Handles OBJECT_INDEX, OBJECT_SEQUENCE, OBJECT_TYPE, OBJECT_FUNCTION, OBJECT_PROCEDURE, and OBJECT_TRIGGER.

For OBJECT_TABLE and OBJECT_VIEW, use RemoveRelations instead. For OBJECT_SCHEMA, use RemoveSchemas instead.

pg: src/backend/commands/dropcmds.c — RemoveObjects

func (*Catalog) RemoveRelations

func (c *Catalog) RemoveRelations(stmt *nodes.DropStmt) error

RemoveRelations handles DROP TABLE/VIEW/MATERIALIZED VIEW for one or more objects.

pg: src/backend/commands/tablecmds.c — RemoveRelations

func (*Catalog) RemoveSchemas

func (c *Catalog) RemoveSchemas(stmt *nodes.DropStmt) error

RemoveSchemas drops one or more schemas from the catalog. Called from RemoveObjects when the drop target is OBJECT_SCHEMA.

pg: src/backend/commands/schemacmds.c — (drop case in RemoveObjects via dropcmds.c)

func (*Catalog) ResetRole

func (c *Catalog) ResetRole()

ResetRole reverts the current user to the session user. Equivalent to SET ROLE NONE or RESET ROLE.

pg: src/backend/utils/init/miscinit.c — SetCurrentRoleId (InvalidOid case)

func (*Catalog) ResolveType

func (c *Catalog) ResolveType(tn TypeName) (oid uint32, typmod int32, err error)

ResolveType resolves a TypeName to an OID and typmod.

func (*Catalog) SequencesOf

func (c *Catalog) SequencesOf(schemaName string) []*Sequence

SequencesOf returns all sequences in the given schema.

func (*Catalog) SessionUser

func (c *Catalog) SessionUser() string

SessionUser returns the session user name.

func (*Catalog) SetRole

func (c *Catalog) SetRole(name string)

SetRole changes the current user to the given role name. In PostgreSQL this triggers search path recomputation when $user is present.

pg: src/backend/commands/variable.c — assign_role pg: src/backend/utils/init/miscinit.c — SetCurrentRoleId

func (*Catalog) SetSearchPath

func (c *Catalog) SetSearchPath(schemas []string)

SetSearchPath sets the schema search path by name. Non-existent schemas are accepted and silently skipped at lookup time, matching PostgreSQL's behavior.

pg: src/backend/utils/init/postinit.c — InitializeSearchPath

func (*Catalog) SetSessionUser

func (c *Catalog) SetSessionUser(name string)

SetSessionUser sets the session user (the user that authenticated). This also resets the current user to match, equivalent to RESET ROLE.

pg: src/backend/utils/init/miscinit.c — SetSessionAuthorization

func (*Catalog) TriggersOf

func (c *Catalog) TriggersOf(relOID uint32) []*Trigger

TriggersOf returns all triggers on the given relation.

func (*Catalog) TypeByOID

func (c *Catalog) TypeByOID(oid uint32) *BuiltinType

TypeByOID returns the type with the given OID, or nil.

func (*Catalog) TypeIsVisible

func (c *Catalog) TypeIsVisible(typOID uint32) bool

TypeIsVisible checks whether a type is visible in the current search path. A type is visible if its namespace is in the search path and no type with the same name appears in an earlier search path entry.

pg: src/backend/catalog/namespace.c — TypeIsVisibleExt

func (*Catalog) UserSchemas

func (c *Catalog) UserSchemas() []*Schema

UserSchemas returns all user-created schemas (excludes pg_catalog, pg_toast). Schemas are returned sorted by OID.

type CoalesceExprQ

type CoalesceExprQ struct {
	Args       []AnalyzedExpr
	ResultType uint32
	Collation  uint32 // result collation
}

CoalesceExprQ represents an analyzed COALESCE expression.

pg: src/include/nodes/primnodes.h — CoalesceExpr

type CoerceToDomainExpr

type CoerceToDomainExpr struct {
	Arg        AnalyzedExpr
	ResultType uint32
	TypeMod    int32
}

CoerceToDomainExpr represents a coercion to a domain type.

pg: src/include/nodes/primnodes.h — CoerceToDomain

type CoerceToDomainValueExpr

type CoerceToDomainValueExpr struct {
	TypeOID   uint32
	TypeMod   int32
	Collation uint32
}

CoerceToDomainValueExpr represents a reference to the VALUE keyword in domain CHECK constraints. PG creates this node in domainAddCheckConstraint() via a parser hook that replaces "value" ColumnRef nodes.

pg: src/include/nodes/primnodes.h — CoerceToDomainValue

type CoerceViaIOExpr

type CoerceViaIOExpr struct {
	Arg        AnalyzedExpr
	ResultType uint32
	Collation  uint32 // result collation
	Format     byte   // 'e'=explicit, 'i'=implicit
}

CoerceViaIOExpr represents a type cast via I/O conversion.

pg: src/include/nodes/primnodes.h — CoerceViaIO

type CoercionPathway

type CoercionPathway int

CoercionPathway describes how a type cast is performed.

const (
	CoercionNone    CoercionPathway = iota // no coercion possible
	CoercionRelabel                        // binary compatible (no-op cast)
	CoercionFunc                           // cast via function
	CoercionIO                             // cast via I/O conversion
)

type CollateExprQ

type CollateExprQ struct {
	Arg      AnalyzedExpr
	CollOID  uint32 // collation OID (0 if not resolved)
	CollName string // collation name for deparse
}

CollateExprQ represents an expr COLLATE "name" expression.

pg: src/include/nodes/primnodes.h — CollateExpr

type Column

type Column struct {
	AttNum          int16
	Name            string
	TypeOID         uint32
	TypeMod         int32
	NotNull         bool
	HasDefault      bool
	Default         string
	Len             int16
	ByVal           bool
	Align           byte
	Storage         byte
	Collation       uint32
	DefaultAnalyzed AnalyzedExpr // analyzed form of default expression (for Tier 2 deparse)
	Generated       byte         // 's' = stored generated, 0 = none
	Identity        byte         // 'a' = ALWAYS, 'd' = BY DEFAULT, 0 = none
	IsLocal         bool         // true if defined locally (not only inherited)
	InhCount        int          // number of inheritance ancestors that define this column
	Compression     byte         // attcompression: 'p'=pglz, 'l'=lz4, 0=default
	GenerationExpr  string       // expression text for generated columns
	CollationName   string       // explicit collation name (empty = type default)
	Ndims           int16        // attndims — declared array dimensions
}

Column represents a table column.

type ColumnDef

type ColumnDef struct {
	Name             string
	Type             TypeName
	NotNull          bool
	Default          string          // opaque expression; empty = no default
	RawDefault       nodes.Node      // raw AST node for default expression (for analysis)
	IsSerial         byte            // 0=none, 2=smallserial, 4=serial, 8=bigserial
	Generated        byte            // 's' = stored generated, 0 = none
	GenerationExpr   string          // expression text for generated column
	RawGenExpr       nodes.Node      // raw AST node for generated expression (for analysis)
	Identity         byte            // 'a' = ALWAYS, 'd' = BY DEFAULT, 0 = none
	IdentityOptions  *nodes.List     // raw sequence options from GENERATED ... AS IDENTITY
	IdentitySequence *nodes.RangeVar // selected sequence name after transform/expansion
	IsLocal          bool            // true if defined locally (not only inherited)
	InhCount         int             // number of inheritance ancestors that define this column
	CollationName    string          // explicit COLLATE clause; empty = type default
	IsFromType       bool            // true if column came from OF TYPE (typed table)
}

ColumnDef describes a column in a CREATE TABLE statement.

type ColumnDiffEntry

type ColumnDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Column
	To     *Column
}

ColumnDiffEntry describes a column change within a relation.

type CommentDiffEntry

type CommentDiffEntry struct {
	Action         DiffAction
	ObjType        byte
	ObjDescription string
	SubID          int16
	From           string
	To             string
}

CommentDiffEntry describes a comment change.

type CommonTableExprQ

type CommonTableExprQ struct {
	Name         string
	Aliases      []string // explicit column aliases
	Query        *Query
	Recursive    bool
	Materialized int // 0=default, 1=materialized, 2=not materialized
}

CommonTableExprQ represents an analyzed CTE.

pg: src/include/nodes/parsenodes.h — CommonTableExpr

type CompositeTypeDiffEntry

type CompositeTypeDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	From       *Relation // RelKind='c'
	To         *Relation // RelKind='c'
}

CompositeTypeDiffEntry describes a composite type change.

type ConstExpr

type ConstExpr struct {
	TypeOID   uint32
	TypeMod   int32
	Collation uint32 // collation OID
	IsNull    bool
	Value     string // textual representation
}

ConstExpr represents a typed constant.

pg: src/include/nodes/primnodes.h — Const

type Constraint

type Constraint struct {
	OID           uint32
	Name          string
	Type          ConstraintType
	RelOID        uint32
	Namespace     uint32       // connamespace (schema OID)
	Columns       []int16      // attnums
	FRelOID       uint32       // FK: referenced relation OID
	FColumns      []int16      // FK: referenced attnums
	FKUpdAction   byte         // FK: 'a'=NO ACTION, 'r'=RESTRICT, 'c'=CASCADE, 'n'=SET NULL, 'd'=SET DEFAULT
	FKDelAction   byte         // FK: same codes
	FKMatchType   byte         // FK: 's'=SIMPLE, 'f'=FULL, 'p'=PARTIAL
	Deferrable    bool         // condeferrable
	Deferred      bool         // condeferred
	Validated     bool         // convalidated
	CheckExpr     string       // CHECK: opaque expression
	CheckAnalyzed AnalyzedExpr // CHECK: analyzed form (for Tier 2 deparse)
	IndexOID      uint32       // PK/UNIQUE/EXCLUDE: backing index OID
	ExclOps       []string     // EXCLUDE only: operator names per column

	// Inheritance/partition fields.
	// pg: src/include/catalog/pg_constraint.h lines 89-108
	ConParentID  uint32 // parent constraint OID (partitions)
	ConIsLocal   bool   // locally defined (not only inherited)
	ConInhCount  int16  // inheritance count
	ConNoInherit bool   // cannot be inherited

	// FK operator arrays.
	// pg: src/include/catalog/pg_constraint.h lines 123-145
	PFEqOp       []uint32 // FK: PK=FK equality operators
	PPEqOp       []uint32 // FK: PK=PK equality operators
	FFEqOp       []uint32 // FK: FK=FK equality operators
	FKDelSetCols []int16  // FK: subset of columns for ON DELETE SET NULL/DEFAULT
}

Constraint represents a table constraint.

pg: src/include/catalog/pg_constraint.h

type ConstraintDef

type ConstraintDef struct {
	Name           string // empty = auto-generate
	Type           ConstraintType
	Columns        []string   // PK/UNIQUE/FK local columns
	IndexName      string     // PK/UNIQUE: user-specified USING INDEX name
	RefSchema      string     // FK only
	RefTable       string     // FK only
	RefColumns     []string   // FK only (empty = use PK of target)
	FKUpdAction    byte       // FK only: 'a', 'r', 'c', 'n', 'd'
	FKDelAction    byte       // FK only: 'a', 'r', 'c', 'n', 'd'
	FKMatchType    byte       // FK only: 's', 'f', 'p'
	Deferrable     bool       // DEFERRABLE
	Deferred       bool       // INITIALLY DEFERRED
	SkipValidation bool       // NOT VALID (CHECK/FK only)
	CheckExpr      string     // CHECK only
	RawCheckExpr   nodes.Node // raw AST node for CHECK expression (for analysis)
	ExclOps        []string   // EXCLUDE only: operator names per column
	AccessMethod   string     // EXCLUDE only: access method (default "gist")
}

ConstraintDef describes a constraint in a CREATE TABLE statement.

type ConstraintDiffEntry

type ConstraintDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Constraint
	To     *Constraint
}

ConstraintDiffEntry describes a constraint change within a relation.

type ConstraintType

type ConstraintType byte

ConstraintType identifies the kind of table constraint.

const (
	ConstraintPK      ConstraintType = 'p'
	ConstraintUnique  ConstraintType = 'u'
	ConstraintFK      ConstraintType = 'f'
	ConstraintCheck   ConstraintType = 'c'
	ConstraintExclude ConstraintType = 'x'
	ConstraintTrigger ConstraintType = 't' // constraint trigger
)

type ConvertRowtypeExprQ

type ConvertRowtypeExprQ struct {
	Arg        AnalyzedExpr
	ResultType uint32
}

ConvertRowtypeExprQ represents a row type conversion between compatible composite types.

pg: src/include/nodes/primnodes.h — ConvertRowtypeExpr

type DepEntry

type DepEntry struct {
	ObjType  byte // 'r'=relation, 'i'=index, 'c'=constraint, 't'=type
	ObjOID   uint32
	ObjSubID int32 // pg: pg_depend.objsubid (attnum, or 0 for whole object)
	RefType  byte
	RefOID   uint32
	RefSubID int32 // pg: pg_depend.refobjsubid (attnum, or 0 for whole object)
	DepType  DepType
}

DepEntry records a dependency between two catalog objects.

pg: src/include/catalog/pg_depend.h

type DepType

type DepType byte

DepType classifies a dependency.

const (
	DepNormal       DepType = 'n' // requires CASCADE to drop referent
	DepAuto         DepType = 'a' // auto-dropped with referent
	DepInternal     DepType = 'i' // inseparable from referent
	DepPartitionPri DepType = 'P' // partition object → parent object
	DepPartitionSec DepType = 'S' // partition object → partition table
)

type DiffAction

type DiffAction int

DiffAction describes what happened to an object between two catalog states.

const (
	// DiffAdd means the object exists in `to` but not in `from`.
	DiffAdd DiffAction = iota + 1
	// DiffDrop means the object exists in `from` but not in `to`.
	DiffDrop
	// DiffModify means the object exists in both but has changed.
	DiffModify
)

type DistinctExprQ

type DistinctExprQ struct {
	OpOID      uint32
	OpName     string
	ResultType uint32
	Left       AnalyzedExpr
	Right      AnalyzedExpr
	IsNot      bool // true for IS NOT DISTINCT FROM
}

DistinctExprQ represents IS [NOT] DISTINCT FROM. In PG, DistinctExpr is derived from OpExpr; the deparser checks the node tag.

pg: src/include/nodes/primnodes.h — DistinctExpr

type DomainConstraint

type DomainConstraint struct {
	OID           uint32
	Name          string
	DomainOID     uint32
	CheckExpr     string
	CheckAnalyzed AnalyzedExpr // analyzed form (for Tier 2 deparse)
	ConValidated  bool         // true if constraint has been validated
}

DomainConstraint represents a CHECK constraint on a domain.

type DomainDiffEntry

type DomainDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	From       *DomainType
	To         *DomainType
}

DomainDiffEntry describes a domain type change.

type DomainType

type DomainType struct {
	TypeOID     uint32
	BaseTypeOID uint32
	BaseTypMod  int32
	NotNull     bool
	Default     string
	Constraints []*DomainConstraint
}

DomainType holds metadata for a user-created domain type.

type EnumDiffEntry

type EnumDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	FromValues []string
	ToValues   []string
}

EnumDiffEntry describes an enum type change.

type EnumType

type EnumType struct {
	TypeOID uint32
	Values  []*EnumValue
	// contains filtered or unexported fields
}

EnumType holds the metadata for a user-created enum type.

type EnumValue

type EnumValue struct {
	OID       uint32
	EnumOID   uint32
	SortOrder float32
	Label     string
}

EnumValue represents one label of an enum type.

type Error

type Error struct {
	Code    string
	Message string
}

Error represents a PostgreSQL-compatible error with an SQLSTATE code.

func (*Error) Error

func (e *Error) Error() string

type ExecOptions

type ExecOptions struct {
	// ContinueOnError, when true, continues executing subsequent statements
	// after a failure, collecting all errors. When false (default), execution
	// stops at the first error.
	ContinueOnError bool
}

ExecOptions controls execution behavior.

type ExecResult

type ExecResult struct {
	Index    int       // statement position in the batch (0-based)
	SQL      string    // original SQL text for this statement
	Line     int       // 1-based start line in the original SQL
	Skipped  bool      // true if the statement was not processed (DML, etc.)
	Error    error     // nil = success or skipped
	Warnings []Warning // non-fatal notices emitted during execution
}

ExecResult is the execution result for a single statement.

type Extension

type Extension struct {
	OID         uint32
	Name        string
	SchemaOID   uint32
	Relocatable bool
}

Extension represents a registered extension.

pg: src/backend/commands/extension.c — ExtensionControlFile

type ExtensionDiffEntry

type ExtensionDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Extension
	To     *Extension
}

ExtensionDiffEntry describes an extension change.

type FieldSelectExprQ

type FieldSelectExprQ struct {
	Arg        AnalyzedExpr
	FieldNum   int16  // attribute number (1-based)
	FieldName  string // for deparse
	ResultType uint32
	TypeMod    int32
	Collation  uint32 // result collation
}

FieldSelectExprQ represents a composite.field selection.

pg: src/include/nodes/primnodes.h — FieldSelect

type FieldStoreExprQ

type FieldStoreExprQ struct {
	Arg        AnalyzedExpr
	FieldNums  []int
	NewVals    []AnalyzedExpr
	ResultType uint32
}

FieldStoreExprQ represents a composite field store (updating a field of a composite value).

pg: src/include/nodes/primnodes.h — FieldStore

type FuncCallExpr

type FuncCallExpr struct {
	FuncOID      uint32
	FuncName     string // for deparse
	ResultType   uint32
	ResultTypMod int32
	Collation    uint32 // result collation
	Args         []AnalyzedExpr
	CoerceFormat byte // 0=normal func, 'e'=explicit cast, 'i'=implicit cast
}

FuncCallExpr represents a resolved function call.

pg: src/include/nodes/primnodes.h — FuncExpr

type FunctionDiffEntry

type FunctionDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	Identity   string
	From       *UserProc
	To         *UserProc
}

FunctionDiffEntry describes a function or procedure change.

type Grant

type Grant struct {
	ObjType   byte   // 'r'=relation, 's'=sequence, 'f'=function, 'n'=schema
	ObjOID    uint32 // OID of the object
	Grantee   string // role name ("" = PUBLIC)
	Privilege string // SELECT, INSERT, UPDATE, DELETE, REFERENCES, TRIGGER, EXECUTE, USAGE, CREATE, ALL
	Columns   []string
	WithGrant bool
}

Grant represents a recorded privilege grant.

type GrantDiffEntry

type GrantDiffEntry struct {
	Action DiffAction
	From   Grant
	To     Grant
}

GrantDiffEntry describes a grant change.

type GroupingFuncExpr

type GroupingFuncExpr struct {
	Args    []AnalyzedExpr // arguments (column references)
	Refs    []int          // ressortgrouprefs of arguments
	TypeOID uint32
}

GroupingFuncExpr represents a GROUPING(col1, col2, ...) expression.

pg: src/include/nodes/primnodes.h — GroupingFunc

type GroupingSetKind

type GroupingSetKind int

GroupingSetKind identifies the type of grouping set.

const (
	GroupingSetSimple GroupingSetKind = iota // plain GROUP BY column
	GroupingSetRollup                        // ROLLUP(...)
	GroupingSetCube                          // CUBE(...)
	GroupingSetSets                          // GROUPING SETS((...), (...))
)

type GroupingSetQ

type GroupingSetQ struct {
	Kind    GroupingSetKind
	Content []*SortGroupClause // the columns in this set
	Sets    []*GroupingSetQ    // for GROUPING SETS containing nested sets
}

GroupingSetQ represents GROUPING SETS / CUBE / ROLLUP.

pg: src/include/nodes/parsenodes.h — GroupingSet

type Index

type Index struct {
	OID              uint32
	Name             string
	Schema           *Schema
	RelOID           uint32
	Columns          []int16 // attnums (0 = expression column)
	IsUnique         bool
	IsPrimary        bool
	IsClustered      bool     // indisclustered
	IsReplicaIdent   bool     // indisreplident
	ConstraintOID    uint32   // 0 if standalone
	AccessMethod     string   // "btree" (default), "hash", "gist", "gin", "brin"
	NKeyColumns      int      // number of key columns (rest are INCLUDE); 0 = all are key
	WhereClause      string   // analyzed WHERE predicate text; empty = no partial index
	IndOption        []int16  // per-column flags: bit0=DESC, bit1=NULLS_FIRST
	NullsNotDistinct bool     // NULLS NOT DISTINCT for unique indexes
	Exprs            []string // deparsed expressions for expression columns (attnum=0)
}

Index represents an index on a relation.

type IndexDiffEntry

type IndexDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Index
	To     *Index
}

IndexDiffEntry describes an index change within a relation.

type InferenceElemExpr

type InferenceElemExpr struct {
	Expr       AnalyzedExpr
	ResultType uint32
}

InferenceElemExpr is a plan-internal stub for ON CONFLICT inference.

type InhEntry

type InhEntry struct {
	InhRelID  uint32 // child relation OID
	InhParent uint32 // parent relation OID
	InhSeqNo  int32  // order in INHERITS list (1-based)
}

InhEntry represents a row in pg_inherits.

type JoinExprNode

type JoinExprNode struct {
	JoinType    JoinType
	Left        JoinNode
	Right       JoinNode
	Quals       AnalyzedExpr // ON condition
	UsingClause []string     // USING column names (for deparse)
	RTIndex     int          // this join's RTE index
}

JoinExprNode represents a JOIN expression in the FROM clause.

pg: src/include/nodes/primnodes.h — JoinExpr

type JoinNode

type JoinNode interface {
	// contains filtered or unexported methods
}

JoinNode is the interface for FROM clause items.

type JoinTree

type JoinTree struct {
	FromList []JoinNode   // top-level FROM items
	Quals    AnalyzedExpr // WHERE condition (may be nil)
}

JoinTree represents the FROM clause structure.

pg: src/include/nodes/primnodes.h — FromExpr

type JoinType

type JoinType int

JoinType identifies the kind of JOIN.

const (
	JoinInner JoinType = iota
	JoinLeft
	JoinRight
	JoinFull
	JoinCross
)

type JsonConstructorExprQ

type JsonConstructorExprQ struct {
	ConstructorType JsonConstructorType
	Args            []AnalyzedExpr
	ResultType      uint32
	Collation       uint32
}

JsonConstructorExprQ represents JSON_OBJECT(...) or JSON_ARRAY(...) constructors.

pg: src/include/nodes/primnodes.h — JsonConstructorExpr (PG16+)

type JsonConstructorType

type JsonConstructorType int

JsonConstructorType identifies the kind of JSON constructor.

const (
	JsonConstructorObject JsonConstructorType = iota
	JsonConstructorArray
	JsonConstructorScalar
	JsonConstructorParse
	JsonConstructorSerialize
)

type JsonExprOpQ

type JsonExprOpQ int

JsonExprOp identifies the kind of JSON function expression.

const (
	JsonExprExists JsonExprOpQ = iota
	JsonExprQuery
	JsonExprValue
)

type JsonExprQ

type JsonExprQ struct {
	Op         JsonExprOpQ
	Expr       AnalyzedExpr // context item expression
	Path       string       // JSON path string
	ResultType uint32
	Collation  uint32
}

JsonExprQ represents JSON_VALUE(...), JSON_QUERY(...), JSON_EXISTS(...).

pg: src/include/nodes/primnodes.h — JsonExpr (PG16+)

type JsonIsPredicateExpr

type JsonIsPredicateExpr struct {
	Expr       AnalyzedExpr
	ItemType   int // 0=ANY, 1=OBJECT, 2=ARRAY, 3=SCALAR
	UniqueKeys bool
	IsNot      bool
}

JsonIsPredicateExpr represents expr IS [NOT] JSON [OBJECT|ARRAY|SCALAR].

pg: src/include/nodes/primnodes.h — JsonIsPredicate (PG16+)

type JsonValueExprQ

type JsonValueExprQ struct {
	Expr       AnalyzedExpr
	ResultType uint32
}

JsonValueExprQ represents a JSON value expression with optional FORMAT clause.

pg: src/include/nodes/primnodes.h — JsonValueExpr (PG16+)

type LockClauseStrength

type LockClauseStrength int

LockClauseStrength identifies the lock strength.

const (
	LockNone LockClauseStrength = iota
	LockForKeyShare
	LockForShare
	LockForNoKeyUpdate
	LockForUpdate
)

type LockWaitPolicy

type LockWaitPolicy int

LockWaitPolicy identifies the wait policy.

const (
	LockWaitBlock LockWaitPolicy = iota // default: wait for lock
	LockWaitSkip                        // SKIP LOCKED
	LockWaitError                       // NOWAIT
)

type LockingClauseQ

type LockingClauseQ struct {
	Strength   LockClauseStrength
	WaitPolicy LockWaitPolicy
	Tables     []string // table names (empty = all tables)
}

LockingClauseQ represents a FOR UPDATE/SHARE clause.

pg: src/include/nodes/parsenodes.h — LockingClause

type MergeSupportFuncExpr

type MergeSupportFuncExpr struct {
	ResultType uint32
}

MergeSupportFuncExpr is a plan-internal stub for MERGE actions.

type MigrationOp

type MigrationOp struct {
	Type          MigrationOpType
	SchemaName    string
	ObjectName    string
	SQL           string
	Warning       string
	Transactional bool
	ParentObject  string // optional, for FK deferred creation

	// Metadata for dependency-driven ordering (used by sortMigrationOps).
	Phase    MigrationPhase // PhasePre, PhaseMain, or PhasePost
	ObjType  byte           // 'r'=relation, 'f'=function, 'i'=index, 'c'=constraint, 't'=type, 'S'=sequence, 'n'=schema, 'T'=trigger, 'p'=policy, 'e'=extension
	ObjOID   uint32         // OID in source catalog (from for DROP, to for CREATE)
	Priority int            // tie-breaker for topo sort (lower = earlier)
}

MigrationOp represents a single DDL operation in a migration plan.

type MigrationOpType

type MigrationOpType string

MigrationOpType classifies a single DDL operation.

const (
	OpCreateSchema    MigrationOpType = "CreateSchema"
	OpDropSchema      MigrationOpType = "DropSchema"
	OpAlterSchema     MigrationOpType = "AlterSchema"
	OpCreateTable     MigrationOpType = "CreateTable"
	OpDropTable       MigrationOpType = "DropTable"
	OpAddColumn       MigrationOpType = "AddColumn"
	OpDropColumn      MigrationOpType = "DropColumn"
	OpAlterColumn     MigrationOpType = "AlterColumn"
	OpAddConstraint   MigrationOpType = "AddConstraint"
	OpDropConstraint  MigrationOpType = "DropConstraint"
	OpCreateIndex     MigrationOpType = "CreateIndex"
	OpDropIndex       MigrationOpType = "DropIndex"
	OpCreateSequence  MigrationOpType = "CreateSequence"
	OpDropSequence    MigrationOpType = "DropSequence"
	OpAlterSequence   MigrationOpType = "AlterSequence"
	OpCreateFunction  MigrationOpType = "CreateFunction"
	OpDropFunction    MigrationOpType = "DropFunction"
	OpAlterFunction   MigrationOpType = "AlterFunction"
	OpCreateType      MigrationOpType = "CreateType"
	OpDropType        MigrationOpType = "DropType"
	OpAlterType       MigrationOpType = "AlterType"
	OpCreateTrigger   MigrationOpType = "CreateTrigger"
	OpDropTrigger     MigrationOpType = "DropTrigger"
	OpCreateView      MigrationOpType = "CreateView"
	OpDropView        MigrationOpType = "DropView"
	OpAlterView       MigrationOpType = "AlterView"
	OpCreateExtension MigrationOpType = "CreateExtension"
	OpDropExtension   MigrationOpType = "DropExtension"
	OpAlterExtension  MigrationOpType = "AlterExtension"
	OpCreatePolicy    MigrationOpType = "CreatePolicy"
	OpDropPolicy      MigrationOpType = "DropPolicy"
	OpAlterPolicy     MigrationOpType = "AlterPolicy"
	OpAlterTable      MigrationOpType = "AlterTable"
	OpComment         MigrationOpType = "Comment"
	OpGrant           MigrationOpType = "Grant"
	OpRevoke          MigrationOpType = "Revoke"
)

type MigrationPhase

type MigrationPhase int

MigrationPhase classifies when a DDL operation should be executed relative to other operations.

const (
	PhasePre  MigrationPhase = iota // DROP operations
	PhaseMain                       // CREATE + ALTER operations
	PhasePost                       // Deferred (FK constraints)
)

type MigrationPlan

type MigrationPlan struct {
	Ops []MigrationOp
}

MigrationPlan holds an ordered list of DDL operations that transform one catalog state into another.

func GenerateMigration

func GenerateMigration(from, to *Catalog, diff *SchemaDiff) *MigrationPlan

GenerateMigration produces a MigrationPlan that transforms the `from` catalog into the `to` catalog, using the precomputed diff.

func (*MigrationPlan) Filter

func (p *MigrationPlan) Filter(fn func(MigrationOp) bool) *MigrationPlan

Filter returns a new MigrationPlan containing only operations for which fn returns true.

func (*MigrationPlan) HasWarnings

func (p *MigrationPlan) HasWarnings() bool

HasWarnings returns true if any operation has a non-empty warning.

func (*MigrationPlan) SQL

func (p *MigrationPlan) SQL() string

SQL returns all operations joined with ";\n".

func (*MigrationPlan) Summary

func (p *MigrationPlan) Summary() string

Summary returns a human-readable summary grouping operations by type and counting create/drop/alter categories.

func (*MigrationPlan) Warnings

func (p *MigrationPlan) Warnings() []MigrationOp

Warnings returns all operations that have a non-empty warning.

type MinMaxExprQ

type MinMaxExprQ struct {
	Op         MinMaxOp // IS_GREATEST or IS_LEAST
	Args       []AnalyzedExpr
	ResultType uint32
	Collation  uint32 // result collation
}

MinMaxExprQ represents GREATEST/LEAST.

pg: src/include/nodes/primnodes.h — MinMaxExpr

type MinMaxOp

type MinMaxOp int

MinMaxOp identifies GREATEST vs LEAST.

const (
	MinMaxGreatest MinMaxOp = iota
	MinMaxLeast
)

type NamedArgExprQ

type NamedArgExprQ struct {
	Name   string       // argument name
	Arg    AnalyzedExpr // the argument expression
	ArgNum int          // argument number in positional notation
}

NamedArgExprQ represents a named argument in a function call (arg_name => value).

pg: src/include/nodes/primnodes.h — NamedArgExpr

type NextValueExprQ

type NextValueExprQ struct {
	SeqOID  uint32
	SeqName string // for deparse
}

NextValueExprQ represents nextval for IDENTITY columns.

pg: src/include/nodes/primnodes.h — NextValueExpr

type NullIfExprQ

type NullIfExprQ struct {
	OpOID      uint32
	Args       []AnalyzedExpr // exactly 2 args
	ResultType uint32
}

NullIfExprQ represents an analyzed NULLIF expression. Named NullIfExprQ to avoid collision with pgparser's NullIfExpr.

pg: src/include/nodes/primnodes.h — NullIfExpr (derived from OpExpr)

type NullTestExpr

type NullTestExpr struct {
	Arg    AnalyzedExpr
	IsNull bool // true=IS NULL, false=IS NOT NULL
}

NullTestExpr represents IS [NOT] NULL.

pg: src/include/nodes/primnodes.h — NullTest

type OIDGenerator

type OIDGenerator struct {
	// contains filtered or unexported fields
}

OIDGenerator allocates monotonically increasing OIDs starting at FirstNormalObjectId.

func NewOIDGenerator

func NewOIDGenerator() *OIDGenerator

NewOIDGenerator returns a generator starting at FirstNormalObjectId.

func (*OIDGenerator) Next

func (g *OIDGenerator) Next() uint32

Next returns the next available OID.

type OpClass

type OpClass struct {
	OID       uint32
	Name      string
	FamilyOID uint32
	AMOID     uint32
	TypeOID   uint32
	IsDefault bool
	Schema    uint32
}

OpClass represents an operator class for an access method.

pg: src/include/catalog/pg_opclass.h

type OpExpr

type OpExpr struct {
	OpOID      uint32
	OpName     string // for deparse
	ResultType uint32
	Collation  uint32       // result collation
	Left       AnalyzedExpr // nil for prefix
	Right      AnalyzedExpr
}

OpExpr represents a resolved operator expression.

pg: src/include/nodes/primnodes.h — OpExpr

type OpFamily

type OpFamily struct {
	OID    uint32
	Name   string
	AMOID  uint32
	Schema uint32
}

OpFamily represents an operator family (groups related operator classes).

pg: src/include/catalog/pg_opfamily.h

type ParamExpr

type ParamExpr struct {
	ParamNum  int
	ParamType uint32
}

ParamExpr represents a $N parameter placeholder.

pg: src/include/nodes/primnodes.h — Param

type PartitionBound

type PartitionBound struct {
	Strategy   byte // must match parent's strategy
	IsDefault  bool
	ListValues []string // deparsed datum strings (LIST)
	LowerBound []string // deparsed lower bound values (RANGE)
	UpperBound []string // deparsed upper bound values (RANGE)
	Modulus    int      // HASH modulus
	Remainder  int      // HASH remainder
}

PartitionBound stores partition bound for a partition child.

type PartitionBoundSpecExpr

type PartitionBoundSpecExpr struct {
	Strategy   byte // 'r' range, 'l' list, 'h' hash
	LowerBound []AnalyzedExpr
	UpperBound []AnalyzedExpr
	ListValues []AnalyzedExpr
}

PartitionBoundSpecExpr is a plan-internal stub for partition bound specs.

type PartitionInfo

type PartitionInfo struct {
	Strategy   byte    // 'l'=list, 'r'=range, 'h'=hash
	KeyAttNums []int16 // partition key column attnums
	NKeyAttrs  int16
}

PartitionInfo stores partition key information for a partitioned table.

type PgAttrdefRow

type PgAttrdefRow struct {
	OID     uint32
	AdRelID uint32
	AdNum   int16
	AdBin   string // pg_get_expr(adbin) text
}

PgAttrdefRow mirrors pg_attrdef.

type PgAttributeRow

type PgAttributeRow struct {
	AttRelID     uint32
	AttName      string
	AttTypID     uint32
	AttNum       int16
	AttTypMod    int32
	AttLen       int16
	AttByVal     bool
	AttAlign     byte
	AttStorage   byte
	AttNotNull   bool
	AttHasDef    bool
	AttIsDropped bool
	AttCollation uint32
	AttGenerated byte // 's' = stored generated, 0 = none
	AttIdentity  byte // 'a' = ALWAYS, 'd' = BY DEFAULT, 0 = none
	AttIsLocal   bool // true if defined locally
	AttInhCount  int  // number of inheritance ancestors
}

PgAttributeRow mirrors pg_attribute.

type PgClassRow

type PgClassRow struct {
	OID                 uint32
	RelName             string
	RelNamespace        uint32
	RelType             uint32 // composite type OID
	RelKind             byte   // 'r', 'v', 'i', 'S'
	RelNatts            int16
	RelChecks           int16
	RelHasTriggers      bool
	RelHasIndex         bool
	RelPersistence      byte   // 'p'=permanent, 'u'=unlogged, 't'=temp
	ReplicaIdentity     byte   // 'd'=default, 'f'=full, 'n'=nothing, 'i'=index
	RelOfType           uint32 // reloftype — 0 if not a typed table
	RelRowSecurity      bool   // relrowsecurity
	RelForceRowSecurity bool   // relforcerowsecurity
}

PgClassRow mirrors pg_class (subset of columns relevant to DDL).

type PgConstraintRow

type PgConstraintRow struct {
	OID           uint32
	ConName       string
	ConNamespace  uint32
	ConType       byte // 'c', 'f', 'p', 'u'
	ConRelID      uint32
	ConTypID      uint32  // for domain constraints
	ConKey        []int16 // constrained columns
	ConFRelID     uint32  // FK: referenced relation
	ConFKey       []int16 // FK: referenced columns
	ConFUpdType   byte    // FK: ON UPDATE action
	ConFDelType   byte    // FK: ON DELETE action
	ConFMatchType byte    // FK: match type
	ConDeferrable bool
	ConDeferred   bool
	ConValidated  bool
	ConIndexID    uint32 // backing index (PK/UNIQUE)
	ConExpr       string // CHECK expression text

	// Inheritance/partition fields.
	ConParentID  uint32 // parent constraint OID
	ConIsLocal   bool   // locally defined
	ConInhCount  int16  // inheritance count
	ConNoInherit bool   // cannot be inherited

	// FK operator arrays.
	PFEqOp       []uint32 // PK=FK equality operators
	PPEqOp       []uint32 // PK=PK equality operators
	FFEqOp       []uint32 // FK=FK equality operators
	FKDelSetCols []int16  // ON DELETE SET NULL/DEFAULT column subset
}

PgConstraintRow mirrors pg_constraint.

type PgDependRow

type PgDependRow struct {
	ClassID    uint32
	ObjID      uint32
	ObjSubID   int32
	RefClassID uint32
	RefObjID   uint32
	RefSubID   int32
	DepType    byte
}

PgDependRow mirrors pg_depend.

pg: src/include/catalog/pg_depend.h

type PgDescriptionRow

type PgDescriptionRow struct {
	ObjOID      uint32
	ClassOID    uint32
	ObjSubID    int16
	Description string
}

PgDescriptionRow mirrors pg_description.

type PgDomainConstraintRow

type PgDomainConstraintRow struct {
	DomainName   string
	ConName      string
	ConDef       string // CHECK ((expr)) form
	ConValidated bool
}

PgDomainConstraintRow mirrors a domain CHECK constraint as visible through pg_constraint.

type PgEnumRow

type PgEnumRow struct {
	OID           uint32
	EnumTypID     uint32
	EnumSortOrder float32
	EnumLabel     string
}

PgEnumRow mirrors pg_enum.

type PgIndexRow

type PgIndexRow struct {
	IndexRelID     uint32
	IndRelID       uint32
	IndNatts       int16
	IndNKeyAtts    int16
	IndIsUnique    bool
	IndIsPrimary   bool
	IndIsClustered bool
	IndIsReplIdent bool
	IndKey         []int16
	IndOption      []int16
	IndExprs       string // deparsed expression text (pg_get_expr format)
	IndPred        string // WHERE clause text (pg_get_expr format)
}

PgIndexRow mirrors pg_index.

type PgInheritsRow

type PgInheritsRow struct {
	InhRelID  uint32 // child relation OID
	InhParent uint32 // parent relation OID
	InhSeqNo  int32  // order in INHERITS list (1-based)
}

PgInheritsRow mirrors pg_inherits.

type PgNamespaceRow

type PgNamespaceRow struct {
	OID     uint32
	NspName string
}

PgNamespaceRow mirrors pg_namespace.

type PgPolicyRow

type PgPolicyRow struct {
	OID        uint32
	PolName    string
	PolRelID   uint32
	PolCmd     string // "all", "select", "insert", "update", "delete"
	Permissive bool
	Roles      []string
	PolQual    string // USING expression
	PolCheck   string // WITH CHECK expression
}

PgPolicyRow mirrors pg_policy.

type PgProcRow

type PgProcRow struct {
	OID             uint32
	ProName         string
	ProNamespace    uint32
	ProKind         byte // 'f', 'p'
	ProArgTypes     []uint32
	ProRetType      uint32
	ProRetSet       bool
	ProIsStrict     bool
	ProVolatile     byte
	ProParallel     byte
	ProSecDef       bool
	ProLeakProof    bool
	ProLang         string   // language name
	ProSrc          string   // function body
	ProArgNames     []string // all parameter names; nil if no names
	ProArgModes     []byte   // parameter modes; nil if all IN
	ProAllArgTypes  []uint32 // all parameter types; nil if no OUT params
	ProNArgDefaults int16    // number of parameters with defaults
}

PgProcRow mirrors pg_proc (user-created only).

type PgSequenceRow

type PgSequenceRow struct {
	SeqRelID     uint32
	SeqTypID     uint32
	SeqStart     int64
	SeqIncrement int64
	SeqMax       int64
	SeqMin       int64
	SeqCache     int64
	SeqCycle     bool
}

PgSequenceRow mirrors pg_sequence.

type PgTriggerRow

type PgTriggerRow struct {
	OID        uint32
	TgRelID    uint32
	TgName     string
	TgFOID     uint32
	TgType     int16
	TgEnabled  byte
	TgAttr     []int16
	TgQual     string // WHEN clause expression (pg_get_expr format)
	TgOldTable string // OLD TABLE AS transition table name
	TgNewTable string // NEW TABLE AS transition table name
}

PgTriggerRow mirrors pg_trigger.

type PgTypeRow

type PgTypeRow struct {
	OID          uint32
	TypName      string
	TypNamespace uint32
	TypLen       int16
	TypByVal     bool
	TypType      byte // 'b', 'c', 'd', 'e'
	TypCategory  byte
	TypIsDefined bool
	TypDelim     byte
	TypRelID     uint32 // for composite types
	TypElem      uint32 // array element type
	TypArray     uint32 // corresponding array type
	TypBaseType  uint32 // for domains
	TypTypMod    int32
	TypAlign     byte
	TypStorage   byte
	TypNotNull   bool
	TypCollation uint32
}

PgTypeRow mirrors pg_type.

type Policy

type Policy struct {
	OID           uint32
	Name          string
	RelOID        uint32
	CmdType       string // "all", "select", "insert", "update", "delete"
	Permissive    bool
	Roles         []string
	UsingExpr     string       // deparsed USING expression
	CheckExpr     string       // deparsed WITH CHECK expression
	UsingAnalyzed AnalyzedExpr // analyzed USING expression (for Tier 2 deparse)
	CheckAnalyzed AnalyzedExpr // analyzed WITH CHECK expression (for Tier 2 deparse)
}

Policy represents a row-level security policy.

type PolicyDiffEntry

type PolicyDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Policy
	To     *Policy
}

PolicyDiffEntry describes a policy change within a relation.

type Query

type Query struct {
	TargetList     []*TargetEntry
	RangeTable     []*RangeTableEntry
	JoinTree       *JoinTree
	GroupClause    []*SortGroupClause
	HavingQual     AnalyzedExpr
	SortClause     []*SortGroupClause
	LimitCount     AnalyzedExpr
	LimitOffset    AnalyzedExpr
	SetOp          SetOpType // SetOpNone for simple SELECT
	AllSetOp       bool      // true for ALL variants
	LArg           *Query    // left side of set op
	RArg           *Query    // right side of set op
	Distinct       bool      // SELECT DISTINCT
	DistinctOn     []*SortGroupClause
	HasAggs        bool
	CTEList        []*CommonTableExprQ // WITH clause CTEs
	WindowClause   []*WindowClauseQ    // WINDOW clause
	IsRecursive    bool                // WITH RECURSIVE
	GroupingSets   []*GroupingSetQ     // GROUPING SETS/ROLLUP/CUBE (nil for plain GROUP BY)
	LockingClauses []*LockingClauseQ   // FOR UPDATE/SHARE clauses
}

Query represents an analyzed SELECT statement.

pg: src/include/nodes/parsenodes.h — Query

type RTEKind

type RTEKind int

RTEKind identifies the kind of range table entry.

const (
	RTERelation RTEKind = iota // plain table
	RTESubquery                // subquery in FROM
	RTEJoin                    // join result
	RTECTE                     // CTE reference
	RTEFunction                // function in FROM clause
)

type RangeDiffEntry

type RangeDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	From       *RangeType
	To         *RangeType
}

RangeDiffEntry describes a range type change.

type RangeTableEntry

type RangeTableEntry struct {
	Kind          RTEKind
	RelOID        uint32              // for RTERelation
	RelName       string              // original table name
	SchemaName    string              // schema name (for deparse)
	Alias         string              // user-provided alias (empty = none)
	ERef          string              // effective reference name for deparse
	ColNames      []string            // column names visible from this RTE
	ColTypes      []uint32            // column type OIDs
	ColTypMods    []int32             // column type modifiers
	ColCollations []uint32            // column collation OIDs
	Subquery      *Query              // for RTESubquery
	JoinType      JoinType            // for RTEJoin
	Lateral       bool                // LATERAL subquery or function
	CTEName       string              // for RTECTE: name of referenced CTE
	CTEIndex      int                 // for RTECTE: index into Query.CTEList
	FuncExprs     []AnalyzedExpr      // for RTEFunction: function call expressions
	Ordinality    bool                // for RTEFunction: WITH ORDINALITY
	Tablesample   *TablesampleClauseQ // for RTERelation: TABLESAMPLE clause
}

RangeTableEntry represents an entry in the query's range table.

pg: src/include/nodes/parsenodes.h — RangeTblEntry

type RangeTableRef

type RangeTableRef struct {
	RTIndex int // index into RangeTable (0-based)
}

RangeTableRef references a range table entry.

pg: src/include/nodes/primnodes.h — RangeTblRef

type RangeType

type RangeType struct {
	OID           uint32
	Name          string
	Namespace     uint32
	SubTypeOID    uint32
	ArrayOID      uint32
	MultirangeOID uint32 // auto-generated multirange type
}

RangeType holds the metadata for a user-created range type.

type RangeVar

type RangeVar = nodes.RangeVar

RangeVar is an alias used in this file for convenience.

type RelabelExpr

type RelabelExpr struct {
	Arg        AnalyzedExpr
	ResultType uint32
	TypeMod    int32
	Collation  uint32 // result collation
	Format     byte   // 'e'=explicit, 'i'=implicit
}

RelabelExpr represents a binary-compatible type cast (no-op).

pg: src/include/nodes/primnodes.h — RelabelType

type Relation

type Relation struct {
	OID     uint32
	Name    string
	Schema  *Schema
	RelKind byte // 'r'=table, 'v'=view, 'c'=composite, 'p'=partitioned, 'm'=matview
	Columns []*Column

	RowTypeOID    uint32
	ArrayOID      uint32
	AnalyzedQuery *Query // non-nil for views (analyzed form, for deparse)

	// Persistence (pg_class.relpersistence).
	Persistence     byte   // 'p'=permanent, 'u'=unlogged, 't'=temp (default 'p')
	ReplicaIdentity byte   // 'd'=default, 'f'=full, 'n'=nothing, 'i'=index
	OfTypeOID       uint32 // reloftype — 0 if not a typed table

	// Inheritance (pg_inherits).
	InhParents []uint32 // parent relation OIDs
	InhCount   int      // number of inheritance parents

	// Partitioning.
	PartitionInfo  *PartitionInfo  // non-nil if PARTITION BY (partitioned table)
	PartitionBound *PartitionBound // non-nil if PARTITION OF (partition)
	PartitionOf    uint32          // parent partitioned table OID (0 if not a partition)

	// Row-level security.
	RowSecurity      bool // relrowsecurity
	ForceRowSecurity bool // relforcerowsecurity

	// View options.
	CheckOption byte // 0=none, 'l'=LOCAL, 'c'=CASCADED (views only)

	// ON COMMIT behavior for temp tables.
	OnCommit byte // 0=noop, 'p'=preserve rows, 'd'=delete rows, 'D'=drop

	// Relation flags (pg_class).
	Owner       uint32 // relowner
	HasRules    bool   // relhasrules
	HasSubclass bool   // relhassubclass — has child tables/partitions
	IsPopulated bool   // relispopulated — matview populated state
	IsPartition bool   // relispartition
	// contains filtered or unexported fields
}

Relation represents a table, view, or other relation.

type RelationDiffEntry

type RelationDiffEntry struct {
	Action          DiffAction
	SchemaName      string
	Name            string
	From            *Relation
	To              *Relation
	Columns         []ColumnDiffEntry
	Constraints     []ConstraintDiffEntry
	Indexes         []IndexDiffEntry
	Triggers        []TriggerDiffEntry
	Policies        []PolicyDiffEntry
	RLSChanged      bool
	RLSEnabled      bool
	ForceRLSEnabled bool
}

RelationDiffEntry describes a relation (table/view/matview) change.

type ResultColumn

type ResultColumn struct {
	Name      string
	TypeOID   uint32
	TypeMod   int32
	Collation uint32
}

ResultColumn is the output of SELECT type inference.

pg: src/backend/commands/view.c — DefineVirtualRelation (column metadata)

type RowCompareExprQ

type RowCompareExprQ struct {
	RCType int            // comparison type: 1=<, 2=<=, 3=>=, 4=>, 5==, 6=<>
	LArgs  []AnalyzedExpr // left-side expressions
	RArgs  []AnalyzedExpr // right-side expressions
	OpNos  []uint32       // operator OIDs per column
}

RowCompareExprQ represents a row comparison like (a,b) < (c,d).

pg: src/include/nodes/primnodes.h — RowCompareExpr

type RowExprQ

type RowExprQ struct {
	Args       []AnalyzedExpr
	ResultType uint32 // RECORDOID typically
	RowFormat  byte   // 0=implicit, 'e'=explicit ROW keyword
}

RowExprQ represents a ROW(...) or (...) expression.

pg: src/include/nodes/primnodes.h — RowExpr

type SQLValueFuncExpr

type SQLValueFuncExpr struct {
	Op      SVFOp
	TypeOID uint32
	TypeMod int32
}

SQLValueFuncExpr represents CURRENT_DATE, CURRENT_TIMESTAMP, etc.

pg: src/include/nodes/primnodes.h — SQLValueFunction

type SVFOp

type SVFOp int

SVFOp identifies which SQL-standard function this is.

const (
	SVFCurrentDate SVFOp = iota
	SVFCurrentTime
	SVFCurrentTimeN
	SVFCurrentTimestamp
	SVFCurrentTimestampN
	SVFLocaltime
	SVFLocaltimeN
	SVFLocaltimestamp
	SVFLocaltimestampN
	SVFCurrentRole
	SVFCurrentUser
	SVFUser
	SVFSessionUser
	SVFCurrentCatalog
	SVFCurrentSchema
)

type ScalarArrayOpExpr

type ScalarArrayOpExpr struct {
	OpOID  uint32
	OpName string
	UseOr  bool         // true for ANY (=IN), false for ALL
	Left   AnalyzedExpr // scalar argument
	Right  AnalyzedExpr // array expression (matches PG args[1])
}

ScalarArrayOpExpr represents op ANY/ALL (array). Used for IN-list expansion: x IN (a,b,c) → x = ANY(ARRAY[a,b,c]).

pg: src/include/nodes/primnodes.h — ScalarArrayOpExpr

type Schema

type Schema struct {
	OID       uint32
	Name      string
	Owner     string // role name of the schema owner (empty = current user)
	Relations map[string]*Relation
	Indexes   map[string]*Index
	Sequences map[string]*Sequence
}

Schema represents a PostgreSQL namespace.

type SchemaDiff

type SchemaDiff struct {
	Schemas        []SchemaDiffEntry
	Relations      []RelationDiffEntry
	Sequences      []SequenceDiffEntry
	Functions      []FunctionDiffEntry
	Enums          []EnumDiffEntry
	Domains        []DomainDiffEntry
	Ranges         []RangeDiffEntry
	CompositeTypes []CompositeTypeDiffEntry
	Extensions     []ExtensionDiffEntry
	Comments       []CommentDiffEntry
	Grants         []GrantDiffEntry
}

SchemaDiff holds all differences between two catalog states.

func Diff

func Diff(from, to *Catalog) *SchemaDiff

Diff compares two catalog states and returns all differences. The from catalog represents the old state and to represents the new state.

func (*SchemaDiff) IsEmpty

func (d *SchemaDiff) IsEmpty() bool

IsEmpty returns true if there are no differences.

type SchemaDiffEntry

type SchemaDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Schema
	To     *Schema
}

SchemaDiffEntry describes a schema that was added, dropped, or modified.

type Sequence

type Sequence struct {
	OID         uint32
	Name        string
	Schema      *Schema
	TypeOID     uint32 // int2/int4/int8
	Start       int64
	Increment   int64
	MinValue    int64
	MaxValue    int64
	CacheValue  int64
	Cycle       bool
	OwnerRelOID uint32 // 0 if not owned
	OwnerAttNum int16
}

Sequence represents a PostgreSQL sequence.

type SequenceDiffEntry

type SequenceDiffEntry struct {
	Action     DiffAction
	SchemaName string
	Name       string
	From       *Sequence
	To         *Sequence
}

SequenceDiffEntry describes a standalone sequence change.

type SetOpType

type SetOpType int

SetOpType identifies a set operation.

const (
	SetOpNone SetOpType = iota
	SetOpUnion
	SetOpUnionAll
	SetOpIntersect
	SetOpIntersectAll
	SetOpExcept
	SetOpExceptAll
)

type SetToDefaultExpr

type SetToDefaultExpr struct {
	TypeOID uint32
}

SetToDefaultExpr represents the DEFAULT keyword in expression context.

pg: src/include/nodes/primnodes.h — SetToDefault

type SortGroupClause

type SortGroupClause struct {
	TLESortGroupRef uint32 // index into TargetList (0-based)
	Descending      bool
	NullsFirst      bool
}

SortGroupClause identifies an output column for ORDER BY / GROUP BY.

pg: src/include/nodes/parsenodes.h — SortGroupClause

type SubLinkExpr

type SubLinkExpr struct {
	SubLinkType SubLinkType
	TestExpr    AnalyzedExpr // left side of IN/ANY/ALL; nil for EXISTS/scalar
	SubQuery    *Query
	ResultType  uint32
}

SubLinkExpr represents a subquery expression (scalar or EXISTS).

pg: src/include/nodes/primnodes.h — SubLink

type SubLinkType

type SubLinkType int

SubLinkType identifies the kind of subquery.

const (
	SubLinkExprType   SubLinkType = iota // scalar subquery
	SubLinkExistsType                    // EXISTS subquery
	SubLinkAnyType                       // ANY/IN subquery
	SubLinkAllType                       // ALL subquery
)

type SubPlanExpr

type SubPlanExpr struct{}

SubPlanExpr is a plan-internal stub (never in user DDL).

type SubscriptingRefExpr

type SubscriptingRefExpr struct {
	ContainerExpr  AnalyzedExpr   // the array expression
	SubscriptExprs []AnalyzedExpr // subscript expressions
	ResultType     uint32         // element type OID
	IsSlice        bool           // true for arr[1:3]
	LowerExprs     []AnalyzedExpr // lower bounds for slice (nil entries = open)
}

SubscriptingRefExpr represents an array subscript expression (arr[1]).

pg: src/include/nodes/primnodes.h — SubscriptingRef

type TablesampleClauseQ

type TablesampleClauseQ struct {
	Method     string         // sampling method name (e.g. "bernoulli", "system")
	Args       []AnalyzedExpr // arguments for sampling method
	Repeatable AnalyzedExpr   // REPEATABLE expression (nil if none)
}

TablesampleClauseQ represents a TABLESAMPLE clause on a relation.

pg: src/include/nodes/parsenodes.h — TableSampleClause

type TargetEntry

type TargetEntry struct {
	Expr            AnalyzedExpr
	ResNo           int16  // position (1-based)
	ResName         string // output column name
	ResJunk         bool   // hidden (ORDER BY helper)
	ResOrigTbl      uint32 // source table OID (for provenance)
	ResOrigCol      int16  // source column number
	ResSortGroupRef uint32 // nonzero if referenced by GROUP BY/ORDER BY
}

TargetEntry represents a column in the SELECT list.

pg: src/include/nodes/primnodes.h — TargetEntry

type Trigger

type Trigger struct {
	OID               uint32
	Name              string
	RelOID            uint32
	FuncOID           uint32
	Timing            TriggerTiming
	Events            TriggerEvent
	ForEachRow        bool
	WhenExpr          string
	Columns           []int16  // UPDATE OF columns; nil = all
	Enabled           byte     // 'O'=origin(enabled), 'D'=disabled, 'A'=always, 'R'=replica
	OldTransitionName string   // OLD TABLE AS name (transition tables)
	NewTransitionName string   // NEW TABLE AS name (transition tables)
	IsConstraint      bool     // constraint trigger (pg: tgconstraint != 0)
	Deferrable        bool     // constraint trigger is DEFERRABLE
	Initdeferred      bool     // constraint trigger is INITIALLY DEFERRED
	ConstraintRelOID  uint32   // referenced relation for FK constraint triggers
	Args              []string // trigger function arguments
}

Trigger represents a trigger on a relation.

type TriggerDiffEntry

type TriggerDiffEntry struct {
	Action DiffAction
	Name   string
	From   *Trigger
	To     *Trigger
}

TriggerDiffEntry describes a trigger change within a relation.

type TriggerEvent

type TriggerEvent uint8

TriggerEvent is a bitmask of trigger events.

const (
	TriggerEventInsert TriggerEvent = 1 << iota
	TriggerEventUpdate
	TriggerEventDelete
	TriggerEventTruncate
)

type TriggerTiming

type TriggerTiming byte

TriggerTiming indicates when a trigger fires.

const (
	TriggerBefore    TriggerTiming = 'B'
	TriggerAfter     TriggerTiming = 'A'
	TriggerInsteadOf TriggerTiming = 'I'
)

type TypeName

type TypeName struct {
	Schema  string // empty = use search path
	Name    string
	TypeMod int32 // -1 = no typmod
	IsArray bool
}

TypeName identifies a type for resolution.

type UserProc

type UserProc struct {
	OID          uint32
	Name         string
	Schema       *Schema
	Kind         byte // 'f' or 'p'
	ArgTypes     []uint32
	RetType      uint32
	RetSet       bool
	Volatile     byte
	Parallel     byte
	IsStrict     bool
	SecDef       bool
	LeakProof    bool
	Language     string
	Body         string
	ArgNames     []string // all parameter names (IN+OUT+INOUT+TABLE)
	ArgModes     []byte   // 'i','o','b','v','t' per parameter; nil if all IN
	AllArgTypes  []uint32 // all parameter types (IN+OUT+INOUT); nil if no OUT params
	NArgDefaults int16    // count of input parameters with defaults
}

UserProc represents a user-defined function or procedure.

type VarExpr

type VarExpr struct {
	RangeIdx  int    // index into Query.RangeTable (0-based)
	AttNum    int16  // column number (1-based)
	TypeOID   uint32 // result type
	TypeMod   int32  // type modifier
	Collation uint32 // collation OID
	LevelsUp  int    // 0 = current query, 1 = parent, etc. (for correlated subqueries)
}

VarExpr represents a resolved column reference.

pg: src/include/nodes/primnodes.h — Var

type Warning

type Warning struct {
	Code    string // SQLSTATE code
	Message string
}

Warning represents a non-fatal notice emitted during DDL processing, analogous to PostgreSQL's NOTICE/WARNING messages.

type WindowClauseQ

type WindowClauseQ struct {
	Name         string             // window name (empty if inline OVER)
	PartitionBy  []*SortGroupClause // PARTITION BY
	OrderBy      []*SortGroupClause // ORDER BY
	FrameOptions int                // bitmask
	StartOffset  AnalyzedExpr       // frame start expression
	EndOffset    AnalyzedExpr       // frame end expression
}

WindowClauseQ represents an analyzed WINDOW clause entry.

pg: src/include/nodes/parsenodes.h — WindowClause

type WindowFuncExpr

type WindowFuncExpr struct {
	FuncOID    uint32
	FuncName   string
	ResultType uint32
	Collation  uint32 // result collation
	Args       []AnalyzedExpr
	AggStar    bool         // e.g. count(*)
	AggFilter  AnalyzedExpr // FILTER (WHERE ...), may be nil
	WinRef     uint32       // index into Query.WindowClause
}

WindowFuncExpr represents a window function call.

pg: src/include/nodes/primnodes.h — WindowFunc

type XmlExprQ

type XmlExprQ struct {
	Op        int            // XmlOp* constant
	Name      string         // name in xml(NAME foo ...) syntaxes
	NamedArgs []AnalyzedExpr // non-XML expressions for xml_attributes
	ArgNames  []string       // parallel list of attribute names
	Args      []AnalyzedExpr // list of expressions
	Xmloption int            // DOCUMENT or CONTENT
	TypeOID   uint32         // result type
	TypeMod   int32          // result type modifier
}

XmlExprQ represents various SQL/XML functions.

pg: src/include/nodes/primnodes.h — XmlExpr

Jump to

Keyboard shortcuts

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