Commit 1387e715 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5281 Partitioning issue after upgrade from 10.0.3-1 to 10.0.5-1

merged from 5.6:
Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING
Bug#16589511: MYSQL_UPGRADE FAILS TO WRITE OUT ENTIRE ALTER TABLE ... ALGORITHM= ... STATEMENT
Bug#16274455: CAN NOT ACESS PARTITIONED TABLES WHEN DOWNGRADED FROM 5.6.11 TO 5.6.10

plus minor changes from 5.6, mainly comments
parent 44db9c41
/*
Copyright (c) 2001, 2012, Oracle and/or its affiliates.
Copyright (c) 2010, 2011, Monty Program Ab.
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -18,7 +18,7 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
#define CHECK_VERSION "2.7.2"
#define CHECK_VERSION "2.7.2-MariaDB"
#include "client_priv.h"
#include <m_ctype.h>
......@@ -32,6 +32,10 @@
#define EX_USAGE 1
#define EX_MYSQLERR 2
/* ALTER instead of repair. */
#define MAX_ALTER_STR_SIZE 128 * 1024
#define KEY_PARTITIONING_CHANGED_STR "KEY () partitioning changed"
static MYSQL mysql_connection, *sock = 0;
static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
opt_compress = 0, opt_databases = 0, opt_fast = 0,
......@@ -47,7 +51,7 @@ static char *opt_password = 0, *current_user = 0,
*default_charset= 0, *current_host= 0;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static int first_error = 0;
DYNAMIC_ARRAY tables4repair, tables4rebuild;
DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds;
static char *shared_memory_base_name=0;
static uint opt_protocol=0;
......@@ -816,6 +820,7 @@ static void print_result()
MYSQL_RES *res;
MYSQL_ROW row;
char prev[(NAME_LEN+9)*2+2];
char prev_alter[MAX_ALTER_STR_SIZE];
uint i;
my_bool found_error=0, table_rebuild=0;
DBUG_ENTER("print_result");
......@@ -823,6 +828,7 @@ static void print_result()
res = mysql_use_result(sock);
prev[0] = '\0';
prev_alter[0]= 0;
for (i = 0; (row = mysql_fetch_row(res)); i++)
{
int changed = strcmp(prev, row[0]);
......@@ -839,12 +845,18 @@ static void print_result()
strcmp(row[3],"OK"))
{
if (table_rebuild)
insert_dynamic(&tables4rebuild, (uchar*) prev);
{
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
else
insert_dynamic(&tables4rebuild, (uchar*) prev);
}
else
insert_dynamic(&tables4repair, (uchar*) prev);
insert_dynamic(&tables4repair, prev);
}
found_error=0;
table_rebuild=0;
prev_alter[0]= 0;
if (opt_silent)
continue;
}
......@@ -861,7 +873,7 @@ static void print_result()
printf("%-50s %s", row[0], "Needs upgrade");
else
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
if (strcmp(row[2],"note"))
if (opt_auto_repair && strcmp(row[2],"note"))
{
found_error=1;
if (opt_auto_repair && strstr(row[3], "ALTER TABLE") != NULL)
......@@ -877,9 +889,14 @@ static void print_result()
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
{
if (table_rebuild)
insert_dynamic(&tables4rebuild, (uchar*) prev);
{
if (prev_alter[0])
insert_dynamic(&alter_table_cmds, prev_alter);
else
insert_dynamic(&tables4rebuild, prev);
}
else
insert_dynamic(&tables4repair, (uchar*) prev);
insert_dynamic(&tables4repair, prev);
}
mysql_free_result(res);
DBUG_VOID_RETURN;
......@@ -999,7 +1016,9 @@ int main(int argc, char **argv)
(my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,
64, MYF(0)) ||
my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,
64, MYF(0))))
64, MYF(0)) ||
my_init_dynamic_array(&alter_table_cmds, MAX_ALTER_STR_SIZE, 0, 1,
MYF(0))))
goto end;
if (opt_alldbs)
......@@ -1024,6 +1043,8 @@ int main(int argc, char **argv)
}
for (i = 0; i < tables4rebuild.elements ; i++)
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
for (i = 0; i < alter_table_cmds.elements ; i++)
run_query((char*) dynamic_array_ptr(&alter_table_cmds, i));
}
ret= test(first_error);
......
......@@ -483,14 +483,13 @@ enum ha_base_keytype {
#define HA_ERR_GENERIC 168 /* Generic error */
/* row not actually updated: new values same as the old values */
#define HA_ERR_RECORD_IS_THE_SAME 169
/* It is not possible to log this statement */
#define HA_ERR_LOGGING_IMPOSSIBLE 170
/* The event was corrupt, leading to illegal data being read */
#define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this
statement */
#define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to
illegal data being read */
#define HA_ERR_NEW_FILE 172 /* New file format */
/* The event could not be processed no other handler error happened */
#define HA_ERR_ROWS_EVENT_APPLY 173
#define HA_ERR_ROWS_EVENT_APPLY 173 /* The event could not be processed
no other hanlder error happened */
#define HA_ERR_INITIALIZATION 174 /* Error during initialization */
#define HA_ERR_FILE_TOO_SHORT 175 /* File too short */
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
......@@ -504,10 +503,11 @@ enum ha_base_keytype {
#define HA_ERR_TABLE_IN_FK_CHECK 183 /* Table being used in foreign key check */
#define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */
#define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */
#define HA_ERR_ROW_NOT_VISIBLE 186
#define HA_ERR_ABORTED_BY_USER 187
#define HA_ERR_DISK_FULL 188
#define HA_ERR_LAST 188 /* Copy of last error nr */
#define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */
#define HA_ERR_ROW_NOT_VISIBLE 187
#define HA_ERR_ABORTED_BY_USER 188
#define HA_ERR_DISK_FULL 189
#define HA_ERR_LAST 189 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
......
#ifndef MYSYS_MY_HANDLER_ERRORS_INCLUDED
#define MYSYS_MY_HANDLER_ERRORS_INCLUDED
/* Copyright (c) 2008, 2012, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2013, Oracle and/or its affiliates.
Copyright (c) 2011, 2013, SkySQL Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -88,6 +89,7 @@ static const char *handler_error_messages[]=
"Table is being used in foreign key check",
"Tablespace already exists",
"Too many columns",
"Row in wrong partition",
"Row is not visible by the current transaction",
"Operation was interrupted by end user (probably kill command?)",
"Disk full"
......
......@@ -1806,13 +1806,13 @@ engine=MEMORY
partition by key (a);
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note The storage engine for the table doesn't support optimize
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check note The storage engine for the table doesn't support check
test.t1 check status OK
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze note The storage engine for the table doesn't support analyze
......
......@@ -849,7 +849,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -1341,7 +1341,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -1848,7 +1848,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -2349,7 +2349,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -2850,7 +2850,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -3360,7 +3360,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -3872,7 +3872,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -4372,7 +4372,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -4865,7 +4865,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -5357,7 +5357,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -5864,7 +5864,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -6365,7 +6365,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -6866,7 +6866,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -7376,7 +7376,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -7888,7 +7888,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -8388,7 +8388,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -8898,7 +8898,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -9406,7 +9406,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -9929,7 +9929,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -10446,7 +10446,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -10963,7 +10963,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -11489,7 +11489,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -12017,7 +12017,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -12533,7 +12533,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -13042,7 +13042,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -13550,7 +13550,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -14073,7 +14073,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -14590,7 +14590,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -15107,7 +15107,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -15633,7 +15633,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -16161,7 +16161,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......@@ -16677,7 +16677,7 @@ test.t1 optimize status OK
# check layout success: 1
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
test.t1 repair status OK
# check layout success: 1
TRUNCATE t1;
......
This diff is collapsed.
This diff is collapsed.
......@@ -5883,6 +5883,7 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
(and the old record is in record[1]).
*/
DBUG_ASSERT(new_data == table->record[0]);
DBUG_ASSERT(old_data == table->record[1]);
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
......@@ -5906,6 +5907,11 @@ int handler::ha_delete_row(const uchar *buf)
Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type == F_WRLCK);
/*
Normally table->record[0] is used, but sometimes table->record[1] is used.
*/
DBUG_ASSERT(buf == table->record[0] ||
buf == table->record[1]);
MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7990,7 +7990,7 @@ int spider_discover_table_structure(
DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM);
}
if (!(part_syntax = generate_partition_syntax(part_info, &part_syntax_len,
FALSE, TRUE, info, NULL)))
FALSE, TRUE, info, NULL, NULL)))
{
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment