1/*****************************************************************************
2
3Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2014, 2017, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file handler/i_s.h
22InnoDB INFORMATION SCHEMA tables interface to MySQL.
23
24Created July 18, 2007 Vasil Dimov
25Modified Dec 29, 2014 Jan Lindström
26*******************************************************/
27
28#ifndef i_s_h
29#define i_s_h
30
31const char plugin_author[] = "Oracle Corporation";
32const char maria_plugin_author[] = "MariaDB Corporation";
33
34extern struct st_maria_plugin i_s_innodb_trx;
35extern struct st_maria_plugin i_s_innodb_locks;
36extern struct st_maria_plugin i_s_innodb_lock_waits;
37extern struct st_maria_plugin i_s_innodb_cmp;
38extern struct st_maria_plugin i_s_innodb_cmp_reset;
39extern struct st_maria_plugin i_s_innodb_cmp_per_index;
40extern struct st_maria_plugin i_s_innodb_cmp_per_index_reset;
41extern struct st_maria_plugin i_s_innodb_cmpmem;
42extern struct st_maria_plugin i_s_innodb_cmpmem_reset;
43extern struct st_maria_plugin i_s_innodb_metrics;
44extern struct st_maria_plugin i_s_innodb_ft_default_stopword;
45extern struct st_maria_plugin i_s_innodb_ft_deleted;
46extern struct st_maria_plugin i_s_innodb_ft_being_deleted;
47extern struct st_maria_plugin i_s_innodb_ft_index_cache;
48extern struct st_maria_plugin i_s_innodb_ft_index_table;
49extern struct st_maria_plugin i_s_innodb_ft_config;
50extern struct st_maria_plugin i_s_innodb_buffer_page;
51extern struct st_maria_plugin i_s_innodb_buffer_page_lru;
52extern struct st_maria_plugin i_s_innodb_buffer_stats;
53extern struct st_maria_plugin i_s_innodb_sys_tables;
54extern struct st_maria_plugin i_s_innodb_sys_tablestats;
55extern struct st_maria_plugin i_s_innodb_sys_indexes;
56extern struct st_maria_plugin i_s_innodb_sys_columns;
57extern struct st_maria_plugin i_s_innodb_sys_fields;
58extern struct st_maria_plugin i_s_innodb_sys_foreign;
59extern struct st_maria_plugin i_s_innodb_sys_foreign_cols;
60extern struct st_maria_plugin i_s_innodb_sys_tablespaces;
61extern struct st_maria_plugin i_s_innodb_sys_datafiles;
62extern struct st_maria_plugin i_s_innodb_mutexes;
63extern struct st_maria_plugin i_s_innodb_sys_virtual;
64extern struct st_maria_plugin i_s_innodb_tablespaces_encryption;
65extern struct st_maria_plugin i_s_innodb_tablespaces_scrubbing;
66extern 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) \
79do { \
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
102HPUX 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/*******************************************************************//**
135Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field.
136If the value is ULINT_UNDEFINED then the field it set to NULL.
137@return 0 on success */
138int
139field_store_ulint(
140/*==============*/
141 Field* field, /*!< in/out: target field for storage */
142 ulint n); /*!< in: value to store */
143
144/*******************************************************************//**
145Auxiliary function to store char* value in MYSQL_TYPE_STRING field.
146@return 0 on success */
147int
148field_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