pganalyze / pg_query_go Goto Github PK
View Code? Open in Web Editor NEWGo library to parse and normalize SQL queries using the PostgreSQL query parser
License: BSD 3-Clause "New" or "Revised" License
Go library to parse and normalize SQL queries using the PostgreSQL query parser
License: BSD 3-Clause "New" or "Revised" License
there is an error with run go build command,and the error msg is below
In file included from include/postgres.h:47,
from gopkg/src/github.com/lfittl/pg_query_go/parser/contrib_pgcrypto_sha1.c:50:
include/c.h:298: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘int128’
include/c.h:299: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘uint128’
after i commented c.h:298 and c.h:299 , run go build again ,there is an other errors
gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:98: undefined reference to _Static_assert' gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:98: undefined reference to
_Static_assert'
gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:100: undefined reference to _Static_assert' gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:100: undefined reference to
_Static_assert'
gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:105: undefined reference to _Static_assert' /tmp/go-build140904706/github.com/lfittl/pg_query_go/parser/_obj/pg_query_fingerprint.o:/home/cloud/gopkg/src/github.com/lfittl/pg_query_go/parser/pg_query_fingerprint.c:105: more undefined references to
_Static_assert' follow
if true {
sql := `ALTER TABLE ONLY public."Test1我们123@#$%"
ADD CONSTRAINT "Test1我们123@#$%_pkey" PRIMARY KEY (c1);`
result, err := pg_query.Parse(sql)
if err != nil {
fmt.Println("Parse err ", err)
return
}
for _, rawStmt := range result.Stmts {
var (
tree = &pg_query.ParseResult{
Version: result.Version,
Stmts: []*pg_query.RawStmt{rawStmt},
}
)
stmt, err := pg_query.Deparse(tree)
if err != nil {
fmt.Println("Deparse err ", err)
return
}
fmt.Printf("newSQL: %s\n", stmt)
}
}
output:
newSQL: ALTER TABLE ONLY public."Test1我们123@#$%" ADD CONSTRAINT Test1我们123@#$%_pkey PRIMARY KEY (c1)
env go:
go 1.19
require github.com/pganalyze/pg_query_go/v4 v4.2.1
Hi,
when i run the secend example ,I find this error:"undefined: "github.com/lfittl/pg_query_go/nodes".Value" .How can i solve this ?
The C-library function pg_query_parse_plpgsql
is currently not exposed via API.
Currently, I'm using pg_query.Normalize
to get a normalized query. However, there are no functionality that allows extracting all the args. Is it possible to have that in future release?
I noticed there is a C function CommandIsReadOnly and the implementation is in Postgres repo as below
https://github.com/postgres/postgres/blob/bde60daa0ec9d0ee8dc79c0caa2c94d128527867/src/backend/tcop/utility.c#L100-L127
But I don't figure out how to call it in Golang. I think I probably need to make a little bit code. Could you please point me to the right direction? thanks
sql := "SELECT 1"
result, err := pg_query.Parse(sql)
if err != nil {
panic(err);
}
for _, stmt := range result.Statements {
isReadOnly := pg_query.CommandIsReadOnly(stmt) # this doesn't work
}
pg_query_fingerprint.c: In function ‘pg_query_fingerprint_with_opts’:
pg_query_fingerprint.c:262:3: warning: implicit declaration of function ‘asprintf’ [-Wimplicit-function-declaration]
int err = asprintf(&result.fingerprint_str, "%02x%02x%02x%02x%02x%02x%02x%02x",
➜ [email protected] go version
go version go1.13.9 linux/amd64
-> go env
CGO_CFLAGS="-g -O2 -std=gnu99"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
I am trying to extract the function body from us user defined function using the parser, and was wondering why it seems to be stored as a raw string under Options
instead of under SqlBody
:
package main
import (
"fmt"
pgQuery "github.com/pganalyze/pg_query_go/v4"
)
func main() {
userFn := `
CREATE FUNCTION foo()
RETURNS text AS
$$
BEGIN
RETURN 'test';
END;
$$
LANGUAGE plpgsql;`
stmts, err := pgQuery.Parse(userFn)
if err != nil {
panic(err)
}
fn := stmts.Stmts[0].Stmt.GetCreateFunctionStmt()
fmt.Println("SqlBody:", fn.SqlBody)
fmt.Println("Options:", fn.Options)
}
Running this, i get:
SqlBody: <nil>
Options: [def_elem:{defname:"as" arg:{list:{items:{string:{sval:"\nBEGIN\n\tRETURN 'test';\nEND;\n"}}}} defaction:DEFELEM_UNSPEC location:36} def_elem:{defname:"language" arg:{string:{sval:"plpgsql"}} defaction:DEFELEM_UNSPEC location:72}]
Is this the expected behavior? If so, what does SqlBody
store?
Hi,
We are using pg_query_go
as a dependency for harbourbridge.
When I vendor in pg_query_go
using go mod vendor
, I get a missing C header error:
⇪manitgupta:🏠hb_main/harbourbridge#>go mod vendor
⇪manitgupta:🏠hb_main/harbourbridge#>make build-static
go build -a -tags osusergo,netgo -ldflags '-w -extldflags "-static"' -o harbourbridge main.go
# github.com/pganalyze/pg_query_go/v2/parser
vendor/github.com/pganalyze/pg_query_go/v2/parser/parser.go:6:10: fatal error: 'pg_query.h' file not found
#include "pg_query.h"
^~~~~~~~~~~~
1 error generated.
make: *** [Makefile:6: build-static] Error 2
I am on pg_query_go
v2.0.5.
This is what gets vendored in:
⇪manitgupta:🏠hb_main/harbourbridge#>tree vendor/github.com/pganalyze/pg_query_go/
vendor/github.com/pganalyze/pg_query_go/
└── v2
├── CHANGELOG.md
├── go.mod
├── go.sum
├── LICENSE
├── LICENSE.POSTGRESQL
├── Makefile
├── makefuncs.go
├── parser
│ ├── guc-file.c
│ ├── parser.go
│ ├── pg_query.c
│ ├── pg_query_deparse.c
│ ├── pg_query_fingerprint.c
│ ├── pg_query_fingerprint.h
│ ├── pg_query_internal.h
│ ├── pg_query_json_plpgsql.c
│ ├── pg_query_json_plpgsql.h
│ ├── pg_query_normalize.c
│ ├── pg_query_outfuncs.h
│ ├── pg_query_outfuncs_json.c
│ ├── pg_query_outfuncs_protobuf.c
│ ├── pg_query_parse.c
│ ├── pg_query_parse_plpgsql.c
│ ├── pg_query.pb-c.c
│ ├── pg_query_readfuncs.h
│ ├── pg_query_readfuncs_protobuf.c
│ ├── pg_query_scan.c
│ ├── pg_query_split.c
│ ├── protobuf-c.c
│ ├── src_backend_catalog_namespace.c
│ ├── src_backend_catalog_pg_proc.c
│ ├── src_backend_commands_define.c
│ ├── src_backend_libpq_pqcomm.c
│ ├── src_backend_nodes_bitmapset.c
│ ├── src_backend_nodes_copyfuncs.c
│ ├── src_backend_nodes_equalfuncs.c
│ ├── src_backend_nodes_extensible.c
│ ├── src_backend_nodes_list.c
│ ├── src_backend_nodes_makefuncs.c
│ ├── src_backend_nodes_nodeFuncs.c
│ ├── src_backend_nodes_value.c
│ ├── src_backend_parser_gram.c
│ ├── src_backend_parser_parse_expr.c
│ ├── src_backend_parser_parser.c
│ ├── src_backend_parser_scan.c
│ ├── src_backend_parser_scansup.c
│ ├── src_backend_postmaster_postmaster.c
│ ├── src_backend_storage_ipc_ipc.c
│ ├── src_backend_storage_lmgr_s_lock.c
│ ├── src_backend_tcop_postgres.c
│ ├── src_backend_utils_adt_datum.c
│ ├── src_backend_utils_adt_expandeddatum.c
│ ├── src_backend_utils_adt_format_type.c
│ ├── src_backend_utils_adt_ruleutils.c
│ ├── src_backend_utils_error_assert.c
│ ├── src_backend_utils_error_elog.c
│ ├── src_backend_utils_fmgr_fmgr.c
│ ├── src_backend_utils_hash_dynahash.c
│ ├── src_backend_utils_init_globals.c
│ ├── src_backend_utils_mb_mbutils.c
│ ├── src_backend_utils_misc_guc.c
│ ├── src_backend_utils_mmgr_aset.c
│ ├── src_backend_utils_mmgr_mcxt.c
│ ├── src_common_encnames.c
│ ├── src_common_hashfn.c
│ ├── src_common_keywords.c
│ ├── src_common_kwlist_d.h
│ ├── src_common_kwlookup.c
│ ├── src_common_psprintf.c
│ ├── src_common_string.c
│ ├── src_common_stringinfo.c
│ ├── src_common_wchar.c
│ ├── src_pl_plpgsql_src_pl_comp.c
│ ├── src_pl_plpgsql_src_pl_funcs.c
│ ├── src_pl_plpgsql_src_pl_gram.c
│ ├── src_pl_plpgsql_src_pl_handler.c
│ ├── src_pl_plpgsql_src_pl_reserved_kwlist_d.h
│ ├── src_pl_plpgsql_src_pl_scanner.c
│ ├── src_pl_plpgsql_src_pl_unreserved_kwlist_d.h
│ ├── src_port_erand48.c
│ ├── src_port_pg_bitutils.c
│ ├── src_port_pgsleep.c
│ ├── src_port_pgstrcasecmp.c
│ ├── src_port_qsort.c
│ ├── src_port_random.c
│ ├── src_port_snprintf.c
│ ├── src_port_strerror.c
│ ├── src_port_strnlen.c
│ └── xxhash.c
├── pg_query.go
├── pg_query.pb.go
└── README.md
2 directories, 91 files
When I just rm -r vendor
, this problem goes away and everything works fine.
I saw a similar issue in another repo here: goccy/go-graphviz#28
Could you please suggest a path to vendoring in this library?
Parse this simple query
SELECT COUNT(OrderID) AS ord FROM SalesOrders
You will see that the location for the ord alias and the function COUNT(OrderID) is the same -- location 7. This prevents its use with databases where case sensitivity of column, table, function or alias names is important. Basically it is not possible to reconstitute the statement by traversing the AST because offsets to the names in the query to restore actual names would be incorrect. Could a fix be provided? Thanks
"ResTarget": { "name": "ord", "val": { "FuncCall": { "funcname": [ { "String": { "str": "count" } } ], "args": [ { "ColumnRef": { "fields": [ { "String": { "str": "orderid" } } ], "location": 13 } } ], "location": 7 } }, "location": 7 }
Hi,
please give me some how to use pg_query_go,like pg_query.Parse ,when I get the ParsetreeList , how can i get where the sql is select or update ?
I am using
go version go1.16.13 linux/amd64
When running https://github.com/pganalyze/pg_query_go/#parsing-a-query-into-go-structs , I got the following error:
package command-line-arguments
imports github.com/pganalyze/pg_query_go/v2
imports github.com/pganalyze/pg_query_go/v2: import cycle not allowed
Hi,
If I try to parse and then de-parse the SQL:
CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE PROCEDURE p()
then I end up with the slightly different result:
CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p()
Unfortunately, the latter is a syntax error:
postgres=# CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p();
ERROR: syntax error at or near "FUNCTION"
LINE 1: ...IGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p...
I have attached a reproducer: deparse_proc_func.go.gz
I was following instruction:
go get github.com/pganalyze/pg_query_go/v2
go get: module github.com/pganalyze/pg_query_go@upgrade found (v1.0.3), but does not contain package github.com/pganalyze/pg_query_go/v2
go version go1.16.13 linux/amd64
I'm using pg_query_go to power the PostgreSQL support in https://github.com/kyleconroy/sqlc. Someone ran into an issue where their CREATE TRIGGER statement was failing to parse because they used new syntax introduced in PostgreSQL 11.
Are there plans to upgrade the parser to the current version of PostgreSQL?
Hi,
I'm trying to use this library and compile it to windows from Ubuntu 20.
When I'm compiling it I have an error:
# github.com/pganalyze/pg_query_go/v2/parser In file included from ../../go/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/c.h:1318, from ../../go/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/postgres.h:46, from pg_query_internal.h:4, from pg_query.c:2: ../../go/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/port.h:17:10: fatal error: netdb.h: No such file or directory 17 | #include <netdb.h> | ^~~~~~~~~
Compile command for example:
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -o /bin/file ./cmd/file
From some google search i found that it's talking about that file that already exists:
ls -l /usr/include/rpc/netdb.h
-rw-r--r-- 1 root root 2897 Dec 16 2020 /usr/include/rpc/netdb.h
What I'm doing wrong? Please help
SELECT * FROM FUNC(...) AS (t int)
<- No ColumnDefs
SELECT * ROWS FROM (FUNC(...))
<- Syntax error
The returned RangeFunction node is a list of just one element instead of several (because the ROWS syntax fails to parse). That one element is indeed a list of 2 elements as documented:
Any clue what's going on?
First off thank you - I love this library!
In my case, I wrap several queries, and run them through a parser like a bunch of other folks. My simplified example looks like:
res, _ := pg_query.Parse(query)
stmt := res.Stmts[0].Stmt.GetSelectStmt()
for _, f := range stmt.GetTargetList() {
sp := f.GetResTarget().GetVal().GetColumnRef().GetFields()[0]
fmt.Println(sp.GetString_().Sval)
}
The following query of course, works: select username, password from foo where user = 'somehuman'
target_list:{res_target:{val:{column_ref:{fields:{string:{sval:\"username\"}} location:7}} location:7}} target_list:{res_target:{val:{column_ref:{fields:{string:{sval:\"password\"}} location:17}} location:17}} from_clause:{range_var:{relname:\"foo\" inh:true relpersistence:\"p\" location:31}} where_clause:{a_expr:{kind:AEXPR_OP name:{string:{sval:\">\"}} lexpr:{column_ref:{fields:{string:{sval:\"x\"}} location:41}} rexpr:{a_const:{ival:{ival:17} location:45}} location:43}} limit_option:LIMIT_OPTION_DEFAULT op:SETOP_NONE" time="2023-07-05T11:55:54+03:00" level=debug msg="column_ref:{fields:{string:{sval:\"username\"}} location:7
The second, I change username
to user
, when attempting to call f.GetResTarget().GetVal().GetColumnRef().GetFields()[0]
as clearly there's an indexing issue, do the the following parsed version of the object.
target_list:{res_target:{val:{sqlvalue_function:{op:SVFOP_USER typmod:-1 location:7}} location:7}} target_list:{res_target:{val:{column_ref:{fields:{string:{sval:\"password\"}} location:13}} location:13}} from_clause:{range_var:{relname:\"foo\" inh:true relpersistence:\"p\" location:27}} where_clause:{a_expr:{kind:AEXPR_OP name:{string:{sval:\">\"}} lexpr:{column_ref:{fields:{string:{sval:\"x\"}} location:37}} rexpr:{a_const:{ival:{ival:17} location:41}} location:39}} limit_option:LIMIT_OPTION_DEFAULT op:SETOP_NONE"
Is this an underlying libpq issue? I would have assumed my query would parse, and I'd just have a column named user
Note that the original Ruby version of this library is much more feature complete.
Which features are missing from the Go library? Anything but deparse?
I noticed that the go library exports ScanToken
and ScanResult
but no functions which return those structs. I expect the go version of pg_query_scan
from pg_query.h
would generate them.
We're coming up on a year since the last commit to this repository. Is there any plan to restart development?
I have compiled this project on an ARM64 device, and I got this error:
github.com/lfittl/pg_query_go/parser
# github.com/lfittl/pg_query_go/parser
In file included from go/src/github.com/lfittl/pg_query_go/parser/include/utils/dsa.h:17,
from go/src/github.com/lfittl/pg_query_go/parser/include/nodes/tidbitmap.h:26,
from go/src/github.com/lfittl/pg_query_go/parser/include/access/genam.h:19,
from go/src/github.com/lfittl/pg_query_go/parser/include/nodes/execnodes.h:17,
from go/src/github.com/lfittl/pg_query_go/parser/include/commands/trigger.h:17,
from go/src/github.com/lfittl/pg_query_go/parser/include/plpgsql.h:21,
from pg_query_json_plpgsql.h:5,
from pg_query_json_plpgsql.c:2:
go/src/github.com/lfittl/pg_query_go/parser/include/port/atomics.h:68:10: fatal error: port/atomics/arch-arm.h: No such file or directory
#include "port/atomics/arch-arm.h"
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
... and atomics.h seems to support ARM devices.
#if defined(__arm__) || defined(__arm) || \
defined(__aarch64__) || defined(__aarch64)
#include "port/atomics/arch-arm.h"
...
I found arch-arm.h
on PostgreSQL repository:
After adding this file, I was able to compile without any problems.
Is there any reason not to support ARM(and other architectures)? if it doesn't matter, can you add support for architectures other than x86?
When parsing a invalid query, Parse
returns an error string starting with "syntax error ...". Would it be possible to get the offset of the syntax error, similar to SyntaxError type in the json package?
Thanks again for the awesome package :) I'm using it to power my new project https://github.com/kyleconroy/sqlc
Hi,lfittl:
how can i know the meaning of the json key?
like this:What's the meaning of the key "inh"?
[
{
"RawStmt": {
"stmt": {
"DeleteStmt": {
"relation": {
"RangeVar": {
"relname": "a",
"inh": true,
"relpersistence": "p",
"location": 12
}
},
"whereClause": {
"BoolExpr": {
"boolop": 1,
"args": [
{
"A_Expr": {
"kind": 0,
"name": [
{
"String": {
"str": "="
}
}
],
"lexpr": {
"A_Const": {
"val": {
"Integer": {
"ival": 1
}
},
"location": 20
}
},
"rexpr": {
"A_Const": {
"val": {
"Integer": {
"ival": 1
}
},
"location": 22
}
},
"location": 21
}
},
{
"A_Expr": {
"kind": 0,
"name": [
{
"String": {
"str": "="
}
}
],
"lexpr": {
"ColumnRef": {
"fields": [
{
"String": {
"str": "a"
}
}
],
"location": 27
}
},
"rexpr": {
"A_Const": {
"val": {
"Integer": {
"ival": 1
}
},
"location": 29
}
},
"location": 28
}
}
],
"location": 24
}
}
}
},
"stmt_len": 30
}
}
]
Hi Lukas, thanks for this library, it's the base for sqlc
which is my favourite Go SQL library, and I'm very grateful! I had a quick look at your protobuf generation strategy after you mentioned it in sqlc-dev/sqlc#948, and as I'm a bit of a subject matter expert, I'd recommend migrating to the new APIv2 tooling in https://pkg.go.dev/google.golang.org/protobuf/. Judging by your go.mod
this should be a simple affair as you're already on v1.4.2 of the github.com/golang/protobuf
module. It should just be a matter of replacing any imports of the old library with the new and changing the generator to google.golang.org/protobuf/cmd/protoc-gen-go
. You can read more about the APIv2 features here: https://blog.golang.org/protobuf-apiv2.
Sidenote, I work for Buf (creators of https://github.com/bufbuild/buf), and we're working on making protobuf tooling better for everyone (and we're using sqlc
in our internal codebase!). For a simple generation use case such as yours, it may not be worth replacing your existing generation strategy, but I would recommend taking a look at our linting and breaking change detection tooling. It's all documented on our docs site: https://docs.buf.build/. I'd be happy to explain in more detail if you have any questions around it.
Thanks again for the great library!
Hi @lfittl,
I would like to implement query deparsing, and wondered if the _deparse.go
files can be edited. Assuming there is no way to auto generate them, we can set the overwrite
flag to false only for these files.
Also, couldn't find any how to contribute section. Are there any specific guidelines I should follow before opening PR?
Thanks!
I'd like to know the position in the input string each node is at. I'm working on sqlc support for inserting multiple rows and want to find the location of the VALUES clause in the input string to repeat it for each row.
(I know COPY FROM is better, faster and stronger - but it lacks ON CONFLICT)
along the same lines of go/printer
, would be very nice to turn a ParsetreeList
back into text (potentially allowing a decent autoformatter to be written).
If this is already in the books / someone is working on it, that'd be great to know before I take a crack at it myself
I recently encountered the issue described in #66 after updating Xcode, and updating this library has restored the original functionality. After the update to pg_query_go v2.2.0
, the original functionality has been restored, but I continue to get warnings:
# github.com/pganalyze/pg_query_go/v2/parser
src_port_snprintf.c:1030:11: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use
snprintf(3) instead. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
src_port_snprintf.c:1212:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use
snprintf(3) instead. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
src_port_snprintf.c:1219:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use
snprintf(3) instead. [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
Seems to point to a few calls to sprintf
that presumably should be replaced with snprintf
, for example:
pg_query_go/parser/src_port_snprintf.c
Line 1030 in 920eb98
For context, this is when running https://github.com/kyleconroy/sqlc, but looks like the warnings are stemming from here.
In the process of upgrading from v2 to v4 (sqlc-dev/sqlc#2114) I discovered a breaking change. In v2, the following query parses without an error:
SELECT * FROM users WHERE id = ?
However, in v4, this same query now returns a syntax error.
Is this a PostgreSQL change or pg_query_go change?
A full reproduction here: https://gist.github.com/kyleconroy/792b77389287f34a501e572b6c7281df
Hi
I need to translate parse errors to pgproto error responses with the struct below
type ErrorResponse struct {
Severity string
SeverityUnlocalized string // only in 9.6 and greater
Code string
Message string
Detail string
Hint string
Position int32
InternalPosition int32
InternalQuery string
Where string
SchemaName string
TableName string
ColumnName string
DataTypeName string
ConstraintName string
File string
Line int32
Routine string
UnknownFields map[byte]string
}
but I was not able to find a way to query parse errors (like invalid queries, etc.)
I parse my pgsql to go struct, and I have changed some value of the struct's members, How can i make the struct turn back to pgsqls?
Since the split methods are included in pg_query.h
, I'd like to add them to pg_query_go.
I am trying to parse a SQL query go object, but cannot switch on any of its types. For example
`func TestSQLParseAliasQueryAsObject(t *testing.T) {
var aliasQuery = SELECT s.sl_name, s.sl_avail + shoelace_arrive.arr_quant, current_user, current_timestamp FROM shoelace_arrive shoelace_arrive, shoelace_data shoelace_data, shoelace_data s WHERE s.sl_name = shoelace_arrive.arr_name AND shoelace_data.sl_name = s.sl_name AND s.sl_avail + shoelace_arrive.arr_quant <> s.sl_avail
fmt.Print("TestSQLParseTree --->")
tree, err := pg_query.Parse(aliasQuery)
nodes := tree.Statements
fmt.Println(len(nodes))
for key, value := range nodes {
fmt.Printf("The key is %v", key)
switch valueType := value.(type) {
case nodes.RawStmt: //nodes.RawStmt undefined (type []"github.com/lfittl/pg_query_go/nodes".Node has no field or method RawStmt)
default:
fmt.Printf("default type is %v", valueType)
}
//fmt.Print(reflect.TypeOf(value))
}
if err != nil {
panic(err)
}
fmt.Printf("%s\n", tree)
}`
Please look at the above switch statement. My code needs to make a decision on whether the type is of nodes.RawStmt. But I get the error shown in comments when I do that.
I would like to modify the parse tree so that in (1)
and in (1,2,3)
end up looking the same. I can find the list node well enough, but it's not clear how to replace it - not only do I not know what function to use to make a new list node with a single item, it's not clear to me how that would affect the locations of all the other parse tree tokens.
If you could give an example of this, that would be amazing.
Hi, first of all, thank you for this project!
I've noticed that the badge in the README points to the v1 godocs, but the README refers to v2. If the intention is to link to v2, I'd be happy to open a PR to update the badge.
Hi.
How can i get table names from the query parser?
in pg_query its mentioned as follows :
PgQuery.parse("SELECT ? FROM x JOIN y USING (id) WHERE z = ?").tables
but when i do it in pg_query_go as follows:
tables := pg_query.Parse("SELECT ? FROM x JOIN y USING (id) WHERE z = ?").tables
it returns an error.
Can you please post an example for this?
Thanks
Thanks for providing a very nice package. I'm using it to normalize queries that ultimately get put into Elasticsearch. Things work fine most of the time, but it panics randomly when we turn on the full load (about 10 million queries per hour). I haven't run it with -race yet (will do soon).
My code is here: https://github.com/brianbroderick/pg_log_shipper
My stack trace is below.
I'm using PG 9.6 so I haven't upgraded the package to your version 10 code.
Have you seen this before?
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x108 pc=0x6b3edb]
runtime stack:
runtime.throw(0x7678a7, 0x2a)
/usr/local/src/runtime/panic.go:605 +0x95
runtime.sigpanic()
/usr/local/src/runtime/signal_unix.go:351 +0x2b8
goroutine 56 [syscall, locked to thread]:
runtime.cgocall(0x65f240, 0xc420c77b10, 0xc420c77b18)
/usr/local/src/runtime/cgocall.go:132 +0xe4 fp=0xc420c77ae0 sp=0xc420c77aa0 pc=0x4076e4
github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go/parser._Cfunc_pg_query_normalize(0x7f4bb80008c0, 0x0, 0x0)
github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go/parser/_obj/_cgo_gotypes.go:172 +0x53 fp=0xc420c77b10 sp=0xc420c77ae0 pc=0x651113
github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go/parser.Normalize(0xc4207f5f9f, 0xf, 0x0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go/parser/parser.go:45 +0x9b fp=0xc420c77b70 sp=0xc420c77b10 pc=0x65129b
github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go.Normalize(0xc4207f5f9f, 0xf, 0x4ca701, 0xc4207f5f80, 0x0, 0x3)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/github.com/lfittl/pg_query_go/pg_query.go:38 +0x35 fp=0xc420c77bb0 sp=0xc420c77b70 pc=0x6515a5
main.normalizeQuery(0xc4207f5f9f, 0xf, 0x75d138, 0x9, 0xc420da2418, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/normalize_query.go:11 +0x39 fp=0xc420c77c00 sp=0xc420c77bb0 pc=0x659ca9
main.parseMessage(0xc420a43560, 0x1c, 0xc420480c80)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:319 +0x6e8 fp=0xc420c77db0 sp=0xc420c77c00 pc=0x65c038
main.newQuery(0xc420879180, 0x1bb, 0x1bb, 0xc4201020d2, 0x15, 0x1bb, 0x1bb, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:83 +0x464 fp=0xc420c77e18 sp=0xc420c77db0 pc=0x65a284
main.getMultiLog(0xc4201020d2, 0x15, 0xc42005ed00, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:110 +0x452 fp=0xc420c77f18 sp=0xc420c77e18 pc=0x65e252
main.startRedisBatch(0xc4201020d2, 0x15)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:50 +0x5c fp=0xc420c77fd0 sp=0xc420c77f18 pc=0x65dbdc
runtime.goexit()
/usr/local/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420c77fd8 sp=0xc420c77fd0 pc=0x45d461
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 1 [chan receive]:
main.main()
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:49 +0x1ba
goroutine 23 [select]:
net/http.(*persistConn).writeLoop(0xc42008f7a0)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 11 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6f70, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420112518, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420112518, 0xc420111000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420112500, 0xc420111000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420112500, 0xc420111000, 0x1000, 0x1000, 0x4318cb, 0xc420045a40, 0x459850)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc42000e0c8, 0xc420111000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008ed80, 0xc420111000, 0x1000, 0x1000, 0xc42001a190, 0xc420022778, 0x457be0)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc420062a20)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc420062a20, 0x1, 0x0, 0x0, 0x1, 0xc42011e240, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008ed80)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 21 [select]:
net/http.(*persistConn).writeLoop(0xc42008f680)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 32 [select]:
github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*Client).sniffer(0xc420076820)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/client.go:813 +0x190
created by github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.NewClient
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/client.go:282 +0x882
goroutine 12 [select]:
net/http.(*persistConn).writeLoop(0xc42008ed80)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 20 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6eb0, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420104618, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420104618, 0xc42016e000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420104600, 0xc42016e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420104600, 0xc42016e000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014d40)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124048, 0xc42016e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008f680, 0xc42016e000, 0x1000, 0x1000, 0x2, 0xc420043e58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c480)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c480, 0x1, 0x0, 0x0, 0x0, 0xc42011e300, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008f680)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 25 [select]:
net/http.(*persistConn).writeLoop(0xc42008f8c0)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 22 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6df0, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420104818, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420104818, 0xc420178000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420104800, 0xc420178000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420104800, 0xc420178000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014d60)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124050, 0xc420178000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008f7a0, 0xc420178000, 0x1000, 0x1000, 0x2, 0xc42014be58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c540)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c540, 0x1, 0x0, 0x0, 0x0, 0xc42011e420, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008f7a0)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 27 [select]:
net/http.(*persistConn).writeLoop(0xc42008f9e0)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 24 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6d30, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420104a18, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420104a18, 0xc42017a000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420104a00, 0xc42017a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420104a00, 0xc42017a000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014d80)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124058, 0xc42017a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008f8c0, 0xc42017a000, 0x1000, 0x1000, 0x2, 0xc42014ce58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c600)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c600, 0x1, 0x0, 0x0, 0x0, 0xc42011e540, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008f8c0)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 29 [select]:
net/http.(*persistConn).writeLoop(0xc42008fb00)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 26 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6c70, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420104c98, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420104c98, 0xc42017e000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420104c80, 0xc42017e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420104c80, 0xc42017e000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014da0)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124060, 0xc42017e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008f9e0, 0xc42017e000, 0x1000, 0x1000, 0x2, 0xc42014de58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c6c0)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c6c0, 0x1, 0x0, 0x0, 0x0, 0xc42011e660, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008f9e0)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 31 [select]:
net/http.(*persistConn).writeLoop(0xc42008fc20)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 28 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6bb0, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420104e98, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420104e98, 0xc420180000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420104e80, 0xc420180000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420104e80, 0xc420180000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014dc0)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124068, 0xc420180000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008fb00, 0xc420180000, 0x1000, 0x1000, 0x2, 0xc420146e58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c780)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c780, 0x1, 0x0, 0x0, 0x0, 0xc42011e780, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008fb00)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 33 [select]:
github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*Client).healthchecker(0xc420076820)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/client.go:1000 +0x195
created by github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.NewClient
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/client.go:285 +0x858
goroutine 30 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6af0, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420105098, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420105098, 0xc42018a000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420105080, 0xc42018a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420105080, 0xc42018a000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014de0)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420124070, 0xc42018a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008fc20, 0xc42018a000, 0x1000, 0x1000, 0x2, 0xc420147e58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42010c840)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42010c840, 0x1, 0x0, 0x0, 0x0, 0xc42011e8a0, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008fc20)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 51 [IO wait]:
internal/poll.runtime_pollWait(0x7f4bdc1c6a30, 0x72, 0x0)
/usr/local/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420105298, 0x72, 0xffffffffffffff00, 0xb85600, 0xb82278)
/usr/local/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc420105298, 0xc420167000, 0x1000, 0x1000)
/usr/local/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420105280, 0xc420167000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc420105280, 0xc420167000, 0x1000, 0x1000, 0x0, 0x0, 0xc420014e00)
/usr/local/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc42000e218, 0xc420167000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/src/net/net.go:176 +0x6d
net/http.(*persistConn).Read(0xc42008fd40, 0xc420167000, 0x1000, 0x1000, 0x2, 0xc420188e58, 0x2)
/usr/local/src/net/http/transport.go:1391 +0x140
bufio.(*Reader).fill(0xc42018c2a0)
/usr/local/src/bufio/bufio.go:97 +0x11a
bufio.(*Reader).Peek(0xc42018c2a0, 0x1, 0x0, 0x0, 0x0, 0xc4200239e0, 0x0)
/usr/local/src/bufio/bufio.go:129 +0x3a
net/http.(*persistConn).readLoop(0xc42008fd40)
/usr/local/src/net/http/transport.go:1539 +0x185
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1186 +0xa2e
goroutine 52 [select]:
net/http.(*persistConn).writeLoop(0xc42008fd40)
/usr/local/src/net/http/transport.go:1759 +0x165
created by net/http.(*Transport).dialConn
/usr/local/src/net/http/transport.go:1187 +0xa53
goroutine 66 [select]:
github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*bulkWorker).work(0xc420116bc0, 0xb87d80, 0xc420016078)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go:436 +0x13b
created by github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*BulkProcessor).Start
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go:299 +0x1ba
goroutine 67 [select]:
github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*BulkProcessor).flusher(0xc4201560c0, 0x2540be400)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go:386 +0x13f
created by github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic%2ev5.(*BulkProcessor).Start
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/vendor/gopkg.in/olivere/elastic.v5/bulk_processor.go:305 +0x48e
goroutine 68 [chan receive]:
main.main.func1(0xc420116c00)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:38 +0x83
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:37 +0x117
goroutine 69 [sleep]:
time.Sleep(0x3b9aca00)
/usr/local/src/runtime/time.go:65 +0x130
main.startRedisBatch(0xc4201020a0, 0xd)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:58 +0xa6
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 53 [sleep]:
time.Sleep(0x3b9aca00)
/usr/local/src/runtime/time.go:65 +0x130
main.startRedisBatch(0xc4201020ae, 0xe)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:58 +0xa6
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 73 [runnable]:
encoding/json.compact(0xc420944420, 0xc42025bb90, 0x59, 0x8d, 0x1, 0x0, 0x98)
/usr/local/src/encoding/json/indent.go:17 +0x46
encoding/json.marshalerEncoder(0xc420944420, 0x707320, 0xc420cd0f60, 0x16, 0xc420ae0100)
/usr/local/src/encoding/json/encode.go:446 +0x1d4
encoding/json.(*mapEncoder).encode(0xc42000e2d8, 0xc420944420, 0x704620, 0xc420bff440, 0x15, 0x700100)
/usr/local/src/encoding/json/encode.go:682 +0x4c1
encoding/json.(*mapEncoder).(encoding/json.encode)-fm(0xc420944420, 0x704620, 0xc420bff440, 0x15, 0xc420bf0100)
/usr/local/src/encoding/json/encode.go:698 +0x64
encoding/json.(*encodeState).reflectValue(0xc420944420, 0x704620, 0xc420bff440, 0x15, 0x100)
/usr/local/src/encoding/json/encode.go:323 +0x82
encoding/json.(*encodeState).marshal(0xc420944420, 0x704620, 0xc420bff440, 0xc420960100, 0x0, 0x0)
/usr/local/src/encoding/json/encode.go:296 +0xaf
encoding/json.Marshal(0x704620, 0xc420bff440, 0x14, 0x75d1ad, 0x9, 0x0, 0x0)
/usr/local/src/encoding/json/encode.go:161 +0x5f
main.(*query).marshal(0xc42092d680, 0x0, 0x0, 0x1c, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:435 +0x11a
main.newQuery(0xc420635200, 0x20a, 0x20a, 0xc4201020bd, 0x14, 0x20a, 0x20a, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:89 +0x329
main.getMultiLog(0xc4201020bd, 0x14, 0xc42002d700, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:110 +0x452
main.startRedisBatch(0xc4201020bd, 0x14)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:50 +0x5c
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 60 [runnable]:
regexp/syntax.(*parser).push(0xc42018ca80, 0xc42080f5e0, 0xc42080f5e0)
/usr/local/src/regexp/syntax/parse.go:108 +0x391
regexp/syntax.(*parser).literal(0xc42018ca80, 0x64)
/usr/local/src/regexp/syntax/parse.go:210 +0x53
regexp/syntax.Parse(0x76bb31, 0x6a, 0xc4201e00d4, 0xc42000e368, 0x19, 0x707320)
/usr/local/src/regexp/syntax/parse.go:729 +0x2ba
regexp.compile(0x76bb31, 0x6a, 0xc4200000d4, 0x416277, 0xc420126410, 0x50)
/usr/local/src/regexp/regexp.go:170 +0x5a
regexp.Compile(0x76bb31, 0x6a, 0x48, 0x50, 0xc420126410)
/usr/local/src/regexp/regexp.go:133 +0x41
regexp.MustCompile(0x76bb31, 0x6a, 0xc4205f3d38)
/usr/local/src/regexp/regexp.go:238 +0x4d
main.regexMessage(0xc420309000, 0x31, 0xc4205f3c60)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:98 +0x48
main.parseMessage(0xc4207c78c0, 0x1c, 0xc420f4aa20)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:281 +0xa92
main.newQuery(0xc4208f2a80, 0x180, 0x180, 0xc4201020e8, 0x12, 0x180, 0x180, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/query.go:83 +0x464
main.getMultiLog(0xc4201020e8, 0x12, 0xc420032f00, 0x0, 0x0)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:110 +0x452
main.startRedisBatch(0xc4201020e8, 0x12)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:50 +0x5c
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 64 [sleep]:
time.Sleep(0x3b9aca00)
/usr/local/src/runtime/time.go:65 +0x130
main.startRedisBatch(0xc4201020fb, 0x13)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:58 +0xa6
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 74 [sleep]:
time.Sleep(0x3b9aca00)
/usr/local/src/runtime/time.go:65 +0x130
main.startRedisBatch(0xc42010210f, 0x14)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:58 +0xa6
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
goroutine 78 [sleep]:
time.Sleep(0x3b9aca00)
/usr/local/src/runtime/time.go:65 +0x130
main.startRedisBatch(0xc420102124, 0x15)
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/redis.go:58 +0xa6
created by main.main
/home/ubuntu/go/src/github.com/brianbroderick/pg_log_shipper/main.go:44 +0x161
Hi,
If I parse and then de-parse the following statement:
CREATE INDEX "foo.index" ON foo USING btree (bar)
then I end up with a result where the index name is unquoted, which is a syntax error:
CREATE INDEX foo.index ON foo USING btree (bar)
PostgresQL (tested on 10.23 and 15.1) reports:
postgres=# CREATE INDEX foo.index ON foo USING btree (bar);
ERROR: syntax error at or near "." (SQLSTATE 42601)
I started seeing the following warnings recently while building the upstream package of pg_query_go
when building on MacOS -
MacOS Ventura - 13.3
Xcode version - version: 14.3.0.0.1.1679647830
Could you please help me understand the issue? I see that the sprintf
issue would is already logged on #67 and will be fixed in the subsequent release. Not sure about the passing arguments to a function..
❯ make build
go build
# github.com/pganalyze/pg_query_go/v2/parser
src_backend_nodes_nodeFuncs.c:923:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:925:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:930:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:933:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:941:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:948:16: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:950:16: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:953:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:959:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:961:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:963:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:968:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:971:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:976:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:978:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:983:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:985:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:987:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:989:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:998:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1002:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1009:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1017:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1019:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1021:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1023:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1025:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1027:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1035:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1037:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1039:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1041:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1043:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1051:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1053:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1055:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1057:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1059:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1061:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1069:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1071:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1073:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1075:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1077:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1079:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1081:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1083:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1085:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1087:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1089:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1091:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1093:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1095:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1097:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1099:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1107:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1109:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1118:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1129:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1131:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1133:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1135:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1141:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1146:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1148:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1156:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1158:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1163:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1168:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1170:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1175:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1180:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1182:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1187:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1189:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1194:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1196:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1198:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1200:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1208:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1210:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1218:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1220:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1222:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1230:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1233:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1235:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1243:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1245:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1247:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1249:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1251:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1259:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1261:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1269:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1271:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1280:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1282:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1284:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1293:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1299:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1301:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1306:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1308:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1313:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1318:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1320:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1328:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1330:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1332:15: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
src_backend_nodes_nodeFuncs.c:1337:17: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
# github.com/pganalyze/pg_query_go/v2/parser
src_port_snprintf.c:1030:11: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
src_port_snprintf.c:1212:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
src_port_snprintf.c:1219:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
result, err := parser.Parse("CREATE TABLE SHELL.SESSION_TMP_YXKD_INF( STAT_MO INTEGER, CMCC_BRANCH_CD CHAR(4),)WITH(appendonly=true,compresstype=zstd, compresslevel=5,orientation=column) DISTRIBUTED BY(STAT_MO)")
result, err := parser.Parse("CREATE TABLE SHELL.SESSION_TMP_YXKD_INF( STAT_MO INTEGER, CMCC_BRANCH_CD CHAR(4),)WITH(appendonly=true,compresstype=zstd, compresslevel=5,orientation=column) ")
e.g. select * from sample limit 50 can be modified to select * from sample limit 100
Now this is just a simple case, I would like to achieve the same for complex queries and sub-queries, the intention is just to modify the limit for the outermost select query.
https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.5
libpg_query/srcdata/enum_defs.json
has none NOT_EXPR
use Parse method:
`
import pq "github.com/pganalyze/pg_query_go/v2"
func main() {
sql := "select * from x where y != 0"
result, err := pq.Parse(sql)
fmt.Printf("%+v, %+v\n",result,err)
}
`
In the result, the inequality sign ‘!=’ becomes to '<>'
Has anyone encountered this problem
Hi, I am tryoing to build this project on windows and getting below error
$ go get github.com/lfittl/pg_query_go # github.com/lfittl/pg_query_go/parser In file included from .\include/c.h:1129:0, from .\include/postgres.h:47, from contrib_pgcrypto_sha1.c:50: .\include/port.h:17:19: fatal error: netdb.h: No such file or directory compilation terminated.
I have tried the modules step as well but no success. I have searched for netdb.h and this file is not there in the include folder.
How I can resolve this. Thanks
Hi, while trying integrate this library into my project, I got an error from gcc saying there were multiple xxhash definitions because another package I used also includes the xxhash library.
Is there any good way to solved this problem? Currently, it seems that I have no choice but fork and rename all the conflicted definitions.
GCC error:
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH_versionNumber':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:322: multiple definition of `XXH_versionNumber'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1694: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_copyState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:329: multiple definition of `XXH32_copyState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1986: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_copyState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:334: multiple definition of `XXH64_copyState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2545: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:409: multiple definition of `XXH32'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1950: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:521: multiple definition of `XXH64'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2511: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_createState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:552: multiple definition of `XXH32_createState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1974: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_freeState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:556: multiple definition of `XXH32_freeState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1979: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_createState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:562: multiple definition of `XXH64_createState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2533: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_freeState':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:566: multiple definition of `XXH64_freeState'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2538: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_reset':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:575: multiple definition of `XXH32_reset'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:1992: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_reset':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:588: multiple definition of `XXH64_reset'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2551: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_update':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:659: multiple definition of `XXH32_update'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2008: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_digest':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:707: multiple definition of `XXH32_digest'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2072: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_update':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:776: multiple definition of `XXH64_update'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2566: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_digest':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:840: multiple definition of `XXH64_digest'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2627: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_canonicalFromHash':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:861: multiple definition of `XXH32_canonicalFromHash'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2107: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_canonicalFromHash':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:868: multiple definition of `XXH64_canonicalFromHash'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2655: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH32_hashFromCanonical':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:875: multiple definition of `XXH32_hashFromCanonical'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2114: first defined here
/usr/bin/ld: /tmp/go-link-014105907/000112.o: in function `XXH64_hashFromCanonical':
/home/circleci/.go_workspace/pkg/mod/github.com/!data!dog/[email protected]/xxhash.c:880: multiple definition of `XXH64_hashFromCanonical'; /tmp/go-link-014105907/000081.o:/home/circleci/.go_workspace/pkg/mod/github.com/pganalyze/pg_query_go/[email protected]/parser/include/xxhash.h:2663: first defined here
collect2: error: ld returned 1 exit status
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.