Skip to content

Commit

Permalink
Merge pull request #4822 from HubSpot/order-by-column-position
Browse files Browse the repository at this point in the history
normalizer: do not normalize in order by
  • Loading branch information
sougou authored Apr 22, 2019
2 parents 21167f1 + e991740 commit eb85db2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/vt/sqlparser/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions go/vt/sqlparser/normalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit eb85db2

Please sign in to comment.