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
#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
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
Returns true if the thread is executing a SELECT statement.
178
@return true if thd is executing SELECT */
183
const void* thd); /*!< in: thread handle (THD*) */
185
/******************************************************************//**
186
Converts an identifier to a table name. */
189
innobase_convert_from_table_id(
190
/*===========================*/
191
struct charset_info_st* cs, /*!< in: the 'from' character set */
192
char* to, /*!< out: converted identifier */
193
const char* from, /*!< in: identifier to convert */
194
ulint len); /*!< in: length of 'to', in bytes; should
195
be at least 5 * strlen(to) + 1 */
196
/******************************************************************//**
197
Converts an identifier to UTF-8. */
200
innobase_convert_from_id(
201
/*=====================*/
202
struct charset_info_st* cs, /*!< in: the 'from' character set */
203
char* to, /*!< out: converted identifier */
204
const char* from, /*!< in: identifier to convert */
205
ulint len); /*!< in: length of 'to', in bytes; should
206
be at least 3 * strlen(to) + 1 */
207
/******************************************************************//**
208
Makes all characters in a NUL-terminated UTF-8 string lower case. */
213
char* a); /*!< in/out: string to put in lower case */
215
/**********************************************************************//**
216
Determines the connection character set.
217
@return connection character set */
218
struct charset_info_st*
219
innobase_get_charset(
220
/*=================*/
221
void* mysql_thd); /*!< in: MySQL thread handle */
223
/******************************************************************//**
224
This function is used to find the storage length in bytes of the first n
225
characters for prefix indexes using a multibyte character set. The function
226
finds charset information and returns length of prefix_len characters in the
227
index field in bytes.
228
@return number of bytes occupied by the first n characters */
231
innobase_get_at_most_n_mbchars(
232
/*===========================*/
233
ulint charset_id, /*!< in: character set id */
234
ulint prefix_len, /*!< in: prefix length in bytes of the index
235
(this has to be divided by mbmaxlen to get the
236
number of CHARACTERS n in the prefix) */
237
ulint data_len, /*!< in: length of the string in bytes */
238
const char* str); /*!< in: character string */
240
/******************************************************************//**
241
Returns true if the thread supports XA,
242
global value of innodb_supports_xa if thd is NULL.
243
@return true if thd supports XA */
248
void* thd); /*!< in: thread handle (THD*), or NULL to query
249
the global innodb_supports_xa */
251
/******************************************************************//**
252
Returns the lock wait timeout for the current connection.
253
@return the lock wait timeout, in seconds */
256
thd_lock_wait_timeout(
257
/*==================*/
258
void* thd); /*!< in: thread handle (THD*), or NULL to query
259
the global innodb_lock_wait_timeout */