-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Vinai/dbeaver fixes #338
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.
Looks good, just a couple missing tests and some small changes
server/handler.go
Outdated
queriedDatabase := ctx.GetQueriedDatabase() | ||
|
||
if queriedDatabase != "" { | ||
ctx.SetQueriedDatabase("") // reset the queried database variable |
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.
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 { |
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.
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.
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 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. |
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.
Note that this should only be used internally by the engine
This pr allows for queries like
CREATE TABLE x.table(pk int)
when the mysql client is not set to x.