1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
Header File that defines all the charset declarations being used in Drizzle source code
26
#include <sys/types.h>
28
#include <drizzled/visibility.h>
29
#include <drizzled/definitions.h>
33
#define MY_CS_NAME_SIZE 32
34
#define MY_CS_CTYPE_TABLE_SIZE 257
35
#define MY_CS_TO_LOWER_TABLE_SIZE 256
36
#define MY_CS_TO_UPPER_TABLE_SIZE 256
37
#define MY_CS_SORT_ORDER_TABLE_SIZE 256
38
#define MY_CS_TO_UNI_TABLE_SIZE 256
39
#define CHARSET_DIR "charsets/"
40
#define my_wc_t unsigned long
41
/* wm_wc and wc_mb return codes */
42
#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */
43
#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */
44
#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */
45
#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */
46
#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */
47
/* These following three are currently not really used */
48
#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */
49
#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */
50
#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */
51
#define MY_SEQ_INTTAIL 1
52
#define MY_SEQ_SPACES 2
53
#define MY_CS_COMPILED 1 /* compiled-in sets */
54
#define MY_CS_CONFIG 2 /* sets that have a *.conf file */
55
#define MY_CS_INDEX 4 /* sets listed in the Index file */
56
#define MY_CS_LOADED 8 /* sets that are currently loaded */
57
#define MY_CS_BINSORT 16 /* if binary sort order */
58
#define MY_CS_PRIMARY 32 /* if primary collation */
59
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
60
#define MY_CS_UNICODE 128 /* is a charset is full unicode */
61
#define MY_CS_READY 256 /* if a charset is initialized */
62
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
63
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
64
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
65
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
66
#define MY_CHARSET_UNDEFINED 0
67
/* Flags for strxfrm */
68
#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
69
#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
70
#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
71
#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
72
#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
73
#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
74
#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
75
#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
76
#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
77
#define MY_STRXFRM_UNUSED_00000080 0x00000080 /* for future extensions */
78
#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
79
#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
80
#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
81
#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
82
#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
83
#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
84
#define MY_STRXFRM_DESC_SHIFT 8
85
#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
86
#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
87
#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
88
#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
89
#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
90
#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
91
#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
92
#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
93
#define MY_STRXFRM_REVERSE_SHIFT 16
94
#define ILLEGAL_CHARSET_INFO_NUMBER (UINT32_MAX)
95
#define MY_UTF8MB4 "utf8"
96
#define my_charset_utf8_general_ci ::drizzled::my_charset_utf8mb4_general_ci
97
#define my_charset_utf8_bin ::drizzled::my_charset_utf8mb4_bin
98
#define _MY_U 01 /* Upper case */
99
#define _MY_L 02 /* Lower case */
100
#define _MY_NMR 04 /* Numeral (digit) */
101
#define _MY_SPC 010 /* Spacing character */
102
#define _MY_PNT 020 /* Punctuation */
103
#define _MY_CTR 040 /* Control character */
104
#define _MY_B 0100 /* Blank */
105
#define _MY_X 0200 /* heXadecimal digit */
107
/* Some typedef to make it easy for C++ to make function pointers */
108
typedef int (*my_charset_conv_mb_wc)(const struct charset_info_st * const, my_wc_t *,
109
const unsigned char *, const unsigned char *);
110
typedef int (*my_charset_conv_wc_mb)(const struct charset_info_st * const, my_wc_t,
111
unsigned char *, unsigned char *);
112
typedef size_t (*my_charset_conv_case)(const struct charset_info_st * const,
113
char *, size_t, char *, size_t);
114
struct charset_info_st;
115
typedef struct unicase_info_st
122
typedef struct uni_ctype_st
124
unsigned char pctype;
125
unsigned char *ctype;
128
/* A helper function for "need at least n bytes" */
129
inline static int my_cs_toosmalln(int n)
134
typedef struct my_uni_idx_st
150
MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT,
151
MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
152
MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
153
MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
154
MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
155
MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE,
156
MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON,
157
MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP,
158
MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
159
MY_LEX_IDENT_OR_KEYWORD,
160
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN,
161
MY_LEX_STRING_OR_DELIMITER
164
struct charset_info_st;
166
/* See strings/charset_info_st.txt for information about this structure */
167
typedef struct my_collation_handler_st
169
bool (*init)(charset_info_st&, unsigned char *(*alloc)(size_t));
170
/* Collation routines */
171
int (*strnncoll)(const struct charset_info_st * const,
172
const unsigned char *, size_t, const unsigned char *, size_t, bool);
173
int (*strnncollsp)(const struct charset_info_st * const,
174
const unsigned char *, size_t, const unsigned char *, size_t,
175
bool diff_if_only_endspace_difference);
176
size_t (*strnxfrm)(const struct charset_info_st * const,
177
unsigned char *dst, size_t dstlen, uint32_t nweights,
178
const unsigned char *src, size_t srclen, uint32_t flags);
179
size_t (*strnxfrmlen)(const struct charset_info_st * const, size_t);
180
bool (*like_range)(const struct charset_info_st * const,
181
const char *s, size_t s_length,
182
char escape, char w_one, char w_many,
184
char *min_str, char *max_str,
185
size_t *min_len, size_t *max_len);
186
int (*wildcmp)(const struct charset_info_st * const,
187
const char *str,const char *str_end,
188
const char *wildstr,const char *wildend,
189
int escape,int w_one, int w_many);
191
int (*strcasecmp)(const struct charset_info_st * const, const char *, const char *);
193
uint32_t (*instr)(const struct charset_info_st * const,
194
const char *b, size_t b_length,
195
const char *s, size_t s_length,
196
my_match_t *match, uint32_t nmatch);
198
/* Hash calculation */
199
void (*hash_sort)(const struct charset_info_st *cs, const unsigned char *key, size_t len,
200
uint32_t *nr1, uint32_t *nr2);
201
bool (*propagate)(const struct charset_info_st *cs, const unsigned char *str, size_t len);
202
} MY_COLLATION_HANDLER;
204
/* See strings/charset_info_st.txt about information on this structure */
205
typedef struct my_charset_handler_st
207
void (*init_unused)();
208
/* Multibyte routines */
209
uint32_t (*ismbchar)(const struct charset_info_st * const, const char *, const char *);
210
uint32_t (*mbcharlen)(const struct charset_info_st * const, uint32_t c);
211
size_t (*numchars)(const struct charset_info_st * const, const char *b, const char *e);
212
size_t (*charpos)(const struct charset_info_st * const, const char *b, const char *e,
214
size_t (*well_formed_len)(const struct charset_info_st * const,
215
const char *b,const char *e,
216
size_t nchars, int *error);
217
size_t (*lengthsp)(const struct charset_info_st * const, const char *ptr, size_t length);
218
size_t (*numcells)(const struct charset_info_st * const, const char *b, const char *e);
220
/* Unicode conversion */
221
my_charset_conv_mb_wc mb_wc;
222
my_charset_conv_wc_mb wc_mb;
225
int (*ctype)(const struct charset_info_st *cs, int *ctype,
226
const unsigned char *s, const unsigned char *e);
228
/* Functions for case and sort conversion */
229
size_t (*caseup_str)(const struct charset_info_st * const, char *);
230
size_t (*casedn_str)(const struct charset_info_st * const, char *);
232
my_charset_conv_case caseup;
233
my_charset_conv_case casedn;
235
/* Charset dependant snprintf() */
236
size_t (*snprintf)(const struct charset_info_st * const, char *to, size_t n,
239
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
240
__attribute__((format(printf, 4, 5)))
243
size_t (*long10_to_str)(const struct charset_info_st * const, char *to, size_t n,
244
int radix, long int val);
245
size_t (*int64_t10_to_str)(const struct charset_info_st * const, char *to, size_t n,
246
int radix, int64_t val);
248
void (*fill)(const struct charset_info_st * const, char *to, size_t len, int fill);
250
/* String-to-number conversion routines */
251
long (*strntol)(const struct charset_info_st * const, const char *s, size_t l,
252
int base, char **e, int *err);
253
unsigned long (*strntoul)(const struct charset_info_st * const, const char *s, size_t l,
254
int base, char **e, int *err);
255
int64_t (*strntoll)(const struct charset_info_st * const, const char *s, size_t l,
256
int base, char **e, int *err);
257
uint64_t (*strntoull)(const struct charset_info_st * const, const char *s, size_t l,
258
int base, char **e, int *err);
259
double (*strntod)(const struct charset_info_st * const, char *s, size_t l, char **e,
261
int64_t (*strtoll10)(const struct charset_info_st *cs,
262
const char *nptr, char **endptr, int *error);
263
uint64_t (*strntoull10rnd)(const struct charset_info_st *cs,
264
const char *str, size_t length,
266
char **endptr, int *error);
267
size_t (*scan)(const struct charset_info_st * const, const char *b, const char *e,
269
} MY_CHARSET_HANDLER;
272
/* See strings/charset_info_st.txt about information on this structure */
273
struct charset_info_st
276
uint32_t primary_number;
277
uint32_t binary_number;
282
const char *tailoring;
283
unsigned char *ctype;
284
unsigned char *to_lower;
285
unsigned char *to_upper;
286
unsigned char *sort_order;
287
uint16_t *contractions;
288
uint16_t **sort_order_big;
289
uint16_t *tab_to_uni;
290
MY_UNI_IDX *tab_from_uni;
291
MY_UNICASE_INFO **caseinfo;
292
unsigned char *state_map;
293
unsigned char *ident_map;
294
uint32_t strxfrm_multiply;
295
unsigned char caseup_multiply;
296
unsigned char casedn_multiply;
299
uint16_t min_sort_char;
300
uint16_t max_sort_char; /* For LIKE optimization */
301
unsigned char pad_char;
302
bool escape_with_backslash_is_dangerous;
303
unsigned char levels_for_compare;
304
unsigned char levels_for_order;
306
MY_CHARSET_HANDLER *cset;
307
MY_COLLATION_HANDLER *coll;
311
extern DRIZZLED_API charset_info_st *all_charsets[256];
312
extern charset_info_st compiled_charsets[];
313
extern uint32_t get_charset_number(const char *cs_name, uint32_t cs_flags);
314
extern uint32_t get_collation_number(const char *name);
315
extern const char *get_charset_name(uint32_t cs_number);
316
extern bool resolve_charset(const char *cs_name,
317
const charset_info_st *default_cs,
318
const charset_info_st **cs);
319
extern bool resolve_collation(const char *cl_name,
320
const charset_info_st *default_cl,
321
const charset_info_st **cl);
322
extern void free_charsets();
323
extern char *get_charsets_dir(char *buf);
324
extern bool my_charset_same(const charset_info_st *cs1, const charset_info_st *cs2);
325
extern size_t escape_string_for_drizzle(const charset_info_st *charset_info,
326
char *to, size_t to_length,
327
const char *from, size_t length);
328
extern size_t escape_quotes_for_drizzle(const charset_info_st *charset_info,
329
char *to, size_t to_length,
330
const char *from, size_t length);
331
extern DRIZZLED_API const charset_info_st *default_charset_info;
332
extern DRIZZLED_API const charset_info_st *system_charset_info;
333
extern const charset_info_st *files_charset_info;
334
extern const charset_info_st *table_alias_charset;
335
extern MY_UNICASE_INFO *my_unicase_default[256];
336
extern MY_UNICASE_INFO *my_unicase_turkish[256];
337
extern MY_UNI_CTYPE my_uni_ctype[256];
338
extern DRIZZLED_API charset_info_st my_charset_bin;
339
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_bin;
340
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_general_ci;
341
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_unicode_ci;
342
size_t my_strnxfrmlen_simple(const charset_info_st * const, size_t);
343
extern int my_strnncollsp_simple(const charset_info_st * const, const unsigned char *, size_t,
344
const unsigned char *, size_t,
345
bool diff_if_only_endspace_difference);
346
extern size_t my_lengthsp_8bit(const charset_info_st * const cs, const char *ptr, size_t length);
347
extern uint32_t my_instr_simple(const charset_info_st * const,
348
const char *b, size_t b_length,
349
const char *s, size_t s_length,
350
my_match_t *match, uint32_t nmatch);
351
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
352
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
353
extern int my_strcasecmp_mb(const charset_info_st * const cs, const char *s, const char *t);
354
extern bool my_parse_charset_xml(const char *bug, size_t len,
355
int (*add)(charset_info_st *cs));
357
DRIZZLED_API const charset_info_st *get_charset(uint32_t cs_number);
358
DRIZZLED_API const charset_info_st *get_charset_by_name(const char *cs_name);
359
DRIZZLED_API const charset_info_st *get_charset_by_csname(const char *cs_name, uint32_t cs_flags);
361
/* Functions for 8bit */
362
int my_mb_ctype_8bit(const charset_info_st * const,int *, const unsigned char *,const unsigned char *);
363
int my_mb_ctype_mb(const charset_info_st * const,int *, const unsigned char *,const unsigned char *);
365
size_t my_scan_8bit(const charset_info_st * const cs, const char *b, const char *e, int sq);
367
size_t my_snprintf_8bit(const charset_info_st * const, char *to, size_t n,
368
const char *fmt, ...)
369
__attribute__((format(printf, 4, 5)));
371
long my_strntol_8bit(const charset_info_st * const, const char *s, size_t l, int base,
373
unsigned long my_strntoul_8bit(const charset_info_st * const, const char *s, size_t l, int base,
375
int64_t my_strntoll_8bit(const charset_info_st * const, const char *s, size_t l, int base,
377
uint64_t my_strntoull_8bit(const charset_info_st * const, const char *s, size_t l, int base,
379
double my_strntod_8bit(const charset_info_st * const, char *s, size_t l,char **e,
381
size_t my_long10_to_str_8bit(const charset_info_st * const, char *to, size_t l, int radix,
383
size_t my_int64_t10_to_str_8bit(const charset_info_st * const, char *to, size_t l, int radix,
385
int64_t my_strtoll10_8bit(const charset_info_st * const cs,
386
const char *nptr, char **endptr, int *error);
387
int64_t my_strtoll10_ucs2(charset_info_st *cs,
388
const char *nptr, char **endptr, int *error);
390
uint64_t my_strntoull10rnd_8bit(const charset_info_st * const cs,
391
const char *str, size_t length, int
392
unsigned_fl, char **endptr, int *error);
393
uint64_t my_strntoull10rnd_ucs2(charset_info_st *cs,
394
const char *str, size_t length,
395
int unsigned_fl, char **endptr, int *error);
397
void my_fill_8bit(const charset_info_st * const cs, char* to, size_t l, int fill);
399
bool my_like_range_simple(const charset_info_st * const cs,
400
const char *ptr, size_t ptr_length,
401
char escape, char w_one, char w_many,
403
char *min_str, char *max_str,
404
size_t *min_length, size_t *max_length);
406
bool my_like_range_mb(const charset_info_st * const cs,
407
const char *ptr, size_t ptr_length,
408
char escape, char w_one, char w_many,
410
char *min_str, char *max_str,
411
size_t *min_length, size_t *max_length);
413
bool my_like_range_ucs2(const charset_info_st * const cs,
414
const char *ptr, size_t ptr_length,
415
char escape, char w_one, char w_many,
417
char *min_str, char *max_str,
418
size_t *min_length, size_t *max_length);
420
bool my_like_range_utf16(const charset_info_st * const cs,
421
const char *ptr, size_t ptr_length,
422
char escape, char w_one, char w_many,
424
char *min_str, char *max_str,
425
size_t *min_length, size_t *max_length);
427
bool my_like_range_utf32(const charset_info_st * const cs,
428
const char *ptr, size_t ptr_length,
429
char escape, char w_one, char w_many,
431
char *min_str, char *max_str,
432
size_t *min_length, size_t *max_length);
435
int my_wildcmp_8bit(const charset_info_st * const,
436
const char *str,const char *str_end,
437
const char *wildstr,const char *wildend,
438
int escape, int w_one, int w_many);
440
int my_wildcmp_bin(const charset_info_st * const,
441
const char *str,const char *str_end,
442
const char *wildstr,const char *wildend,
443
int escape, int w_one, int w_many);
445
size_t my_numchars_8bit(const charset_info_st * const, const char *b, const char *e);
446
size_t my_numcells_8bit(const charset_info_st * const, const char *b, const char *e);
447
size_t my_charpos_8bit(const charset_info_st * const, const char *b, const char *e, size_t pos);
448
size_t my_well_formed_len_8bit(const charset_info_st * const, const char *b, const char *e,
449
size_t pos, int *error);
450
typedef unsigned char *(*cs_alloc_func)(size_t);
451
bool my_coll_init_simple(charset_info_st *cs, cs_alloc_func alloc);
452
bool my_cset_init_8bit(charset_info_st *cs, cs_alloc_func alloc);
453
uint32_t my_mbcharlen_8bit(const charset_info_st * const, uint32_t c);
455
/* Functions for multibyte charsets */
456
int my_wildcmp_mb(const charset_info_st * const,
457
const char *str,const char *str_end,
458
const char *wildstr,const char *wildend,
459
int escape, int w_one, int w_many);
460
size_t my_numchars_mb(const charset_info_st * const, const char *b, const char *e);
461
size_t my_numcells_mb(const charset_info_st * const, const char *b, const char *e);
462
size_t my_charpos_mb(const charset_info_st * const, const char *b, const char *e, size_t pos);
463
size_t my_well_formed_len_mb(const charset_info_st * const, const char *b, const char *e,
464
size_t pos, int *error);
465
uint32_t my_instr_mb(const charset_info_st * const,
466
const char *b, size_t b_length,
467
const char *s, size_t s_length,
468
my_match_t *match, uint32_t nmatch);
470
int my_strnncoll_mb_bin(const charset_info_st * const cs,
471
const unsigned char *s, size_t slen,
472
const unsigned char *t, size_t tlen,
475
int my_strnncollsp_mb_bin(const charset_info_st * const cs,
476
const unsigned char *a, size_t a_length,
477
const unsigned char *b, size_t b_length,
478
bool diff_if_only_endspace_difference);
480
int my_wildcmp_mb_bin(const charset_info_st * const cs,
481
const char *str,const char *str_end,
482
const char *wildstr,const char *wildend,
483
int escape, int w_one, int w_many);
485
int my_strcasecmp_mb_bin(const charset_info_st * const, const char *s, const char *t);
487
void my_hash_sort_mb_bin(const charset_info_st * const,
488
const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
490
size_t my_strnxfrm_mb(const charset_info_st * const,
491
unsigned char *dst, size_t dstlen, uint32_t nweights,
492
const unsigned char *src, size_t srclen, uint32_t flags);
494
int my_wildcmp_unicode(const charset_info_st * const cs,
495
const char *str, const char *str_end,
496
const char *wildstr, const char *wildend,
497
int escape, int w_one, int w_many,
498
MY_UNICASE_INFO **weights);
500
bool my_propagate_simple(const charset_info_st * const cs, const unsigned char *str, size_t len);
501
bool my_propagate_complex(const charset_info_st * const cs, const unsigned char *str, size_t len);
504
uint32_t my_strxfrm_flag_normalize(uint32_t flags, uint32_t nlevels);
505
void my_strxfrm_desc_and_reverse(unsigned char *str, unsigned char *strend,
506
uint32_t flags, uint32_t level);
507
size_t my_strxfrm_pad_desc_and_reverse(const charset_info_st * const cs,
508
unsigned char *str, unsigned char *frmend, unsigned char *strend,
509
uint32_t nweights, uint32_t flags, uint32_t level);
511
bool my_charset_is_ascii_compatible(const charset_info_st * const cs);
514
Compare 0-terminated UTF8 strings.
517
my_strcasecmp_utf8mb3()
518
cs character set handler
519
s First 0-terminated string to compare
520
t Second 0-terminated string to compare
525
- negative number if s < t
526
- positive number if s > t
527
- 0 is the strings are equal
529
int my_wc_mb_filename(const charset_info_st * const,
530
my_wc_t wc, unsigned char *s, unsigned char *e);
532
int my_mb_wc_filename(const charset_info_st * const,
533
my_wc_t *pwc, const unsigned char *s, const unsigned char *e);
536
unsigned int my_ismbchar_utf8mb4(const charset_info_st * const cs, const char *b, const char *e);
537
unsigned int my_mbcharlen_utf8mb4(const charset_info_st * const, uint32_t c);
539
size_t my_strnxfrmlen_utf8mb4(const charset_info_st * const, size_t len);
541
my_strnxfrm_utf8mb4(const charset_info_st * const cs,
542
unsigned char *dst, size_t dstlen, uint32_t nweights,
543
const unsigned char *src, size_t srclen, uint32_t flags);
545
int my_wildcmp_utf8mb4(const charset_info_st * const cs,
546
const char *str, const char *strend,
547
const char *wildstr, const char *wildend,
548
int escape, int w_one, int w_many);
549
int my_strnncollsp_utf8mb4(const charset_info_st * const cs,
550
const unsigned char *s, size_t slen,
551
const unsigned char *t, size_t tlen,
552
bool diff_if_only_endspace_difference);
553
int my_strcasecmp_utf8mb4(const charset_info_st * const cs,
554
const char *s, const char *t);
556
int my_strnncoll_utf8mb4(const charset_info_st * const cs,
557
const unsigned char *s, size_t slen,
558
const unsigned char *t, size_t tlen,
561
int my_mb_wc_utf8mb4(const charset_info_st * const cs,
562
my_wc_t * pwc, const unsigned char *s, const unsigned char *e);
564
int my_wc_mb_utf8mb4(const charset_info_st * const cs,
565
my_wc_t wc, unsigned char *r, unsigned char *e);
567
size_t my_caseup_str_utf8mb4(const charset_info_st * const cs, char *src);
568
size_t my_casedn_str_utf8mb4(const charset_info_st * const cs, char *src);
570
size_t my_caseup_utf8mb4(const charset_info_st * const cs, char *src, size_t srclen,
571
char *dst, size_t dstlen);
572
size_t my_casedn_utf8mb4(const charset_info_st * const cs,
573
char *src, size_t srclen,
574
char *dst, size_t dstlen);
577
int my_strnncoll_any_uca(const charset_info_st * const cs,
578
const unsigned char *s, size_t slen,
579
const unsigned char *t, size_t tlen,
582
int my_strnncollsp_any_uca(const charset_info_st * const cs,
583
const unsigned char *s, size_t slen,
584
const unsigned char *t, size_t tlen,
585
bool diff_if_only_endspace_difference);
587
void my_hash_sort_any_uca(const charset_info_st * const cs,
588
const unsigned char *s, size_t slen,
589
uint32_t *n1, uint32_t *n2);
591
size_t my_strnxfrm_any_uca(const charset_info_st * const cs,
592
unsigned char *dst, size_t dstlen, uint32_t nweights,
593
const unsigned char *src, size_t srclen,
596
int my_wildcmp_uca(const charset_info_st * const cs,
597
const char *str,const char *str_end,
598
const char *wildstr,const char *wildend,
599
int escape, int w_one, int w_many);
601
int my_strnncoll_8bit_bin(const charset_info_st * const,
602
const unsigned char *s, size_t slen,
603
const unsigned char *t, size_t tlen,
605
int my_strnncollsp_8bit_bin(const charset_info_st * const,
606
const unsigned char *a, size_t a_length,
607
const unsigned char *b, size_t b_length,
608
bool diff_if_only_endspace_difference);
609
size_t my_case_str_bin(const charset_info_st * const, char *);
610
size_t my_case_bin(const charset_info_st * const, char *,
611
size_t srclen, char *, size_t);
612
int my_strcasecmp_bin(const charset_info_st * const,
613
const char *s, const char *t);
614
size_t my_strnxfrm_8bit_bin(const charset_info_st * const cs,
615
unsigned char * dst, size_t dstlen, uint32_t nweights,
616
const unsigned char *src, size_t srclen, uint32_t flags);
617
uint32_t my_instr_bin(const charset_info_st * const,
618
const char *b, size_t b_length,
619
const char *s, size_t s_length,
620
my_match_t *match, uint32_t nmatch);
621
size_t my_lengthsp_binary(const charset_info_st * const,
622
const char *, size_t length);
623
int my_mb_wc_bin(const charset_info_st * const,
624
my_wc_t *wc, const unsigned char *str,
625
const unsigned char *end);
626
int my_wc_mb_bin(const charset_info_st * const, my_wc_t wc,
627
unsigned char *str, unsigned char *end);
628
void my_hash_sort_8bit_bin(const charset_info_st * const,
629
const unsigned char *key, size_t len,
630
uint32_t *nr1, uint32_t *nr2);
631
bool my_coll_init_8bit_bin(charset_info_st *cs,
633
int my_strnncoll_binary(const charset_info_st * const,
634
const unsigned char *s, size_t slen,
635
const unsigned char *t, size_t tlen,
637
int my_strnncollsp_binary(const charset_info_st * const cs,
638
const unsigned char *s, size_t slen,
639
const unsigned char *t, size_t tlen,
642
inline static bool my_isascii(char c)
644
return (!(c & ~0177));
647
inline static char my_toascii(char c)
652
inline static char my_tocntrl(char c)
657
inline static char my_toprint(char c)
662
inline static char my_toupper(const charset_info_st *s, unsigned char c)
664
return s->to_upper[c];
667
inline static char my_tolower(const charset_info_st *s, unsigned char c)
669
return s->to_lower[c];
672
inline static bool my_isalpha(const charset_info_st *s, unsigned char c)
674
return (s->ctype+1)[c] & (_MY_U | _MY_L);
677
inline static bool my_isupper(const charset_info_st *s, unsigned char c)
679
return (s->ctype+1)[c] & _MY_U;
682
inline static bool my_islower(const charset_info_st *s, unsigned char c)
684
return (s->ctype+1)[c] & _MY_L;
687
inline static bool my_isdigit(const charset_info_st *s, unsigned char c)
689
return (s->ctype+1)[c] & _MY_NMR;
692
inline static bool my_isxdigit(const charset_info_st *s, unsigned char c)
694
return (s->ctype+1)[c] & _MY_X;
697
inline static bool my_isalnum(const charset_info_st *s, unsigned char c)
699
return (s->ctype+1)[c] & (_MY_U | _MY_L | _MY_NMR);
702
inline static bool my_isspace(const charset_info_st *s, unsigned char c)
704
return (s->ctype+1)[c] & _MY_SPC;
707
inline static bool my_ispunct(const charset_info_st *s, unsigned char c)
709
return (s->ctype+1)[c] & _MY_PNT;
712
inline static bool my_isprint(const charset_info_st *s, unsigned char c)
714
return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
717
inline static bool my_isgraph(const charset_info_st *s, unsigned char c)
719
return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
722
inline static bool my_iscntrl(const charset_info_st *s, unsigned char c)
724
return (s->ctype+1)[c] & _MY_CTR;
727
/* Some macros that should be cleaned up a little */
728
inline static bool my_isvar(const charset_info_st *s, char c)
730
return my_isalnum(s,c) || (c) == '_';
733
inline static bool my_isvar_start(const charset_info_st *s, char c)
735
return my_isalpha(s,c) || (c) == '_';
738
inline static bool my_binary_compare(const charset_info_st *s)
740
return s->state & MY_CS_BINSORT;
743
inline static bool use_strnxfrm(const charset_info_st *s)
745
return s->state & MY_CS_STRNXFRM;
748
inline static size_t my_strnxfrm(const charset_info_st *cs,
751
const unsigned char *src,
752
const uint32_t srclen)
754
return (cs->coll->strnxfrm(cs, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE));
757
inline static int my_strnncoll(const charset_info_st *cs,
758
const unsigned char *s,
760
const unsigned char *t,
763
return (cs->coll->strnncoll(cs, s, slen, t, tlen, 0));
766
inline static bool my_like_range(const charset_info_st *cs,
767
const char *ptr, const size_t ptrlen,
772
char *minstr, char *maxstr,
773
size_t *minlen, size_t *maxlen)
775
return (cs->coll->like_range(cs, ptr, ptrlen, escape, w_one, w_many, reslen,
776
minstr, maxstr, minlen, maxlen));
779
inline static int my_wildcmp(const charset_info_st *cs,
780
const char *str, const char *strend,
781
const char *w_str, const char *w_strend,
783
const int w_one, const int w_many)
785
return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
788
inline static int my_strcasecmp(const charset_info_st *cs, const char *s, const char *t)
790
return (cs->coll->strcasecmp(cs, s, t));
793
template <typename CHAR_T>
794
inline static size_t my_charpos(const charset_info_st *cs,
795
const CHAR_T *b, const CHAR_T* e, size_t num)
797
return cs->cset->charpos(cs, reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(e), num);
800
inline static bool use_mb(const charset_info_st *cs)
802
return cs->cset->ismbchar != NULL;
805
inline static unsigned int my_ismbchar(const charset_info_st *cs, const char *a, const char *b)
807
return cs->cset->ismbchar(cs, a, b);
810
inline static unsigned int my_mbcharlen(const charset_info_st *cs, uint32_t c)
812
return cs->cset->mbcharlen(cs, c);
816
inline static size_t my_caseup_str(const charset_info_st *cs, char *src)
818
return cs->cset->caseup_str(cs, src);
821
inline static size_t my_casedn_str(const charset_info_st *cs, char *src)
823
return cs->cset->casedn_str(cs, src);
826
inline static long my_strntol(const charset_info_st *cs,
827
const char* s, const size_t l, const int base, char **e, int *err)
829
return (cs->cset->strntol(cs, s, l, base, e, err));
832
inline static unsigned long my_strntoul(const charset_info_st *cs,
833
const char* s, const size_t l, const int base,
836
return (cs->cset->strntoul(cs, s, l, base, e, err));
839
inline static int64_t my_strntoll(const charset_info_st *cs,
840
const char* s, const size_t l, const int base, char **e, int *err)
842
return (cs->cset->strntoll(cs, s, l, base, e, err));
845
inline static int64_t my_strntoull(const charset_info_st *cs,
846
const char* s, const size_t l, const int base,
849
return (cs->cset->strntoull(cs, s, l, base, e, err));
853
inline static double my_strntod(const charset_info_st *cs,
854
char* s, const size_t l, char **e, int *err)
856
return (cs->cset->strntod(cs, s, l, e, err));
859
int make_escape_code(const charset_info_st * const cs, const char *escape);
861
} /* namespace drizzled */