diff --git a/go/vt/sqlparser/normalizer.go b/go/vt/sqlparser/normalizer.go index a2ac08337ab..ac223477e27 100644 --- a/go/vt/sqlparser/normalizer.go +++ b/go/vt/sqlparser/normalizer.go @@ -88,6 +88,9 @@ func (nz *normalizer) WalkSelect(node SQLNode) (bool, error) { // Common node types that never contain SQLVals or ListArgs but create a lot of object // allocations. return false, nil + case OrderBy, GroupBy: + // do not make a bind var for order by column_position + return false, nil } return true, nil } diff --git a/go/vt/sqlparser/normalizer_test.go b/go/vt/sqlparser/normalizer_test.go index 7aa24814d55..b102b0ec2ad 100644 --- a/go/vt/sqlparser/normalizer_test.go +++ b/go/vt/sqlparser/normalizer_test.go @@ -127,6 +127,16 @@ func TestNormalize(t *testing.T) { in: "update a set v1 = b'11'", outstmt: "update a set v1 = B'11'", outbv: map[string]*querypb.BindVariable{}, + }, { + // ORDER BY column_position + in: "select a, b from t order by 1 asc", + outstmt: "select a, b from t order by 1 asc", + outbv: map[string]*querypb.BindVariable{}, + }, { + // ORDER BY variable + in: "select a, b from t order by c asc", + outstmt: "select a, b from t order by c asc", + outbv: map[string]*querypb.BindVariable{}, }, { // Values up to len 256 will reuse. in: fmt.Sprintf("select * from t where v1 = '%256s' and v2 = '%256s'", "a", "a"),