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

Vinai/dbeaver fixes #338

Merged
merged 15 commits into from
Mar 19, 2021
Merged

Vinai/dbeaver fixes #338

merged 15 commits into from
Mar 19, 2021

Conversation

VinaiRachakonda
Copy link
Contributor

This pr allows for queries like CREATE TABLE x.table(pk int) when the mysql client is not set to x.

@VinaiRachakonda VinaiRachakonda changed the title [Wip] Vinai/dbeaver fixes Vinai/dbeaver fixes Mar 17, 2021
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.

Looks good, just a couple missing tests and some small changes

queriedDatabase := ctx.GetQueriedDatabase()

if queriedDatabase != "" {
ctx.SetQueriedDatabase("") // reset the queried database variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should happen every statement, regardless of the logic at the call site for this function. Clients have access to this variable too, so we need to be setting it consistently on every query.

@@ -124,17 +124,27 @@ func applyTriggers(ctx *sql.Context, a *Analyzer, n sql.Node, scope *Scope) (sql

var affectedTables []string
var triggerEvent plan.TriggerEvent
db := ctx.GetCurrentDatabase()
plan.Inspect(n, func(n sql.Node) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add some engine tests for triggers on inserts that specify a non-current DB for inserts / updates / deletes. Just copy and tweak some existing trigger tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think mysql supports cross-db trigger queries. Following up in messages.

sql/session.go Outdated
@@ -82,6 +82,10 @@ type Session interface {
DelLock(lockName string) error
// IterLocks iterates through all locks owned by this user
IterLocks(cb func(name string) error) error
// GetQueriedDatabase represents the database the user is running a query on that is NOT the current database.
GetQueriedDatabase() string
// SetQueriedDatabase sets the queried database.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this should only be used internally by the engine

@VinaiRachakonda VinaiRachakonda merged commit 7fcc1fc into master Mar 19, 2021
@Hydrocharged Hydrocharged deleted the vinai/dbeaver-fixes branch December 8, 2021 07:07
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.

2 participants