Merge pull request #1715 from tgruben/cleanup-query

addsql version to handler
This commit is contained in:
tgruben 2021-09-27 16:37:04 -05:00 committed by GitHub
commit f0b93da070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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.

View file

@ -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)
}

View file

@ -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 {