snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
45
internal/engine/postgresql/seed.go
Normal file
45
internal/engine/postgresql/seed.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package postgresql
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"sync"
|
||||
|
||||
"github.com/sqlc-dev/sqlc/internal/core"
|
||||
"github.com/sqlc-dev/sqlc/internal/core/seed"
|
||||
"github.com/sqlc-dev/sqlc/internal/sql/catalog"
|
||||
)
|
||||
|
||||
// The dialect directory describes PostgreSQL's type system. Two things in it
|
||||
// are worth knowing about: the serial types are column definition sugar for an
|
||||
// integer plus a sequence, but they are what a schema declares, so the catalog
|
||||
// carries them as types of their own; and the numeric, string and datetime
|
||||
// categories are listed as mutually castable, which is what an unadorned
|
||||
// "WHERE bigint_col = 1" depends on.
|
||||
//
|
||||
// functions.jsonl and relations.jsonl are pg_catalog's functions and the
|
||||
// tables and views of pg_catalog and information_schema, all generated from
|
||||
// a live PostgreSQL 16 server by goldeneye (internal/goldeneye), which also
|
||||
// checks them against one. Both the analysis core and the catalog the legacy
|
||||
// compiler builds read them. Each contrib extension sqlc knows is a directory
|
||||
// under extensions/ holding the types and functions CREATE EXTENSION adds.
|
||||
//
|
||||
//go:embed dialect
|
||||
var dialectFS embed.FS
|
||||
|
||||
// Dialect returns the catalog option that seeds PostgreSQL's type system.
|
||||
func Dialect() core.Option {
|
||||
return seed.Dialect(dialectFS, "dialect")
|
||||
}
|
||||
|
||||
// pgCatalogFuncs is pg_catalog's functions in the form the catalog uses. The
|
||||
// list runs to thousands of entries and never changes within a run, so it is
|
||||
// read once.
|
||||
var pgCatalogFuncs = sync.OnceValue(func() []*catalog.Function {
|
||||
funcs, err := seed.Functions(dialectFS, "dialect")
|
||||
if err != nil {
|
||||
// The list is embedded in the binary: a failure here means sqlc was
|
||||
// built from a broken tree, which no caller can do anything about.
|
||||
panic(err)
|
||||
}
|
||||
return funcs
|
||||
})
|
||||
Reference in New Issue
Block a user