41 Commits

Author SHA1 Message Date
Sveta Smirnova
75feef2f96 PT-2401 - pt-online-schema-change 'table does not exist' on macos
- Modified code, so it still checks table name but based on the lower_case_table_names option
2025-08-15 17:16:37 +03:00
Taehyung Lim
5989d2883c remove check to fix the 'table does not exist' problem when lower_case_table_names=2 is set 2025-05-19 20:09:04 +09:00
Sveta Smirnova
94bcfd2b69 PT-2340 - Support MySQL 8.4
- Updated documentation
2024-09-03 20:05:26 +03:00
Sveta Smirnova
ab6e5aa1bb PT-1717 - resume pt-online-schema-change if it's interrupted
- Added options --history, --history-table, and --binary-index
- Added code that creates history table to store pt-osc progress
2024-02-20 20:08:20 +03:00
Sveta Smirnova
3e1e9b8425 PT-1860 make pt-osc respect case insesitive lookup on Windows and osx #516
- Run update-modules
- Adjusted fix, so it does not create extra variable to hold $EVAL_ERROR
- Adjusted test case, so it runs on Linux
2023-11-09 17:16:43 +03:00
Sveta Smirnova
e4583b0542 Merge branch '3.x' into HEAD 2023-11-09 13:43:17 +03:00
Ivan Kruglov
8d38d0900a PT-1860 make pt-osc respect case insesitive lookup on Windows and osx 2023-11-08 20:16:31 +01:00
Viktor Szépe
2bd40d8c39 Remove trailing spaces (#665)
* Remove trailing spaces

* PR-665 -  Remove trailing spaces

- Updated not stable test t/pt-online-schema-change/preserve_triggers.t
- Updated utilities in bin directory

* PR-665 -  Remove trailing spaces

- Fixed typos

* PR-665 -  Remove trailing spaces

- Fixed typos

---------

Co-authored-by: Sveta Smirnova <sveta.smirnova@percona.com>
2023-09-06 01:15:12 +03:00
hanzhongzi
b980c6e149 Fix An error occurred when I migrated... (#614)
HI, i am back
An error occurred when I migrated data from MySQL to OceanBase:【 DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near ':= @OLD_SQL_MODE, @@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE /' at line 1 [for Statement "/!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */"] at /usr/bin/pt-archiver line 1932.】

I'm not a Perl programmer. But by reading the source code and making some changes, the migration was done successfully, so I submit this report


- [x] The contributed code is licensed under GPL v2.0
- [x] Contributor Licence Agreement (CLA) is signed
- [x] util/update-modules has been ran
- [x] Not involved Documention updated
- [x] Not involved Test suite update
2023-06-26 14:54:13 +03:00
Sveta Smirnova
642253ce52 PT-2156 Fix tests for lib (#606)
* PT-2156 - Fix tests for lib

- Fixed tests broken for lib/TableParser.pm after fix for PT-1059
- Updated tests for lib/TableParser.pm that are broken due to SHOW CREATE TABLE output format change in 8.0
- Updated modules for all tools that use lib/TableParser.pm

* Revert "Fixed pt-archiver tests"

This reverts commit a3ab87b12e.

This commit wa needed, because removed code in sandbox/slave_channels.sql broked the test. Proper fix would be to do not remove channel names rather than chaging the test. So revertig it.

* PT-2156 - Fix tests for lib

- Updated test t/lib/TableChecksum.t so it reflects changes, introduced in the fix for PT-2016
- Updated test t/lib/RowChecksum.t so it reflects changes added to in the fix for PT-2138: UTF8 support
- Uncommented SQL in sandbox/slave_channels.sql that made t/lib/MasterSlave.t to fail
- Added check for undef into t/pt-archiver/archive_using_channels.t
- Updated lib/Cxn.pm so it uses $dbh->{Active} after issue with the ping() call, reported at https://github.com/perl5-dbi/DBD-mysql/issues/306

* PT-2156 - Fix tests for lib

- Impoved the fix for PT-2016, so it does not files with keys with USING keyword
- Added brackets to expression in lib/TableNibbler.pm, so it does not crap query wit many indexes with OR keyword
- Adjusted test t/lib/TableNibbler.t, so it reflects above chages
- Modified lib/Cxn.pm, so it has workaround for https://github.com/perl5-dbi/DBD-mysql/issues/306 , introduced in DBD::mysql 4.0.50
- Updated tests: added debugging code and cleanups
- Updated modules for tools
2023-03-27 14:18:26 +03:00
Sveta Smirnova
bfc00b93a8 PT-2160 fix tests for pt online schema change (#602)
* PT-2160 - Fix tests for pt-online-schema-change

Re-enabled tests after MySQL bug #89441 fix in 8.0.14 and later
Updated t/pt-online-schema-change/samples/basic_no_fks_innodb.sql, so its unique index is NOT NULL
Added synchonizations when tests are waiting for too long due to slave catch up
Added innodb_directories option for t/pt-online-schema-change/pt-244.t

* PT-2160 - Fix tests for pt-online-schema-change
PT-2048 - pt-osc spans excessive connections to the replica when executing in the source

t/pt-online-schema-change/slave_lag.t was failing due to PT-2048. I added code that reuses already created connections when checks for slave in the wait loop. It fixes slave_lag.t too.
I also added that prints more detailed error when fails to connect to the replica.

* PT-2160 - Fix tests for pt-online-schema-change

Modified t/pt-online-schema-change/slave_lag.t, so it runs and clean ups faster.

* PT-2160 - Fix tests for pt-online-schema-change

Modified t/pt-online-schema-change/pt-1455.t, so it runs and clean ups faster.

* PT-2160 - Fix tests for pt-online-schema-change

Fixed search for HASH and BTREE keys broken by fix for PT-2123
Updated modules for pt-archiver
Fixed die message for sandbox/start-sandbox
Added global_grants table to list of exceptions for the ok function in lib/Sandbox.pm
Added wait_for_slaves to bugs.t, so changes on the source are copied to replica before pt-osc starts working
Updated PXC tests
Added wait_for_slaves to pt-1455.t
Fixed regular expression in pt-229.t, so it works with both 5.x and 8.0 versions
Added innodb_directories option for pt-244.t, so it does not fail on 8.0
Modified slave_lag.t, so it is more stable and slow enough, so pt-osc can print message about delayed replicas
2023-02-27 01:19:11 +03:00
Sveta Smirnova
f9726e75cc PT-1059 tools cannot parse index names containing newlines (#578)
* PT-1059 - Tools can't parse index names containing newlines

Fixed regular expressions in TableParser.
Added test case, including test for new lines in the column name

* PT-1059 - Tools can't parse index names containing newlines

Disabled pt-1637.t until PT-2174 is fixed.
Updated number of tables in b/t/pt-table-checksum/issue_1485195.t

* Patch newlines in table columns (#369)

Will accept this change as part of the fix for PT-1059 - Tools cannot parse index names containing new lines. We will later fix the issue with the patch ourselves.

mysql 5.6.40 allows newlines in column names however the following code:

my @defs = $ddl =~ m/^(\s+`.*?),?$/gm;

breaks due to it detecting newlines as line ends. The 'm' argument at the end does this by auto-detecting lines by newline characters.

To correct this issue I've made use of zero-length assertions known as " positive lookback"

https://www.regular-expressions.info/lookaround.html

what does it do?

m/(?:(?<=,\n)|(?<=\(\n))(\s+`(?:.|\n)+?`.+?),?\n/g;

TLDR:

Treat the string as one long string and don't treat \n as the end of a line.

look for (\s+`(?:.|\n)+?`.+?),?\n

if one of those matches look at what precedes the string

if it's ',\n' or ')\n' the string matches. Only save what's in (\s+`(?:.|\n)+?`.+?),?\n

m/ is declaring this a matching regex.

(?:(?<=,\n)|(?<=(\n)) This is an OR statement including two look-behind clauses. The ?: tells the enclosing parentheses to not store the result as a variable. I've put the two look-behinds in this OR statement below this line:

(?<=,\n) Look behind the matched string for a comma followed by a newline, the comma must be there for this look behind to match.

(?<=(\n) Look behind the matched string for a open parentheses followed by a newline, the open parentheses must be there.

(\s+`(?:.|\n)+?`.+?),?\n This is the actual match. Match newline character followed by one or more spaces followed by back-tick followed by a character which can be any character or a newline one or more times, but don't be greedy and take the rest of the match into consideration. Followed by a back tick and any character one or more times. This match stops where there is a comma or failing that a newline following a back tick and some characters.

,?\n match a comma that may not be there followed by a newline.
/g don't stop if this pattern matches keep looking for more patterns to the end of the string.

* PT-1059 - Tools can't parse index names containing newlines

Placed fix from PR-369 into proper place and created test case for this fix.

---------

Co-authored-by: geneguido <31323560+geneguido@users.noreply.github.com>
2023-02-02 17:09:13 +03:00
Carlos Salguero
e570cecbab PT-1914 Column data lost when 'Generated' is in the column comment (#482)
* PMM-1914 Fixed column parsing having generated

Fixed table parser code that errouneously considered a column as
generated when the default was empty DEFAULT '' and the COMMENT had
the word 'Generated'.

* PMM-1914 Updated TableParser in all programs

* PT-1914 Updated changelog

* PT-1914 Added test
2021-03-09 11:46:05 -03:00
Carlos Salguero
602c1f0ea2 PT-1570 pt-archiver fails to detect columns with the word GENERATED as part of the comment 2018-06-14 14:15:20 -03:00
Carlos Salguero
b51d09d811 PT-202 pt-online-schema-change fails with virtual columns
Modified TableParser to ignore GENERATED columns from the columns list
used to construct SELECTs/INSERTs
2017-10-05 15:19:57 -03:00
Carlos Salguero
c375fd068b PT-193 Fixed regex in TableParser
TableParser's parse function was failing while trying to lowercase
column names in the provided 'SHOW CREATE TABLE'.
The problem was it was trying to lowercase everything between backticks
but lines like these:

`field_name` int comment "here is a ` in the comment"
`second_field_name` int

made the original regex to fail, matching `in the coment"` as an
expression to be lowercased while second_file_name was considered as
outside backticks.
2017-08-14 21:01:30 -03:00
frank-cizmich
2134e3f1b4 Merge branch 'handle-literal-backticks-lp-1462904' into release-2.2.15 2015-09-08 15:45:39 -03:00
Daniel Nichter
32dba7e7f2 Test and fix parsing literal backticks in TableParser:parse() (lp 1462904). 2015-06-25 13:20:00 -07:00
Daniel Nichter
7764955209 Handle losing replica connection in check_slave_tables(). Add save eval error in TableParser::check_table() in check_table_error. 2015-06-24 18:20:02 -07:00
Brian Fraser
a9661d09eb Fix for bug 1099836: pt-online-schema-change fails with "Duplicate entry" on MariaDB 2013-01-30 12:33:42 -03:00
Daniel Nichter
feab2f0925 s/Percona Inc/Percona Ireland Ltd/g 2013-01-02 17:19:16 -07:00
Brian Fraser
511a402911 Merged fix-1047335-crashed-tables 2012-11-09 13:48:17 -03:00
Daniel Nichter
ddda26fb7f Merged fix-i26211-1058285-821722-implicit-ansi_quotes 2012-11-05 10:57:11 -07:00
Daniel Nichter
a0cd575c95 Merge fix-1009510-1039569-ptc-check-table-on-replicas 2012-11-05 10:54:21 -07:00
Daniel Nichter
0cffac95de Simplify how ptc checks slave tables. Move that code from TableParser to pt_table_checksum::check_slave_tables. Change --[no]check-replicate-table-columns to --[no]check-slave-tables. Move tests to error_handling.t. 2012-11-02 15:22:47 -06:00
Daniel Nichter
949cf31037 Set sql_mode='' before SHOW CREATE TABLE--don't bother with replacing certain values. Move and rewrite tests to ansi_quotes.t. 2012-11-01 11:31:31 -06:00
Brian Fraser
35f5f8d1e4 Fix for 1047335: SchemaIterator fails when it encounters a crashed table 2012-10-30 18:35:49 -03:00
Daniel Nichter
f50d8e9120 Remove TableParser::check_table() privs check (re bug 1036747). 2012-10-19 17:14:07 -06:00
Brian Fraser
2bcc380c68 Fix for customer issue 26211 ($avg_rate might be zero), plus a fix for bug 1058285 (also related to 26211), and an emergent part of 821722: Several sql_modes implicitly turn on ANSI_QUOTES 2012-10-17 15:52:15 -03:00
Brian Fraser
c444384c6c Fix for 1009510 and 1039569: pt-table-checksum doesn't check that tables exist on all replicas / shouldn't die if it can't create db/table 2012-08-23 03:14:14 -03:00
Brian Fraser
64c14e18f4 Remove MySQL 4.0 checks from several libraries, losing the VP dependency 2012-07-19 13:19:26 -03:00
Brian Fraser
f30c50be44 Updated the fles in /lib to use the new VersionParser 2012-07-11 15:10:33 -03:00
Baron Schwartz
8e9dfeec68 Some fixes for ANSI SQL quotes 2012-06-07 14:53:47 -04:00
Baron Schwartz
f7c97e749e Make TableParser.pm handle ANSI quotes 2012-06-07 00:59:59 -04:00
Daniel Nichter
8e9e8eb7a6 Test and fix space-flattening bug. 2012-02-21 13:22:56 -07:00
Daniel Nichter
88304e69fb Replace MKDEBUG with PTDEBUG in modules. 2012-01-19 12:46:56 -07:00
Daniel Nichter
006b93ddf9 Create ReplicaLagLimiter. Replace --max-lag, --check-interval, and --check-slave-lag with --replica-lag and --replica-lag-dsn. Use TableParser::get_table_status() in NibbleItertor. Eval SHOW TABLE STATUS. Auto-add "n" (name) part to parsed DSNs. 2011-09-16 17:35:40 -06:00
Daniel Nichter
756142c1d1 Remove MySQLDump; move get_create_table() and get_table_status() to TableParser and remove saving results in each function. 2011-09-15 09:39:32 -06:00
Daniel Nichter
b805f7c92d Remove $Revision$ and finish re-branding modules. Rename MaatkitTest.pm to PerconaTest.pm. Put copyrights on one line. 2011-07-12 15:47:07 -06:00
Daniel Nichter
55c69ffbc1 Move module docu to work for NaturalDocs. 2011-07-02 12:29:08 -06:00
Daniel Nichter
6c501128e6 Add lib/, t/lib/, and sandbox/. All modules are updated and passing on MySQL 5.1. 2011-06-24 11:22:06 -06:00