-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Refactor prepards #1939
Refactor prepards #1939
Conversation
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.
Just a couple comments
bindings = make(map[string]*querypb.BindVariable) | ||
} | ||
if strings.HasPrefix(name.String(), "@") { | ||
t, val, err := ctx.GetUserVariable(ctx, strings.TrimPrefix(name.String(), "@")) |
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.
Is this a real use case? You can pass user var names in as bindvar arguments?
;`, | ||
|
||
`, | ||
//SkipPrepared: true, |
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.
Revert?
Query: `SELECT SUBSTRING(s, 1, 10) AS sub_s, SUBSTRING(SUB_S, 2, 3) AS sub_sub_s FROM mytable`, | ||
ExpectedErr: sql.ErrMisusedAlias, | ||
}, | ||
// todo: we should be case-sensitive and reject SUB_S as a valid field |
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.
Since when are alias names case sensitive?
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.
hmm yeah this is wrong, thanks for pointing out, it's fixed now
This is a partial view of the larger name resolution PR. For review, not intended to merge.
In summary, this refactor caches saves a buffer of the original query string, with indices for bind variable replacement. Post-prepare is: 1) generate a query string with bind variables, 2) run analysis and execute.
Related vitess PR: dolthub/vitess#262