~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to plugin/innobase/include/ha_prototypes.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
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.
 
8
 
 
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.
 
12
 
 
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
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/*******************************************************************//**
 
20
@file include/ha_prototypes.h
 
21
Prototypes for global functions in ha_innodb.cc that are called by
 
22
InnoDB C code
 
23
 
 
24
Created 5/11/2006 Osku Salerma
 
25
************************************************************************/
 
26
 
 
27
#ifndef HA_INNODB_PROTOTYPES_H
 
28
#define HA_INNODB_PROTOTYPES_H
 
29
 
 
30
#include "trx0types.h"
 
31
#if !defined(BUILD_DRIZZLE)
 
32
# include "m_ctype.h" /* CHARSET_INFO */
 
33
 
 
34
/*********************************************************************//**
 
35
Wrapper around MySQL's copy_and_convert function.
 
36
@return        number of bytes copied to 'to' */
 
37
UNIV_INTERN
 
38
ulint
 
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 */
 
50
 
 
51
#endif /* DRIZZLE */
 
52
/* Prototypes for global functions in ha_innodb.cc that are called by
 
53
InnoDB's C-code. */
 
54
 
 
55
 
 
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
 
63
terminating NUL).
 
64
@return number of bytes that were written */
 
65
UNIV_INTERN
 
66
ulint
 
67
innobase_raw_format(
 
68
/*================*/
 
69
        const char*     data,           /*!< in: raw data */
 
70
        ulint           data_len,       /*!< in: raw data length
 
71
                                        in bytes */
 
72
        ulint           charset_coll,   /*!< in: charset collation */
 
73
        char*           buf,            /*!< out: output buffer */
 
74
        ulint           buf_size);      /*!< in: output buffer size
 
75
                                        in bytes */
 
76
 
 
77
/*****************************************************************//**
 
78
Invalidates the MySQL query cache for the table. */
 
79
UNIV_INTERN
 
80
void
 
81
innobase_invalidate_query_cache(
 
82
/*============================*/
 
83
        trx_t*          trx,            /*!< in: transaction which
 
84
                                        modifies the table */
 
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 */
 
92
 
 
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 */
 
97
UNIV_INTERN
 
98
char*
 
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 */
 
108
 
 
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 */
 
116
UNIV_INTERN
 
117
ibool
 
118
thd_is_replication_slave_thread(
 
119
/*============================*/
 
120
        void*   thd);   /*!< in: thread handle (THD*) */
 
121
 
 
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 */
 
128
UNIV_INTERN
 
129
ibool
 
130
thd_has_edited_nontrans_tables(
 
131
/*===========================*/
 
132
        void*   thd);   /*!< in: thread handle (THD*) */
 
133
 
 
134
/*************************************************************//**
 
135
Prints info of a THD object (== user session thread) to the given file. */
 
136
UNIV_INTERN
 
137
void
 
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 */
 
144
 
 
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, ... */
 
150
UNIV_INTERN
 
151
ulint
 
152
get_innobase_type_from_mysql_type(
 
153
/*==============================*/
 
154
        ulint*          unsigned_flag,  /*!< out: DATA_UNSIGNED if an
 
155
                                        'unsigned type';
 
156
                                        at least ENUM and SET,
 
157
                                        and unsigned integer
 
158
                                        types are 'unsigned types' */
 
159
        const void*     field)          /*!< in: MySQL Field */
 
160
        __attribute__((nonnull));
 
161
 
 
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
 
168
the kernel_mutex. */
 
169
UNIV_INTERN
 
170
void
 
171
innobase_mysql_prepare_print_arbitrary_thd(void);
 
172
/*============================================*/
 
173
 
 
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. */
 
179
UNIV_INTERN
 
180
void
 
181
innobase_mysql_end_print_arbitrary_thd(void);
 
182
/*========================================*/
 
183
 
 
184
/******************************************************************//**
 
185
Get the variable length bounds of the given character set. */
 
186
UNIV_INTERN
 
187
void
 
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) */
 
193
 
 
194
/******************************************************************//**
 
195
Compares NUL-terminated UTF-8 strings case insensitively.
 
196
@return 0 if a=b, <0 if a<b, >1 if a>b */
 
197
UNIV_INTERN
 
198
int
 
199
innobase_strcasecmp(
 
200
/*================*/
 
201
        const char*     a,      /*!< in: first string to compare */
 
202
        const char*     b);     /*!< in: second string to compare */
 
203
 
 
204
/******************************************************************//**
 
205
Returns true if the thread is executing a SELECT statement.
 
206
@return true if thd is executing SELECT */
 
207
 
 
208
UNIV_INTERN
 
209
ibool
 
210
thd_is_select(
 
211
/*==========*/
 
212
        const void*     thd);   /*!< in: thread handle (THD*) */
 
213
 
 
214
/******************************************************************//**
 
215
Converts an identifier to a table name. */
 
216
UNIV_INTERN
 
217
void
 
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. */
 
227
UNIV_INTERN
 
228
void
 
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. */
 
238
UNIV_INTERN
 
239
void
 
240
innobase_casedn_str(
 
241
/*================*/
 
242
        char*   a);     /*!< in/out: string to put in lower case */
 
243
 
 
244
/**********************************************************************//**
 
245
Determines the connection character set.
 
246
@return connection character set */
 
247
UNIV_INTERN
 
248
const void *
 
249
innobase_get_charset(
 
250
/*=================*/
 
251
        void*   mysql_thd);     /*!< in: MySQL thread handle */
 
252
 
 
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 */
 
259
UNIV_INTERN
 
260
ulint
 
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 */
 
269
 
 
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 */
 
274
 
 
275
UNIV_INTERN
 
276
ibool
 
277
thd_supports_xa(
 
278
/*============*/
 
279
        void*   thd);   /*!< in: thread handle (THD*), or NULL to query
 
280
                        the global innodb_supports_xa */
 
281
 
 
282
/******************************************************************//**
 
283
Returns the lock wait timeout for the current connection.
 
284
@return the lock wait timeout, in seconds */
 
285
 
 
286
UNIV_INTERN
 
287
ulong
 
288
thd_lock_wait_timeout(
 
289
/*==================*/
 
290
        void*   thd);   /*!< in: thread handle (THD*), or NULL to query
 
291
                        the global innodb_lock_wait_timeout */
 
292
 
 
293
UNIV_INTERN
 
294
bool
 
295
innobase_isspace(
 
296
        const void * cs,
 
297
        char char_to_test);
 
298
 
 
299
UNIV_INTERN
 
300
int
 
301
innobase_fast_mutex_init(
 
302
        os_fast_mutex_t*        fast_mutex);
 
303
                
 
304
 
 
305
#endif