Skip to content

Support zero date and zero in date, via dedicated command line flag #31

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

Merged
merged 6 commits into from
Oct 21, 2021

Conversation

shlomi-noach
Copy link

@shlomi-noach shlomi-noach commented Oct 21, 2021

Users may want to e.g. datetime not null default '0000-00-00 00:00:00'. Right now gh-ost uses the global sql_mode, so if that is set to ...NO_ZERO_IN_DATE,NO_ZERO_DATE... the alter will fail.

There's a use case to allow users to still alter the table, and have gh-ost modify sql_mode temporarily on their behalf.

Initial commit: adding a test that should fail a zero-date migration. Code to enable desired behavior will follow, and make the test work.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach
Copy link
Author

Tests fail as expected:

021-10-21 11:23:47 FATAL Error 1067: Invalid default value for 'dt'
goroutine 1 [running]:
runtime/debug.Stack(0x44, 0xc00001c900, 0x2a)
	/opt/hostedtoolcache/go/1.16.9/x64/src/runtime/debug/stack.go:24 +0x9f
runtime/debug.PrintStack()
	/opt/hostedtoolcache/go/1.16.9/x64/src/runtime/debug/stack.go:16 +0x25
github.com/openark/golib/log.logErrorEntry(0x0, 0x87d5c0, 0xc00000e0d8, 0xc00003c800, 0xc000056020)
	/home/runner/work/gh-ost/gh-ost/.gopath/src/github.com/github/gh-ost/vendor/github.com/openark/golib/log/log.go:188 +0xf4
github.com/openark/golib/log.Fatale(0x87d5c0, 0xc00000e0d8, 0x7d9201, 0xc000074000)
	/home/runner/work/gh-ost/gh-ost/.gopath/src/github.com/github/gh-ost/vendor/github.com/openark/golib/log/log.go:265 +0x3e
github.com/github/gh-ost/go/base.(*simpleLogger).Fatale(0xad1800, 0x87d5c0, 0xc00000e0d8, 0x0, 0x0)
	/home/runner/work/gh-ost/gh-ost/.gopath/src/github.com/github/gh-ost/go/base/default_logger.go:62 +0x35
main.main()
	/home/runner/work/gh-ost/gh-ost/.gopath/src/github.com/github/gh-ost/go/cmd/gh-ost/main.go:297 +0x2b1f
+ FAIL

https://github.com/openark/gh-ost/pull/31/checks?check_run_id=3963105598

Will now work on functionality.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ort for 5.5 soon

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach shlomi-noach merged commit addd7bf into master Oct 21, 2021
@shlomi-noach shlomi-noach deleted the zero-date branch October 21, 2021 13:03
shlomi-noach added a commit that referenced this pull request Aug 21, 2022
* Merge pull request #31 from openark/zero-date

Support zero date and zero in date, via dedicated command line flag

* Merge pull request #32 from openark/existing-date-with-zero

Support tables with existing zero dates

* Remove un-needed ignore_versions file

* Fix new lint errors from golang-ci update

Co-authored-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
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