From 51876b1821d28acf193f47b021c68e9c7678f14e Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 27 Sep 2021 15:42:07 -0500 Subject: [PATCH 1/3] addsql version to handler --- pg/protocol.go | 3 ++- pg/query.go | 1 + server.go | 2 -- server/pg.go | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pg/protocol.go b/pg/protocol.go index 0fa52a5e9..e58540e1d 100644 --- a/pg/protocol.go +++ b/pg/protocol.go @@ -432,7 +432,8 @@ func (p *Portal) Execute() (shouldTerminate bool, queryReady bool, err error) { return } p.Add(rowDescription) - dataRow, _ := p.Encoder.TextRow("PostgresSQL 13.0 (molecula)") + mesg := fmt.Sprintf("PostgresSQL 13.0 (molecula.%v)", p.server.QueryHandler.Version()) + dataRow, _ := p.Encoder.TextRow(mesg) p.Add(dataRow) case pgSelect1: rowDescription, e := p.Encoder.EncodeColumn("?column?", int32(23), 4) diff --git a/pg/query.go b/pg/query.go index 7aa231670..ebf48e84e 100644 --- a/pg/query.go +++ b/pg/query.go @@ -61,6 +61,7 @@ type QueryHandler interface { // HandleQuery executes a query and writes the results back. HandleQuery(context.Context, QueryResultWriter, Query) error HandleSchema(context.Context, *Portal) error + Version() string } // queryResultWriter implements QueryResultWrtiter over postgres wire protocol. diff --git a/server.go b/server.go index 2e75045d4..93d9947a0 100644 --- a/server.go +++ b/server.go @@ -39,7 +39,6 @@ import ( "github.com/molecula/featurebase/v2/stats" "github.com/molecula/featurebase/v2/storage" "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/vprint" "github.com/pkg/errors" "golang.org/x/sync/errgroup" @@ -1355,7 +1354,6 @@ func (s *Server) PlanSQL(ctx context.Context, q string) (*Stmt, error) { if err != nil { return nil, err } - vprint.VV("PLanning SQL: (%v)", q) return NewPlanner(s.executor).PlanStatement(ctx, st) } diff --git a/server/pg.go b/server/pg.go index 8b7d6478f..533ca0b43 100644 --- a/server/pg.go +++ b/server/pg.go @@ -596,7 +596,16 @@ func (qdh *QueryDecodeHandler) HandleQuery(ctx context.Context, w pg.QueryResult return qdh.Child.HandleQuery(ctx, w, q) } +func (qdh *QueryDecodeHandler) Version() string { + return qdh.Child.Version() +} +func (pqh *PilosaQueryHandler) Version() string { + if pqh.sqlVersion > 0 { + return "v2" + } + return "v1" +} func (pqh *PilosaQueryHandler) HandleSchema(ctx context.Context, portal *pg.Portal) error { schema, err := pqh.Api.Schema(context.Background(), false) if err != nil { From 2b3662508140356950ecf336e34d568415518756 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 27 Sep 2021 16:04:40 -0500 Subject: [PATCH 2/3] missed test handler --- go.mod | 2 +- pg/pgtest/handler.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e590bdd1b..d64a32730 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect golang.org/x/text v0.3.5 // indirect google.golang.org/grpc v1.28.0 - gopkg.in/yaml.v2 v2.3.0 // indirect + gopkg.in/yaml.v2 v2.3.0 modernc.org/mathutil v1.0.0 modernc.org/strutil v1.0.0 sigs.k8s.io/yaml v1.2.0 // indirect diff --git a/pg/pgtest/handler.go b/pg/pgtest/handler.go index 02b1361e2..845aedf19 100644 --- a/pg/pgtest/handler.go +++ b/pg/pgtest/handler.go @@ -33,6 +33,9 @@ func (h HandlerFunc) HandleQuery(ctx context.Context, w pg.QueryResultWriter, q func (h HandlerFunc) HandleSchema(ctx context.Context, portal *pg.Portal) error { return nil } +func (h HandlerFunc) Version() string { + return "testv1" +} var _ pg.QueryHandler = HandlerFunc(nil) From 79c066a9a01dd6b48b63896ccde5c5e0d9c6ca57 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 27 Sep 2021 16:11:27 -0500 Subject: [PATCH 3/3] mod tidy fun --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d64a32730..e590bdd1b 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect golang.org/x/text v0.3.5 // indirect google.golang.org/grpc v1.28.0 - gopkg.in/yaml.v2 v2.3.0 + gopkg.in/yaml.v2 v2.3.0 // indirect modernc.org/mathutil v1.0.0 modernc.org/strutil v1.0.0 sigs.k8s.io/yaml v1.2.0 // indirect