~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/dict0dict.h

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#ifndef UNIV_HOTBACKUP
30
30
/**********************************************************************
31
31
Makes all characters in a NUL-terminated UTF-8 string lower case. */
32
 
UNIV_INTERN
 
32
 
33
33
void
34
34
dict_casedn_str(
35
35
/*============*/
37
37
#endif /* !UNIV_HOTBACKUP */
38
38
/************************************************************************
39
39
Get the database name length in a table name. */
40
 
UNIV_INTERN
 
40
 
41
41
ulint
42
42
dict_get_db_name_len(
43
43
/*=================*/
53
53
                                /* out: table name */
54
54
        const char*     name);  /* in: table name in the form
55
55
                                dbname '/' tablename */
56
 
/**************************************************************************
57
 
Returns a table object based on table id. */
58
 
UNIV_INTERN
59
 
dict_table_t*
60
 
dict_table_get_on_id(
61
 
/*=================*/
62
 
                                /* out: table, NULL if does not exist */
63
 
        dulint  table_id,       /* in: table id */
64
 
        trx_t*  trx);           /* in: transaction handle */
65
56
/************************************************************************
66
57
Decrements the count of open MySQL handles to a table. */
67
 
UNIV_INTERN
 
58
 
68
59
void
69
60
dict_table_decrement_handle_count(
70
61
/*==============================*/
71
 
        dict_table_t*   table,          /* in/out: table */
72
 
        ibool           dict_locked);   /* in: TRUE=data dictionary locked */
 
62
        dict_table_t*   table); /* in: table */
73
63
/**************************************************************************
74
64
Inits the data dictionary module. */
75
 
UNIV_INTERN
 
65
 
76
66
void
77
67
dict_init(void);
78
68
/*===========*/
82
72
can be called at database startup if we did not need to do a crash recovery.
83
73
In crash recovery we must scan the space id's from the .ibd files in MySQL
84
74
database directories. */
85
 
UNIV_INTERN
 
75
 
86
76
void
87
77
dict_load_space_id_list(void);
88
78
/*=========================*/
94
84
/*===============*/
95
85
        const dict_col_t*       col,    /* in: column */
96
86
        dtype_t*                type);  /* out: data type */
 
87
/*************************************************************************
 
88
Gets the column data type. */
 
89
 
 
90
void
 
91
dict_col_copy_type_noninline(
 
92
/*=========================*/
 
93
        const dict_col_t*       col,    /* in: column */
 
94
        dtype_t*                type);  /* out: data type */
97
95
#ifdef UNIV_DEBUG
98
96
/*************************************************************************
99
97
Assert that a column and a data type match. */
155
153
/*===================*/
156
154
        const dict_col_t*       col,            /* in: table column */
157
155
        const dict_index_t*     clust_index);   /* in: clustered index */
 
156
/*************************************************************************
 
157
Gets the column position in the clustered index. */
 
158
 
 
159
ulint
 
160
dict_col_get_clust_pos_noninline(
 
161
/*=============================*/
 
162
        const dict_col_t*       col,            /* in: table column */
 
163
        const dict_index_t*     clust_index);   /* in: clustered index */
158
164
/********************************************************************
159
165
If the given column name is reserved for InnoDB system columns, return
160
166
TRUE. */
161
 
UNIV_INTERN
 
167
 
162
168
ibool
163
169
dict_col_name_is_reserved(
164
170
/*======================*/
166
172
        const char*     name);  /* in: column name */
167
173
/************************************************************************
168
174
Acquire the autoinc lock.*/
169
 
UNIV_INTERN
 
175
 
170
176
void
171
177
dict_table_autoinc_lock(
172
178
/*====================*/
173
 
        dict_table_t*   table); /* in/out: table */
 
179
        dict_table_t*   table); /* in: table */
174
180
/************************************************************************
175
181
Initializes the autoinc counter. It is not an error to initialize an already
176
182
initialized counter. */
177
 
UNIV_INTERN
 
183
 
178
184
void
179
185
dict_table_autoinc_initialize(
180
186
/*==========================*/
181
 
        dict_table_t*   table,  /* in/out: table */
182
 
        ib_uint64_t     value); /* in: next value to assign to a row */
 
187
        dict_table_t*   table,  /* in: table */
 
188
        ib_longlong     value); /* in: next value to assign to a row */
183
189
/************************************************************************
184
190
Reads the next autoinc value (== autoinc counter value), 0 if not yet
185
191
initialized. */
186
 
UNIV_INTERN
187
 
ib_uint64_t
 
192
 
 
193
ib_longlong
188
194
dict_table_autoinc_read(
189
195
/*====================*/
190
 
                                        /* out: value for a new row, or 0 */
191
 
        const dict_table_t*     table); /* in: table */
 
196
                                /* out: value for a new row, or 0 */
 
197
        dict_table_t*   table); /* in: table */
192
198
/************************************************************************
193
199
Updates the autoinc counter if the value supplied is equal or bigger than the
194
200
current value. If not inited, does nothing. */
195
 
UNIV_INTERN
 
201
 
196
202
void
197
203
dict_table_autoinc_update(
198
204
/*======================*/
199
205
 
200
 
        dict_table_t*   table,  /* in/out: table */
201
 
        ib_uint64_t     value); /* in: value which was assigned to a row */
 
206
        dict_table_t*   table,  /* in: table */
 
207
        ib_longlong     value); /* in: value which was assigned to a row */
202
208
/************************************************************************
203
209
Release the autoinc lock.*/
204
 
UNIV_INTERN
 
210
 
205
211
void
206
212
dict_table_autoinc_unlock(
207
213
/*======================*/
208
 
        dict_table_t*   table); /* in/out: table */
 
214
        dict_table_t*   table); /* in: table */
209
215
/**************************************************************************
210
216
Adds system columns to a table object. */
211
 
UNIV_INTERN
 
217
 
212
218
void
213
219
dict_table_add_system_columns(
214
220
/*==========================*/
216
222
        mem_heap_t*     heap);  /* in: temporary heap */
217
223
/**************************************************************************
218
224
Adds a table object to the dictionary cache. */
219
 
UNIV_INTERN
 
225
 
220
226
void
221
227
dict_table_add_to_cache(
222
228
/*====================*/
224
230
        mem_heap_t*     heap);  /* in: temporary heap */
225
231
/**************************************************************************
226
232
Removes a table object from the dictionary cache. */
227
 
UNIV_INTERN
 
233
 
228
234
void
229
235
dict_table_remove_from_cache(
230
236
/*=========================*/
231
237
        dict_table_t*   table); /* in, own: table */
232
238
/**************************************************************************
233
239
Renames a table object. */
234
 
UNIV_INTERN
 
240
 
235
241
ibool
236
242
dict_table_rename_in_cache(
237
243
/*=======================*/
238
244
                                        /* out: TRUE if success */
239
 
        dict_table_t*   table,          /* in/out: table */
 
245
        dict_table_t*   table,          /* in: table */
240
246
        const char*     new_name,       /* in: new name */
241
247
        ibool           rename_also_foreigns);/* in: in ALTER TABLE we want
242
248
                                        to preserve the original table name
244
250
/**************************************************************************
245
251
Change the id of a table object in the dictionary cache. This is used in
246
252
DISCARD TABLESPACE. */
247
 
UNIV_INTERN
 
253
 
248
254
void
249
255
dict_table_change_id_in_cache(
250
256
/*==========================*/
251
 
        dict_table_t*   table,  /* in/out: table object already in cache */
 
257
        dict_table_t*   table,  /* in: table object already in cache */
252
258
        dulint          new_id);/* in: new id to set */
253
259
/**************************************************************************
254
260
Adds a foreign key constraint object to the dictionary cache. May free
255
261
the object if there already is an object with the same identifier in.
256
262
At least one of foreign table or referenced table must already be in
257
263
the dictionary cache! */
258
 
UNIV_INTERN
 
264
 
259
265
ulint
260
266
dict_foreign_add_to_cache(
261
267
/*======================*/
264
270
        ibool           check_charsets);/* in: TRUE=check charset
265
271
                                        compatibility */
266
272
/*************************************************************************
267
 
Check if the index is referenced by a foreign key, if TRUE return the
268
 
matching instance NULL otherwise. */
269
 
UNIV_INTERN
270
 
dict_foreign_t*
271
 
dict_table_get_referenced_constraint(
272
 
/*=================================*/
273
 
                                /* out: pointer to foreign key struct if index
274
 
                                is defined for foreign key, otherwise NULL */
275
 
        dict_table_t*   table,  /* in: InnoDB table */
276
 
        dict_index_t*   index); /* in: InnoDB index */
277
 
/*************************************************************************
278
273
Checks if a table is referenced by foreign keys. */
279
 
UNIV_INTERN
 
274
 
280
275
ibool
281
 
dict_table_is_referenced_by_foreign_key(
282
 
/*====================================*/
283
 
                                        /* out: TRUE if table is referenced
284
 
                                        by a foreign key */
285
 
        const dict_table_t*     table); /* in: InnoDB table */
286
 
/**************************************************************************
287
 
Replace the index in the foreign key list that matches this index's
288
 
definition with an equivalent index. */
289
 
UNIV_INTERN
290
 
void
291
 
dict_table_replace_index_in_foreign_list(
292
 
/*=====================================*/
293
 
        dict_table_t*   table,  /* in/out: table */
294
 
        dict_index_t*   index); /* in: index to be replaced */
 
276
dict_table_referenced_by_foreign_key(
 
277
/*=================================*/
 
278
                                /* out: TRUE if table is referenced by a
 
279
                                foreign key */
 
280
        dict_table_t*   table); /* in: InnoDB table */
295
281
/**************************************************************************
296
282
Determines whether a string starts with the specified keyword. */
297
 
UNIV_INTERN
 
283
 
298
284
ibool
299
285
dict_str_starts_with_keyword(
300
286
/*=========================*/
304
290
        const char*     str,            /* in: string to scan for keyword */
305
291
        const char*     keyword);       /* in: keyword to look for */
306
292
/*************************************************************************
307
 
Checks if a index is defined for a foreign key constraint. Index is a part
308
 
of a foreign key constraint if the index is referenced by foreign key
309
 
or index is a foreign key index */
310
 
UNIV_INTERN
311
 
dict_foreign_t*
312
 
dict_table_get_foreign_constraint(
313
 
/*==============================*/
314
 
                                /* out: pointer to foreign key struct if index
315
 
                                is defined for foreign key, otherwise NULL */
316
 
        dict_table_t*   table,  /* in: InnoDB table */
317
 
        dict_index_t*   index); /* in: InnoDB index */
318
 
/*************************************************************************
319
293
Scans a table create SQL string and adds to the data dictionary
320
294
the foreign key constraints declared in the string. This function
321
295
should be called after the indexes for a table have been created.
322
296
Each foreign key constraint must be accompanied with indexes in
323
297
bot participating tables. The indexes are allowed to contain more
324
298
fields than mentioned in the constraint. */
325
 
UNIV_INTERN
 
299
 
326
300
ulint
327
301
dict_create_foreign_constraints(
328
302
/*============================*/
344
318
                                        any foreign keys are found. */
345
319
/**************************************************************************
346
320
Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. */
347
 
UNIV_INTERN
 
321
 
348
322
ulint
349
323
dict_foreign_parse_drop_constraints(
350
324
/*================================*/
365
339
NOTE! This is a high-level function to be used mainly from outside the
366
340
'dict' directory. Inside this directory dict_table_get_low is usually the
367
341
appropriate function. */
368
 
UNIV_INTERN
 
342
 
369
343
dict_table_t*
370
344
dict_table_get(
371
345
/*===========*/
376
350
                                        /* in: whether to increment the open
377
351
                                        handle count on the table */
378
352
/**************************************************************************
379
 
Returns a index object, based on table and index id, and memoryfixes it. */
380
 
UNIV_INTERN
381
 
dict_index_t*
382
 
dict_index_get_on_id_low(
 
353
Returns a table object based on table id. */
 
354
 
 
355
dict_table_t*
 
356
dict_table_get_on_id(
 
357
/*=================*/
 
358
                                /* out: table, NULL if does not exist */
 
359
        dulint  table_id,       /* in: table id */
 
360
        trx_t*  trx);           /* in: transaction handle */
 
361
/**************************************************************************
 
362
Returns a table object based on table id. */
 
363
UNIV_INLINE
 
364
dict_table_t*
 
365
dict_table_get_on_id_low(
383
366
/*=====================*/
384
 
                                        /* out: index, NULL if does not
385
 
                                        exist */
386
 
        dict_table_t*   table,          /* in: table */
387
 
        dulint          index_id);      /* in: index id */
 
367
                                /* out: table, NULL if does not exist */
 
368
        dulint  table_id);      /* in: table id */
388
369
/**************************************************************************
389
370
Checks if a table is in the dictionary cache. */
390
 
 
391
371
UNIV_INLINE
392
372
dict_table_t*
393
373
dict_table_check_if_in_cache_low(
404
384
                                        /* out: table, NULL if not found */
405
385
        const char*     table_name);    /* in: table name */
406
386
/**************************************************************************
407
 
Returns a table object based on table id. */
 
387
A noninlined version of dict_table_get_low. */
 
388
 
 
389
dict_table_t*
 
390
dict_table_get_low_noninlined(
 
391
/*==========================*/
 
392
                                        /* out: table, NULL if not found */
 
393
        const char*     table_name);    /* in: table name */
 
394
/**************************************************************************
 
395
Returns an index object. */
408
396
UNIV_INLINE
409
 
dict_table_t*
410
 
dict_table_get_on_id_low(
411
 
/*=====================*/
412
 
                                /* out: table, NULL if does not exist */
413
 
        dulint  table_id);      /* in: table id */
 
397
dict_index_t*
 
398
dict_table_get_index(
 
399
/*=================*/
 
400
                                /* out: index, NULL if does not exist */
 
401
        dict_table_t*   table,  /* in: table */
 
402
        const char*     name);  /* in: index name */
414
403
/**************************************************************************
415
 
Returns an index object by matching on the name and column names and if
416
 
more than index is found return the index with the higher id.*/
417
 
UNIV_INTERN
 
404
Returns an index object. */
 
405
 
418
406
dict_index_t*
419
 
dict_table_get_index_by_max_id(
 
407
dict_table_get_index_noninline(
420
408
/*===========================*/
421
 
                                /* out: matching index, NULL if not found */
 
409
                                /* out: index, NULL if does not exist */
422
410
        dict_table_t*   table,  /* in: table */
423
 
        const char*     name,   /* in: the index name to find */
424
 
        const char**    columns,/* in: array of column names */
425
 
        ulint           n_cols);/* in: number of columns */
 
411
        const char*     name);  /* in: index name */
426
412
/**************************************************************************
427
413
Returns a column's name. */
428
414
 
438
424
 
439
425
/**************************************************************************
440
426
Prints a table definition. */
441
 
UNIV_INTERN
 
427
 
442
428
void
443
429
dict_table_print(
444
430
/*=============*/
445
431
        dict_table_t*   table); /* in: table */
446
432
/**************************************************************************
447
433
Prints a table data. */
448
 
UNIV_INTERN
 
434
 
449
435
void
450
436
dict_table_print_low(
451
437
/*=================*/
452
438
        dict_table_t*   table); /* in: table */
453
439
/**************************************************************************
454
440
Prints a table data when we know the table name. */
455
 
UNIV_INTERN
 
441
 
456
442
void
457
443
dict_table_print_by_name(
458
444
/*=====================*/
459
445
        const char*     name);
460
446
/**************************************************************************
461
447
Outputs info on foreign keys of a table. */
462
 
UNIV_INTERN
 
448
 
463
449
void
464
450
dict_print_info_on_foreign_keys(
465
451
/*============================*/
473
459
/**************************************************************************
474
460
Outputs info on a foreign key of a table in a format suitable for
475
461
CREATE TABLE. */
476
 
UNIV_INTERN
477
462
void
478
463
dict_print_info_on_foreign_key_in_create_format(
479
464
/*============================================*/
483
468
        ibool           add_newline);   /* in: whether to add a newline */
484
469
/************************************************************************
485
470
Displays the names of the index and the table. */
486
 
UNIV_INTERN
487
471
void
488
472
dict_index_name_print(
489
473
/*==================*/
490
474
        FILE*                   file,   /* in: output stream */
491
475
        trx_t*                  trx,    /* in: transaction */
492
476
        const dict_index_t*     index); /* in: index to print */
493
 
#ifdef UNIV_DEBUG
494
477
/************************************************************************
495
478
Gets the first index on the table (the clustered index). */
496
479
UNIV_INLINE
497
480
dict_index_t*
498
481
dict_table_get_first_index(
499
482
/*=======================*/
500
 
                                        /* out: index, NULL if none exists */
501
 
        const dict_table_t*     table); /* in: table */
 
483
                                /* out: index, NULL if none exists */
 
484
        dict_table_t*   table); /* in: table */
 
485
/************************************************************************
 
486
Gets the first index on the table (the clustered index). */
 
487
 
 
488
dict_index_t*
 
489
dict_table_get_first_index_noninline(
 
490
/*=================================*/
 
491
                                /* out: index, NULL if none exists */
 
492
        dict_table_t*   table); /* in: table */
502
493
/************************************************************************
503
494
Gets the next index on the table. */
504
495
UNIV_INLINE
505
496
dict_index_t*
506
497
dict_table_get_next_index(
507
498
/*======================*/
508
 
                                        /* out: index, NULL if none left */
509
 
        const dict_index_t*     index); /* in: index */
510
 
#else /* UNIV_DEBUG */
511
 
# define dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes)
512
 
# define dict_table_get_next_index(index) UT_LIST_GET_NEXT(indexes, index)
513
 
#endif /* UNIV_DEBUG */
514
 
/************************************************************************
515
 
Check whether the index is the clustered index. */
516
 
UNIV_INLINE
517
 
ulint
518
 
dict_index_is_clust(
519
 
/*================*/
520
 
                                        /* out: nonzero for clustered index,
521
 
                                        zero for other indexes */
522
 
        const dict_index_t*     index)  /* in: index */
523
 
        __attribute__((pure));
524
 
/************************************************************************
525
 
Check whether the index is unique. */
526
 
UNIV_INLINE
527
 
ulint
528
 
dict_index_is_unique(
529
 
/*=================*/
530
 
                                        /* out: nonzero for unique index,
531
 
                                        zero for other indexes */
532
 
        const dict_index_t*     index)  /* in: index */
533
 
        __attribute__((pure));
534
 
/************************************************************************
535
 
Check whether the index is the insert buffer tree. */
536
 
UNIV_INLINE
537
 
ulint
538
 
dict_index_is_ibuf(
539
 
/*===============*/
540
 
                                        /* out: nonzero for insert buffer,
541
 
                                        zero for other indexes */
542
 
        const dict_index_t*     index)  /* in: index */
543
 
        __attribute__((pure));
 
499
                                /* out: index, NULL if none left */
 
500
        dict_index_t*   index); /* in: index */
 
501
/************************************************************************
 
502
Gets the next index on the table. */
544
503
 
 
504
dict_index_t*
 
505
dict_table_get_next_index_noninline(
 
506
/*================================*/
 
507
                                /* out: index, NULL if none left */
 
508
        dict_index_t*   index); /* in: index */
545
509
/************************************************************************
546
510
Gets the number of user-defined columns in a table in the dictionary
547
511
cache. */
549
513
ulint
550
514
dict_table_get_n_user_cols(
551
515
/*=======================*/
552
 
                                        /* out: number of user-defined
553
 
                                        (e.g., not ROW_ID)
554
 
                                        columns of a table */
555
 
        const dict_table_t*     table); /* in: table */
 
516
                                /* out: number of user-defined (e.g., not
 
517
                                ROW_ID) columns of a table */
 
518
        dict_table_t*   table); /* in: table */
556
519
/************************************************************************
557
520
Gets the number of system columns in a table in the dictionary cache. */
558
521
UNIV_INLINE
559
522
ulint
560
523
dict_table_get_n_sys_cols(
561
524
/*======================*/
562
 
                                        /* out: number of system (e.g.,
563
 
                                        ROW_ID) columns of a table */
564
 
        const dict_table_t*     table); /* in: table */
 
525
                                /* out: number of system (e.g.,
 
526
                                ROW_ID) columns of a table */
 
527
        dict_table_t*   table); /* in: table */
565
528
/************************************************************************
566
529
Gets the number of all columns (also system) in a table in the dictionary
567
530
cache. */
569
532
ulint
570
533
dict_table_get_n_cols(
571
534
/*==================*/
572
 
                                        /* out: number of columns of a table */
573
 
        const dict_table_t*     table); /* in: table */
574
 
#ifdef UNIV_DEBUG
 
535
                                /* out: number of columns of a table */
 
536
        dict_table_t*   table); /* in: table */
575
537
/************************************************************************
576
538
Gets the nth column of a table. */
577
539
UNIV_INLINE
578
 
dict_col_t*
 
540
const dict_col_t*
579
541
dict_table_get_nth_col(
580
542
/*===================*/
581
543
                                        /* out: pointer to column object */
582
544
        const dict_table_t*     table,  /* in: table */
583
545
        ulint                   pos);   /* in: position of column */
584
546
/************************************************************************
 
547
Gets the nth column of a table. */
 
548
 
 
549
const dict_col_t*
 
550
dict_table_get_nth_col_noninline(
 
551
/*=============================*/
 
552
                                        /* out: pointer to column object */
 
553
        const dict_table_t*     table,  /* in: table */
 
554
        ulint                   pos);   /* in: position of column */
 
555
/************************************************************************
585
556
Gets the given system column of a table. */
586
557
UNIV_INLINE
587
 
dict_col_t*
 
558
const dict_col_t*
588
559
dict_table_get_sys_col(
589
560
/*===================*/
590
561
                                        /* out: pointer to column object */
591
562
        const dict_table_t*     table,  /* in: table */
592
563
        ulint                   sys);   /* in: DATA_ROW_ID, ... */
593
 
#else /* UNIV_DEBUG */
594
 
#define dict_table_get_nth_col(table, pos) \
595
 
((table)->cols + (pos))
596
 
#define dict_table_get_sys_col(table, sys) \
597
 
((table)->cols + (table)->n_cols + (sys) - DATA_N_SYS_COLS)
598
 
#endif /* UNIV_DEBUG */
599
564
/************************************************************************
600
565
Gets the given system column number of a table. */
601
566
UNIV_INLINE
602
567
ulint
603
568
dict_table_get_sys_col_no(
604
569
/*======================*/
605
 
                                        /* out: column number */
606
 
        const dict_table_t*     table,  /* in: table */
607
 
        ulint                   sys);   /* in: DATA_ROW_ID, ... */
608
 
/************************************************************************
609
 
Returns the minimum data size of an index record. */
610
 
UNIV_INLINE
611
 
ulint
612
 
dict_index_get_min_size(
613
 
/*====================*/
614
 
                                        /* out: minimum data size in bytes */
615
 
        const dict_index_t*     index); /* in: index */
 
570
                                /* out: column number */
 
571
        dict_table_t*   table,  /* in: table */
 
572
        ulint           sys);   /* in: DATA_ROW_ID, ... */
616
573
/************************************************************************
617
574
Check whether the table uses the compact page format. */
618
575
UNIV_INLINE
623
580
                                        compact page format */
624
581
        const dict_table_t*     table); /* in: table */
625
582
/************************************************************************
626
 
Determine the file format of a table. */
627
 
UNIV_INLINE
628
 
ulint
629
 
dict_table_get_format(
630
 
/*==================*/
631
 
                                        /* out: file format version */
632
 
        const dict_table_t*     table); /* in: table */
633
 
/************************************************************************
634
 
Set the file format of a table. */
635
 
UNIV_INLINE
636
 
void
637
 
dict_table_set_format(
638
 
/*==================*/
639
 
        dict_table_t*   table,  /* in/out: table */
640
 
        ulint           format);/* in: file format version */
641
 
/************************************************************************
642
 
Extract the compressed page size from table flags. */
643
 
UNIV_INLINE
644
 
ulint
645
 
dict_table_flags_to_zip_size(
 
583
Check whether the table uses the compact page format. */
 
584
 
 
585
ibool
 
586
dict_table_is_comp_noninline(
646
587
/*=========================*/
647
 
                        /* out: compressed page size,
648
 
                        or 0 if not compressed */
649
 
        ulint   flags)  /* in: flags */
650
 
        __attribute__((__const__));
651
 
/************************************************************************
652
 
Check whether the table uses the compressed compact page format. */
653
 
UNIV_INLINE
654
 
ulint
655
 
dict_table_zip_size(
656
 
/*================*/
657
 
                                        /* out: compressed page size,
658
 
                                        or 0 if not compressed */
 
588
                                        /* out: TRUE if table uses the
 
589
                                        compact page format */
659
590
        const dict_table_t*     table); /* in: table */
660
591
/************************************************************************
661
592
Checks if a column is in the ordering columns of the clustered index of a
662
593
table. Column prefixes are treated like whole columns. */
663
 
UNIV_INTERN
 
594
 
664
595
ibool
665
596
dict_table_col_in_clustered_key(
666
597
/*============================*/
667
 
                                        /* out: TRUE if the column, or its
668
 
                                        prefix, is in the clustered key */
669
 
        const dict_table_t*     table,  /* in: table */
670
 
        ulint                   n);     /* in: column number */
 
598
                                /* out: TRUE if the column, or its prefix, is
 
599
                                in the clustered key */
 
600
        dict_table_t*   table,  /* in: table */
 
601
        ulint           n);     /* in: column number */
671
602
/***********************************************************************
672
 
Copies types of columns contained in table to tuple and sets all
673
 
fields of the tuple to the SQL NULL value.  This function should
674
 
be called right after dtuple_create(). */
675
 
UNIV_INTERN
 
603
Copies types of columns contained in table to tuple. */
 
604
 
676
605
void
677
606
dict_table_copy_types(
678
607
/*==================*/
679
 
        dtuple_t*               tuple,  /* in/out: data tuple */
680
 
        const dict_table_t*     table); /* in: table */
 
608
        dtuple_t*       tuple,  /* in: data tuple */
 
609
        dict_table_t*   table); /* in: index */
681
610
/**************************************************************************
682
611
Looks for an index with the given id. NOTE that we do not reserve
683
612
the dictionary mutex: this function is for emergency purposes like
684
613
printing info of a corrupt database page! */
685
 
UNIV_INTERN
 
614
 
686
615
dict_index_t*
687
616
dict_index_find_on_id_low(
688
617
/*======================*/
690
619
        dulint  id);    /* in: index id */
691
620
/**************************************************************************
692
621
Adds an index to the dictionary cache. */
693
 
UNIV_INTERN
694
 
ulint
 
622
 
 
623
void
695
624
dict_index_add_to_cache(
696
625
/*====================*/
697
 
                                /* out: DB_SUCCESS or error code */
698
626
        dict_table_t*   table,  /* in: table on which the index is */
699
627
        dict_index_t*   index,  /* in, own: index; NOTE! The index memory
700
628
                                object is freed in this function! */
701
629
        ulint           page_no);/* in: root page number of the index */
702
 
/**************************************************************************
703
 
Removes an index from the dictionary cache. */
704
 
UNIV_INTERN
705
 
void
706
 
dict_index_remove_from_cache(
707
 
/*=========================*/
708
 
        dict_table_t*   table,  /* in/out: table */
709
 
        dict_index_t*   index); /* in, own: index */
710
630
/************************************************************************
711
631
Gets the number of fields in the internal representation of an index,
712
632
including fields added by the dictionary system. */
714
634
ulint
715
635
dict_index_get_n_fields(
716
636
/*====================*/
717
 
                                        /* out: number of fields */
718
 
        const dict_index_t*     index); /* in: an internal
719
 
                                        representation of index (in
720
 
                                        the dictionary cache) */
 
637
                                /* out: number of fields */
 
638
        dict_index_t*   index); /* in: an internal representation of index
 
639
                                (in the dictionary cache) */
721
640
/************************************************************************
722
641
Gets the number of fields in the internal representation of an index
723
642
that uniquely determine the position of an index entry in the index, if
727
646
ulint
728
647
dict_index_get_n_unique(
729
648
/*====================*/
730
 
                                        /* out: number of fields */
731
 
        const dict_index_t*     index); /* in: an internal representation
732
 
                                        of index (in the dictionary cache) */
 
649
                                /* out: number of fields */
 
650
        dict_index_t*   index); /* in: an internal representation of index
 
651
                                (in the dictionary cache) */
733
652
/************************************************************************
734
653
Gets the number of fields in the internal representation of an index
735
654
which uniquely determine the position of an index entry in the index, if
738
657
ulint
739
658
dict_index_get_n_unique_in_tree(
740
659
/*============================*/
741
 
                                        /* out: number of fields */
742
 
        const dict_index_t*     index); /* in: an internal representation
743
 
                                        of index (in the dictionary cache) */
 
660
                                /* out: number of fields */
 
661
        dict_index_t*   index); /* in: an internal representation of index
 
662
                                (in the dictionary cache) */
744
663
/************************************************************************
745
664
Gets the number of user-defined ordering fields in the index. In the internal
746
665
representation we add the row id to the ordering fields to make all indexes
750
669
ulint
751
670
dict_index_get_n_ordering_defined_by_user(
752
671
/*======================================*/
753
 
                                        /* out: number of fields */
754
 
        const dict_index_t*     index); /* in: an internal representation
755
 
                                        of index (in the dictionary cache) */
756
 
#ifdef UNIV_DEBUG
 
672
                                /* out: number of fields */
 
673
        dict_index_t*   index); /* in: an internal representation of index
 
674
                                (in the dictionary cache) */
757
675
/************************************************************************
758
676
Gets the nth field of an index. */
759
677
UNIV_INLINE
760
678
dict_field_t*
761
679
dict_index_get_nth_field(
762
680
/*=====================*/
763
 
                                        /* out: pointer to field object */
 
681
                                /* out: pointer to field object */
764
682
        const dict_index_t*     index,  /* in: index */
765
 
        ulint                   pos);   /* in: position of field */
766
 
#else /* UNIV_DEBUG */
767
 
# define dict_index_get_nth_field(index, pos) ((index)->fields + (pos))
768
 
#endif /* UNIV_DEBUG */
 
683
        ulint           pos);   /* in: position of field */
769
684
/************************************************************************
770
685
Gets pointer to the nth column in an index. */
771
686
UNIV_INLINE
786
701
        ulint                   pos);   /* in: position of the field */
787
702
/************************************************************************
788
703
Looks for column n in an index. */
789
 
UNIV_INTERN
 
704
 
790
705
ulint
791
706
dict_index_get_nth_col_pos(
792
707
/*=======================*/
793
 
                                        /* out: position in internal
794
 
                                        representation of the index;
795
 
                                        if not contained, returns
796
 
                                        ULINT_UNDEFINED */
797
 
        const dict_index_t*     index,  /* in: index */
798
 
        ulint                   n);     /* in: column number */
 
708
                                /* out: position in internal representation
 
709
                                of the index; if not contained, returns
 
710
                                ULINT_UNDEFINED */
 
711
        dict_index_t*   index,  /* in: index */
 
712
        ulint           n);     /* in: column number */
799
713
/************************************************************************
800
714
Returns TRUE if the index contains a column or a prefix of that column. */
801
 
UNIV_INTERN
 
715
 
802
716
ibool
803
717
dict_index_contains_col_or_prefix(
804
718
/*==============================*/
805
 
                                        /* out: TRUE if contains the column
806
 
                                        or its prefix */
807
 
        const dict_index_t*     index,  /* in: index */
808
 
        ulint                   n);     /* in: column number */
 
719
                                /* out: TRUE if contains the column or its
 
720
                                prefix */
 
721
        dict_index_t*   index,  /* in: index */
 
722
        ulint           n);     /* in: column number */
809
723
/************************************************************************
810
724
Looks for a matching field in an index. The column has to be the same. The
811
725
column in index must be complete, or must contain a prefix longer than the
812
726
column in index2. That is, we must be able to construct the prefix in index2
813
727
from the prefix in index. */
814
 
UNIV_INTERN
 
728
 
815
729
ulint
816
730
dict_index_get_nth_field_pos(
817
731
/*=========================*/
818
 
                                        /* out: position in internal
819
 
                                        representation of the index;
820
 
                                        if not contained, returns
821
 
                                        ULINT_UNDEFINED */
822
 
        const dict_index_t*     index,  /* in: index from which to search */
823
 
        const dict_index_t*     index2, /* in: index */
824
 
        ulint                   n);     /* in: field number in index2 */
 
732
                                /* out: position in internal representation
 
733
                                of the index; if not contained, returns
 
734
                                ULINT_UNDEFINED */
 
735
        dict_index_t*   index,  /* in: index from which to search */
 
736
        dict_index_t*   index2, /* in: index */
 
737
        ulint           n);     /* in: field number in index2 */
825
738
/************************************************************************
826
739
Looks for column n position in the clustered index. */
827
 
UNIV_INTERN
 
740
 
828
741
ulint
829
742
dict_table_get_nth_col_pos(
830
743
/*=======================*/
831
 
                                        /* out: position in internal
832
 
                                        representation of
833
 
                                        the clustered index */
834
 
        const dict_table_t*     table,  /* in: table */
835
 
        ulint                   n);     /* in: column number */
 
744
                                /* out: position in internal representation
 
745
                                of the clustered index */
 
746
        dict_table_t*   table,  /* in: table */
 
747
        ulint           n);     /* in: column number */
836
748
/************************************************************************
837
749
Returns the position of a system column in an index. */
838
750
UNIV_INLINE
839
751
ulint
840
752
dict_index_get_sys_col_pos(
841
753
/*=======================*/
842
 
                                        /* out: position,
843
 
                                        ULINT_UNDEFINED if not contained */
844
 
        const dict_index_t*     index,  /* in: index */
845
 
        ulint                   type);  /* in: DATA_ROW_ID, ... */
 
754
                                /* out: position, ULINT_UNDEFINED if not
 
755
                                contained */
 
756
        dict_index_t*   index,  /* in: index */
 
757
        ulint           type);  /* in: DATA_ROW_ID, ... */
846
758
/***********************************************************************
847
759
Adds a column to index. */
848
 
UNIV_INTERN
 
760
 
849
761
void
850
762
dict_index_add_col(
851
763
/*===============*/
852
 
        dict_index_t*           index,          /* in/out: index */
853
 
        const dict_table_t*     table,          /* in: table */
854
 
        dict_col_t*             col,            /* in: column */
855
 
        ulint                   prefix_len);    /* in: column prefix length */
 
764
        dict_index_t*   index,          /* in: index */
 
765
        dict_table_t*   table,          /* in: table */
 
766
        dict_col_t*     col,            /* in: column */
 
767
        ulint           prefix_len);    /* in: column prefix length */
856
768
/***********************************************************************
857
769
Copies types of fields contained in index to tuple. */
858
 
UNIV_INTERN
 
770
 
859
771
void
860
772
dict_index_copy_types(
861
773
/*==================*/
862
 
        dtuple_t*               tuple,          /* in/out: data tuple */
863
 
        const dict_index_t*     index,          /* in: index */
864
 
        ulint                   n_fields);      /* in: number of
865
 
                                                field types to copy */
 
774
        dtuple_t*       tuple,          /* in: data tuple */
 
775
        dict_index_t*   index,          /* in: index */
 
776
        ulint           n_fields);      /* in: number of field types to copy */
866
777
/*************************************************************************
867
778
Gets the field column. */
868
779
UNIV_INLINE
871
782
/*===============*/
872
783
        const dict_field_t*     field);
873
784
 
874
 
/**************************************************************************
875
 
Returns an index object if it is found in the dictionary cache.
876
 
Assumes that dict_sys->mutex is already being held. */
877
 
UNIV_INTERN
878
 
dict_index_t*
879
 
dict_index_get_if_in_cache_low(
880
 
/*===========================*/
881
 
                                /* out: index, NULL if not found */
882
 
        dulint  index_id);      /* in: index id */
883
 
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 
785
#ifdef UNIV_DEBUG
884
786
/**************************************************************************
885
787
Returns an index object if it is found in the dictionary cache. */
886
 
UNIV_INTERN
 
788
 
887
789
dict_index_t*
888
790
dict_index_get_if_in_cache(
889
791
/*=======================*/
890
792
                                /* out: index, NULL if not found */
891
793
        dulint  index_id);      /* in: index id */
892
 
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
893
 
#ifdef UNIV_DEBUG
894
794
/**************************************************************************
895
795
Checks that a tuple has n_fields_cmp value in a sensible range, so that
896
796
no comparison can occur with the page number field in a node pointer. */
897
 
UNIV_INTERN
 
797
 
898
798
ibool
899
799
dict_index_check_search_tuple(
900
800
/*==========================*/
901
 
                                        /* out: TRUE if ok */
902
 
        const dict_index_t*     index,  /* in: index tree */
903
 
        const dtuple_t*         tuple); /* in: tuple used in a search */
904
 
/**************************************************************************
905
 
Check for duplicate index entries in a table [using the index name] */
906
 
UNIV_INTERN
907
 
void
908
 
dict_table_check_for_dup_indexes(
909
 
/*=============================*/
910
 
        const dict_table_t*     table); /* in: Check for dup indexes
911
 
                                        in this table */
912
 
 
 
801
                                /* out: TRUE if ok */
 
802
        dict_index_t*   index,  /* in: index */
 
803
        dtuple_t*       tuple); /* in: tuple used in a search */
913
804
#endif /* UNIV_DEBUG */
914
805
/**************************************************************************
915
806
Builds a node pointer out of a physical record and a page number. */
916
 
UNIV_INTERN
 
807
 
917
808
dtuple_t*
918
809
dict_index_build_node_ptr(
919
810
/*======================*/
920
 
                                        /* out, own: node pointer */
921
 
        const dict_index_t*     index,  /* in: index */
922
 
        const rec_t*            rec,    /* in: record for which to build node
923
 
                                        pointer */
924
 
        ulint                   page_no,/* in: page number to put in node
925
 
                                        pointer */
926
 
        mem_heap_t*             heap,   /* in: memory heap where pointer
927
 
                                        created */
928
 
        ulint                   level); /* in: level of rec in tree:
929
 
                                        0 means leaf level */
 
811
                                /* out, own: node pointer */
 
812
        dict_index_t*   index,  /* in: index */
 
813
        rec_t*          rec,    /* in: record for which to build node
 
814
                                pointer */
 
815
        ulint           page_no,/* in: page number to put in node pointer */
 
816
        mem_heap_t*     heap,   /* in: memory heap where pointer created */
 
817
        ulint           level);  /* in: level of rec in tree: 0 means leaf
 
818
                                level */
930
819
/**************************************************************************
931
820
Copies an initial segment of a physical record, long enough to specify an
932
821
index entry uniquely. */
933
 
UNIV_INTERN
 
822
 
934
823
rec_t*
935
824
dict_index_copy_rec_order_prefix(
936
825
/*=============================*/
937
 
                                        /* out: pointer to the prefix record */
938
 
        const dict_index_t*     index,  /* in: index */
939
 
        const rec_t*            rec,    /* in: record for which to
940
 
                                        copy prefix */
941
 
        ulint*                  n_fields,/* out: number of fields copied */
942
 
        byte**                  buf,    /* in/out: memory buffer for the
943
 
                                        copied prefix, or NULL */
944
 
        ulint*                  buf_size);/* in/out: buffer size */
 
826
                                /* out: pointer to the prefix record */
 
827
        dict_index_t*   index,  /* in: index */
 
828
        rec_t*          rec,    /* in: record for which to copy prefix */
 
829
        ulint*          n_fields,/* out: number of fields copied */
 
830
        byte**          buf,    /* in/out: memory buffer for the copied prefix,
 
831
                                or NULL */
 
832
        ulint*          buf_size);/* in/out: buffer size */
945
833
/**************************************************************************
946
834
Builds a typed data tuple out of a physical record. */
947
 
UNIV_INTERN
 
835
 
948
836
dtuple_t*
949
837
dict_index_build_data_tuple(
950
838
/*========================*/
959
847
ulint
960
848
dict_index_get_space(
961
849
/*=================*/
962
 
                                        /* out: space id */
963
 
        const dict_index_t*     index); /* in: index */
 
850
                                /* out: space id */
 
851
        dict_index_t*   index); /* in: index */
964
852
/*************************************************************************
965
853
Sets the space id of the root of the index tree. */
966
854
UNIV_INLINE
967
855
void
968
856
dict_index_set_space(
969
857
/*=================*/
970
 
        dict_index_t*   index,  /* in/out: index */
 
858
        dict_index_t*   index,  /* in: index */
971
859
        ulint           space); /* in: space id */
972
860
/*************************************************************************
973
861
Gets the page number of the root of the index tree. */
975
863
ulint
976
864
dict_index_get_page(
977
865
/*================*/
978
 
                                        /* out: page number */
979
 
        const dict_index_t*     tree);  /* in: index */
 
866
                                /* out: page number */
 
867
        dict_index_t*   tree);  /* in: index */
980
868
/*************************************************************************
981
869
Sets the page number of the root of index tree. */
982
870
UNIV_INLINE
983
871
void
984
872
dict_index_set_page(
985
873
/*================*/
986
 
        dict_index_t*   index,  /* in/out: index */
 
874
        dict_index_t*   index,  /* in: index */
987
875
        ulint           page);  /* in: page number */
988
876
/*************************************************************************
989
877
Gets the type of the index tree. */
991
879
ulint
992
880
dict_index_get_type(
993
881
/*================*/
994
 
                                        /* out: type */
995
 
        const dict_index_t*     index); /* in: index */
 
882
                                /* out: type */
 
883
        dict_index_t*   index); /* in: index */
996
884
/*************************************************************************
997
885
Gets the read-write lock of the index tree. */
998
886
UNIV_INLINE
1013
901
                                reserved for updates */
1014
902
/*************************************************************************
1015
903
Calculates the minimum record length in an index. */
1016
 
UNIV_INTERN
 
904
 
1017
905
ulint
1018
906
dict_index_calc_min_rec_len(
1019
907
/*========================*/
1020
 
        const dict_index_t*     index); /* in: index */
 
908
        dict_index_t*   index); /* in: index */
1021
909
/*************************************************************************
1022
910
Calculates new estimates for table and index statistics. The statistics
1023
911
are used in query optimization. */
1024
 
UNIV_INTERN
 
912
 
1025
913
void
1026
914
dict_update_statistics_low(
1027
915
/*=======================*/
1028
 
        dict_table_t*   table,          /* in/out: table */
 
916
        dict_table_t*   table,          /* in: table */
1029
917
        ibool           has_dict_mutex);/* in: TRUE if the caller has the
1030
918
                                        dictionary mutex */
1031
919
/*************************************************************************
1032
920
Calculates new estimates for table and index statistics. The statistics
1033
921
are used in query optimization. */
1034
 
UNIV_INTERN
 
922
 
1035
923
void
1036
924
dict_update_statistics(
1037
925
/*===================*/
1038
 
        dict_table_t*   table); /* in/out: table */
 
926
        dict_table_t*   table); /* in: table */
1039
927
/************************************************************************
1040
928
Reserves the dictionary system mutex for MySQL. */
1041
 
UNIV_INTERN
 
929
 
1042
930
void
1043
931
dict_mutex_enter_for_mysql(void);
1044
932
/*============================*/
1045
933
/************************************************************************
1046
934
Releases the dictionary system mutex for MySQL. */
1047
 
UNIV_INTERN
 
935
 
1048
936
void
1049
937
dict_mutex_exit_for_mysql(void);
1050
938
/*===========================*/
1051
939
/************************************************************************
1052
940
Checks if the database name in two table names is the same. */
1053
 
UNIV_INTERN
 
941
 
1054
942
ibool
1055
943
dict_tables_have_same_db(
1056
944
/*=====================*/
1070
958
                                /* out: scanned up to this */
1071
959
        const char*     ptr,    /* in: scan from */
1072
960
        const char*     string);/* in: look for this */
1073
 
/*************************************************************************
1074
 
Get index by name */
1075
 
UNIV_INTERN
1076
 
dict_index_t*
1077
 
dict_table_get_index_on_name(
1078
 
/*=========================*/
1079
 
                                /* out: index, NULL if does not exist */
1080
 
        dict_table_t*   table,  /* in: table */
1081
 
        const char*     name);  /* in: name of the index to find */
1082
 
/**************************************************************************
1083
 
Find and index that is equivalent to the one passed in and is not marked
1084
 
for deletion. */
1085
 
UNIV_INTERN
1086
 
dict_index_t*
1087
 
dict_table_find_equivalent_index(
1088
 
/*=============================*/
1089
 
        dict_table_t*   table,  /* in/out: table */
1090
 
        dict_index_t*   index); /* in: index to match */
1091
 
/**************************************************************************
1092
 
In case there is more than one index with the same name return the index
1093
 
with the min(id). */
1094
 
UNIV_INTERN
1095
 
dict_index_t*
1096
 
dict_table_get_index_on_name_and_min_id(
1097
 
/*====================================*/
1098
 
                                /* out: index, NULL if does not exist */
1099
 
        dict_table_t*   table,  /* in: table */
1100
 
        const char*     name);  /* in: name of the index to find */
1101
961
/* Buffers for storing detailed information about the latest foreign key
1102
962
and unique key errors */
1103
963
extern FILE*    dict_foreign_err_file;