1 /* Copyright (c) 2009, 2021, Oracle and/or its affiliates.
2 
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License, version 2.0,
5   as published by the Free Software Foundation.
6 
7   This program is also distributed with certain software (including
8   but not limited to OpenSSL) that is licensed under separate terms,
9   as designated in a particular file or component or in included license
10   documentation.  The authors of MySQL hereby grant you an additional
11   permission to link the program and your derivative works with the
12   separately licensed software that they have included with MySQL.
13 
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License, version 2.0, for more details.
18 
19   You should have received a copy of the GNU General Public License
20   along with this program; if not, write to the Free Software Foundation,
21   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 /**
24   @file storage/perfschema/pfs_check.cc
25   Check the performance schema table structure.
26   The code in this file is implemented in pfs_check.cc
27   instead of pfs_server.cc, to separate dependencies to server
28   structures (THD, ...) in a dedicated file.
29   This code organization helps a lot maintenance of the unit tests.
30 */
31 
32 #include "my_global.h"
33 #include "pfs_server.h"
34 #include "pfs_engine_table.h"
35 #include "sql_class.h"
36 
37 /**
38   Check that the performance schema tables
39   have the expected structure.
40   Discrepancies are written in the server log,
41   but are not considered fatal, so this function does not
42   return an error code:
43   - some differences are compatible, and should not cause a failure
44   - some differences are not compatible, but then the DBA needs an operational
45   server to be able to DROP+CREATE the tables with the proper structure,
46   as part of the initial server installation or during an upgrade.
47   In case of discrepancies, later attempt to perform DML against
48   the performance schema will be rejected with an error.
49 */
check_performance_schema()50 void check_performance_schema()
51 {
52   DBUG_ENTER("check_performance_schema");
53 
54   THD *thd= new THD();
55   if (thd == NULL)
56     DBUG_VOID_RETURN;
57 
58   thd->thread_stack= (char*) &thd;
59   thd->store_globals();
60 
61   PFS_engine_table_share::check_all_tables(thd);
62 
63   thd->restore_globals();
64   delete thd;
65   DBUG_VOID_RETURN;
66 }
67 
68