Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle empty query correctly #654

Merged
merged 2 commits into from
Mar 19, 2023
Merged
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: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FROM node:16-alpine as FE
RUN apk add --no-cache git

# specify git revision for arana-db/arana-ui repo
ARG UI_REVISION="3d46401"
ARG UI_REVISION="6ec7d61"

WORKDIR /arana-ui

Expand Down
8 changes: 7 additions & 1 deletion pkg/executor/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
var (
errMissingTx = stdErrors.New("no transaction found")
errNoDatabaseSelected = mysqlErrors.NewSQLError(mConstants.ERNoDb, mConstants.SSNoDatabaseSelected, "No database selected")
errEmptyQuery = mysqlErrors.NewSQLError(mConstants.EREmptyQuery, mConstants.SS42000, "Query was empty")
)

var (
Expand Down Expand Up @@ -305,7 +306,12 @@ func (executor *RedirectExecutor) doExecutorComQuery(ctx *proto.Context, act ast
func (executor *RedirectExecutor) ExecutorComQuery(ctx *proto.Context, h func(result proto.Result, warns uint16, failure error) error) error {
p := parser.New()
query := ctx.GetQuery()
log.Debugf("ComQuery: %s", query)

if len(query) < 1 {
return h(nil, 0, errEmptyQuery)
}

log.Debugf("ComQuery: '%s'", query)

charset, collation := getCharsetCollation(ctx.C.CharacterSet())

Expand Down
2 changes: 1 addition & 1 deletion pkg/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
import (
_ "github.com/arana-db/parser/test_driver"

uconfig "github.com/arana-db/arana/pkg/util/config"
perrors "github.com/pkg/errors"

"go.uber.org/atomic"
Expand All @@ -46,6 +45,7 @@ import (
"github.com/arana-db/arana/pkg/mysql/errors"
"github.com/arana-db/arana/pkg/proto"
"github.com/arana-db/arana/pkg/security"
uconfig "github.com/arana-db/arana/pkg/util/config"
"github.com/arana-db/arana/pkg/util/log"
)

Expand Down