Skip to content
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
6 changes: 1 addition & 5 deletions go/vt/vttablet/endtoend/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package endtoend

import (
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -230,10 +229,7 @@ func TestForUpdate(t *testing.T) {
client := framework.NewClient()
query := fmt.Sprintf("select * from vitess_test where intval=2 %s", mode)
_, err := client.Execute(query, nil)
want := "SelectLock disallowed outside transaction"
if err == nil || !strings.HasPrefix(err.Error(), want) {
t.Errorf("%v, must have prefix %s", err, want)
}
require.NoError(t, err)

// We should not get errors here
err = client.Begin(false)
Expand Down
3 changes: 0 additions & 3 deletions go/vt/vttablet/tabletserver/planbuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ func analyzeSelect(sel *sqlparser.Select, tables map[string]*schema.Table) (plan
FieldQuery: GenerateFieldQuery(sel),
FullQuery: GenerateLimitQuery(sel),
}
if sel.Lock != sqlparser.NoLock {
plan.PlanID = PlanSelectLock
}

if sel.Where != nil {
comp, ok := sel.Where.Expr.(*sqlparser.ComparisonExpr)
Expand Down
4 changes: 1 addition & 3 deletions go/vt/vttablet/tabletserver/planbuilder/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type PlanType int
// The following are PlanType values.
const (
PlanSelect PlanType = iota
PlanSelectLock
PlanNextval
PlanSelectImpossible
PlanInsert
Expand Down Expand Up @@ -78,7 +77,6 @@ const (
// Must exactly match order of plan constants.
var planName = []string{
"Select",
"SelectLock",
"Nextval",
"SelectImpossible",
"Insert",
Expand Down Expand Up @@ -123,7 +121,7 @@ func PlanByName(s string) (pt PlanType, ok bool) {

// IsSelect returns true if PlanType is about a select query.
func (pt PlanType) IsSelect() bool {
return pt == PlanSelect || pt == PlanSelectLock || pt == PlanSelectImpossible
return pt == PlanSelect || pt == PlanSelectImpossible
}

// MarshalJSON returns a json string for PlanType.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
# for update
"select eid from a for update"
{
"PlanID": "SelectLock",
"PlanID": "Select",
"TableName": "a",
"Permissions": [
{
Expand All @@ -212,7 +212,7 @@
# lock in share mode
"select eid from a lock in share mode"
{
"PlanID": "SelectLock",
"PlanID": "Select",
"TableName": "a",
"Permissions": [
{
Expand Down
4 changes: 1 addition & 3 deletions go/vt/vttablet/tabletserver/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ func (qre *QueryExecutor) Execute() (reply *sqltypes.Result, err error) {
return nil, err
}
return qr, nil
case p.PlanSelectLock:
return nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "%s disallowed outside transaction", qre.plan.PlanID.String())
case p.PlanOtherRead, p.PlanOtherAdmin, p.PlanFlush:
return qre.execOther()
case p.PlanSavepoint, p.PlanRelease, p.PlanSRollback:
Expand Down Expand Up @@ -208,7 +206,7 @@ func (qre *QueryExecutor) txConnExec(conn *StatefulConnection) (*sqltypes.Result
return qre.execStatefulConn(conn, qre.query, true)
case p.PlanSavepoint, p.PlanRelease, p.PlanSRollback:
return qre.execStatefulConn(conn, qre.query, true)
case p.PlanSelect, p.PlanSelectLock, p.PlanSelectImpossible, p.PlanShow:
case p.PlanSelect, p.PlanSelectImpossible, p.PlanShow:
maxrows := qre.getSelectLimit()
qre.bindVars["#maxLimit"] = sqltypes.Int64BindVariable(maxrows + 1)
if qre.bindVars[sqltypes.BvReplaceSchemaName] != nil {
Expand Down
7 changes: 2 additions & 5 deletions go/vt/vttablet/tabletserver/query_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,9 @@ func TestQueryExecutorPlanPassSelectWithLockOutsideATransaction(t *testing.T) {
tsv := newTestTabletServer(ctx, noFlags, db)
qre := newTestQueryExecutor(ctx, tsv, query, 0)
defer tsv.StopService()
assert.Equal(t, planbuilder.PlanSelectLock, qre.plan.PlanID)
assert.Equal(t, planbuilder.PlanSelect, qre.plan.PlanID)
_, err := qre.Execute()
if code := vterrors.Code(err); code != vtrpcpb.Code_FAILED_PRECONDITION {
assert.NoError(t, err)
t.Fatalf("qre.Execute: %v, want %v", code, vtrpcpb.Code_FAILED_PRECONDITION)
}
assert.NoError(t, err)
}

func TestQueryExecutorPlanNextval(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/rules/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestFilterByPlan(t *testing.T) {

qr2 := NewQueryRule("rule 2", "r2", QRFail)
qr2.AddPlanCond(planbuilder.PlanSelect)
qr2.AddPlanCond(planbuilder.PlanSelectLock)
qr2.AddPlanCond(planbuilder.PlanSelect)
qr2.AddBindVarCond("a", true, false, QRNoOp, nil)

qr3 := NewQueryRule("rule 3", "r3", QRFail)
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestFilterByPlan(t *testing.T) {
t.Errorf("qrs1:\n%s, want\n%s", got, want)
}

qrs1 = qrs.FilterByPlan("insert", planbuilder.PlanSelectLock, "a")
qrs1 = qrs.FilterByPlan("insert", planbuilder.PlanSelect, "a")
got = marshalled(qrs1)
if got != want {
t.Errorf("qrs1:\n%s, want\n%s", got, want)
Expand Down