1
/*****************************************************************************
3
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/*******************************************************************//**
20
@file include/ha_prototypes.h
21
Prototypes for global functions in ha_innodb.cc that are called by
24
Created 5/11/2006 Osku Salerma
25
************************************************************************/
27
#ifndef HA_INNODB_PROTOTYPES_H
28
#define HA_INNODB_PROTOTYPES_H
30
#include "trx0types.h"
31
#include "m_ctype.h" /* CHARSET_INFO */
33
/*********************************************************************//**
34
Wrapper around MySQL's copy_and_convert function.
35
@return number of bytes copied to 'to' */
38
innobase_convert_string(
39
/*====================*/
40
void* to, /*!< out: converted string */
41
ulint to_length, /*!< in: number of bytes reserved
42
for the converted string */
43
CHARSET_INFO* to_cs, /*!< in: character set to convert to */
44
const void* from, /*!< in: string to convert */
45
ulint from_length, /*!< in: number of bytes to convert */
46
CHARSET_INFO* from_cs, /*!< in: character set to convert from */
47
uint* errors); /*!< out: number of errors encountered
48
during the conversion */
50
/*******************************************************************//**
51
Formats the raw data in "data" (in InnoDB on-disk format) that is of
52
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
53
the result to "buf". The result is converted to "system_charset_info".
54
Not more than "buf_size" bytes are written to "buf".
55
The result is always NUL-terminated (provided buf_size > 0) and the
56
number of bytes that were written to "buf" is returned (including the
58
@return number of bytes that were written */
63
const char* data, /*!< in: raw data */
64
ulint data_len, /*!< in: raw data length
66
ulint charset_coll, /*!< in: charset collation */
67
char* buf, /*!< out: output buffer */
68
ulint buf_size); /*!< in: output buffer size
71
/*****************************************************************//**
72
Invalidates the MySQL query cache for the table. */
75
innobase_invalidate_query_cache(
76
/*============================*/
77
trx_t* trx, /*!< in: transaction which
79
const char* full_name, /*!< in: concatenation of
80
database name, null char NUL,
81
table name, null char NUL;
82
NOTE that in Windows this is
83
always in LOWER CASE! */
84
ulint full_name_len); /*!< in: full name length where
85
also the null chars count */
87
/*****************************************************************//**
88
Convert a table or index name to the MySQL system_charset_info (UTF-8)
89
and quote it if needed.
90
@return pointer to the end of buf */
93
innobase_convert_name(
94
/*==================*/
95
char* buf, /*!< out: buffer for converted identifier */
96
ulint buflen, /*!< in: length of buf, in bytes */
97
const char* id, /*!< in: identifier to convert */
98
ulint idlen, /*!< in: length of id, in bytes */
99
void* thd, /*!< in: MySQL connection thread, or NULL */
100
ibool table_id);/*!< in: TRUE=id is a table or database name;
101
FALSE=id is an index name */
103
/******************************************************************//**
104
Returns true if the thread is the replication thread on the slave
105
server. Used in srv_conc_enter_innodb() to determine if the thread
106
should be allowed to enter InnoDB - the replication thread is treated
107
differently than other threads. Also used in
108
srv_conc_force_exit_innodb().
109
@return true if thd is the replication thread */
112
thd_is_replication_slave_thread(
113
/*============================*/
114
const void* thd); /*!< in: thread handle (THD*) */
116
/******************************************************************//**
117
Returns true if the transaction this thread is processing has edited
118
non-transactional tables. Used by the deadlock detector when deciding
119
which transaction to rollback in case of a deadlock - we try to avoid
120
rolling back transactions that have edited non-transactional tables.
121
@return true if non-transactional tables have been edited */
124
thd_has_edited_nontrans_tables(
125
/*===========================*/
126
void* thd); /*!< in: thread handle (THD*) */
128
/*************************************************************//**
129
Prints info of a THD object (== user session thread) to the given file. */
132
innobase_mysql_print_thd(
133
/*=====================*/
134
FILE* f, /*!< in: output stream */
135
void* thd, /*!< in: pointer to a MySQL THD object */
136
uint max_query_len); /*!< in: max query length to print, or 0 to
137
use the default max length */
139
/**************************************************************//**
140
Converts a MySQL type to an InnoDB type. Note that this function returns
141
the 'mtype' of InnoDB. InnoDB differentiates between MySQL's old <= 4.1
142
VARCHAR and the new true VARCHAR in >= 5.0.3 by the 'prtype'.
143
@return DATA_BINARY, DATA_VARCHAR, ... */
146
get_innobase_type_from_mysql_type(
147
/*==============================*/
148
ulint* unsigned_flag, /*!< out: DATA_UNSIGNED if an
150
at least ENUM and SET,
152
types are 'unsigned types' */
153
const void* field) /*!< in: MySQL Field */
154
__attribute__((nonnull));
156
/******************************************************************//**
157
Get the variable length bounds of the given character set. */
160
innobase_get_cset_width(
161
/*====================*/
162
ulint cset, /*!< in: MySQL charset-collation code */
163
ulint* mbminlen, /*!< out: minimum length of a char (in bytes) */
164
ulint* mbmaxlen); /*!< out: maximum length of a char (in bytes) */
166
/******************************************************************//**
167
Compares NUL-terminated UTF-8 strings case insensitively.
168
@return 0 if a=b, <0 if a<b, >1 if a>b */
173
const char* a, /*!< in: first string to compare */
174
const char* b); /*!< in: second string to compare */
176
/******************************************************************//**
177
Strip dir name from a full path name and return only its file name.
178
@return file name or "null" if no file name */
183
const char* path_name); /*!< in: full path name */
185
/******************************************************************//**
186
Returns true if the thread is executing a SELECT statement.
187
@return true if thd is executing SELECT */
192
const void* thd); /*!< in: thread handle (THD*) */
194
/******************************************************************//**
195
Converts an identifier to a table name. */
198
innobase_convert_from_table_id(
199
/*===========================*/
200
struct charset_info_st* cs, /*!< in: the 'from' character set */
201
char* to, /*!< out: converted identifier */
202
const char* from, /*!< in: identifier to convert */
203
ulint len); /*!< in: length of 'to', in bytes; should
204
be at least 5 * strlen(to) + 1 */
205
/******************************************************************//**
206
Converts an identifier to UTF-8. */
209
innobase_convert_from_id(
210
/*=====================*/
211
struct charset_info_st* cs, /*!< in: the 'from' character set */
212
char* to, /*!< out: converted identifier */
213
const char* from, /*!< in: identifier to convert */
214
ulint len); /*!< in: length of 'to', in bytes; should
215
be at least 3 * strlen(to) + 1 */
216
/******************************************************************//**
217
Makes all characters in a NUL-terminated UTF-8 string lower case. */
222
char* a); /*!< in/out: string to put in lower case */
224
/**********************************************************************//**
225
Determines the connection character set.
226
@return connection character set */
228
struct charset_info_st*
229
innobase_get_charset(
230
/*=================*/
231
void* mysql_thd); /*!< in: MySQL thread handle */
232
/**********************************************************************//**
233
Determines the current SQL statement.
234
@return SQL statement string */
239
void* mysql_thd, /*!< in: MySQL thread handle */
240
size_t* length) /*!< out: length of the SQL statement */
241
__attribute__((nonnull));
242
/******************************************************************//**
243
This function is used to find the storage length in bytes of the first n
244
characters for prefix indexes using a multibyte character set. The function
245
finds charset information and returns length of prefix_len characters in the
246
index field in bytes.
247
@return number of bytes occupied by the first n characters */
250
innobase_get_at_most_n_mbchars(
251
/*===========================*/
252
ulint charset_id, /*!< in: character set id */
253
ulint prefix_len, /*!< in: prefix length in bytes of the index
254
(this has to be divided by mbmaxlen to get the
255
number of CHARACTERS n in the prefix) */
256
ulint data_len, /*!< in: length of the string in bytes */
257
const char* str); /*!< in: character string */
259
/*************************************************************//**
260
InnoDB index push-down condition check
261
@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */
263
handler_index_cond_check(
265
void* file) /*!< in/out: pointer to ha_innobase */
266
__attribute__((nonnull, warn_unused_result));
267
/******************************************************************//**
268
Returns true if the thread supports XA,
269
global value of innodb_supports_xa if thd is NULL.
270
@return true if thd supports XA */
275
void* thd); /*!< in: thread handle (THD*), or NULL to query
276
the global innodb_supports_xa */
278
/******************************************************************//**
279
Returns the lock wait timeout for the current connection.
280
@return the lock wait timeout, in seconds */
283
thd_lock_wait_timeout(
284
/*==================*/
285
void* thd); /*!< in: thread handle (THD*), or NULL to query
286
the global innodb_lock_wait_timeout */
287
/******************************************************************//**
288
Add up the time waited for the lock for the current query. */
291
thd_set_lock_wait_time(
292
/*===================*/
293
void* thd, /*!< in: thread handle (THD*) */
294
ulint value); /*!< in: time waited for the lock */
295
/******************************************************************//**
299
thd_flush_log_at_trx_commit(
300
/*================================*/
303
/**********************************************************************//**
304
Get the current setting of the lower_case_table_names global parameter from
305
mysqld.cc. We do a dirty read because for one there is no synchronization
306
object and secondly there is little harm in doing so even if we get a torn
308
@return value of lower_case_table_names */
311
innobase_get_lower_case_table_names(void);
312
/*=====================================*/
315
/********************************************************************//**
316
Returns the merge-sort block size used for the secondary index creation
317
for the current connection.
318
@return the merge-sort block size, in bytes */
321
thd_merge_sort_block_size(
322
/*======================*/
323
void* thd); /*!< in: thread handle (THD*), or NULL to query
324
the global merge_sort_block_size */
326
/**********************************************************************
327
Check if the length of the identifier exceeds the maximum allowed.
328
The input to this function is an identifier in charset my_charset_filename.
329
return true when length of identifier is too long. */
332
innobase_check_identifier_length(
333
/*=============================*/
334
const char* id); /* in: identifier to check. it must belong
335
to charset my_charset_filename */
337
/**********************************************************************
338
Converts an identifier from my_charset_filename to UTF-8 charset. */
340
innobase_convert_to_system_charset(
341
/*===============================*/
342
char* to, /* out: converted identifier */
343
const char* from, /* in: identifier to convert */
344
ulint len, /* in: length of 'to', in bytes */
345
uint* errors); /* out: error return */
347
/**********************************************************************
348
Converts an identifier from my_charset_filename to UTF-8 charset. */
350
innobase_convert_to_filename_charset(
351
/*=================================*/
352
char* to, /* out: converted identifier */
353
const char* from, /* in: identifier to convert */
354
ulint len); /* in: length of 'to', in bytes */