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

Refactor prepards #1939

Closed
wants to merge 2 commits into from
Closed

Refactor prepards #1939

wants to merge 2 commits into from

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Aug 14, 2023

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

Copy link
Member

@zachmu zachmu left a 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(), "@"))
Copy link
Member

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,
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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

@Hydrocharged Hydrocharged deleted the max/refactor-prepards branch August 24, 2023 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants