1
#ifndef HA_INNODB_PROTOTYPES_H
2
#define HA_INNODB_PROTOTYPES_H
6
#include "univ.i" /* ulint, uint */
7
#if defined(BUILD_DRIZZLE)
8
# include <mystrings/m_ctype.h>
10
# include "m_ctype.h" /* CHARSET_INFO */
13
/* Prototypes for global functions in ha_innodb.cc that are called by
16
/*************************************************************************
17
Wrapper around MySQL's copy_and_convert function, see it for
21
innobase_convert_string(
22
/*====================*/
25
const CHARSET_INFO* to_cs,
28
const CHARSET_INFO* from_cs,
31
/***********************************************************************
32
Formats the raw data in "data" (in InnoDB on-disk format) that is of
33
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
34
the result to "buf". The result is converted to "system_charset_info".
35
Not more than "buf_size" bytes are written to "buf".
36
The result is always '\0'-terminated (provided buf_size > 0) and the
37
number of bytes that were written to "buf" is returned (including the
43
/* out: number of bytes
45
const char* data, /* in: raw data */
46
ulint data_len, /* in: raw data length
48
ulint charset_coll, /* in: charset collation */
49
char* buf, /* out: output buffer */
50
ulint buf_size); /* in: output buffer size
53
/*********************************************************************
54
Convert a table or index name to the MySQL system_charset_info (UTF-8)
55
and quote it if needed. */
58
innobase_convert_name(
59
/*==================*/
60
/* out: pointer to the end of buf */
61
char* buf, /* out: buffer for converted identifier */
62
ulint buflen, /* in: length of buf, in bytes */
63
const char* id, /* in: identifier to convert */
64
ulint idlen, /* in: length of id, in bytes */
65
void* thd, /* in: MySQL connection thread, or NULL */
66
ibool table_id);/* in: TRUE=id is a table or database name;
67
FALSE=id is an index name */
69
/**********************************************************************
70
Returns true if the thread is the replication thread on the slave
71
server. Used in srv_conc_enter_innodb() to determine if the thread
72
should be allowed to enter InnoDB - the replication thread is treated
73
differently than other threads. Also used in
74
srv_conc_force_exit_innodb(). */
77
thd_is_replication_slave_thread(
78
/*============================*/
79
/* out: true if thd is the replication thread */
80
void* thd); /* in: thread handle (THD*) */
82
/**********************************************************************
83
Returns true if the transaction this thread is processing has edited
84
non-transactional tables. Used by the deadlock detector when deciding
85
which transaction to rollback in case of a deadlock - we try to avoid
86
rolling back transactions that have edited non-transactional tables. */
89
thd_has_edited_nontrans_tables(
90
/*===========================*/
91
/* out: true if non-transactional tables have
93
void* thd); /* in: thread handle (THD*) */
95
/*****************************************************************
96
Prints info of a THD object (== user session thread) to the given file. */
99
innobase_mysql_print_thd(
100
/*=====================*/
101
FILE* f, /* in: output stream */
102
void* thd, /* in: pointer to a MySQL THD object */
103
uint max_query_len); /* in: max query length to print, or 0 to
104
use the default max length */
106
/******************************************************************
107
Converts a MySQL type to an InnoDB type. Note that this function returns
108
the 'mtype' of InnoDB. InnoDB differentiates between MySQL's old <= 4.1
109
VARCHAR and the new true VARCHAR in >= 5.0.3 by the 'prtype'. */
112
get_innobase_type_from_mysql_type(
113
/*==============================*/
116
ulint* unsigned_flag, /* out: DATA_UNSIGNED if an
118
at least ENUM and SET,
120
types are 'unsigned types' */
121
const void* field) /* in: MySQL Field */
122
__attribute__((nonnull));
124
/*****************************************************************
125
If you want to print a thd that is not associated with the current thread,
126
you must call this function before reserving the InnoDB kernel_mutex, to
127
protect MySQL from setting thd->query NULL. If you print a thd of the current
128
thread, we know that MySQL cannot modify thd->query, and it is not necessary
129
to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release
133
innobase_mysql_prepare_print_arbitrary_thd(void);
134
/*============================================*/
136
/*****************************************************************
137
Releases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd().
138
In the InnoDB latching order, the mutex sits right above the
139
kernel_mutex. In debug builds, we assert that the kernel_mutex is
140
released before this function is invoked. */
143
innobase_mysql_end_print_arbitrary_thd(void);
144
/*========================================*/
146
/**********************************************************************
147
Get the variable length bounds of the given character set. */
150
innobase_get_cset_width(
151
/*====================*/
152
ulint cset, /* in: MySQL charset-collation code */
153
ulint* mbminlen, /* out: minimum length of a char (in bytes) */
154
ulint* mbmaxlen); /* out: maximum length of a char (in bytes) */
156
/**********************************************************************
157
Compares NUL-terminated UTF-8 strings case insensitively. */
162
/* out: 0 if a=b, <0 if a<b, >1 if a>b */
163
const char* a, /* in: first string to compare */
164
const char* b); /* in: second string to compare */
166
/**********************************************************************
167
Returns true if the thread is executing a SELECT statement. */
172
/* out: true if thd is executing SELECT */
173
const void* thd); /* in: thread handle (THD*) */
175
/**********************************************************************
176
Converts an identifier to a table name. */
179
innobase_convert_from_table_id(
180
/*===========================*/
181
struct charset_info_st* cs, /* in: the 'from' character set */
182
char* to, /* out: converted identifier */
183
const char* from, /* in: identifier to convert */
184
ulint len); /* in: length of 'to', in bytes; should
185
be at least 5 * strlen(to) + 1 */
186
/**********************************************************************
187
Converts an identifier to UTF-8. */
190
innobase_convert_from_id(
191
/*=====================*/
192
struct charset_info_st* cs, /* in: the 'from' character set */
193
char* to, /* out: converted identifier */
194
const char* from, /* in: identifier to convert */
195
ulint len); /* in: length of 'to', in bytes; should
196
be at least 3 * strlen(to) + 1 */
197
/**********************************************************************
198
Makes all characters in a NUL-terminated UTF-8 string lower case. */
203
char* a); /* in/out: string to put in lower case */
205
/**************************************************************************
206
Determines the connection character set. */
207
struct charset_info_st*
208
innobase_get_charset(
209
/*=================*/
210
/* out: connection character set */
211
void* mysql_thd); /* in: MySQL thread handle */
213
/**********************************************************************
214
Returns true if the thread is executing in innodb_strict_mode. */
219
/* out: true if thd is in strict mode */
220
void* thd); /* in: thread handle (THD*) */
222
/**********************************************************************
223
Returns the lock wait timeout for the current connection. */
226
thd_lock_wait_timeout(
227
/*==================*/
228
/* out: the lock wait timeout, in seconds */
229
void* thd); /* in: thread handle (THD*), or NULL to query
230
the global innodb_lock_wait_timeout */