-
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
evalengine: Handle zero dates correctly #14610
evalengine: Handle zero dates correctly #14610
Conversation
This removes the different configuration for testing to ensure we have the same settings as production defaults and subsequently fixes the failing evalengine issues. Signed-off-by: Dirkjan Bussink <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
go/vt/vtgate/vcursor_impl.go
Outdated
@@ -211,6 +211,11 @@ func (vc *vcursorImpl) TimeZone() *time.Location { | |||
return vc.safeSession.TimeZone() | |||
} | |||
|
|||
func (vc *vcursorImpl) AllowZeroDate() bool { | |||
// TODO: Implement detecting zero date |
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.
@harshit-gangal Do you have a recommendation for how we can implement this 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.
We would need sql_mode representation which can provide these answers
Signed-off-by: Dirkjan Bussink <[email protected]>
Signed-off-by: Dirkjan Bussink <[email protected]>
Signed-off-by: Dirkjan Bussink <[email protected]>
8d08eb9
to
a935164
Compare
// We have tests for zero dates, so we need to allow that for this session. | ||
if _, err := dConn.ExecuteFetch("SET @@session.sql_mode=REPLACE(REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '')", 0, false); err != nil { | ||
t.Fatal(err) | ||
} |
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 is now needed since the tests try to insert zero dates and we need to test those, so they need to be allowed for this session here.
|
||
// default mysql flavor allows invalid dates: so disallow explicitly for this test | ||
if err := env.Mysqld.ExecuteSuperQuery(context.Background(), "SET @@global.sql_mode=REPLACE(REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '')"); err != nil { | ||
if _, err := conn.ExecuteFetch("SET @@session.sql_mode=REPLACE(REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '')", 0, false); err != 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.
So the logic here tried to set up the connection to allow zero dates. It didn't do that correctly though, but it accidentally worked since we didn't enforce zero dates in the past due to the different test MySQL config fixed in this PR.
The changes here actually fix the logic so we can insert zero dates for the test.
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.
Good catch!
|
||
// default mysql flavor allows invalid dates: so disallow explicitly for this test | ||
if err := env.Mysqld.ExecuteSuperQuery(context.Background(), "SET @@global.sql_mode=REPLACE(REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '')"); err != nil { | ||
if _, err := conn.ExecuteFetch("SET @@session.sql_mode=REPLACE(REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', ''), 'NO_ZERO_IN_DATE', '')", 0, false); err != 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.
Good catch!
Signed-off-by: Vicent Marti <[email protected]>
func (vc *vcursorImpl) SQLMode() string { | ||
// TODO: Implement return the current sql_mode. | ||
// This is currently hardcoded to the default in MySQL 8.0. | ||
return config.DefaultSQLMode | ||
} | ||
|
||
// MaxMemoryRows returns the maxMemoryRows flag value. |
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 still have to honour the changed sql_mode stored in the session.
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.
check if any value is stored in session, if not then return the default value.
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.
@harshit-gangal I think this already is a strict improvement and we can do this separately. We used the wrong setting before (evalengine mismatched default sql_mode). I'll also open a feature request to track that.
Signed-off-by: Dirkjan Bussink <[email protected]> Signed-off-by: Vicent Marti <[email protected]> Co-authored-by: Vicent Marti <[email protected]>
This removes the different configuration for testing to ensure we have the same settings as production defaults and subsequently fixes the failing evalengine issues.
Related Issue(s)
Fixes #14609
Checklist