Commit Graph

164 Commits

Author SHA1 Message Date
Josh Bielick
84e55ff904
copy and update text using convert when charset changes
addresses #290

Note: there is currently no issue backfilling the ghost table when the
characterset changes, likely because it's a insert-into-select-from and
it all occurs within mysql.

However, when applying DML events (UPDATE, DELETE, etc) the values are
sprintf'd into a prepared statement and due to the possibility of
migrating text column data containing invalid characters in the
destination charset, a conversion step is often necessary.

For example, when migrating a table/column from latin1 to utf8mb4, the
latin1 column may contain characters that are invalid single-byte utf8
characters. Characters in the \x80-\xFF range are most common. When
written to utf8mb4 column without conversion, they fail as they do not
exist in the utf8 codepage.

Converting these texts/characters to the destination charset using
convert(? using {charset}) will convert appropriately and the
update/replace will succeed.

I only point out the "Note:" above because there are two tests added
for this: latin1text-to-utf8mb4 and latin1text-to-ut8mb4-insert

The former is a test that fails prior to this commit. The latter is a
test that succeeds prior to this comment. Both are affected by the code
in this commit.

convert text to original charset, then destination

converting text first to the original charset and then to the
destination charset produces the most consistent results, as inserting
the binary into a utf8-charset column may encounter an error if there is
no prior context of latin1 encoding.

mysql> select hex(convert(char(189) using utf8mb4));
+---------------------------------------+
| hex(convert(char(189) using utf8mb4)) |
+---------------------------------------+
|                                       |
+---------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select hex(convert(convert(char(189) using latin1) using utf8mb4));
+-------------------------------------------------------------+
| hex(convert(convert(char(189) using latin1) using utf8mb4)) |
+-------------------------------------------------------------+
| C2BD                                                        |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

as seen in this failure on 5.5.62

 Error 1300: Invalid utf8mb4 character string: 'BD'; query=
			replace /* gh-ost `test`.`_gh_ost_test_gho` */ into
				`test`.`_gh_ost_test_gho`
					(`id`, `t`)
				values
					(?, convert(? using utf8mb4))
2021-07-14 09:20:24 -04:00
Josh Bielick
b84af7bdc7
add failing test for #290, invalid utf8 char
this test assumes a latin1-encoded table with content containing bytes
in the \x80-\xFF, which are invalid single-byte characters in utf8 and
cannot be inserted in the altered table when the column containing these
characters is changed to utf8(mb4).

since these characters cannot be inserted, gh-ost fails.
2021-07-14 09:20:19 -04:00
Tim Vaillancourt
47d49c6b92
Add go mod (#935)
* Add a go.mod file

* run go mod vendor again

* Move to a well-supported ini file reader

* Remove GO111MODULE=off

* Use go 1.16

* Rename github.com/outbrain/golib -> github.com/openark/golib

* Remove *.go-e files

* Fix for `strconv.ParseInt: parsing "": invalid syntax` error

* Add test for '[osc]' section

Co-authored-by: Nate Wernimont <nate.wernimont@workiva.com>
2021-06-24 20:19:37 +02:00
Shlomi Noach
9bc508f068
Enum to varchar (#963)
* v1.1.0

* WIP: copying AUTO_INCREMENT value to ghost table
Initial commit: towards setting up a test suite

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

* greping for 'expect_table_structure' content

* Adding simple test for 'expect_table_structure' scenario

* adding tests for AUTO_INCREMENT value after row deletes. Should initially fail

* clear event beforehand

* parsing AUTO_INCREMENT from alter query, reading AUTO_INCREMENT from original table, applying AUTO_INCREMENT value onto ghost table if applicable and user has not specified AUTO_INCREMENT in alter statement

* support GetUint64

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

* minor update to test

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

* adding test for user defined AUTO_INCREMENT statement

* Generated column as part of UNIQUE (or PRIMARY) KEY

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

* skip analysis of generated column data type in unique key

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

* All MySQL DBs limited to max 3 concurrent/idle connections

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

* hooks: reporting GH_OST_ETA_SECONDS. ETA stored as part of migration context

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

* GH_OST_ETA_NANOSECONDS

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

* N/A denoted by negative value

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

* ETAUnknown constant

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

* Convering enum to varchar

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

* test: not null

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

* first attempt at setting enum-to-string right

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

* fix insert query

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

* store enum values, use when populating

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

* apply EnumValues to mapped column

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

* fix compilation error

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

* gofmt

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
2021-06-10 17:17:49 +02:00
Tim Vaillancourt
8f42dedef8
Add GO111MODULE=off to build.sh, use Golang 1.16 (#966)
* Add GO111MODULE=off to build.sh

* Use golang 1.16

* Update go version in README.md

* Add missing GO111MODULE=off

* Add missing GO111MODULE=off again

* Use go1.16.3 explicitly

* Use 1.16 for CI test

* Update min go version

* Use go 1.16.4
2021-05-25 13:22:28 +02:00
Shlomi Noach
36c669dd75
Generated column as part of UNIQUE (or PRIMARY) KEY (#919)
* v1.1.0

* WIP: copying AUTO_INCREMENT value to ghost table
Initial commit: towards setting up a test suite

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

* greping for 'expect_table_structure' content

* Adding simple test for 'expect_table_structure' scenario

* adding tests for AUTO_INCREMENT value after row deletes. Should initially fail

* clear event beforehand

* parsing AUTO_INCREMENT from alter query, reading AUTO_INCREMENT from original table, applying AUTO_INCREMENT value onto ghost table if applicable and user has not specified AUTO_INCREMENT in alter statement

* support GetUint64

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

* minor update to test

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

* adding test for user defined AUTO_INCREMENT statement

* Generated column as part of UNIQUE (or PRIMARY) KEY

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

* skip analysis of generated column data type in unique key

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
2021-05-24 20:16:49 +02:00
Tim Vaillancourt
c71dbf9ef3
Copy auto increment (#967)
* v1.1.0

* WIP: copying AUTO_INCREMENT value to ghost table
Initial commit: towards setting up a test suite

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

* greping for 'expect_table_structure' content

* Adding simple test for 'expect_table_structure' scenario

* adding tests for AUTO_INCREMENT value after row deletes. Should initially fail

* clear event beforehand

* parsing AUTO_INCREMENT from alter query, reading AUTO_INCREMENT from original table, applying AUTO_INCREMENT value onto ghost table if applicable and user has not specified AUTO_INCREMENT in alter statement

* support GetUint64

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

* minor update to test

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

* adding test for user defined AUTO_INCREMENT statement

Co-authored-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
2021-05-14 15:32:56 +02:00
Shlomi Noach
eaa1839a9b
Merge branch 'master' into test-latin1text 2020-02-15 09:27:10 +02:00
Shlomi Noach
30e2512b39
Merge branch 'master' into test-latin1text 2020-02-15 08:33:25 +02:00
Shlomi Noach
ef5cbed0ec
Merge branch 'master' into tests-varbinary 2020-02-15 08:33:12 +02:00
Shlomi Noach
4fd4be1308
Merge branch 'master' into tests-varbinary 2020-02-14 09:03:38 +02:00
Shlomi Noach
3cc41e24a8
Merge branch 'master' into test-latin1text 2020-02-14 09:02:53 +02:00
Shlomi Noach
6894916516
Merge branch 'master' into bigint-change-nullable 2020-02-14 09:00:05 +02:00
Shlomi Noach
a6d0d5ca26 not null for unique key test 2020-02-05 10:12:29 +02:00
Shlomi Noach
90ab2368dd graceful sleep; remove extra debug info 2019-08-11 15:21:04 +03:00
Shlomi Noach
1305ff6e01 debug info 2019-08-11 15:17:48 +03:00
Zach Moazeni
84fe34b22c
Bump default-retries to 3
There are some legitimate retries that can occur during testing. Namely
`logic.ExpectProcess()` (in `applier.go`). We'll look for a process that
does exist, but timing-wise doesn't have the `state` or `info` columns
populated.

Without this, the test will fail abruptly.
2019-06-10 09:24:03 -04:00
Shlomi Noach
4d7370529b Always use NO_AUTO_VALUE_ON_ZERO 2019-03-24 11:32:37 +02:00
Shlomi Noach
c37ea5dea0
Merge branch 'master' into tests-updates 2019-02-10 11:24:19 +02:00
Shlomi Noach
dd41d9a4b1 Testing nullable int 2019-01-03 11:18:07 +02:00
Shlomi Noach
6f673fa627
Merge branch 'master' into test-decimal 2018-11-28 10:20:07 +02:00
Shlomi Noach
00f5044f4f Testing DECIMAL datatype 2018-11-28 10:19:28 +02:00
Shlomi Noach
a7aa4eb2c0 adding latin1 2018-11-20 19:48:59 +02:00
Shlomi Noach
5d4d1cd31b more interesting sample data 2018-11-20 19:37:51 +02:00
Shlomi Noach
13b17b93c4 testing: convert to character set utf8mb4 2018-11-20 19:35:03 +02:00
Shlomi Noach
c32823c10a BIT datatype tests 2018-11-01 15:27:28 +02:00
Shlomi Noach
48e01ad39b Adding binary/varbinary tests 2018-10-29 10:09:15 +02:00
Shlomi Noach
02602302a0 more attempts at session time zone 2018-10-16 11:25:46 +03:00
Shlomi Noach
9512a2de40 forcinf UTC timezone 2018-10-16 10:30:19 +03:00
Shlomi Noach
b8e02df0fe reading original_sql_mode once 2018-10-16 10:22:59 +03:00
Shlomi Noach
789d247d83 localtests support throttle flag file 2018-10-16 09:47:30 +03:00
Shlomi Noach
2c6b79c4e7 test: add generated column 2018-05-22 14:09:48 +03:00
Shlomi Noach
03b8dadda6 added generated column rename test 2018-05-22 12:55:57 +03:00
Shlomi Noach
db871b42c4 Support for GENERATED (aka virtual) columns 2018-05-22 12:36:52 +03:00
Shlomi Noach
08637009a6 supporting modified sql_mode 2018-05-15 13:47:33 +03:00
Shlomi Noach
7d3514be08
Merge branch 'master' into incorrect-datetime-1970 2018-05-08 21:17:19 +03:00
Shlomi Noach
fb00a13871 Rejecting RENAME TO|AS 2018-05-06 11:19:03 +03:00
Shlomi Noach
2376c91704 Fix to long JSON values 2018-04-11 09:11:27 +03:00
Shlomi Noach
a17f2df359 more elaborate test 2018-03-08 07:25:52 +02:00
Shlomi Noach
b7eacbb75f testing gbk charset 2018-03-08 07:21:50 +02:00
Shlomi Noach
db9a12a6cf Added spatial (GEOMETRY, POINT) tests 2018-03-05 09:06:58 +02:00
Shlomi Noach
07a4a69049 quiet grep 2018-02-26 18:44:36 +02:00
Shlomi Noach
49b3917d2b skipping wording 2018-02-26 18:43:41 +02:00
Shlomi Noach
fa96757332 5.5 excluded tests 2018-02-26 18:41:42 +02:00
Shlomi Noach
9061d4fa5b 5.5 excluded tests 2018-02-26 18:38:39 +02:00
Shlomi Noach
ac7765eb9f 5.5 excluded tests 2018-02-26 18:35:55 +02:00
Shlomi Noach
242ee08363 5.5 excluded tests 2018-02-26 18:33:38 +02:00
Shlomi Noach
2d56df3304 5.5 excluded tests 2018-02-26 18:29:45 +02:00
Shlomi Noach
a9ead9e0f0 5.5 excluded tests 2018-02-26 18:24:42 +02:00
Shlomi Noach
df9dd49a47 support for ignored versions 2018-02-26 15:22:50 +02:00