1 Star 0 Fork 0

github_repo/pg_query_go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pg_query.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
package pg_query
import (
proto "github.com/golang/protobuf/proto"
"github.com/pganalyze/pg_query_go/v2/parser"
)
// ParseToJSON - Parses the given SQL statement into a parse tree (JSON format)
func ParseToJSON(input string) (result string, err error) {
return parser.ParseToJSON(input)
}
// Parse the given SQL statement into a parse tree (Go struct format)
func Parse(input string) (tree *ParseResult, err error) {
protobufTree, err := parser.ParseToProtobuf(input)
if err != nil {
return
}
tree = &ParseResult{}
err = proto.Unmarshal(protobufTree, tree)
return
}
// Deparses a given Go parse tree into a SQL statement
func Deparse(tree *ParseResult) (output string, err error) {
protobufTree, err := proto.Marshal(tree)
if err != nil {
return
}
output, err = parser.DeparseFromProtobuf(protobufTree)
return
}
// ParsePlPgSqlToJSON - Parses the given PL/pgSQL function statement into a parse tree (JSON format)
func ParsePlPgSqlToJSON(input string) (result string, err error) {
return parser.ParsePlPgSqlToJSON(input)
}
// Normalize the passed SQL statement to replace constant values with ? characters
func Normalize(input string) (result string, err error) {
return parser.Normalize(input)
}
// FastFingerprint - Fingerprint the passed SQL statement
func Fingerprint(input string) (result string, err error) {
return parser.Fingerprint(input)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/github_repo/pg_query_go.git
git@gitee.com:github_repo/pg_query_go.git
github_repo
pg_query_go
pg_query_go
lfittl-patch-1

搜索帮助