Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for vexplain prefix and more subquery tests #3

Merged
merged 1 commit into from
Jun 12, 2024
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
1 change: 1 addition & 0 deletions src/vitess-tester/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const (
Q_COMMENT_WITH_COMMAND
Q_EMPTY_LINE
Q_SKIP_IF_BELOW_VERSION
Q_VEXPLAIN
)

// ParseQueries parses an array of string into an array of query object.
Expand Down
19 changes: 19 additions & 0 deletions src/vitess-tester/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type tester struct {
skipBinary string
skipVersion int
skipNext bool
vexplain string

// check expected error, use --error before the statement
// we only care if an error is returned, not the exact error message.
Expand Down Expand Up @@ -131,6 +132,14 @@ func (t *tester) Run() error {
}
case Q_ERROR:
t.expectedErrs = true
case Q_VEXPLAIN:
strs := strings.Split(q.Query, " ")
if len(strs) != 2 {
t.reporter.AddFailure(fmt.Errorf("incorrect syntax for Q_VEXPLAIN in: %v", q.Query))
continue
}

t.vexplain = strs[1]
case Q_QUERY:
if t.skipNext {
t.skipNext = false
Expand All @@ -143,6 +152,16 @@ func (t *tester) Run() error {
continue
}
}
if t.vexplain != "" {
result, err := t.curr.VtConn.ExecuteFetch("vexplain "+t.vexplain+" "+q.Query, -1, false)
t.vexplain = ""
if err != nil {
t.reporter.AddFailure(err)
continue
}

t.reporter.AddFailure(fmt.Errorf("VExplain Output:\n %s\n", result.Rows[0][0].ToString()))
}
t.reporter.AddTestCase(q.Query, q.Line)
if err = t.execute(q); err != nil && !t.expectedErrs {
t.reporter.AddFailure(err)
Expand Down
1 change: 1 addition & 0 deletions src/vitess-tester/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var commandMap = map[string]CmdType{
"begin_concurrent": Q_BEGIN_CONCURRENT,
"end_concurrent": Q_END_CONCURRENT,
"skip_if_below_version": Q_SKIP_IF_BELOW_VERSION,
"vexplain": Q_VEXPLAIN,
}

func findType(cmdName string) CmdType {
Expand Down
16 changes: 15 additions & 1 deletion t/subqueries.test
Original file line number Diff line number Diff line change
Expand Up @@ -455,4 +455,18 @@ FROM
GROUP BY
id, name
ORDER BY
(SELECT SUM(LENGTH(extra_info)) FROM user_extra WHERE user_extra.user_id = user.id);
(SELECT SUM(LENGTH(extra_info)) FROM user_extra WHERE user_extra.user_id = user.id);

select max((select min(user_id) from user_extra))
from user
where id = 1;

select
max((select group_concat(id, name) from user where id = 1));

--skip this is buggy at the moment
select max((select max(name) from user u1 where u1.id = u2.id))
from user u2;

select count(distinct name, id)
from user;
Loading