Skip to content

Commit

Permalink
Merge pull request #1 from cossacklabs/zhars/initial_update
Browse files Browse the repository at this point in the history
Initial update
  • Loading branch information
Zhaars authored Sep 10, 2024
2 parents c3a818d + ed5d68e commit 5397b00
Show file tree
Hide file tree
Showing 9 changed files with 2,296 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pg_query_go [![GoDoc](https://godoc.org/github.com/pganalyze/pg_query_go/v5?status.svg)](https://godoc.org/github.com/pganalyze/pg_query_go/v5)

Go version of https://github.com/pganalyze/pg_query
A fork of the official Go version of [pg_query_go](https://github.com/pganalyze/pg_query), used in [Acra](https://github.com/cossacklabs/acra) as the source PostgreSQL parser.

This Go library and its cgo extension use the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.

Expand Down
4 changes: 2 additions & 2 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package pg_query_test
import (
"testing"

pg_query "github.com/pganalyze/pg_query_go/v5"
"github.com/pganalyze/pg_query_go/v5/parser"
pg_query "github.com/cossacklabs/pg_query_go/v5"
"github.com/cossacklabs/pg_query_go/v5/parser"
)

// Prevent compiler optimizations by assigning all results to global variables
Expand Down
2 changes: 1 addition & 1 deletion fingerprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"testing"

pg_query "github.com/pganalyze/pg_query_go/v5"
pg_query "github.com/cossacklabs/pg_query_go/v5"
)

type fingerprintTest struct {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pganalyze/pg_query_go/v5
module github.com/cossacklabs/pg_query_go/v5

go 1.14

Expand Down
4 changes: 2 additions & 2 deletions normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"reflect"
"testing"

pg_query "github.com/pganalyze/pg_query_go/v5"
"github.com/pganalyze/pg_query_go/v5/parser"
pg_query "github.com/cossacklabs/pg_query_go/v5"
"github.com/cossacklabs/pg_query_go/v5/parser"
)

var normalizeTests = []struct {
Expand Down
4 changes: 2 additions & 2 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"sync"
"testing"

pg_query "github.com/cossacklabs/pg_query_go/v5"
"github.com/cossacklabs/pg_query_go/v5/parser"
"github.com/google/go-cmp/cmp"
pg_query "github.com/pganalyze/pg_query_go/v5"
"github.com/pganalyze/pg_query_go/v5/parser"
"google.golang.org/protobuf/testing/protocmp"
)

Expand Down
22 changes: 21 additions & 1 deletion pg_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package pg_query
import (
"google.golang.org/protobuf/proto"

"github.com/pganalyze/pg_query_go/v5/parser"
"github.com/cossacklabs/pg_query_go/v5/parser"
)

func Scan(input string) (result *ScanResult, err error) {
Expand Down Expand Up @@ -84,3 +84,23 @@ func SplitWithScanner(input string, trimSpace bool) (result []string, err error)
func SplitWithParser(input string, trimSpace bool) (result []string, err error) {
return parser.SplitWithParser(input, trimSpace)
}

// Walk - Walk iterate thought Node recursively and apply Visit method
func Walk(visit Visit, nodes ...*Node) error {
for _, node := range nodes {
if node == nil {
continue
}
kontinue, err := visit(node)
if err != nil {
return err
}
if kontinue {
err = WalkSubtree(node.Node, visit)
if err != nil {
return err
}
}
}
return nil
}
2 changes: 1 addition & 1 deletion split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package pg_query_test
import (
"testing"

pg_query "github.com/pganalyze/pg_query_go/v5"
pg_query "github.com/cossacklabs/pg_query_go/v5"
)

var splitTests = []struct {
Expand Down
Loading

0 comments on commit 5397b00

Please sign in to comment.