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

types: support sql_mode ALLOW_INVALID_DATES #9027

Merged
merged 7 commits into from
Jan 14, 2019

Conversation

bobotu
Copy link
Contributor

@bobotu bobotu commented Jan 11, 2019

What problem does this PR solve?

support mode ALLOW_INVALID_DATES (fix #8263). With this mode enabled it will not perform full checking of dates. Check only that the month is in the range from 1 to 12 and the day is in the range from 1 to 31 (also allow zero values such as 0000-00-00).

What is changed and how it works?

Add a new flag AllowInvalidDate into StatementContext. Then checkMonthDay check the month and day according to this flag.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

@codecov-io
Copy link

codecov-io commented Jan 14, 2019

Codecov Report

Merging #9027 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9027      +/-   ##
==========================================
- Coverage   67.26%   67.26%   -0.01%     
==========================================
  Files         371      371              
  Lines       76000    76009       +9     
==========================================
+ Hits        51123    51128       +5     
- Misses      20365    20367       +2     
- Partials     4512     4514       +2
Impacted Files Coverage Δ
executor/executor.go 67.08% <100%> (+0.28%) ⬆️
types/time.go 61.66% <100%> (+0.08%) ⬆️
ddl/delete_range.go 74.28% <0%> (-4.58%) ⬇️
expression/schema.go 94.95% <0%> (+0.84%) ⬆️
util/systimemon/systime_mon.go 100% <0%> (+20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89532cd...a02c834. Read the comment docs.

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

runWithMode := func(mode string) {
inputs := []string{"0000-00-00", "2019-00-00", "2019-01-00", "2019-00-01", "2019-02-31"}
results := testkit.Rows(`0 0 0`, `2019 0 0`, `2019 1 0`, `2019 0 1`, `2019 2 31`)

Choose a reason for hiding this comment

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

Maybe we should set the original sql_mode back after finishing this test, using defer in line 250.

@bobotu
Copy link
Contributor Author

bobotu commented Jan 14, 2019

PTAL @imtbkcat

Copy link

@imtbkcat imtbkcat left a comment

Choose a reason for hiding this comment

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

LGTM

@ngaut ngaut added the status/LGT2 Indicates that a PR has LGTM 2. label Jan 14, 2019
@ngaut
Copy link
Member

ngaut commented Jan 14, 2019

/run-all-tests

@ngaut ngaut merged commit f20c849 into pingcap:master Jan 14, 2019
@bobotu bobotu deleted the allow-invalid-dates branch January 14, 2019 11:48
morgo added a commit to pingcap/docs that referenced this pull request Jan 15, 2019
bobotu added a commit to bobotu/tidb that referenced this pull request Jan 18, 2019
CaitinChen pushed a commit to pingcap/docs that referenced this pull request Jan 28, 2019
* sql: allow_invalid_dates is now supported

via pingcap/tidb#9027

* Address PR Feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql_mode ALLOW_INVALID_DATES is not supported
5 participants