149
150
#define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE 6
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 */
158
160
dtype_get_at_most_n_mbchars(
159
161
/*========================*/
160
/* out: length of the prefix,
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
177
@return TRUE if string type */
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 */
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 */
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. */
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. */
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 */
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 */
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. */
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. */
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 */
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 */
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
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
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 */
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 */
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 */
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 */
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 */
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. */
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. */
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