~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to storage/xtradb/include/ha_prototypes.h

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 2000, 2013, Oracle and/or its affiliates. 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
#include "m_ctype.h" /* CHARSET_INFO */
 
32
 
 
33
/*********************************************************************//**
 
34
Wrapper around MySQL's copy_and_convert function.
 
35
@return number of bytes copied to 'to' */
 
36
UNIV_INTERN
 
37
ulint
 
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 */
 
49
 
 
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
 
57
terminating NUL).
 
58
@return number of bytes that were written */
 
59
UNIV_INTERN
 
60
ulint
 
61
innobase_raw_format(
 
62
/*================*/
 
63
        const char*     data,           /*!< in: raw data */
 
64
        ulint           data_len,       /*!< in: raw data length
 
65
                                        in bytes */
 
66
        ulint           charset_coll,   /*!< in: charset collation */
 
67
        char*           buf,            /*!< out: output buffer */
 
68
        ulint           buf_size);      /*!< in: output buffer size
 
69
                                        in bytes */
 
70
 
 
71
/*****************************************************************//**
 
72
Invalidates the MySQL query cache for the table. */
 
73
UNIV_INTERN
 
74
void
 
75
innobase_invalidate_query_cache(
 
76
/*============================*/
 
77
        trx_t*          trx,            /*!< in: transaction which
 
78
                                        modifies the table */
 
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 */
 
86
 
 
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 */
 
91
UNIV_INTERN
 
92
char*
 
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 */
 
102
 
 
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 */
 
110
UNIV_INTERN
 
111
ibool
 
112
thd_is_replication_slave_thread(
 
113
/*============================*/
 
114
        const void*     thd);   /*!< in: thread handle (THD*) */
 
115
 
 
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 */
 
122
UNIV_INTERN
 
123
ibool
 
124
thd_has_edited_nontrans_tables(
 
125
/*===========================*/
 
126
        void*   thd);   /*!< in: thread handle (THD*) */
 
127
 
 
128
/*************************************************************//**
 
129
Prints info of a THD object (== user session thread) to the given file. */
 
130
UNIV_INTERN
 
131
void
 
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 */
 
138
 
 
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, ... */
 
144
UNIV_INTERN
 
145
ulint
 
146
get_innobase_type_from_mysql_type(
 
147
/*==============================*/
 
148
        ulint*          unsigned_flag,  /*!< out: DATA_UNSIGNED if an
 
149
                                        'unsigned type';
 
150
                                        at least ENUM and SET,
 
151
                                        and unsigned integer
 
152
                                        types are 'unsigned types' */
 
153
        const void*     field)          /*!< in: MySQL Field */
 
154
        __attribute__((nonnull));
 
155
 
 
156
/******************************************************************//**
 
157
Get the variable length bounds of the given character set. */
 
158
UNIV_INTERN
 
159
void
 
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) */
 
165
 
 
166
/******************************************************************//**
 
167
Compares NUL-terminated UTF-8 strings case insensitively.
 
168
@return 0 if a=b, <0 if a<b, >1 if a>b */
 
169
UNIV_INTERN
 
170
int
 
171
innobase_strcasecmp(
 
172
/*================*/
 
173
        const char*     a,      /*!< in: first string to compare */
 
174
        const char*     b);     /*!< in: second string to compare */
 
175
 
 
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 */
 
179
UNIV_INTERN
 
180
const char*
 
181
innobase_basename(
 
182
/*==============*/
 
183
        const char*     path_name);     /*!< in: full path name */
 
184
 
 
185
/******************************************************************//**
 
186
Returns true if the thread is executing a SELECT statement.
 
187
@return true if thd is executing SELECT */
 
188
 
 
189
ibool
 
190
thd_is_select(
 
191
/*==========*/
 
192
        const void*     thd);   /*!< in: thread handle (THD*) */
 
193
 
 
194
/******************************************************************//**
 
195
Converts an identifier to a table name. */
 
196
UNIV_INTERN
 
197
void
 
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. */
 
207
UNIV_INTERN
 
208
void
 
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. */
 
218
UNIV_INTERN
 
219
void
 
220
innobase_casedn_str(
 
221
/*================*/
 
222
        char*   a);     /*!< in/out: string to put in lower case */
 
223
 
 
224
/**********************************************************************//**
 
225
Determines the connection character set.
 
226
@return connection character set */
 
227
UNIV_INTERN
 
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 */
 
235
UNIV_INTERN
 
236
const char*
 
237
innobase_get_stmt(
 
238
/*==============*/
 
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 */
 
248
UNIV_INTERN
 
249
ulint
 
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 */
 
258
 
 
259
/*************************************************************//**
 
260
InnoDB index push-down condition check
 
261
@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */
 
262
enum icp_result
 
263
handler_index_cond_check(
 
264
/*================*/
 
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 */
 
271
 
 
272
ibool
 
273
thd_supports_xa(
 
274
/*============*/
 
275
        void*   thd);   /*!< in: thread handle (THD*), or NULL to query
 
276
                        the global innodb_supports_xa */
 
277
 
 
278
/******************************************************************//**
 
279
Returns the lock wait timeout for the current connection.
 
280
@return the lock wait timeout, in seconds */
 
281
 
 
282
ulong
 
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. */
 
289
UNIV_INTERN
 
290
void
 
291
thd_set_lock_wait_time(
 
292
/*===================*/
 
293
        void*   thd,    /*!< in: thread handle (THD*) */
 
294
        ulint   value); /*!< in: time waited for the lock */
 
295
/******************************************************************//**
 
296
*/
 
297
 
 
298
ulong
 
299
thd_flush_log_at_trx_commit(
 
300
/*================================*/
 
301
        void*   thd);
 
302
 
 
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
 
307
read.
 
308
@return value of lower_case_table_names */
 
309
UNIV_INTERN
 
310
ulint
 
311
innobase_get_lower_case_table_names(void);
 
312
/*=====================================*/
 
313
 
 
314
 
 
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 */
 
319
 
 
320
ulong
 
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 */
 
325
 
 
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. */
 
330
UNIV_INTERN
 
331
my_bool
 
332
innobase_check_identifier_length(
 
333
/*=============================*/
 
334
        const char*     id);    /* in: identifier to check.  it must belong
 
335
                                to charset my_charset_filename */
 
336
 
 
337
/**********************************************************************
 
338
Converts an identifier from my_charset_filename to UTF-8 charset. */
 
339
uint
 
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 */
 
346
 
 
347
/**********************************************************************
 
348
Converts an identifier from my_charset_filename to UTF-8 charset. */
 
349
uint
 
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 */
 
355
 
 
356
 
 
357
#endif