mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
BUG#26881798: SERVER EXITS WHEN PRIMARY KEY IN MYSQL.PROC
IS DROPPED ANALYSIS: ========= It is advised not to tamper with the system tables. When primary key is dropped from a system table, certain operations on the table which tries to access the table key information may lead to server exit. FIX: ==== An appropriate error is now reported in such a case.
This commit is contained in:
parent
ecc5a07874
commit
9e1035c64f
6 changed files with 36 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -174,6 +174,8 @@ protected:
|
|||
error_log_print(ERROR_LEVEL, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
public:
|
||||
Event_db_intact() { has_keys= TRUE; }
|
||||
};
|
||||
|
||||
/** In case of an error, a message is printed to the error log. */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -351,7 +351,7 @@ private:
|
|||
bool m_print_once;
|
||||
|
||||
public:
|
||||
Proc_table_intact() : m_print_once(TRUE) {}
|
||||
Proc_table_intact() : m_print_once(TRUE) { has_keys= TRUE; }
|
||||
|
||||
protected:
|
||||
void report_error(uint code, const char *fmt, ...);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -949,6 +949,8 @@ protected:
|
|||
va_end(args);
|
||||
}
|
||||
}
|
||||
public:
|
||||
Acl_table_intact() { has_keys= TRUE; }
|
||||
};
|
||||
|
||||
#define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -1899,6 +1899,16 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
|
|||
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (!table->key_info)
|
||||
{
|
||||
my_printf_error(ER_UNKNOWN_ERROR,
|
||||
"The table '%s.%s' does not have the necessary key(s) "
|
||||
"defined on it. Please check the table definition and "
|
||||
"create index(s) accordingly.", MYF(0),
|
||||
table->s->db.str, table->s->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
Pre-acquire audit plugins for events that may potentially occur
|
||||
during [UN]INSTALL PLUGIN.
|
||||
|
|
16
sql/table.cc
16
sql/table.cc
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -3013,7 +3013,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
|
|||
|
||||
/* Whether the table definition has already been validated. */
|
||||
if (table->s->table_field_def_cache == table_def)
|
||||
DBUG_RETURN(FALSE);
|
||||
goto end;
|
||||
|
||||
if (table->s->fields != table_def->count)
|
||||
{
|
||||
|
@ -3129,6 +3129,18 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
|
|||
if (! error)
|
||||
table->s->table_field_def_cache= table_def;
|
||||
|
||||
end:
|
||||
|
||||
if (has_keys && !error && !table->key_info)
|
||||
{
|
||||
my_printf_error(ER_UNKNOWN_ERROR,
|
||||
"The table '%s.%s' does not have the necessary key(s) "
|
||||
"defined on it. Please check the table definition and "
|
||||
"create index(s) accordingly.", MYF(0),
|
||||
table->s->db.str, table->s->table_name.str);
|
||||
error= TRUE;
|
||||
}
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef TABLE_INCLUDED
|
||||
#define TABLE_INCLUDED
|
||||
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
@ -484,10 +484,11 @@ typedef struct st_ha_data_partition
|
|||
class Table_check_intact
|
||||
{
|
||||
protected:
|
||||
bool has_keys;
|
||||
virtual void report_error(uint code, const char *fmt, ...)= 0;
|
||||
|
||||
public:
|
||||
Table_check_intact() {}
|
||||
Table_check_intact() : has_keys(FALSE) {}
|
||||
virtual ~Table_check_intact() {}
|
||||
|
||||
/** Checks whether a table is intact. */
|
||||
|
|
Loading…
Reference in a new issue