~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to strings/CHARSET_INFO.txt

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
CHARSET_INFO
 
3
============
 
4
A structure containing data for charset+collation pair implementation. 
 
5
 
 
6
Virtual functions that use this data are collected into separate
 
7
structures, MY_CHARSET_HANDLER and MY_COLLATION_HANDLER.
 
8
 
 
9
 
 
10
typedef struct charset_info_st
 
11
{
 
12
  uint      number;
 
13
  uint      primary_number;
 
14
  uint      binary_number;
 
15
  uint      state;
 
16
 
 
17
  const char *csname;
 
18
  const char *name;
 
19
  const char *comment;
 
20
 
 
21
  uchar    *ctype;
 
22
  uchar    *to_lower;
 
23
  uchar    *to_upper;
 
24
  uchar    *sort_order;
 
25
 
 
26
  uint16      *tab_to_uni;
 
27
  MY_UNI_IDX  *tab_from_uni;
 
28
 
 
29
  uchar state_map[256];
 
30
  uchar ident_map[256];
 
31
 
 
32
  uint      strxfrm_multiply;
 
33
  uint      mbminlen;
 
34
  uint      mbmaxlen;
 
35
  uint16    max_sort_char; /* For LIKE optimization */
 
36
 
 
37
  MY_CHARSET_HANDLER *cset;
 
38
  MY_COLLATION_HANDLER *coll;
 
39
 
 
40
} CHARSET_INFO;
 
41
 
 
42
 
 
43
CHARSET_INFO fields description:
 
44
===============================
 
45
 
 
46
 
 
47
Numbers (identifiers)
 
48
---------------------
 
49
 
 
50
number - an ID uniquely identifying this charset+collation pair.
 
51
 
 
52
primary_number - ID of a charset+collation pair, which consists
 
53
of the same character set and the default collation of this
 
54
character set. Not really used now. Intended to optimize some
 
55
parts of the code where we need to find the default collation
 
56
using its non-default counterpart for the given character set.
 
57
 
 
58
binary_number - ID of a charset+collation pair, which consists
 
59
of the same character set and the binary collation of this
 
60
character set. Not really used now. 
 
61
 
 
62
Names
 
63
-----
 
64
 
 
65
  csname  - name of the character set for this charset+collation pair.
 
66
  name    - name of the collation for this charset+collation pair.
 
67
  comment - a text comment, displayed in "Description" column of
 
68
            SHOW CHARACTER SET output.
 
69
 
 
70
Conversion tables
 
71
-----------------
 
72
  
 
73
  ctype      - pointer to array[257] of "type of characters"
 
74
               bit mask for each character, e.g., whether a 
 
75
               character is a digit, letter, separator, etc.
 
76
 
 
77
               Monty 2004-10-21:
 
78
                 If you look at the macros, we use ctype[(char)+1].
 
79
                 ctype[0] is traditionally in most ctype libraries
 
80
                 reserved for EOF (-1). The idea is that you can use
 
81
                 the result from fgetc() directly with ctype[]. As
 
82
                 we have to be compatible with external ctype[] versions,
 
83
                 it's better to do it the same way as they do...
 
84
 
 
85
  to_lower   - pointer to array[256] used in LCASE()
 
86
  to_upper   - pointer to array[256] used in UCASE()
 
87
  sort_order - pointer to array[256] used for strings comparison
 
88
 
 
89
In all Asian charsets these arrays are set up as follows:
 
90
 
 
91
- All bytes in the range 0x80..0xFF were marked as letters in the
 
92
  ctype array.
 
93
 
 
94
- The to_lower and to_upper arrays map only ASCII letters.
 
95
  UPPER() and LOWER() doesn't really work for multi-byte characters.
 
96
  Most of the characters in Asian character sets are ideograms
 
97
  anyway and they don't have case mapping. However, there are
 
98
  still some characters from European alphabets.
 
99
  For example:
 
100
  _ujis 0x8FAAF2 - LATIN CAPITAL LETTER Y WITH ACUTE
 
101
  _ujis 0x8FABF2 - LATIN SMALL LETTER Y WITH ACUTE
 
102
 
 
103
  But they don't map to each other with UPPER and LOWER operations.
 
104
 
 
105
- The sort_order array is filled case insensitively for the
 
106
  ASCII range 0x00..0x7F, and in "binary" fashion for the multi-byte
 
107
  range 0x80..0xFF for these collations:
 
108
 
 
109
  cp932_japanese_ci,
 
110
  euckr_korean_ci,
 
111
  eucjpms_japanese_ci,
 
112
  gb2312_chinese_ci,
 
113
  sjis_japanese_ci,
 
114
  ujis_japanese_ci.
 
115
 
 
116
  So multi-byte characters are sorted just according to their codes.
 
117
 
 
118
 
 
119
- Two collations are still case insensitive for the ASCII characters,
 
120
  but have special sorting order for multi-byte characters
 
121
  (something more complex than just according to codes):
 
122
 
 
123
  big5_chinese_ci
 
124
  gbk_chinese_ci
 
125
 
 
126
  So handlers for these collations use only the 0x00..0x7F part
 
127
  of their sort_order arrays, and apply the special functions
 
128
  for multi-byte characters
 
129
 
 
130
In Unicode character sets we have full support of UPPER/LOWER mapping,
 
131
for sorting order, and for character type detection.
 
132
"utf8_general_ci" still has the "old-fashioned" arrays
 
133
like to_upper, to_lower, sort_order and ctype, but they are
 
134
not really used (maybe only in some rare legacy functions).
 
135
 
 
136
 
 
137
 
 
138
Unicode conversion data
 
139
-----------------------
 
140
For 8-bit character sets:
 
141
 
 
142
tab_to_uni  : array[256] of charset->Unicode translation
 
143
tab_from_uni: a structure for Unicode->charset translation
 
144
 
 
145
Non-8-bit charsets have their own structures per charset
 
146
hidden in corresponding ctype-xxx.c file and don't use
 
147
tab_to_uni and tab_from_uni tables.
 
148
 
 
149
 
 
150
Parser maps
 
151
-----------
 
152
state_map[]
 
153
ident_map[]
 
154
 
 
155
These maps are used to quickly identify whether a character is an
 
156
identifier part, a digit, a special character, or a part of another
 
157
SQL language lexical item.
 
158
 
 
159
Probably can be combined with ctype array in the future.
 
160
But for some reasons these two arrays are used in the parser,
 
161
while a separate ctype[] array is used in the other part of the
 
162
code, like fulltext, etc.
 
163
 
 
164
 
 
165
Miscellaneous fields
 
166
--------------------
 
167
 
 
168
  strxfrm_multiply - how many times a sort key (that is, a string
 
169
                     that can be passed into memcmp() for comparison)
 
170
                     can be longer than the original string. 
 
171
                     Usually it is 1. For some complex
 
172
                     collations it can be bigger. For example,
 
173
                     in latin1_german2_ci, a sort key is up to
 
174
                     two times longer than the original string.
 
175
                     e.g. Letter 'A' with two dots above is
 
176
                     substituted with 'AE'. 
 
177
  mbminlen         - minimum multi-byte sequence length.
 
178
                     Now always 1 except for ucs2. For ucs2,
 
179
                     it is 2.
 
180
  mbmaxlen         - maximum multi-byte sequence length.
 
181
                     1 for 8-bit charsets. Can be also 2 or 3.
 
182
 
 
183
  max_sort_char    - for LIKE range
 
184
                     in case of 8-bit character sets - native code
 
185
                     of maximum character (max_str pad byte);
 
186
                     in case of UTF8 and UCS2 - Unicode code of the maximum
 
187
                     possible character (usually U+FFFF). This code is
 
188
                     converted to multi-byte representation (usually 0xEFBFBF)
 
189
                     and then used as a pad sequence for max_str.
 
190
                     in case of other multi-byte character sets -
 
191
                     max_str pad byte (usually 0xFF).
 
192
 
 
193
MY_CHARSET_HANDLER
 
194
==================
 
195
 
 
196
MY_CHARSET_HANDLER is a collection of character-set
 
197
related routines. Defined in m_ctype.h. Have the 
 
198
following set of functions:
 
199
 
 
200
Multi-byte routines
 
201
------------------
 
202
ismbchar()  - detects whether the given string is a multi-byte sequence
 
203
mbcharlen() - returns length of multi-byte sequence starting with
 
204
              the given character
 
205
numchars()  - returns number of characters in the given string, e.g.
 
206
              in SQL function CHAR_LENGTH().
 
207
charpos()   - calculates the offset of the given position in the string.
 
208
              Used in SQL functions LEFT(), RIGHT(), SUBSTRING(), 
 
209
              INSERT()
 
210
 
 
211
well_formed_length()
 
212
            - finds the length of correctly formed multi-byte beginning.
 
213
              Used in INSERTs to cut a beginning of the given string
 
214
              which is
 
215
              a) "well formed" according to the given character set.
 
216
              b) can fit into the given data type
 
217
              Terminates the string in the good position, taking in account
 
218
              multi-byte character boundaries.
 
219
 
 
220
lengthsp()  - returns the length of the given string without trailing spaces.
 
221
 
 
222
 
 
223
Unicode conversion routines
 
224
---------------------------
 
225
mb_wc       - converts the left multi-byte sequence into its Unicode code.
 
226
mc_mb       - converts the given Unicode code into multi-byte sequence.
 
227
 
 
228
 
 
229
Case and sort conversion
 
230
------------------------
 
231
caseup_str  - converts the given 0-terminated string to uppercase
 
232
casedn_str  - converts the given 0-terminated string to lowercase
 
233
caseup      - converts the given string to lowercase using length
 
234
casedn      - converts the given string to lowercase using length
 
235
 
 
236
Number-to-string conversion routines
 
237
------------------------------------
 
238
snprintf()
 
239
long10_to_str()
 
240
longlong10_to_str()
 
241
 
 
242
The names are pretty self-describing.
 
243
 
 
244
String padding routines
 
245
-----------------------
 
246
fill()     - writes the given Unicode value into the given string
 
247
             with the given length. Used to pad the string, usually
 
248
             with space character, according to the given charset.
 
249
 
 
250
String-to-number conversion routines
 
251
------------------------------------
 
252
strntol()
 
253
strntoul()
 
254
strntoll()
 
255
strntoull()
 
256
strntod()
 
257
 
 
258
These functions are almost the same as their STDLIB counterparts,
 
259
but also:
 
260
  - accept length instead of 0-terminator
 
261
  - are character set dependent
 
262
 
 
263
Simple scanner routines
 
264
-----------------------
 
265
scan()    - to skip leading spaces in the given string.
 
266
            Used when a string value is inserted into a numeric field.
 
267
 
 
268
 
 
269
 
 
270
MY_COLLATION_HANDLER
 
271
====================
 
272
strnncoll()   - compares two strings according to the given collation
 
273
strnncollsp() - like the above but ignores trailing spaces
 
274
strnxfrm()    - makes a sort key suitable for memcmp() corresponding
 
275
                to the given string
 
276
like_range()  - creates a LIKE range, for optimizer
 
277
wildcmp()     - wildcard comparison, for LIKE
 
278
strcasecmp()  - 0-terminated string comparison
 
279
instr()       - finds the first substring appearance in the string
 
280
hash_sort()   - calculates hash value taking into account
 
281
                the collation rules, e.g. case-insensitivity, 
 
282
                accent sensitivity, etc.
 
283
 
 
284