1 /*****************************************************************************
2 
3 Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2014, 2019, 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, Fifth Floor, 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 #include "dict0types.h"
31 
32 const char plugin_author[] = "Oracle Corporation";
33 const char maria_plugin_author[] = "MariaDB Corporation";
34 
35 extern struct st_maria_plugin	i_s_innodb_trx;
36 extern struct st_maria_plugin	i_s_innodb_locks;
37 extern struct st_maria_plugin	i_s_innodb_lock_waits;
38 extern struct st_maria_plugin	i_s_innodb_cmp;
39 extern struct st_maria_plugin	i_s_innodb_cmp_reset;
40 extern struct st_maria_plugin	i_s_innodb_cmp_per_index;
41 extern struct st_maria_plugin	i_s_innodb_cmp_per_index_reset;
42 extern struct st_maria_plugin	i_s_innodb_cmpmem;
43 extern struct st_maria_plugin	i_s_innodb_cmpmem_reset;
44 extern struct st_maria_plugin   i_s_innodb_metrics;
45 extern struct st_maria_plugin	i_s_innodb_ft_default_stopword;
46 extern struct st_maria_plugin	i_s_innodb_ft_deleted;
47 extern struct st_maria_plugin	i_s_innodb_ft_being_deleted;
48 extern struct st_maria_plugin	i_s_innodb_ft_index_cache;
49 extern struct st_maria_plugin	i_s_innodb_ft_index_table;
50 extern struct st_maria_plugin	i_s_innodb_ft_config;
51 extern struct st_maria_plugin	i_s_innodb_buffer_page;
52 extern struct st_maria_plugin	i_s_innodb_buffer_page_lru;
53 extern struct st_maria_plugin	i_s_innodb_buffer_stats;
54 extern struct st_maria_plugin	i_s_innodb_sys_tables;
55 extern struct st_maria_plugin	i_s_innodb_sys_tablestats;
56 extern struct st_maria_plugin	i_s_innodb_sys_indexes;
57 extern struct st_maria_plugin	i_s_innodb_sys_columns;
58 extern struct st_maria_plugin	i_s_innodb_sys_fields;
59 extern struct st_maria_plugin	i_s_innodb_sys_foreign;
60 extern struct st_maria_plugin	i_s_innodb_sys_foreign_cols;
61 extern struct st_maria_plugin	i_s_innodb_sys_tablespaces;
62 extern struct st_maria_plugin	i_s_innodb_sys_datafiles;
63 extern struct st_maria_plugin	i_s_innodb_mutexes;
64 extern struct st_maria_plugin	i_s_innodb_sys_virtual;
65 extern struct st_maria_plugin	i_s_innodb_tablespaces_encryption;
66 extern struct st_maria_plugin	i_s_innodb_tablespaces_scrubbing;
67 extern struct st_maria_plugin	i_s_innodb_sys_semaphore_waits;
68 
69 /** The latest successfully looked up innodb_fts_aux_table */
70 extern table_id_t innodb_ft_aux_table_id;
71 
72 /** maximum number of buffer page info we would cache. */
73 #define MAX_BUF_INFO_CACHED		10000
74 
75 #define OK(expr)		\
76 	if ((expr) != 0) {	\
77 		DBUG_RETURN(1);	\
78 	}
79 
80 #define BREAK_IF(expr) if ((expr)) break
81 
82 #define RETURN_IF_INNODB_NOT_STARTED(plugin_name)			\
83 do {									\
84 	if (!srv_was_started) {						\
85 		push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,	\
86 				    ER_CANT_FIND_SYSTEM_REC,		\
87 				    "InnoDB: SELECTing from "		\
88 				    "INFORMATION_SCHEMA.%s but "	\
89 				    "the InnoDB storage engine "	\
90 				    "is not installed", plugin_name);	\
91 		DBUG_RETURN(0);						\
92 	}								\
93 } while (0)
94 
95 /* Don't use a static const variable here, as some C++ compilers (notably
96 HPUX aCC: HP ANSI C++ B3910B A.03.65) can't handle it. */
97 #define END_OF_ST_FIELD_INFO {NULL,0,MYSQL_TYPE_NULL,0,0,"",SKIP_OPEN_TABLE}
98 
99 /** Fields on INFORMATION_SCHEMA.SYS_SEMAMPHORE_WAITS table */
100 #define SYS_SEMAPHORE_WAITS_THREAD_ID	0
101 #define SYS_SEMAPHORE_WAITS_OBJECT_NAME 1
102 #define SYS_SEMAPHORE_WAITS_FILE	2
103 #define SYS_SEMAPHORE_WAITS_LINE	3
104 #define SYS_SEMAPHORE_WAITS_WAIT_TIME	4
105 #define SYS_SEMAPHORE_WAITS_WAIT_OBJECT	5
106 #define SYS_SEMAPHORE_WAITS_WAIT_TYPE	6
107 #define SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID 7
108 #define SYS_SEMAPHORE_WAITS_HOLDER_FILE 8
109 #define SYS_SEMAPHORE_WAITS_HOLDER_LINE 9
110 #define SYS_SEMAPHORE_WAITS_CREATED_FILE 10
111 #define SYS_SEMAPHORE_WAITS_CREATED_LINE 11
112 #define SYS_SEMAPHORE_WAITS_WRITER_THREAD 12
113 #define SYS_SEMAPHORE_WAITS_RESERVATION_MODE 13
114 #define SYS_SEMAPHORE_WAITS_READERS	14
115 #define SYS_SEMAPHORE_WAITS_WAITERS_FLAG 15
116 #define SYS_SEMAPHORE_WAITS_LOCK_WORD	16
117 #define SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE 17
118 #define SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE 18
119 #define SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19
120 
121 /*******************************************************************//**
122 Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field.
123 If the value is ULINT_UNDEFINED then the field it set to NULL.
124 @return	0 on success */
125 int
126 field_store_ulint(
127 /*==============*/
128 	Field*	field,	/*!< in/out: target field for storage */
129 	ulint	n);	/*!< in: value to store */
130 
131 /*******************************************************************//**
132 Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
133 @return	0 on success */
134 int
135 field_store_string(
136 /*===============*/
137 	Field*		field,	/*!< in/out: target field for storage */
138 	const char*	str);	/*!< in: NUL-terminated utf-8 string,
139 				or NULL */
140 
141 #endif /* i_s_h */
142