-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Query executor: preparing for SHOW VITESS_MIGRATIONS
via ShowBasic
#12688
Query executor: preparing for SHOW VITESS_MIGRATIONS
via ShowBasic
#12688
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…es a ShowMigrationsPlan based on ShowBasic, in preparation for ShowBasic statement coming up in next releases Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
if showInternal.Command == sqlparser.Table { | ||
switch showInternal.Command { | ||
case sqlparser.VitessMigrations: | ||
return &Plan{PlanID: PlanShowMigrations, FullStmt: show}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i chose to return a PlanShowMigrations
rather than returning a PlanSelect
and generating SQL here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benefit of doing it at plan time is that it is cached. So, at execution, it does not need to create the select query and parse it.
I will leave this to you as it is not a critical query on execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching is a good point. I feel like it's wrong to construct this query in query_executor
, though, and that it makes more sense in onlineddl.Executor
. We can always change that in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle the variable sidecar database name. Otherwise looks good (two very nitty comments).
go/vt/vttablet/onlineddl/executor.go
Outdated
// ShowMigrations shows migrations, optionally filtered by a condition | ||
func (e *Executor) ShowMigrations(ctx context.Context, show *sqlparser.Show) (result *sqltypes.Result, err error) { | ||
if atomic.LoadInt64(&e.isOpen) == 0 { | ||
return nil, vterrors.New(vtrpcpb.Code_FAILED_PRECONDITION, "online ddl is disabled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but IMO OnlineDDL
or online DDL
is better. I feel like perhaps the former so as to identify that it's really the Vitess OnlineDDL functionality that's disabled (MySQL itself supports online DDL, and this could be confusing for MySQL users).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
go/vt/vttablet/onlineddl/executor.go
Outdated
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] ShowMigrations expects a ShowBasic statement. Got: %s", sqlparser.String(show)) | ||
} | ||
if showBasic.Command != sqlparser.VitessMigrations { | ||
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] ShowMigrations expects a VitessMigrations command, got %v. Statement: %s", showBasic.Command, sqlparser.String(show)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth %+v
for the struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only had two very minor comments. LGTM!
Sorry about the temporary confusion around the sidecardb. That was my fault.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
Today, a
SHOW VITESS_MIGRATIONS
command is parsed invtagte
asShowBasic
, but converted to aSELECT...
before being sent to vttablet:vitess/go/vt/vtgate/planbuilder/show.go
Lines 276 to 290 in 7af519e
We want to send the original
ShowBasic
, instead. However, for compatibility reasons we must first ensurevttablet
can interceptSHOW VITESS_MIGRATIONS
viaShowBasic
.In this PR query executor intercepts a
ShowBasic
and identifies if it has aVitessMigrations
command. It then generates aPlanShowMigrations
. With this plan, the executor callsonlineddl.Executor
'sShowMigrations()
function, which then generates the SQL query, same way that this is done today invtgate
.This code path it not being used now. This will be included in
v17
. And inv18
we will re-implementvtgate
's behavior as explained above.@harshit-gangal please note I chose to create a
PlanShowMigrations
as opposed to generate the SQL directly in query executor.Related Issue(s)
Replaces #12676
Checklist
Deployment Notes