summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <grooverdan@users.sourceforge.net>2015-04-14 12:43:50 +1000
committerDaniel Black <grooverdan@users.sourceforge.net>2015-04-14 12:43:50 +1000
commit97e0aeaf72cde117b8d9551f68d407fa13aafbe1 (patch)
tree8ca6fd60518a70aebeb24ba5dd32368c760ced54
parent808608cb3f4e10ba81679c94b2a299a32cf5e448 (diff)
downloadmariadb-git-97e0aeaf72cde117b8d9551f68d407fa13aafbe1.tar.gz
mysqlcheck fix-view-algorithm -> upgrade-views
Change mysqlcheck option to upgrade-views={NO,YES,FROM_MYSQL} mysql_upgrade now runs upgrade-views=yes to perform a checksum of all views and add mariadb-version by default. upgrade-views=from_mysql if MySQL is detected as teh origin version.
-rw-r--r--client/client_priv.h1
-rw-r--r--client/mysql_upgrade.c13
-rw-r--r--client/mysqlcheck.c51
-rw-r--r--mysql-test/r/mysql_upgrade.result16
-rw-r--r--mysql-test/r/mysql_upgrade_view.result8
-rw-r--r--mysql-test/t/mysql_upgrade_view.test6
6 files changed, 65 insertions, 30 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index e206804d057..a66c3883654 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -79,6 +79,7 @@ enum options_client
OPT_SLAP_COMMIT,
OPT_SLAP_DETACH,
OPT_SLAP_NO_DROP,
+ OPT_UPGRADE_VIEWS,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_AUTO_VERTICAL_OUTPUT,
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 8fd28f2ab41..98021dda377 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -784,19 +784,22 @@ static my_bool is_mysql()
static int run_mysqlcheck_views(void)
{
- if (!is_mysql())
+ const char *upgrade_views="--upgrade-views=YES";
+ if (is_mysql())
{
- verbose("Phase %d/%d: Fixing views - skipped - not required", phase++, phases_total);
- return 0;
+ upgrade_views="--upgrade-views=FROM_MYSQL";
+ verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total);
}
- verbose("Phase %d/%d: Fixing views", phase++, phases_total);
+ else
+ verbose("Phase %d/%d: Fixing views", phase++, phases_total);
+
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
"--no-defaults",
ds_args.str,
"--all-databases",
- "--fix-view-algorithm",
+ upgrade_views,
"--skip-fix-tables",
opt_verbose ? "--verbose": "",
opt_silent ? "--silent": "",
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 2f67452a2d5..dfc743d5493 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -43,7 +43,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0,
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
- opt_fix_view_algorithm= 0, opt_fix_tables= 1;
+ opt_fix_tables= 1;
static my_bool opt_write_binlog= 1, opt_flush_tables= 0;
static uint verbose = 0, opt_mysql_port=0;
static int my_end_arg;
@@ -58,6 +58,20 @@ static uint opt_protocol=0;
enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
+typedef enum {
+ UPGRADE_VIEWS_NO=0,
+ UPGRADE_VIEWS_YES=1,
+ UPGRADE_VIEWS_FROM_MYSQL=2,
+ UPGRADE_VIEWS_COUNT
+} enum_upgrade_views;
+const char *upgrade_views_opts[]=
+{"NO", "YES", "FROM_MYSQL", NullS};
+TYPELIB upgrade_views_typelib=
+ { array_elements(upgrade_views_opts) - 1, "",
+ upgrade_views_opts, NULL };
+static enum_upgrade_views opt_upgrade_views= UPGRADE_VIEWS_NO;
+static char *opt_upgrade_views_str= NullS;
+
static struct my_option my_long_options[] =
{
{"all-databases", 'A',
@@ -197,9 +211,12 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
- {"fix-view-algorithm", 'y',
- "Fix view algorithm view field if it is not new MariaDB view.",
- &opt_fix_view_algorithm, &opt_fix_view_algorithm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"upgrade-views", OPT_UPGRADE_VIEWS,
+ "Repairs/Upgrades views. 'No' (default) doesn't do anything to views. "
+ "'Yes' repairs the checksum and adds a MariaDB version to the frm table defination (if missing)."
+ "Using 'from_mysql' will, when upgrading from MySQL, and ensure the view algorithms are the"
+ "same as what they where previously.",
+ &opt_upgrade_views_str, &opt_upgrade_views_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"fix-tables", 'Y',
"Fix tables. Usually the default however mysql_upgrade will run with --skip-fix-tables.",
&opt_fix_tables, &opt_fix_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
@@ -342,6 +359,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V':
print_version(); exit(0);
break;
+ case OPT_UPGRADE_VIEWS:
+ if (argument == NULL)
+ opt_upgrade_views= UPGRADE_VIEWS_NO;
+ else
+ {
+ opt_upgrade_views= (enum_upgrade_views)
+ (find_type_or_exit(argument, &upgrade_views_typelib, opt->name)-1);
+ }
+ break;
case OPT_MYSQL_PROTOCOL:
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
opt->name);
@@ -372,19 +398,19 @@ static int get_options(int *argc, char ***argv)
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error);
- if (what_to_do==DO_REPAIR && !(opt_fix_view_algorithm || opt_fix_tables))
+ if (what_to_do==DO_REPAIR && !(opt_upgrade_views || opt_fix_tables))
{
- fprintf(stderr, "Error: %s doesn't support repair command without either fix-view-algorithm or fix-tables specified.\n",
+ fprintf(stderr, "Error: %s doesn't support repair command without either upgrade-views or fix-tables specified.\n",
my_progname);
exit(1);
}
- if (opt_fix_view_algorithm && what_to_do!=DO_REPAIR)
+ if (opt_upgrade_views && what_to_do!=DO_REPAIR)
{
if (!what_to_do)
what_to_do= DO_REPAIR;
else
{
- fprintf(stderr, "Error: %s doesn't support non-repair command with option fix-view-algorithm.\n",
+ fprintf(stderr, "Error: %s doesn't support non-repair command with option upgrade-views.\n",
my_progname);
exit(1);
}
@@ -651,7 +677,7 @@ static int process_all_tables_in_db(char *database)
while ((row = mysql_fetch_row(res)))
{
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0) &&
- opt_fix_view_algorithm)
+ opt_upgrade_views)
tot_views_length+= fixed_name_length(row[0]) + 2;
else if (opt_fix_tables)
tot_length+= fixed_name_length(row[0]) + 2;
@@ -674,7 +700,7 @@ static int process_all_tables_in_db(char *database)
{
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
{
- if (!opt_fix_view_algorithm)
+ if (!opt_upgrade_views)
continue;
views_end= fix_table_name(views_end, row[0]);
*views_end++= ',';
@@ -703,7 +729,7 @@ static int process_all_tables_in_db(char *database)
/* Skip views if we don't perform renaming. */
if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
{
- if (!opt_fix_view_algorithm)
+ if (!opt_upgrade_views)
continue;
view= TRUE;
}
@@ -864,7 +890,8 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view)
if (opt_quick) end = strmov(end, " QUICK");
if (opt_extended) end = strmov(end, " EXTENDED");
if (opt_frm) end = strmov(end, " USE_FRM");
- if (opt_fix_view_algorithm && view) end = strmov(end, " FROM MYSQL");
+ if (opt_upgrade_views==UPGRADE_VIEWS_FROM_MYSQL && view)
+ end = strmov(end, " FROM MYSQL");
break;
case DO_ANALYZE:
op= (opt_write_binlog) ? "ANALYZE" : "ANALYZE NO_WRITE_TO_BINLOG";
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index 78e49362032..502242a9845 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -1,5 +1,5 @@
Run mysql_upgrade once
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -37,7 +37,7 @@ OK
Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
Force should run it regardless of wether it's been run before
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -75,7 +75,7 @@ OK
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
Run mysql_upgrade with password protected account
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -118,7 +118,7 @@ Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -162,7 +162,7 @@ CREATE PROCEDURE testproc() BEGIN END;
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -209,7 +209,7 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
Run mysql_upgrade with all privileges on a user
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -259,7 +259,7 @@ OK
#
# Droping the previously created mysql_upgrade_info file..
# Running mysql_upgrade with --skip-write-binlog..
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -320,7 +320,7 @@ GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
CREATE PROCEDURE test.pr() BEGIN END;
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
diff --git a/mysql-test/r/mysql_upgrade_view.result b/mysql-test/r/mysql_upgrade_view.result
index aa4841c213a..aa393190e82 100644
--- a/mysql-test/r/mysql_upgrade_view.result
+++ b/mysql-test/r/mysql_upgrade_view.result
@@ -4,7 +4,11 @@ drop view if exists t1,v1,v2,v3,v4,v1badcheck;
create table t1(a int);
create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50));
flush tables;
-Phase 1/4: Fixing views - skipped - not required
+Phase 1/4: Fixing views
+test.v1 OK
+test.v1badcheck OK
+test.v2 OK
+test.v3 OK
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
@@ -118,7 +122,7 @@ show create view v4;
View Create View character_set_client collation_connection
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
MySQL upgrade detected
-Phase 1/4: Fixing views
+Phase 1/4: Fixing views from mysql
test.v1 OK
test.v2 OK
test.v3 OK
diff --git a/mysql-test/t/mysql_upgrade_view.test b/mysql-test/t/mysql_upgrade_view.test
index 9bd86abd724..1b491a71227 100644
--- a/mysql-test/t/mysql_upgrade_view.test
+++ b/mysql-test/t/mysql_upgrade_view.test
@@ -21,7 +21,7 @@ flush tables;
--replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --force 2>&1
-# "Phase 1/4: Fixing views - skipped - not required" expected
+# "Phase 1/4: Fixing views" expected (without from_mysql)
show create view v1;
show create view v2;
@@ -89,7 +89,7 @@ show create view v2;
show create view v3;
show create view v4;
-# here we test the fixing views does occur
+# here we test the fixing views from mysql to occur
--replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --force 2>&1
@@ -123,7 +123,7 @@ drop view if exists v1,v2,v3;
flush tables;
# check of binlog
---exec $MYSQL_CHECK --write-binlog --fix-view-algorithm --skip-fix-tables --all-databases 2>&1
+--exec $MYSQL_CHECK --write-binlog --upgrade-views=FROM_MYSQL --skip-fix-tables --all-databases 2>&1
--source include/show_binlog_events.inc