~jelmer/pkg-libinnodb/lintian-fixes

« back to all changes in this revision

Viewing changes to include/data0type.h

  • Committer: Monty Taylor
  • Date: 2010-02-25 22:11:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: mordred@inaugust.com-20100225221129-7hp269rppif7b79c
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/data0type.h
20
21
Data types
21
22
 
22
23
Created 1/16/1996 Heikki Tuuri
149
150
#define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE       6
150
151
 
151
152
#ifndef UNIV_HOTBACKUP
152
 
/*************************************************************************
 
153
/*********************************************************************//**
153
154
Determine how many bytes the first n characters of the given string occupy.
154
155
If the string is shorter than n characters, returns the number of bytes
155
 
the characters in the string occupy. */
 
156
the characters in the string occupy.
 
157
@return length of the prefix, in bytes */
156
158
UNIV_INTERN
157
159
ulint
158
160
dtype_get_at_most_n_mbchars(
159
161
/*========================*/
160
 
                                        /* out: length of the prefix,
161
 
                                        in bytes */
162
 
        ulint           prtype,         /* in: precise type */
163
 
        ulint           mbminlen,       /* in: minimum length of a
164
 
                                        multi-byte character */
165
 
        ulint           mbmaxlen,       /* in: maximum length of a
166
 
                                        multi-byte character */
167
 
        ulint           prefix_len,     /* in: length of the requested
 
162
        ulint           prtype,         /*!< in: precise type */
 
163
        ulint           mbminlen,       /*!< in: minimum length of a
 
164
                                        multi-byte character */
 
165
        ulint           mbmaxlen,       /*!< in: maximum length of a
 
166
                                        multi-byte character */
 
167
        ulint           prefix_len,     /*!< in: length of the requested
168
168
                                        prefix, in characters, multiplied by
169
169
                                        dtype_get_mbmaxlen(dtype) */
170
 
        ulint           data_len,       /* in: length of str (in bytes) */
171
 
        const char*     str);           /* in: the string whose prefix
 
170
        ulint           data_len,       /*!< in: length of str (in bytes) */
 
171
        const char*     str);           /*!< in: the string whose prefix
172
172
                                        length is being determined */
173
173
#endif /* !UNIV_HOTBACKUP */
174
 
/*************************************************************************
 
174
/*********************************************************************//**
175
175
Checks if a data main type is a string type. Also a BLOB is considered a
176
 
string type. */
 
176
string type.
 
177
@return TRUE if string type */
177
178
UNIV_INTERN
178
179
ibool
179
180
dtype_is_string_type(
180
181
/*=================*/
181
 
                        /* out: TRUE if string type */
182
 
        ulint   mtype); /* in: InnoDB main data type code: DATA_CHAR, ... */
183
 
/*************************************************************************
 
182
        ulint   mtype); /*!< in: InnoDB main data type code: DATA_CHAR, ... */
 
183
/*********************************************************************//**
184
184
Checks if a type is a binary string type. Note that for tables created with
185
185
< 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For
186
 
those DATA_BLOB columns this function currently returns FALSE. */
 
186
those DATA_BLOB columns this function currently returns FALSE.
 
187
@return TRUE if binary string type */
187
188
UNIV_INTERN
188
189
ibool
189
190
dtype_is_binary_string_type(
190
191
/*========================*/
191
 
                        /* out: TRUE if binary string type */
192
 
        ulint   mtype,  /* in: main data type */
193
 
        ulint   prtype);/* in: precise type */
194
 
/*************************************************************************
 
192
        ulint   mtype,  /*!< in: main data type */
 
193
        ulint   prtype);/*!< in: precise type */
 
194
/*********************************************************************//**
195
195
Checks if a type is a non-binary string type. That is, dtype_is_string_type is
196
196
TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created
197
197
with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column.
198
 
For those DATA_BLOB columns this function currently returns TRUE. */
 
198
For those DATA_BLOB columns this function currently returns TRUE.
 
199
@return TRUE if non-binary string type */
199
200
UNIV_INTERN
200
201
ibool
201
202
dtype_is_non_binary_string_type(
202
203
/*============================*/
203
 
                        /* out: TRUE if non-binary string type */
204
 
        ulint   mtype,  /* in: main data type */
205
 
        ulint   prtype);/* in: precise type */
206
 
/*************************************************************************
 
204
        ulint   mtype,  /*!< in: main data type */
 
205
        ulint   prtype);/*!< in: precise type */
 
206
/*********************************************************************//**
207
207
Sets a data type structure. */
208
208
UNIV_INLINE
209
209
void
210
210
dtype_set(
211
211
/*======*/
212
 
        dtype_t*        type,   /* in: type struct to init */
213
 
        ulint           mtype,  /* in: main data type */
214
 
        ulint           prtype, /* in: precise type */
215
 
        ulint           len);   /* in: precision of type */
216
 
/*************************************************************************
 
212
        dtype_t*        type,   /*!< in: type struct to init */
 
213
        ulint           mtype,  /*!< in: main data type */
 
214
        ulint           prtype, /*!< in: precise type */
 
215
        ulint           len);   /*!< in: precision of type */
 
216
/*********************************************************************//**
217
217
Copies a data type structure. */
218
218
UNIV_INLINE
219
219
void
220
220
dtype_copy(
221
221
/*=======*/
222
 
        dtype_t*        type1,  /* in: type struct to copy to */
223
 
        const dtype_t*  type2); /* in: type struct to copy from */
224
 
/*************************************************************************
225
 
Gets the SQL main data type. */
 
222
        dtype_t*        type1,  /*!< in: type struct to copy to */
 
223
        const dtype_t*  type2); /*!< in: type struct to copy from */
 
224
/*********************************************************************//**
 
225
Gets the SQL main data type.
 
226
@return SQL main data type */
226
227
UNIV_INLINE
227
228
ulint
228
229
dtype_get_mtype(
229
230
/*============*/
230
 
                                /* out: SQL main data type */
231
 
        const dtype_t*  type);  /* in: data type */
232
 
/*************************************************************************
233
 
Gets the precise data type. */
 
231
        const dtype_t*  type);  /*!< in: data type */
 
232
/*********************************************************************//**
 
233
Gets the precise data type.
 
234
@return precise data type */
234
235
UNIV_INLINE
235
236
ulint
236
237
dtype_get_prtype(
237
238
/*=============*/
238
 
                                /* out: precise data type */
239
 
        const dtype_t*  type);  /* in: data type */
 
239
        const dtype_t*  type);  /*!< in: data type */
240
240
#ifndef UNIV_HOTBACKUP
241
 
/*************************************************************************
 
241
/*********************************************************************//**
242
242
Compute the mbminlen and mbmaxlen members of a data type structure. */
243
243
UNIV_INLINE
244
244
void
245
245
dtype_get_mblen(
246
246
/*============*/
247
 
        ulint   mtype,          /* in: main type */
248
 
        ulint   prtype,         /* in: precise type (and collation) */
249
 
        ulint*  mbminlen,       /* out: minimum length of a
 
247
        ulint   mtype,          /*!< in: main type */
 
248
        ulint   prtype,         /*!< in: precise type (and collation) */
 
249
        ulint*  mbminlen,       /*!< out: minimum length of a
250
250
                                multi-byte character */
251
 
        ulint*  mbmaxlen);      /* out: maximum length of a
 
251
        ulint*  mbmaxlen);      /*!< out: maximum length of a
252
252
                                multi-byte character */
253
253
/*************************************************************************
254
254
Gets the user charset-collation code for user string types. */
256
256
ulint
257
257
dtype_get_charset_coll(
258
258
/*===================*/
259
 
        ulint   prtype);/* in: precise data type */
260
 
/*************************************************************************
 
259
        ulint   prtype);/*!< in: precise data type */
 
260
/*********************************************************************//**
261
261
Forms a precise type from the < 4.1.2 format precise type plus the
262
 
charset-collation code. */
 
262
charset-collation code.
 
263
@return precise type, including the charset-collation code */
263
264
UNIV_INTERN
264
265
ulint
265
266
dtype_form_prtype(
266
267
/*==============*/
267
 
        ulint   old_prtype,     /* in: the user type code and the flags
 
268
        ulint   old_prtype,     /*!< in: the user type code and the flags
268
269
                                DATA_BINARY_TYPE etc. */
269
 
        ulint   charset_coll);  /* in: user charset-collation code */
270
 
/*************************************************************************
271
 
Gets the type length. */
 
270
        ulint   charset_coll);  /*!< in: user charset-collation code */
 
271
/*********************************************************************//**
 
272
Gets the type length.
 
273
@return fixed length of the type, in bytes, or 0 if variable-length */
272
274
UNIV_INLINE
273
275
ulint
274
276
dtype_get_len(
275
277
/*==========*/
276
 
                                /* out: fixed length of the type, in bytes,
277
 
                                or 0 if variable-length */
278
 
        const dtype_t*  type);  /* in: data type */
 
278
        const dtype_t*  type);  /*!< in: data type */
279
279
#ifndef UNIV_HOTBACKUP
280
 
/*************************************************************************
281
 
Gets the minimum length of a character, in bytes. */
 
280
/*********************************************************************//**
 
281
Gets the minimum length of a character, in bytes.
 
282
@return minimum length of a char, in bytes, or 0 if this is not a
 
283
character type */
282
284
UNIV_INLINE
283
285
ulint
284
286
dtype_get_mbminlen(
285
287
/*===============*/
286
 
                                /* out: minimum length of a char, in bytes,
287
 
                                or 0 if this is not a character type */
288
 
        const dtype_t*  type);  /* in: type */
289
 
/*************************************************************************
290
 
Gets the maximum length of a character, in bytes. */
 
288
        const dtype_t*  type);  /*!< in: type */
 
289
/*********************************************************************//**
 
290
Gets the maximum length of a character, in bytes.
 
291
@return maximum length of a char, in bytes, or 0 if this is not a
 
292
character type */
291
293
UNIV_INLINE
292
294
ulint
293
295
dtype_get_mbmaxlen(
294
296
/*===============*/
295
 
                                /* out: maximum length of a char, in bytes,
296
 
                                or 0 if this is not a character type */
297
 
        const dtype_t*  type);  /* in: type */
298
 
/*************************************************************************
299
 
Gets the padding character code for the type. */
 
297
        const dtype_t*  type);  /*!< in: type */
 
298
/*********************************************************************//**
 
299
Gets the padding character code for the type.
 
300
@return padding character code, or ULINT_UNDEFINED if no padding specified */
300
301
UNIV_INLINE
301
302
ulint
302
303
dtype_get_pad_char(
303
304
/*===============*/
304
 
                                /* out: padding character code, or
305
 
                                ULINT_UNDEFINED if no padding specified */
306
 
        ulint   mtype,          /* in: main type */
307
 
        ulint   prtype);        /* in: precise type */
 
305
        ulint   mtype,          /*!< in: main type */
 
306
        ulint   prtype);        /*!< in: precise type */
308
307
#endif /* !UNIV_HOTBACKUP */
309
 
/***************************************************************************
310
 
Returns the size of a fixed size data type, 0 if not a fixed size type. */
 
308
/***********************************************************************//**
 
309
Returns the size of a fixed size data type, 0 if not a fixed size type.
 
310
@return fixed size, or 0 */
311
311
UNIV_INLINE
312
312
ulint
313
313
dtype_get_fixed_size_low(
314
314
/*=====================*/
315
 
                                /* out: fixed size, or 0 */
316
 
        ulint   mtype,          /* in: main type */
317
 
        ulint   prtype,         /* in: precise type */
318
 
        ulint   len,            /* in: length */
319
 
        ulint   mbminlen,       /* in: minimum length of a multibyte char */
320
 
        ulint   mbmaxlen,       /* in: maximum length of a multibyte char */
321
 
        ulint   comp);          /* in: nonzero=ROW_FORMAT=COMPACT  */
 
315
        ulint   mtype,          /*!< in: main type */
 
316
        ulint   prtype,         /*!< in: precise type */
 
317
        ulint   len,            /*!< in: length */
 
318
        ulint   mbminlen,       /*!< in: minimum length of a multibyte char */
 
319
        ulint   mbmaxlen,       /*!< in: maximum length of a multibyte char */
 
320
        ulint   comp);          /*!< in: nonzero=ROW_FORMAT=COMPACT  */
322
321
#ifndef UNIV_HOTBACKUP
323
 
/***************************************************************************
324
 
Returns the minimum size of a data type. */
 
322
/***********************************************************************//**
 
323
Returns the minimum size of a data type.
 
324
@return minimum size */
325
325
UNIV_INLINE
326
326
ulint
327
327
dtype_get_min_size_low(
328
328
/*===================*/
329
 
                                /* out: minimum size */
330
 
        ulint   mtype,          /* in: main type */
331
 
        ulint   prtype,         /* in: precise type */
332
 
        ulint   len,            /* in: length */
333
 
        ulint   mbminlen,       /* in: minimum length of a multibyte char */
334
 
        ulint   mbmaxlen);      /* in: maximum length of a multibyte char */
335
 
/***************************************************************************
 
329
        ulint   mtype,          /*!< in: main type */
 
330
        ulint   prtype,         /*!< in: precise type */
 
331
        ulint   len,            /*!< in: length */
 
332
        ulint   mbminlen,       /*!< in: minimum length of a multibyte char */
 
333
        ulint   mbmaxlen);      /*!< in: maximum length of a multibyte char */
 
334
/***********************************************************************//**
336
335
Returns the maximum size of a data type. Note: types in system tables may be
337
 
incomplete and return incorrect information. */
 
336
incomplete and return incorrect information.
 
337
@return maximum size */
338
338
UNIV_INLINE
339
339
ulint
340
340
dtype_get_max_size_low(
341
341
/*===================*/
342
 
                                /* out: maximum size */
343
 
        ulint   mtype,          /* in: main type */
344
 
        ulint   len);           /* in: length */
 
342
        ulint   mtype,          /*!< in: main type */
 
343
        ulint   len);           /*!< in: length */
345
344
#endif /* !UNIV_HOTBACKUP */
346
 
/***************************************************************************
 
345
/***********************************************************************//**
347
346
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type.
348
 
For fixed length types it is the fixed length of the type, otherwise 0. */
 
347
For fixed length types it is the fixed length of the type, otherwise 0.
 
348
@return SQL null storage size in ROW_FORMAT=REDUNDANT */
349
349
UNIV_INLINE
350
350
ulint
351
351
dtype_get_sql_null_size(
352
352
/*====================*/
353
 
                                /* out: SQL null storage size
354
 
                                in ROW_FORMAT=REDUNDANT */
355
 
        const dtype_t*  type,   /* in: type */
356
 
        ulint           comp);  /* in: nonzero=ROW_FORMAT=COMPACT  */
 
353
        const dtype_t*  type,   /*!< in: type */
 
354
        ulint           comp);  /*!< in: nonzero=ROW_FORMAT=COMPACT  */
357
355
#ifndef UNIV_HOTBACKUP
358
 
/**************************************************************************
 
356
/**********************************************************************//**
359
357
Reads to a type the stored information which determines its alphabetical
360
358
ordering and the storage size of an SQL NULL value. */
361
359
UNIV_INLINE
362
360
void
363
361
dtype_read_for_order_and_null_size(
364
362
/*===============================*/
365
 
        dtype_t*        type,   /* in: type struct */
366
 
        const byte*     buf);   /* in: buffer for the stored order info */
367
 
/**************************************************************************
 
363
        dtype_t*        type,   /*!< in: type struct */
 
364
        const byte*     buf);   /*!< in: buffer for the stored order info */
 
365
/**********************************************************************//**
368
366
Stores for a type the information which determines its alphabetical ordering
369
367
and the storage size of an SQL NULL value. */
370
368
UNIV_INLINE
371
369
void
372
370
dtype_new_store_for_order_and_null_size(
373
371
/*====================================*/
374
 
        byte*           buf,    /* in: buffer for
 
372
        byte*           buf,    /*!< in: buffer for
375
373
                                DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE
376
374
                                bytes where we store the info */
377
 
        const dtype_t*  type,   /* in: type struct */
378
 
        ulint           prefix_len);/* in: prefix length to
 
375
        const dtype_t*  type,   /*!< in: type struct */
 
376
        ulint           prefix_len);/*!< in: prefix length to
379
377
                                replace type->len, or 0 */
380
 
/**************************************************************************
 
378
/**********************************************************************//**
381
379
Reads to a type the stored information which determines its alphabetical
382
380
ordering and the storage size of an SQL NULL value. This is the 4.1.x storage
383
381
format. */
385
383
void
386
384
dtype_new_read_for_order_and_null_size(
387
385
/*===================================*/
388
 
        dtype_t*        type,   /* in: type struct */
389
 
        const byte*     buf);   /* in: buffer for stored type order info */
 
386
        dtype_t*        type,   /*!< in: type struct */
 
387
        const byte*     buf);   /*!< in: buffer for stored type order info */
390
388
#endif /* !UNIV_HOTBACKUP */
391
389
 
392
 
/*************************************************************************
393
 
Validates a data type structure. */
 
390
/*********************************************************************//**
 
391
Validates a data type structure.
 
392
@return TRUE if ok */
394
393
UNIV_INTERN
395
394
ibool
396
395
dtype_validate(
397
396
/*===========*/
398
 
                                /* out: TRUE if ok */
399
 
        const dtype_t*  type);  /* in: type struct to validate */
400
 
/*************************************************************************
 
397
        const dtype_t*  type);  /*!< in: type struct to validate */
 
398
/*********************************************************************//**
401
399
Prints a data type structure. */
402
400
UNIV_INTERN
403
401
void
404
402
dtype_print(
405
403
/*========*/
406
 
        const dtype_t*  type);  /* in: type */
 
404
        const dtype_t*  type);  /*!< in: type */
407
405
 
408
406
/*************************************************************************
409
 
Gets the user type code from a dtype. */
 
407
Gets the user type code from a dtype.
 
408
@return type code; this is NOT an InnoDB type code! */
410
409
UNIV_INLINE
411
410
ulint
412
411
dtype_get_attrib(
413
412
/*=============*/
414
 
                                /* out: type code; this is NOT an InnoDB
415
 
                                type code! */
416
 
        const dtype_t*  type);  /* in: type struct */
 
413
        const dtype_t*  type);  /*!< in: type struct */
417
414
/*************************************************************************
418
415
Reset dtype variables. */
419
416
UNIV_INTERN
433
430
want to ensure that they are identical and also want to ensure that
434
431
all bit-fields can be packed tightly in both structs. */
435
432
#define DTYPE_FIELDS                                                    \
436
 
        unsigned        mtype:8;        /* main data type */            \
437
 
        unsigned        prtype:24;      /* precise type; user data      \
 
433
        unsigned        mtype:8;        /*!< main data type */          \
 
434
        unsigned        prtype:24;      /*!< precise type; user data    \
438
435
                                        type, charset code, flags to    \
439
436
                                        indicate nullability,           \
440
437
                                        signedness, whether this is a   \
441
438
                                        binary string */                \
442
439
        /* the remaining fields do not affect alphabetical ordering: */ \
443
 
        unsigned        len:16;         /* length */                    \
444
 
        unsigned        mbminlen:2;     /* minimum length of a          \
 
440
        unsigned        len:16;         /*!< length */                  \
 
441
        unsigned        mbminlen:2;     /*!< minimum length of a        \
445
442
                                        character, in bytes */          \
446
 
        unsigned        mbmaxlen:3;     /* maximum length of a          \
447
 
                                        character, in bytes */
 
443
        unsigned        mbmaxlen:3;     /*!< maximum length of bytes    \
 
444
                                        to store the string length) */
448
445
struct dtype_struct {
449
446
        DTYPE_FIELDS
450
447
#endif /* !UNIV_HOTBACKUP */