diff --git a/internal/compiler/compile.go b/internal/compiler/compile.go index 57a8e48c59..fa59a06697 100644 --- a/internal/compiler/compile.go +++ b/internal/compiler/compile.go @@ -6,7 +6,6 @@ import ( "io" "os" "path/filepath" - "regexp" "strings" "github.com/kyleconroy/sqlc/internal/metadata" @@ -25,33 +24,6 @@ type Parser interface { IsReservedKeyword(string) bool } -// copied over from gen.go -func structName(name string) string { - out := "" - for _, p := range strings.Split(name, "_") { - if p == "id" { - out += "ID" - } else { - out += strings.Title(p) - } - } - return out -} - -var identPattern = regexp.MustCompile("[^a-zA-Z0-9_]+") - -func enumValueName(value string) string { - name := "" - id := strings.Replace(value, "-", "_", -1) - id = strings.Replace(id, ":", "_", -1) - id = strings.Replace(id, "/", "_", -1) - id = identPattern.ReplaceAllString(id, "") - for _, part := range strings.Split(id, "_") { - name += strings.Title(part) - } - return name -} - // end copypasta func (c *Compiler) parseCatalog(schemas []string) error { files, err := sqlpath.Glob(schemas) diff --git a/internal/engine/dolphin/utils.go b/internal/engine/dolphin/utils.go index 3a7e1a9ef2..a05ef00b61 100644 --- a/internal/engine/dolphin/utils.go +++ b/internal/engine/dolphin/utils.go @@ -7,64 +7,6 @@ import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) -type nodeSearch struct { - list []pcast.Node - check func(pcast.Node) bool -} - -func (s *nodeSearch) Enter(n pcast.Node) (pcast.Node, bool) { - if s.check(n) { - s.list = append(s.list, n) - } - return n, false // skipChildren -} - -func (s *nodeSearch) Leave(n pcast.Node) (pcast.Node, bool) { - return n, true // ok -} - -func collect(root pcast.Node, f func(pcast.Node) bool) []pcast.Node { - if root == nil { - return nil - } - ns := &nodeSearch{check: f} - root.Accept(ns) - return ns.list -} - -type nodeVisit struct { - fn func(pcast.Node) -} - -func (s *nodeVisit) Enter(n pcast.Node) (pcast.Node, bool) { - s.fn(n) - return n, false // skipChildren -} - -func (s *nodeVisit) Leave(n pcast.Node) (pcast.Node, bool) { - return n, true // ok -} - -func visit(root pcast.Node, f func(pcast.Node)) { - if root == nil { - return - } - ns := &nodeVisit{fn: f} - root.Accept(ns) -} - -// Maybe not useful? -func text(nodes []pcast.Node) []string { - str := make([]string, len(nodes)) - for i := range nodes { - if nodes[i] == nil { - continue - } - str[i] = nodes[i].Text() - } - return str -} - func parseTableName(n *pcast.TableName) *ast.TableName { return &ast.TableName{ Schema: identifier(n.Schema.String()), diff --git a/internal/engine/postgresql/catalog.go b/internal/engine/postgresql/catalog.go index 625f1cd683..3b37287140 100644 --- a/internal/engine/postgresql/catalog.go +++ b/internal/engine/postgresql/catalog.go @@ -17,12 +17,3 @@ func NewCatalog() *catalog.Catalog { c.LoadExtension = loadExtension return c } - -// The generated pg_catalog is very slow to compare because it has so -// many entries. For testing, don't include it. -func newTestCatalog() *catalog.Catalog { - c := catalog.New("public") - c.Schemas = append(c.Schemas, pgTemp()) - c.LoadExtension = loadExtension - return c -} diff --git a/internal/engine/postgresql/convert.go b/internal/engine/postgresql/convert.go index dd5b52066c..60dac94a4b 100644 --- a/internal/engine/postgresql/convert.go +++ b/internal/engine/postgresql/convert.go @@ -84,18 +84,6 @@ func convertSlice(nodes []*pg.Node) *ast.List { return out } -func convertValuesList(l [][]*pg.Node) *ast.List { - out := &ast.List{} - for _, outer := range l { - o := &ast.List{} - for _, inner := range outer { - o.Items = append(o.Items, convertNode(inner)) - } - out.Items = append(out.Items, o) - } - return out -} - func convert(node *pg.Node) (ast.Node, error) { return convertNode(node), nil } diff --git a/internal/engine/postgresql/parse.go b/internal/engine/postgresql/parse.go index 8b45f9a365..fa1a54a911 100644 --- a/internal/engine/postgresql/parse.go +++ b/internal/engine/postgresql/parse.go @@ -136,10 +136,6 @@ func parseColName(node *nodes.Node) (*ast.ColumnRef, *ast.TableName, error) { } } -func join(list *nodes.List, sep string) string { - return strings.Join(stringSlice(list), sep) -} - func joinNodes(list []*nodes.Node, sep string) string { return strings.Join(stringSliceFromNodes(list), sep) } diff --git a/internal/engine/postgresql/pg_temp.go b/internal/engine/postgresql/pg_temp.go index 6d41fa9246..21849928c7 100644 --- a/internal/engine/postgresql/pg_temp.go +++ b/internal/engine/postgresql/pg_temp.go @@ -1,28 +1,9 @@ package postgresql import ( - "github.com/kyleconroy/sqlc/internal/sql/ast" "github.com/kyleconroy/sqlc/internal/sql/catalog" ) func pgTemp() *catalog.Schema { return &catalog.Schema{Name: "pg_temp"} } - -func typeName(name string) *ast.TypeName { - return &ast.TypeName{Name: name} -} - -func argN(name string, n int) *catalog.Function { - var args []*catalog.Argument - for i := 0; i < n; i++ { - args = append(args, &catalog.Argument{ - Type: &ast.TypeName{Name: "any"}, - }) - } - return &catalog.Function{ - Name: name, - Args: args, - ReturnType: &ast.TypeName{Name: "any"}, - } -} diff --git a/internal/engine/sqlite/utils.go b/internal/engine/sqlite/utils.go index 2213a1f8a1..74050651f2 100644 --- a/internal/engine/sqlite/utils.go +++ b/internal/engine/sqlite/utils.go @@ -10,10 +10,6 @@ type tableNamer interface { Schema_name() parser.ISchema_nameContext } -type multiselect interface { - AllSelect_core() []parser.ISelect_coreContext -} - func parseTableName(c tableNamer) *ast.TableName { name := ast.TableName{ Name: c.Table_name().GetText(), diff --git a/internal/sql/ast/varatt_external.go b/internal/sql/ast/varatt_external.go deleted file mode 100644 index 44d789e29a..0000000000 --- a/internal/sql/ast/varatt_external.go +++ /dev/null @@ -1,12 +0,0 @@ -package ast - -type varatt_external struct { - VaRawsize int32 - VaExtsize int32 - VaValueid Oid - VaToastrelid Oid -} - -func (n *varatt_external) Pos() int { - return 0 -} diff --git a/internal/sql/ast/vartag_external.go b/internal/sql/ast/vartag_external.go deleted file mode 100644 index 86bef3d0a1..0000000000 --- a/internal/sql/ast/vartag_external.go +++ /dev/null @@ -1,7 +0,0 @@ -package ast - -type vartag_external uint - -func (n *vartag_external) Pos() int { - return 0 -} diff --git a/internal/sql/catalog/func.go b/internal/sql/catalog/func.go index 0bbe5c6622..80acd1da50 100644 --- a/internal/sql/catalog/func.go +++ b/internal/sql/catalog/func.go @@ -39,18 +39,6 @@ func (f *Function) InArgs() []*Argument { return args } -func (c *Catalog) getFunc(rel *ast.FuncName, tns []*ast.TypeName) (*Function, int, error) { - ns := rel.Schema - if ns == "" { - ns = c.DefaultSchema - } - s, err := c.getSchema(ns) - if err != nil { - return nil, -1, err - } - return s.getFunc(rel, tns) -} - func (c *Catalog) createFunction(stmt *ast.CreateFunctionStmt) error { ns := stmt.Func.Schema if ns == "" {