1
/*****************************************************************************
3
Copyright (c) 2006, 2009, Innobase Oy. 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
#if !defined(BUILD_DRIZZLE)
32
# include "m_ctype.h" /* CHARSET_INFO */
34
/*********************************************************************//**
35
Wrapper around MySQL's copy_and_convert function.
36
@return number of bytes copied to 'to' */
39
innobase_convert_string(
40
/*====================*/
41
void* to, /*!< out: converted string */
42
ulint to_length, /*!< in: number of bytes reserved
43
for the converted string */
44
drizzled::CHARSET_INFO* to_cs, /*!< in: character set to convert to */
45
const void* from, /*!< in: string to convert */
46
ulint from_length, /*!< in: number of bytes to convert */
47
drizzled::CHARSET_INFO* from_cs, /*!< in: character set to convert from */
48
uint* errors); /*!< out: number of errors encountered
49
during the conversion */
52
/* Prototypes for global functions in ha_innodb.cc that are called by
56
/*******************************************************************//**
57
Formats the raw data in "data" (in InnoDB on-disk format) that is of
58
type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes
59
the result to "buf". The result is converted to "system_charset_info".
60
Not more than "buf_size" bytes are written to "buf".
61
The result is always NUL-terminated (provided buf_size > 0) and the
62
number of bytes that were written to "buf" is returned (including the
64
@return number of bytes that were written */
69
const char* data, /*!< in: raw data */
70
ulint data_len, /*!< in: raw data length
72
ulint charset_coll, /*!< in: charset collation */
73
char* buf, /*!< out: output buffer */
74
ulint buf_size); /*!< in: output buffer size
77
/*****************************************************************//**
78
Invalidates the MySQL query cache for the table. */
81
innobase_invalidate_query_cache(
82
/*============================*/
83
trx_t* trx, /*!< in: transaction which
85
const char* full_name, /*!< in: concatenation of
86
database name, null char NUL,
87
table name, null char NUL;
88
NOTE that in Windows this is
89
always in LOWER CASE! */
90
ulint full_name_len); /*!< in: full name length where
91
also the null chars count */
93
/*****************************************************************//**
94
Convert a table or index name to the MySQL system_charset_info (UTF-8)
95
and quote it if needed.
96
@return pointer to the end of buf */
99
innobase_convert_name(
100
/*==================*/
101
char* buf, /*!< out: buffer for converted identifier */
102
ulint buflen, /*!< in: length of buf, in bytes */
103
const char* id, /*!< in: identifier to convert */
104
ulint idlen, /*!< in: length of id, in bytes */
105
void* thd, /*!< in: MySQL connection thread, or NULL */
106
ibool table_id);/*!< in: TRUE=id is a table or database name;
107
FALSE=id is an index name */
109
/******************************************************************//**
110
Returns true if the thread is the replication thread on the slave
111
server. Used in srv_conc_enter_innodb() to determine if the thread
112
should be allowed to enter InnoDB - the replication thread is treated
113
differently than other threads. Also used in
114
srv_conc_force_exit_innodb().
115
@return true if thd is the replication thread */
118
thd_is_replication_slave_thread(
119
/*============================*/
120
void* thd); /*!< in: thread handle (THD*) */
122
/******************************************************************//**
123
Returns true if the transaction this thread is processing has edited
124
non-transactional tables. Used by the deadlock detector when deciding
125
which transaction to rollback in case of a deadlock - we try to avoid
126
rolling back transactions that have edited non-transactional tables.
127
@return true if non-transactional tables have been edited */
130
thd_has_edited_nontrans_tables(
131
/*===========================*/
132
void* thd); /*!< in: thread handle (THD*) */
134
/*************************************************************//**
135
Prints info of a THD object (== user session thread) to the given file. */
138
innobase_mysql_print_thd(
139
/*=====================*/
140
FILE* f, /*!< in: output stream */
141
void* thd, /*!< in: pointer to a MySQL THD object */
142
uint max_query_len); /*!< in: max query length to print, or 0 to
143
use the default max length */
145
/**************************************************************//**
146
Converts a MySQL type to an InnoDB type. Note that this function returns
147
the 'mtype' of InnoDB. InnoDB differentiates between MySQL's old <= 4.1
148
VARCHAR and the new true VARCHAR in >= 5.0.3 by the 'prtype'.
149
@return DATA_BINARY, DATA_VARCHAR, ... */
152
get_innobase_type_from_mysql_type(
153
/*==============================*/
154
ulint* unsigned_flag, /*!< out: DATA_UNSIGNED if an
156
at least ENUM and SET,
158
types are 'unsigned types' */
159
const void* field) /*!< in: MySQL Field */
160
__attribute__((nonnull));
162
/*************************************************************//**
163
If you want to print a thd that is not associated with the current thread,
164
you must call this function before reserving the InnoDB kernel_mutex, to
165
protect MySQL from setting thd->query NULL. If you print a thd of the current
166
thread, we know that MySQL cannot modify thd->query, and it is not necessary
167
to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release
171
innobase_mysql_prepare_print_arbitrary_thd(void);
172
/*============================================*/
174
/*************************************************************//**
175
Releases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd().
176
In the InnoDB latching order, the mutex sits right above the
177
kernel_mutex. In debug builds, we assert that the kernel_mutex is
178
released before this function is invoked. */
181
innobase_mysql_end_print_arbitrary_thd(void);
182
/*========================================*/
184
/******************************************************************//**
185
Get the variable length bounds of the given character set. */
188
innobase_get_cset_width(
189
/*====================*/
190
ulint cset, /*!< in: MySQL charset-collation code */
191
ulint* mbminlen, /*!< out: minimum length of a char (in bytes) */
192
ulint* mbmaxlen); /*!< out: maximum length of a char (in bytes) */
194
/******************************************************************//**
195
Compares NUL-terminated UTF-8 strings case insensitively.
196
@return 0 if a=b, <0 if a<b, >1 if a>b */
201
const char* a, /*!< in: first string to compare */
202
const char* b); /*!< in: second string to compare */
204
/******************************************************************//**
205
Returns true if the thread is executing a SELECT statement.
206
@return true if thd is executing SELECT */
212
const void* thd); /*!< in: thread handle (THD*) */
214
/******************************************************************//**
215
Converts an identifier to a table name. */
218
innobase_convert_from_table_id(
219
/*===========================*/
220
const void* cs, /*!< in: the 'from' character set */
221
char* to, /*!< out: converted identifier */
222
const char* from, /*!< in: identifier to convert */
223
ulint len); /*!< in: length of 'to', in bytes; should
224
be at least 5 * strlen(to) + 1 */
225
/******************************************************************//**
226
Converts an identifier to UTF-8. */
229
innobase_convert_from_id(
230
/*=====================*/
231
const void* cs, /*!< in: the 'from' character set */
232
char* to, /*!< out: converted identifier */
233
const char* from, /*!< in: identifier to convert */
234
ulint len); /*!< in: length of 'to', in bytes; should
235
be at least 3 * strlen(to) + 1 */
236
/******************************************************************//**
237
Makes all characters in a NUL-terminated UTF-8 string lower case. */
242
char* a); /*!< in/out: string to put in lower case */
244
/**********************************************************************//**
245
Determines the connection character set.
246
@return connection character set */
249
innobase_get_charset(
250
/*=================*/
251
void* mysql_thd); /*!< in: MySQL thread handle */
253
/******************************************************************//**
254
This function is used to find the storage length in bytes of the first n
255
characters for prefix indexes using a multibyte character set. The function
256
finds charset information and returns length of prefix_len characters in the
257
index field in bytes.
258
@return number of bytes occupied by the first n characters */
261
innobase_get_at_most_n_mbchars(
262
/*===========================*/
263
ulint charset_id, /*!< in: character set id */
264
ulint prefix_len, /*!< in: prefix length in bytes of the index
265
(this has to be divided by mbmaxlen to get the
266
number of CHARACTERS n in the prefix) */
267
ulint data_len, /*!< in: length of the string in bytes */
268
const char* str); /*!< in: character string */
270
/******************************************************************//**
271
Returns true if the thread supports XA,
272
global value of innodb_supports_xa if thd is NULL.
273
@return true if thd supports XA */
279
void* thd); /*!< in: thread handle (THD*), or NULL to query
280
the global innodb_supports_xa */
282
/******************************************************************//**
283
Returns the lock wait timeout for the current connection.
284
@return the lock wait timeout, in seconds */
288
thd_lock_wait_timeout(
289
/*==================*/
290
void* thd); /*!< in: thread handle (THD*), or NULL to query
291
the global innodb_lock_wait_timeout */
301
innobase_fast_mutex_init(
302
os_fast_mutex_t* fast_mutex);