1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

ALTER TABLE and replication should convert old row_end timestamps to new timestamp range

MDEV-32188 make TIMESTAMP use whole 32-bit unsigned range

- Added --update-history option to mariadb-dump to change 2038
  row_end timestamp to 2106.
- Updated ALTER TABLE ... to convert old row_end timestamps to
  2106 timestamp for tables created before MariaDB 11.4.0.
- Fixed bug in CHECK TABLE where we wrongly suggested to USE REPAIR
  TABLE when ALTER TABLE...FORCE is needed.
- mariadb-check printed table names that where used with REPAIR TABLE but
  did not print table names used with ALTER TABLE or with name repair.
  Fixed by always printing a table that is fixed if --silent is not
  used.
- Added TABLE::vers_fix_old_timestamp() that will change max-timestamp
  for versioned tables when replication from a pre-11.4.0 server.

A few test cases changed. This is caused by:
- CHECK TABLE now prints 'Please do ALTER TABLE... instead of
  'Please do REPAIR TABLE' when there is a problem with the information
  in the .frm file (for example a very old frm file).
- mariadb-check now prints repaired table names.
- mariadb-check also now prints nicer error message in case ALTER TABLE
  is needed to repair a table.
This commit is contained in:
Monty
2023-12-19 17:51:23 +02:00
committed by Sergei Golubchik
parent c4cad8d50c
commit 24c57165d5
37 changed files with 438 additions and 110 deletions

View File

@@ -801,7 +801,7 @@ static int fix_table_storage_name(const char *name)
name, name + 9);
rc= run_query(qbuf, 1);
if (verbose)
if (!opt_silent)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
DBUG_RETURN(rc);
}
@@ -817,7 +817,7 @@ static int fix_database_storage_name(const char *name)
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %`s UPGRADE DATA DIRECTORY "
"NAME", name);
rc= run_query(qbuf, 1);
if (verbose)
if (!opt_silent)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
DBUG_RETURN(rc);
}
@@ -840,8 +840,8 @@ static int rebuild_table(char *name)
fprintf(stderr, "Error: %s\n", mysql_error(sock));
rc= 1;
}
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "FIXED");
if (!opt_silent)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
my_free(query);
DBUG_RETURN(rc);
}
@@ -1035,7 +1035,6 @@ static void __attribute__((noinline)) print_result()
MYSQL_RES *res;
MYSQL_ROW row;
char prev[(NAME_LEN+9)*3+2];
char prev_alter[MAX_ALTER_STR_SIZE];
size_t length_of_db= strlen(sock->db);
my_bool found_error=0, table_rebuild=0;
DYNAMIC_ARRAY *array4repair= &tables4repair;
@@ -1044,7 +1043,6 @@ static void __attribute__((noinline)) print_result()
res = mysql_use_result(sock);
prev[0] = '\0';
prev_alter[0]= 0;
while ((row = mysql_fetch_row(res)))
{
int changed = strcmp(prev, row[0]);
@@ -1061,19 +1059,13 @@ static void __attribute__((noinline)) print_result()
strcmp(row[3],"OK"))
{
if (table_rebuild)
{
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else
insert_table_name(&tables4rebuild, prev, length_of_db);
}
insert_table_name(&tables4rebuild, prev, length_of_db);
else
insert_table_name(array4repair, prev, length_of_db);
}
array4repair= &tables4repair;
found_error=0;
table_rebuild=0;
prev_alter[0]= 0;
if (opt_silent)
continue;
}
@@ -1083,20 +1075,28 @@ static void __attribute__((noinline)) print_result()
{
/*
If the error message includes REPAIR TABLE, we assume it means
we have to run upgrade on it. In this case we write a nicer message
we have to run REPAIR on it. In this case we write a nicer message
than "Please do "REPAIR TABLE""...
If the message inclused ALTER TABLE then there is something wrong
with the table definition and we have to run ALTER TABLE to fix it.
Write also a nice error message for this csae.
*/
if (!strcmp(row[2],"error") && strstr(row[3],"REPAIR "))
{
printf("%-50s %s", row[0], "Needs upgrade");
printf("%-50s %s", row[0], "Needs upgrade with REPAIR");
array4repair= strstr(row[3], "VIEW") ? &views4repair : &tables4repair;
}
else if (!strcmp(row[2],"error") && strstr(row[3],"ALTER TABLE"))
{
printf("%-50s %s", row[0], "Needs upgrade with ALTER TABLE FORCE");
array4repair= &tables4rebuild;
}
else
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
if (opt_auto_repair && strcmp(row[2],"note"))
if (strcmp(row[2],"note"))
{
found_error=1;
if (opt_auto_repair && strstr(row[3], "ALTER TABLE") != NULL)
if (strstr(row[3], "ALTER TABLE"))
table_rebuild=1;
}
}
@@ -1109,12 +1109,7 @@ static void __attribute__((noinline)) print_result()
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
{
if (table_rebuild)
{
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, prev_alter);
else
insert_table_name(&tables4rebuild, prev, length_of_db);
}
insert_table_name(&tables4rebuild, prev, length_of_db);
else
insert_table_name(array4repair, prev, length_of_db);
}