Skip to content

Commit a4f33df

Browse files
authored
[planbuilder] Limit allows unsigned ints (#2350)
1 parent ac39104 commit a4f33df

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

enginetest/queries/procedure_queries.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ END;`,
11591159
"create table t (i int primary key);",
11601160
"insert into t values (0), (1), (2), (3)",
11611161
"CREATE PROCEDURE limited(the_limit int, the_offset bigint) SELECT * FROM t LIMIT the_limit OFFSET the_offset",
1162+
"CREATE PROCEDURE limited_uns(the_limit int unsigned, the_offset bigint unsigned) SELECT * FROM t LIMIT the_limit OFFSET the_offset",
11621163
},
11631164
Assertions: []ScriptTestAssertion{
11641165
{
@@ -1173,6 +1174,10 @@ END;`,
11731174
Query: "call limited(2,2)",
11741175
Expected: []sql.Row{{2}, {3}},
11751176
},
1177+
{
1178+
Query: "call limited_uns(2,2)",
1179+
Expected: []sql.Row{{2}, {3}},
1180+
},
11761181
{
11771182
Query: "CREATE PROCEDURE limited_inv(the_limit CHAR(3), the_offset INT) SELECT * FROM t LIMIT the_limit OFFSET the_offset",
11781183
ExpectedErrStr: "the variable 'the_limit' has a non-integer based type: char(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin",

sql/planbuilder/select.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (b *Builder) buildLimitVal(inScope *scope, e ast.Expr) sql.Expression {
157157
if col, ok := inScope.proc.GetVar(e.String()); ok {
158158
// proc param is OK
159159
if pp, ok := col.scalarGf().(*expression.ProcedureParam); ok {
160-
if !pp.Type().Promote().Equals(types.Int64) {
160+
if !pp.Type().Promote().Equals(types.Int64) && !pp.Type().Promote().Equals(types.Uint64) {
161161
err := fmt.Errorf("the variable '%s' has a non-integer based type: %s", pp.Name(), pp.Type().String())
162162
b.handleErr(err)
163163
}

0 commit comments

Comments
 (0)