From 2b448e73371f464e0361fe18073ce774cbf76115 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 17 Apr 2025 10:51:48 +0300 Subject: [PATCH] print_ddl_recovery_log.pl ; Print content of the ddl_recovery.log --- .gitignore | 1 + scripts/CMakeLists.txt | 4 +- scripts/print_ddl_recovery_log.pl.in | 120 +++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100755 scripts/print_ddl_recovery_log.pl.in diff --git a/.gitignore b/.gitignore index a8f67d111c3..199776274e7 100644 --- a/.gitignore +++ b/.gitignore @@ -133,6 +133,7 @@ scripts/mysqld_safe scripts/mysqldumpslow scripts/mysqlhotcopy scripts/mytop +scripts/print_ddl_recovery_log.pl scripts/wsrep_sst_backup scripts/wsrep_sst_common scripts/wsrep_sst_mysqldump diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index a136125b5ae..2626aebcff3 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -272,7 +272,7 @@ IF(WIN32) # The resulting files will have .pl extension (those are perl scripts) # Input files with pl.in extension - SET(PLIN_FILES mysql_config) + SET(PLIN_FILES mysql_config print_ddl_recovery_log) # Input files with .sh extension SET(SH_FILES mysql_convert_table_format mysqld_multi mysqldumpslow @@ -331,6 +331,8 @@ ELSE() # Configure this one, for testing, but do not install it. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_config.pl.in ${CMAKE_CURRENT_BINARY_DIR}/mysql_config.pl ESCAPE_QUOTES @ONLY) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/print_ddl_recovery_log.pl.in + ${CMAKE_CURRENT_BINARY_DIR}/print_ddl_recovery_log.pl ESCAPE_QUOTES @ONLY) # On Unix, most of the files end up in the bin directory SET(BIN_SCRIPTS msql2mysql diff --git a/scripts/print_ddl_recovery_log.pl.in b/scripts/print_ddl_recovery_log.pl.in new file mode 100755 index 00000000000..6e300402cae --- /dev/null +++ b/scripts/print_ddl_recovery_log.pl.in @@ -0,0 +1,120 @@ +#!@PERL_PATH@ +use warnings; +use Fcntl qw(:seek); +use Getopt::Long; + +# Constants based on the source +use constant { + BLOCK_SIZE => 4096, + DDL_LOG_ACTION_TYPE_POS => 1, + DDL_LOG_PHASE_POS => 2, + DDL_LOG_NEXT_ENTRY_POS => 4, + DDL_LOG_FLAG_POS => 8, + DDL_LOG_XID_POS => 10, + DDL_LOG_UUID_POS => 18, + MY_UUID_SIZE => 16, + DDL_LOG_ID_POS => 34, + DDL_LOG_END_POS => 42, + NAME_START_POS => 56, +}; + +package main; + +my @log_entrys= ("Unknown", "EXECUTE", "ENTRY", "IGNORED" ); +my @log_actions= ("Unknown", "DELETE_FRM", "RENAME_FRM", "REPLACE", "EXCHANGE", + "RENAME_TABLE", "RENAME_VIEW", "DROP_INIT", "DROP_TABLE", + "DROP_VIEW", "DROP_TRIGGER", "DROP_DB", "CREATE_TABLE", + "CREATE_VIEW", "DELETE_TMP_FILE", "CREATE_TRIGGER", + "ALTER_TABLE", "STORE_QUERY"); + +$opt_skip_not_used= undef; +$opt_skip_ignored= undef; + +sub usage +{ + print < BLOCK_SIZE); + $str = substr($block, $pos, $len); + $pos += $len+1; + push @strings, $str; + } + + print "\n" if ($entry_num > 1); + print "=== DDL Log Entry $entry_num ===\n"; + $entry_num++; + + print "Entry Type : $log_entrys[$entry_type]\n"; + next if ($opt_skip_not_used && $entry_type == 0); + next if ($opt_skip_ignored && $entry_type >= 3); + + print "Action Type : $log_actions[$action_type]\n"; + print "Phase : $phase\n"; + print "Next Entry : $next_entry\n"; + print "Flags : $flags\n"; + print "XID : $xid\n"; + print "UUID : $uuid\n"; + print "Unique ID : $unique_id\n"; + print "Handler Name : $strings[0]\n"; + print "DB : $strings[1]\n"; + print "Name : $strings[2]\n"; + print "From Handler : $strings[3]\n"; + print "From DB : $strings[4]\n"; + print "From Name : $strings[5]\n"; + print "Temp/Extra : $strings[6]\n"; +} + +close $fh;