Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ func (h *Handler) doQuery(
}
}

sqlCtx.SetParsedQuery(parsed)

more := remainder != ""

var queryStr string
Expand Down
17 changes: 17 additions & 0 deletions sql/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"

"github.com/dolthub/vitess/go/vt/sqlparser"
)

type key uint
Expand Down Expand Up @@ -239,6 +241,7 @@ type Context struct {
services Services
pid uint64
query string
parsedQuery sqlparser.Statement
queryTime time.Time
tracer trace.Tracer
rootSpan trace.Span
Expand Down Expand Up @@ -399,6 +402,20 @@ func (c *Context) WithQuery(q string) *Context {
return &nc
}

// ParsedQuery returns the parsed query associated with this context.
// May return nil.
func (c *Context) ParsedQuery() sqlparser.Statement {
if c == nil {
return nil
}
return c.parsedQuery
}

// SetParsedQuery adds the given parsed query to the context.
func (c *Context) SetParsedQuery(parsed sqlparser.Statement) {
c.parsedQuery = parsed
}

// QueryTime returns the time.Time when the context associated with this query was created
func (c *Context) QueryTime() time.Time {
if c == nil {
Expand Down