Commit 9e1035c6 authored by Karthik Kamath's avatar Karthik Kamath

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.
parent ecc5a078
/*
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 @@ class Event_db_intact : public Table_check_intact
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. */
......
/*
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 @@ class Proc_table_intact : public Table_check_intact
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, ...);
......
/* 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 @@ class Acl_table_intact : public Table_check_intact
va_end(args);
}
}
public:
Acl_table_intact() { has_keys= TRUE; }
};
#define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3)
......
/*
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.
......
/*
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);
}
......
#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. */
......
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