| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2014, 2017, MariaDB Corporation. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it under |
| 7 | the terms of the GNU General Public License as published by the Free Software |
| 8 | Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along with |
| 15 | this program; if not, write to the Free Software Foundation, Inc., |
| 16 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 17 | |
| 18 | *****************************************************************************/ |
| 19 | |
| 20 | /**************************************************//** |
| 21 | @file handler/i_s.h |
| 22 | InnoDB INFORMATION SCHEMA tables interface to MySQL. |
| 23 | |
| 24 | Created July 18, 2007 Vasil Dimov |
| 25 | Modified Dec 29, 2014 Jan Lindström |
| 26 | *******************************************************/ |
| 27 | |
| 28 | #ifndef i_s_h |
| 29 | #define i_s_h |
| 30 | |
| 31 | const char plugin_author[] = "Oracle Corporation" ; |
| 32 | const char maria_plugin_author[] = "MariaDB Corporation" ; |
| 33 | |
| 34 | extern struct st_maria_plugin i_s_innodb_trx; |
| 35 | extern struct st_maria_plugin i_s_innodb_locks; |
| 36 | extern struct st_maria_plugin i_s_innodb_lock_waits; |
| 37 | extern struct st_maria_plugin i_s_innodb_cmp; |
| 38 | extern struct st_maria_plugin i_s_innodb_cmp_reset; |
| 39 | extern struct st_maria_plugin i_s_innodb_cmp_per_index; |
| 40 | extern struct st_maria_plugin i_s_innodb_cmp_per_index_reset; |
| 41 | extern struct st_maria_plugin i_s_innodb_cmpmem; |
| 42 | extern struct st_maria_plugin i_s_innodb_cmpmem_reset; |
| 43 | extern struct st_maria_plugin i_s_innodb_metrics; |
| 44 | extern struct st_maria_plugin i_s_innodb_ft_default_stopword; |
| 45 | extern struct st_maria_plugin i_s_innodb_ft_deleted; |
| 46 | extern struct st_maria_plugin i_s_innodb_ft_being_deleted; |
| 47 | extern struct st_maria_plugin i_s_innodb_ft_index_cache; |
| 48 | extern struct st_maria_plugin i_s_innodb_ft_index_table; |
| 49 | extern struct st_maria_plugin i_s_innodb_ft_config; |
| 50 | extern struct st_maria_plugin i_s_innodb_buffer_page; |
| 51 | extern struct st_maria_plugin i_s_innodb_buffer_page_lru; |
| 52 | extern struct st_maria_plugin i_s_innodb_buffer_stats; |
| 53 | extern struct st_maria_plugin i_s_innodb_sys_tables; |
| 54 | extern struct st_maria_plugin i_s_innodb_sys_tablestats; |
| 55 | extern struct st_maria_plugin i_s_innodb_sys_indexes; |
| 56 | extern struct st_maria_plugin i_s_innodb_sys_columns; |
| 57 | extern struct st_maria_plugin i_s_innodb_sys_fields; |
| 58 | extern struct st_maria_plugin i_s_innodb_sys_foreign; |
| 59 | extern struct st_maria_plugin i_s_innodb_sys_foreign_cols; |
| 60 | extern struct st_maria_plugin i_s_innodb_sys_tablespaces; |
| 61 | extern struct st_maria_plugin i_s_innodb_sys_datafiles; |
| 62 | extern struct st_maria_plugin i_s_innodb_mutexes; |
| 63 | extern struct st_maria_plugin i_s_innodb_sys_virtual; |
| 64 | extern struct st_maria_plugin i_s_innodb_tablespaces_encryption; |
| 65 | extern struct st_maria_plugin i_s_innodb_tablespaces_scrubbing; |
| 66 | extern struct st_maria_plugin i_s_innodb_sys_semaphore_waits; |
| 67 | |
| 68 | /** maximum number of buffer page info we would cache. */ |
| 69 | #define MAX_BUF_INFO_CACHED 10000 |
| 70 | |
| 71 | #define OK(expr) \ |
| 72 | if ((expr) != 0) { \ |
| 73 | DBUG_RETURN(1); \ |
| 74 | } |
| 75 | |
| 76 | #define BREAK_IF(expr) if ((expr)) break |
| 77 | |
| 78 | #define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \ |
| 79 | do { \ |
| 80 | if (!srv_was_started) { \ |
| 81 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, \ |
| 82 | ER_CANT_FIND_SYSTEM_REC, \ |
| 83 | "InnoDB: SELECTing from " \ |
| 84 | "INFORMATION_SCHEMA.%s but " \ |
| 85 | "the InnoDB storage engine " \ |
| 86 | "is not installed", plugin_name); \ |
| 87 | DBUG_RETURN(0); \ |
| 88 | } \ |
| 89 | } while (0) |
| 90 | |
| 91 | #if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER && !defined __clang__ |
| 92 | #ifdef HAVE_C99_INITIALIZERS |
| 93 | #define STRUCT_FLD(name, value) .name = value |
| 94 | #else |
| 95 | #define STRUCT_FLD(name, value) name: value |
| 96 | #endif /* HAVE_C99_INITIALIZERS */ |
| 97 | #else |
| 98 | #define STRUCT_FLD(name, value) value |
| 99 | #endif |
| 100 | |
| 101 | /* Don't use a static const variable here, as some C++ compilers (notably |
| 102 | HPUX aCC: HP ANSI C++ B3910B A.03.65) can't handle it. */ |
| 103 | #define END_OF_ST_FIELD_INFO \ |
| 104 | {STRUCT_FLD(field_name, NULL), \ |
| 105 | STRUCT_FLD(field_length, 0), \ |
| 106 | STRUCT_FLD(field_type, MYSQL_TYPE_NULL), \ |
| 107 | STRUCT_FLD(value, 0), \ |
| 108 | STRUCT_FLD(field_flags, 0), \ |
| 109 | STRUCT_FLD(old_name, ""), \ |
| 110 | STRUCT_FLD(open_method, SKIP_OPEN_TABLE)} |
| 111 | |
| 112 | /** Fields on INFORMATION_SCHEMA.SYS_SEMAMPHORE_WAITS table */ |
| 113 | #define SYS_SEMAPHORE_WAITS_THREAD_ID 0 |
| 114 | #define SYS_SEMAPHORE_WAITS_OBJECT_NAME 1 |
| 115 | #define SYS_SEMAPHORE_WAITS_FILE 2 |
| 116 | #define SYS_SEMAPHORE_WAITS_LINE 3 |
| 117 | #define SYS_SEMAPHORE_WAITS_WAIT_TIME 4 |
| 118 | #define SYS_SEMAPHORE_WAITS_WAIT_OBJECT 5 |
| 119 | #define SYS_SEMAPHORE_WAITS_WAIT_TYPE 6 |
| 120 | #define SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID 7 |
| 121 | #define SYS_SEMAPHORE_WAITS_HOLDER_FILE 8 |
| 122 | #define SYS_SEMAPHORE_WAITS_HOLDER_LINE 9 |
| 123 | #define SYS_SEMAPHORE_WAITS_CREATED_FILE 10 |
| 124 | #define SYS_SEMAPHORE_WAITS_CREATED_LINE 11 |
| 125 | #define SYS_SEMAPHORE_WAITS_WRITER_THREAD 12 |
| 126 | #define SYS_SEMAPHORE_WAITS_RESERVATION_MODE 13 |
| 127 | #define SYS_SEMAPHORE_WAITS_READERS 14 |
| 128 | #define SYS_SEMAPHORE_WAITS_WAITERS_FLAG 15 |
| 129 | #define SYS_SEMAPHORE_WAITS_LOCK_WORD 16 |
| 130 | #define SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE 17 |
| 131 | #define SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE 18 |
| 132 | #define SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19 |
| 133 | |
| 134 | /*******************************************************************//** |
| 135 | Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field. |
| 136 | If the value is ULINT_UNDEFINED then the field it set to NULL. |
| 137 | @return 0 on success */ |
| 138 | int |
| 139 | field_store_ulint( |
| 140 | /*==============*/ |
| 141 | Field* field, /*!< in/out: target field for storage */ |
| 142 | ulint n); /*!< in: value to store */ |
| 143 | |
| 144 | /*******************************************************************//** |
| 145 | Auxiliary function to store char* value in MYSQL_TYPE_STRING field. |
| 146 | @return 0 on success */ |
| 147 | int |
| 148 | field_store_string( |
| 149 | /*===============*/ |
| 150 | Field* field, /*!< in/out: target field for storage */ |
| 151 | const char* str); /*!< in: NUL-terminated utf-8 string, |
| 152 | or NULL */ |
| 153 | |
| 154 | #endif /* i_s_h */ |
| 155 | |