Skip to content

Commit 5397b00

Browse files
authored
Merge pull request #1 from cossacklabs/zhars/initial_update
Initial update
2 parents c3a818d + ed5d68e commit 5397b00

File tree

9 files changed

+2296
-11
lines changed

9 files changed

+2296
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 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)
22

3-
Go version of https://github.com/pganalyze/pg_query
3+
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.
44

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

benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ package pg_query_test
66
import (
77
"testing"
88

9-
pg_query "github.com/pganalyze/pg_query_go/v5"
10-
"github.com/pganalyze/pg_query_go/v5/parser"
9+
pg_query "github.com/cossacklabs/pg_query_go/v5"
10+
"github.com/cossacklabs/pg_query_go/v5/parser"
1111
)
1212

1313
// Prevent compiler optimizations by assigning all results to global variables

fingerprint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strconv"
1111
"testing"
1212

13-
pg_query "github.com/pganalyze/pg_query_go/v5"
13+
pg_query "github.com/cossacklabs/pg_query_go/v5"
1414
)
1515

1616
type fingerprintTest struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/pganalyze/pg_query_go/v5
1+
module github.com/cossacklabs/pg_query_go/v5
22

33
go 1.14
44

normalize_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"reflect"
88
"testing"
99

10-
pg_query "github.com/pganalyze/pg_query_go/v5"
11-
"github.com/pganalyze/pg_query_go/v5/parser"
10+
pg_query "github.com/cossacklabs/pg_query_go/v5"
11+
"github.com/cossacklabs/pg_query_go/v5/parser"
1212
)
1313

1414
var normalizeTests = []struct {

parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"sync"
1010
"testing"
1111

12+
pg_query "github.com/cossacklabs/pg_query_go/v5"
13+
"github.com/cossacklabs/pg_query_go/v5/parser"
1214
"github.com/google/go-cmp/cmp"
13-
pg_query "github.com/pganalyze/pg_query_go/v5"
14-
"github.com/pganalyze/pg_query_go/v5/parser"
1515
"google.golang.org/protobuf/testing/protocmp"
1616
)
1717

pg_query.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package pg_query
66
import (
77
"google.golang.org/protobuf/proto"
88

9-
"github.com/pganalyze/pg_query_go/v5/parser"
9+
"github.com/cossacklabs/pg_query_go/v5/parser"
1010
)
1111

1212
func Scan(input string) (result *ScanResult, err error) {
@@ -84,3 +84,23 @@ func SplitWithScanner(input string, trimSpace bool) (result []string, err error)
8484
func SplitWithParser(input string, trimSpace bool) (result []string, err error) {
8585
return parser.SplitWithParser(input, trimSpace)
8686
}
87+
88+
// Walk - Walk iterate thought Node recursively and apply Visit method
89+
func Walk(visit Visit, nodes ...*Node) error {
90+
for _, node := range nodes {
91+
if node == nil {
92+
continue
93+
}
94+
kontinue, err := visit(node)
95+
if err != nil {
96+
return err
97+
}
98+
if kontinue {
99+
err = WalkSubtree(node.Node, visit)
100+
if err != nil {
101+
return err
102+
}
103+
}
104+
}
105+
return nil
106+
}

split_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package pg_query_test
66
import (
77
"testing"
88

9-
pg_query "github.com/pganalyze/pg_query_go/v5"
9+
pg_query "github.com/cossacklabs/pg_query_go/v5"
1010
)
1111

1212
var splitTests = []struct {

0 commit comments

Comments
 (0)