Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add plan-test showing when we need to exhaust the input stream
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
systay committed Dec 18, 2024
1 parent 323cf2b commit 94054f3
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/vt/vtgate/engine/limit.go
Original file line number Diff line number Diff line change
@@ -220,6 +220,9 @@ func (l *Limit) description() PrimitiveDescription {
if l.Offset != nil {
other["Offset"] = sqlparser.String(l.Offset)
}
if l.RequireCompleteInput {
other["RequireCompleteInput"] = true
}

return PrimitiveDescription{
OperatorType: "Limit",
30 changes: 30 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/select_cases.json
Original file line number Diff line number Diff line change
@@ -4957,6 +4957,36 @@
]
}
},
{
"comment": "We are using last_insert_id with argument, so we need to fetch all results",
"query": "select last_insert_id(5) from user limit 12",
"plan": {
"QueryType": "SELECT",
"Original": "select last_insert_id(5) from user limit 12",
"Instructions": {
"OperatorType": "Limit",
"Count": "12",
"RequireCompleteInput": true,
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Scatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FetchLastInsertID": true,
"FieldQuery": "select last_insert_id(5) from `user` where 1 != 1",
"Query": "select last_insert_id(5) from `user` limit 12",
"Table": "`user`"
}
]
},
"TablesUsed": [
"user.user"
]
}
},
{
"comment": "Unmergeable subquery with multiple levels of derived statements, using a multi value `IN` predicate",
"query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (5, 6) LIMIT 10) subquery_for_limit) subquery_for_limit)",

0 comments on commit 94054f3

Please sign in to comment.