~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
19
/**********************************************************************
20
Data dictionary system
21
22
Created 1/8/1996 Heikki Tuuri
23
***********************************************************************/
24
25
#include "dict0load.h"
26
#include "rem0types.h"
27
#include "data0type.h"
28
29
/*************************************************************************
30
Gets the column data type. */
31
UNIV_INLINE
32
void
33
dict_col_copy_type(
34
/*===============*/
35
	const dict_col_t*	col,	/* in: column */
36
	dtype_t*		type)	/* out: data type */
37
{
38
	ut_ad(col && type);
39
40
	type->mtype = col->mtype;
41
	type->prtype = col->prtype;
42
	type->len = col->len;
43
	type->mbminlen = col->mbminlen;
44
	type->mbmaxlen = col->mbmaxlen;
45
}
46
47
#ifdef UNIV_DEBUG
48
/*************************************************************************
49
Assert that a column and a data type match. */
50
UNIV_INLINE
51
ibool
52
dict_col_type_assert_equal(
53
/*=======================*/
54
					/* out: TRUE */
55
	const dict_col_t*	col,	/* in: column */
56
	const dtype_t*		type)	/* in: data type */
57
{
58
	ut_ad(col);
59
	ut_ad(type);
60
61
	ut_ad(col->mtype == type->mtype);
62
	ut_ad(col->prtype == type->prtype);
63
	ut_ad(col->len == type->len);
64
	ut_ad(col->mbminlen == type->mbminlen);
65
	ut_ad(col->mbmaxlen == type->mbmaxlen);
66
67
	return(TRUE);
68
}
69
#endif /* UNIV_DEBUG */
70
71
/***************************************************************************
72
Returns the minimum size of the column. */
73
UNIV_INLINE
74
ulint
75
dict_col_get_min_size(
76
/*==================*/
77
					/* out: minimum size */
78
	const dict_col_t*	col)	/* in: column */
79
{
80
	return(dtype_get_min_size_low(col->mtype, col->prtype, col->len,
81
				      col->mbminlen, col->mbmaxlen));
82
}
83
/***************************************************************************
84
Returns the maximum size of the column. */
85
UNIV_INLINE
86
ulint
87
dict_col_get_max_size(
88
/*==================*/
89
					/* out: maximum size */
90
	const dict_col_t*	col)	/* in: column */
91
{
92
	return(dtype_get_max_size_low(col->mtype, col->len));
93
}
94
/***************************************************************************
95
Returns the size of a fixed size column, 0 if not a fixed size column. */
96
UNIV_INLINE
97
ulint
98
dict_col_get_fixed_size(
99
/*====================*/
100
					/* out: fixed size, or 0 */
101
	const dict_col_t*	col)	/* in: column */
102
{
103
	return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
104
					col->mbminlen, col->mbmaxlen));
105
}
106
/***************************************************************************
107
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
108
For fixed length types it is the fixed length of the type, otherwise 0. */
109
UNIV_INLINE
110
ulint
111
dict_col_get_sql_null_size(
112
/*=======================*/
113
					/* out: SQL null storage size
114
					in ROW_FORMAT=REDUNDANT */
115
	const dict_col_t*	col)	/* in: column */
116
{
117
	return(dict_col_get_fixed_size(col));
118
}
119
120
/*************************************************************************
121
Gets the column number. */
122
UNIV_INLINE
123
ulint
124
dict_col_get_no(
125
/*============*/
126
	const dict_col_t*	col)
127
{
128
	ut_ad(col);
129
130
	return(col->ind);
131
}
132
133
/*************************************************************************
134
Gets the column position in the clustered index. */
135
UNIV_INLINE
136
ulint
137
dict_col_get_clust_pos(
138
/*===================*/
139
	const dict_col_t*	col,		/* in: table column */
140
	const dict_index_t*	clust_index)	/* in: clustered index */
141
{
142
	ulint	i;
143
144
	ut_ad(col);
145
	ut_ad(clust_index);
146
	ut_ad(dict_index_is_clust(clust_index));
147
148
	for (i = 0; i < clust_index->n_def; i++) {
149
		const dict_field_t*	field = &clust_index->fields[i];
150
151
		if (!field->prefix_len && field->col == col) {
152
			return(i);
153
		}
154
	}
155
156
	return(ULINT_UNDEFINED);
157
}
158
159
#ifdef UNIV_DEBUG
160
/************************************************************************
161
Gets the first index on the table (the clustered index). */
162
UNIV_INLINE
163
dict_index_t*
164
dict_table_get_first_index(
165
/*=======================*/
166
					/* out: index, NULL if none exists */
167
	const dict_table_t*	table)	/* in: table */
168
{
169
	ut_ad(table);
170
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
171
172
	return(UT_LIST_GET_FIRST(((dict_table_t*) table)->indexes));
173
}
174
175
/************************************************************************
176
Gets the next index on the table. */
177
UNIV_INLINE
178
dict_index_t*
179
dict_table_get_next_index(
180
/*======================*/
181
					/* out: index, NULL if none left */
182
	const dict_index_t*	index)	/* in: index */
183
{
184
	ut_ad(index);
185
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
186
187
	return(UT_LIST_GET_NEXT(indexes, (dict_index_t*) index));
188
}
189
#endif /* UNIV_DEBUG */
190
191
/************************************************************************
192
Check whether the index is the clustered index. */
193
UNIV_INLINE
194
ulint
195
dict_index_is_clust(
196
/*================*/
197
					/* out: nonzero for clustered index,
198
					zero for other indexes */
199
	const dict_index_t*	index)	/* in: index */
200
{
201
	ut_ad(index);
202
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
203
204
	return(UNIV_UNLIKELY(index->type & DICT_CLUSTERED));
205
}
206
/************************************************************************
207
Check whether the index is unique. */
208
UNIV_INLINE
209
ulint
210
dict_index_is_unique(
211
/*=================*/
212
					/* out: nonzero for unique index,
213
					zero for other indexes */
214
	const dict_index_t*	index)	/* in: index */
215
{
216
	ut_ad(index);
217
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
218
219
	return(UNIV_UNLIKELY(index->type & DICT_UNIQUE));
220
}
221
222
/************************************************************************
223
Check whether the index is the insert buffer tree. */
224
UNIV_INLINE
225
ulint
226
dict_index_is_ibuf(
227
/*===============*/
228
					/* out: nonzero for insert buffer,
229
					zero for other indexes */
230
	const dict_index_t*	index)	/* in: index */
231
{
232
	ut_ad(index);
233
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
234
235
	return(UNIV_UNLIKELY(index->type & DICT_IBUF));
236
}
237
238
/************************************************************************
239
Gets the number of user-defined columns in a table in the dictionary
240
cache. */
241
UNIV_INLINE
242
ulint
243
dict_table_get_n_user_cols(
244
/*=======================*/
245
					/* out: number of user-defined
246
					(e.g., not ROW_ID)
247
					columns of a table */
248
	const dict_table_t*	table)	/* in: table */
249
{
250
	ut_ad(table);
251
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
252
253
	return(table->n_cols - DATA_N_SYS_COLS);
254
}
255
256
/************************************************************************
257
Gets the number of system columns in a table in the dictionary cache. */
258
UNIV_INLINE
259
ulint
260
dict_table_get_n_sys_cols(
261
/*======================*/
262
					/* out: number of system (e.g.,
263
					ROW_ID) columns of a table */
264
	const dict_table_t*	table __attribute__((unused)))	/* in: table */
265
{
266
	ut_ad(table);
267
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
268
	ut_ad(table->cached);
269
270
	return(DATA_N_SYS_COLS);
271
}
272
273
/************************************************************************
274
Gets the number of all columns (also system) in a table in the dictionary
275
cache. */
276
UNIV_INLINE
277
ulint
278
dict_table_get_n_cols(
279
/*==================*/
280
					/* out: number of columns of a table */
281
	const dict_table_t*	table)	/* in: table */
282
{
283
	ut_ad(table);
284
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
285
286
	return(table->n_cols);
287
}
288
289
#ifdef UNIV_DEBUG
290
/************************************************************************
291
Gets the nth column of a table. */
292
UNIV_INLINE
293
dict_col_t*
294
dict_table_get_nth_col(
295
/*===================*/
296
					/* out: pointer to column object */
297
	const dict_table_t*	table,	/* in: table */
298
	ulint			pos)	/* in: position of column */
299
{
300
	ut_ad(table);
301
	ut_ad(pos < table->n_def);
302
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
303
304
	return((dict_col_t*) (table->cols) + pos);
305
}
306
307
/************************************************************************
308
Gets the given system column of a table. */
309
UNIV_INLINE
310
dict_col_t*
311
dict_table_get_sys_col(
312
/*===================*/
313
					/* out: pointer to column object */
314
	const dict_table_t*	table,	/* in: table */
315
	ulint			sys)	/* in: DATA_ROW_ID, ... */
316
{
317
	dict_col_t*	col;
318
319
	ut_ad(table);
320
	ut_ad(sys < DATA_N_SYS_COLS);
321
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
322
323
	col = dict_table_get_nth_col(table, table->n_cols
324
				     - DATA_N_SYS_COLS + sys);
325
	ut_ad(col->mtype == DATA_SYS);
326
	ut_ad(col->prtype == (sys | DATA_NOT_NULL));
327
328
	return(col);
329
}
330
#endif /* UNIV_DEBUG */
331
332
/************************************************************************
333
Gets the given system column number of a table. */
334
UNIV_INLINE
335
ulint
336
dict_table_get_sys_col_no(
337
/*======================*/
338
					/* out: column number */
339
	const dict_table_t*	table,	/* in: table */
340
	ulint			sys)	/* in: DATA_ROW_ID, ... */
341
{
342
	ut_ad(table);
343
	ut_ad(sys < DATA_N_SYS_COLS);
344
	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
345
346
	return(table->n_cols - DATA_N_SYS_COLS + sys);
347
}
348
349
/************************************************************************
350
Check whether the table uses the compact page format. */
351
UNIV_INLINE
352
ibool
353
dict_table_is_comp(
354
/*===============*/
355
					/* out: TRUE if table uses the
356
					compact page format */
357
	const dict_table_t*	table)	/* in: table */
358
{
359
	ut_ad(table);
360
361
#if DICT_TF_COMPACT != TRUE
362
#error
363
#endif
364
365
	return(UNIV_LIKELY(table->flags & DICT_TF_COMPACT));
366
}
367
368
/************************************************************************
369
Determine the file format of a table. */
370
UNIV_INLINE
371
ulint
372
dict_table_get_format(
373
/*==================*/
374
					/* out: file format version */
375
	const dict_table_t*	table)	/* in: table */
376
{
377
	ut_ad(table);
378
379
	return((table->flags & DICT_TF_FORMAT_MASK) >> DICT_TF_FORMAT_SHIFT);
380
}
381
382
/************************************************************************
383
Determine the file format of a table. */
384
UNIV_INLINE
385
void
386
dict_table_set_format(
387
/*==================*/
388
	dict_table_t*	table,	/* in/out: table */
389
	ulint		format)	/* in: file format version */
390
{
391
	ut_ad(table);
392
393
	table->flags = (table->flags & ~DICT_TF_FORMAT_MASK)
394
		| (format << DICT_TF_FORMAT_SHIFT);
395
}
396
397
/************************************************************************
398
Extract the compressed page size from table flags. */
399
UNIV_INLINE
400
ulint
401
dict_table_flags_to_zip_size(
402
/*=========================*/
403
			/* out: compressed page size,
404
			or 0 if not compressed */
405
	ulint	flags)	/* in: flags */
406
{
407
	ulint	zip_size = flags & DICT_TF_ZSSIZE_MASK;
408
409
	if (UNIV_UNLIKELY(zip_size)) {
410
		zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
411
			 << (zip_size >> DICT_TF_ZSSIZE_SHIFT));
412
413
		ut_ad(zip_size <= UNIV_PAGE_SIZE);
414
	}
415
416
	return(zip_size);
417
}
418
419
/************************************************************************
420
Check whether the table uses the compressed compact page format. */
421
UNIV_INLINE
422
ulint
423
dict_table_zip_size(
424
/*================*/
425
					/* out: compressed page size,
426
					or 0 if not compressed */
427
	const dict_table_t*	table)	/* in: table */
428
{
429
	ut_ad(table);
430
431
	return(dict_table_flags_to_zip_size(table->flags));
432
}
433
434
/************************************************************************
435
Gets the number of fields in the internal representation of an index,
436
including fields added by the dictionary system. */
437
UNIV_INLINE
438
ulint
439
dict_index_get_n_fields(
440
/*====================*/
441
					/* out: number of fields */
442
	const dict_index_t*	index)	/* in: an internal
443
					representation of index (in
444
					the dictionary cache) */
445
{
446
	ut_ad(index);
447
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
448
449
	return(index->n_fields);
450
}
451
452
/************************************************************************
453
Gets the number of fields in the internal representation of an index
454
that uniquely determine the position of an index entry in the index, if
455
we do not take multiversioning into account: in the B-tree use the value
456
returned by dict_index_get_n_unique_in_tree. */
457
UNIV_INLINE
458
ulint
459
dict_index_get_n_unique(
460
/*====================*/
461
					/* out: number of fields */
462
	const dict_index_t*	index)	/* in: an internal representation
463
					of index (in the dictionary cache) */
464
{
465
	ut_ad(index);
466
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
467
	ut_ad(index->cached);
468
469
	return(index->n_uniq);
470
}
471
472
/************************************************************************
473
Gets the number of fields in the internal representation of an index
474
which uniquely determine the position of an index entry in the index, if
475
we also take multiversioning into account. */
476
UNIV_INLINE
477
ulint
478
dict_index_get_n_unique_in_tree(
479
/*============================*/
480
					/* out: number of fields */
481
	const dict_index_t*	index)	/* in: an internal representation
482
					of index (in the dictionary cache) */
483
{
484
	ut_ad(index);
485
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
486
	ut_ad(index->cached);
487
488
	if (dict_index_is_clust(index)) {
489
490
		return(dict_index_get_n_unique(index));
491
	}
492
493
	return(dict_index_get_n_fields(index));
494
}
495
496
/************************************************************************
497
Gets the number of user-defined ordering fields in the index. In the internal
498
representation of clustered indexes we add the row id to the ordering fields
499
to make a clustered index unique, but this function returns the number of
500
fields the user defined in the index as ordering fields. */
501
UNIV_INLINE
502
ulint
503
dict_index_get_n_ordering_defined_by_user(
504
/*======================================*/
505
					/* out: number of fields */
506
	const dict_index_t*	index)	/* in: an internal representation
507
					of index (in the dictionary cache) */
508
{
509
	return(index->n_user_defined_cols);
510
}
511
512
#ifdef UNIV_DEBUG
513
/************************************************************************
514
Gets the nth field of an index. */
515
UNIV_INLINE
516
dict_field_t*
517
dict_index_get_nth_field(
518
/*=====================*/
519
					/* out: pointer to field object */
520
	const dict_index_t*	index,	/* in: index */
521
	ulint			pos)	/* in: position of field */
522
{
523
	ut_ad(index);
524
	ut_ad(pos < index->n_def);
525
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
526
527
	return((dict_field_t*) (index->fields) + pos);
528
}
529
#endif /* UNIV_DEBUG */
530
531
/************************************************************************
532
Returns the position of a system column in an index. */
533
UNIV_INLINE
534
ulint
535
dict_index_get_sys_col_pos(
536
/*=======================*/
537
					/* out: position,
538
					ULINT_UNDEFINED if not contained */
539
	const dict_index_t*	index,	/* in: index */
540
	ulint			type)	/* in: DATA_ROW_ID, ... */
541
{
542
	ut_ad(index);
543
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
544
	ut_ad(!(index->type & DICT_UNIVERSAL));
545
546
	if (dict_index_is_clust(index)) {
547
548
		return(dict_col_get_clust_pos(
549
			       dict_table_get_sys_col(index->table, type),
550
			       index));
551
	}
552
553
	return(dict_index_get_nth_col_pos(
554
		       index, dict_table_get_sys_col_no(index->table, type)));
555
}
556
557
/*************************************************************************
558
Gets the field column. */
559
UNIV_INLINE
560
const dict_col_t*
561
dict_field_get_col(
562
/*===============*/
563
	const dict_field_t*	field)
564
{
565
	ut_ad(field);
566
567
	return(field->col);
568
}
569
570
/************************************************************************
571
Gets pointer to the nth column in an index. */
572
UNIV_INLINE
573
const dict_col_t*
574
dict_index_get_nth_col(
575
/*===================*/
576
					/* out: column */
577
	const dict_index_t*	index,	/* in: index */
578
	ulint			pos)	/* in: position of the field */
579
{
580
	return(dict_field_get_col(dict_index_get_nth_field(index, pos)));
581
}
582
583
/************************************************************************
584
Gets the column number the nth field in an index. */
585
UNIV_INLINE
586
ulint
587
dict_index_get_nth_col_no(
588
/*======================*/
589
					/* out: column number */
590
	const dict_index_t*	index,	/* in: index */
591
	ulint			pos)	/* in: position of the field */
592
{
593
	return(dict_col_get_no(dict_index_get_nth_col(index, pos)));
594
}
595
596
/************************************************************************
597
Returns the minimum data size of an index record. */
598
UNIV_INLINE
599
ulint
600
dict_index_get_min_size(
601
/*====================*/
602
					/* out: minimum data size in bytes */
603
	const dict_index_t*	index)	/* in: index */
604
{
605
	ulint	n	= dict_index_get_n_fields(index);
606
	ulint	size	= 0;
607
608
	while (n--) {
609
		size += dict_col_get_min_size(dict_index_get_nth_col(index,
610
								     n));
611
	}
612
613
	return(size);
614
}
615
616
/*************************************************************************
617
Gets the space id of the root of the index tree. */
618
UNIV_INLINE
619
ulint
620
dict_index_get_space(
621
/*=================*/
622
					/* out: space id */
623
	const dict_index_t*	index)	/* in: index */
624
{
625
	ut_ad(index);
626
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
627
628
	return(index->space);
629
}
630
631
/*************************************************************************
632
Sets the space id of the root of the index tree. */
633
UNIV_INLINE
634
void
635
dict_index_set_space(
636
/*=================*/
637
	dict_index_t*	index,	/* in/out: index */
638
	ulint		space)	/* in: space id */
639
{
640
	ut_ad(index);
641
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
642
643
	index->space = space;
644
}
645
646
/*************************************************************************
647
Gets the page number of the root of the index tree. */
648
UNIV_INLINE
649
ulint
650
dict_index_get_page(
651
/*================*/
652
					/* out: page number */
653
	const dict_index_t*	index)	/* in: index */
654
{
655
	ut_ad(index);
656
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
657
658
	return(index->page);
659
}
660
661
/*************************************************************************
662
Sets the page number of the root of index tree. */
663
UNIV_INLINE
664
void
665
dict_index_set_page(
666
/*================*/
667
	dict_index_t*	index,	/* in/out: index */
668
	ulint		page)	/* in: page number */
669
{
670
	ut_ad(index);
671
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
672
673
	index->page = page;
674
}
675
676
/*************************************************************************
677
Gets the read-write lock of the index tree. */
678
UNIV_INLINE
679
rw_lock_t*
680
dict_index_get_lock(
681
/*================*/
682
				/* out: read-write lock */
683
	dict_index_t*	index)	/* in: index */
684
{
685
	ut_ad(index);
686
	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
687
688
	return(&(index->lock));
689
}
690
691
/************************************************************************
692
Returns free space reserved for future updates of records. This is
693
relevant only in the case of many consecutive inserts, as updates
694
which make the records bigger might fragment the index. */
695
UNIV_INLINE
696
ulint
697
dict_index_get_space_reserve(void)
698
/*==============================*/
699
				/* out: number of free bytes on page,
700
				reserved for updates */
701
{
702
	return(UNIV_PAGE_SIZE / 16);
703
}
704
705
/**************************************************************************
706
Checks if a table is in the dictionary cache. */
707
UNIV_INLINE
708
dict_table_t*
709
dict_table_check_if_in_cache_low(
710
/*=============================*/
711
					/* out: table, NULL if not found */
712
	const char*	table_name)	/* in: table name */
713
{
714
	dict_table_t*	table;
715
	ulint		table_fold;
716
717
	ut_ad(table_name);
718
	ut_ad(mutex_own(&(dict_sys->mutex)));
719
720
	/* Look for the table name in the hash table */
721
	table_fold = ut_fold_string(table_name);
722
723
	HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
724
		    dict_table_t*, table, ut_ad(table->cached),
725
		    !strcmp(table->name, table_name));
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
726
	return(table);
727
}
728
729
/**************************************************************************
730
Gets a table; loads it to the dictionary cache if necessary. A low-level
731
function. */
732
UNIV_INLINE
733
dict_table_t*
734
dict_table_get_low(
735
/*===============*/
736
					/* out: table, NULL if not found */
737
	const char*	table_name)	/* in: table name */
738
{
739
	dict_table_t*	table;
740
741
	ut_ad(table_name);
742
	ut_ad(mutex_own(&(dict_sys->mutex)));
743
744
	table = dict_table_check_if_in_cache_low(table_name);
745
746
	if (table == NULL) {
747
		table = dict_load_table(table_name);
748
	}
749
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
750
	ut_ad(!table || table->cached);
751
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
752
	return(table);
753
}
754
755
/**************************************************************************
756
Returns a table object based on table id. */
757
UNIV_INLINE
758
dict_table_t*
759
dict_table_get_on_id_low(
760
/*=====================*/
761
				/* out: table, NULL if does not exist */
762
	dulint	table_id)	/* in: table id */
763
{
764
	dict_table_t*	table;
765
	ulint		fold;
766
767
	ut_ad(mutex_own(&(dict_sys->mutex)));
768
769
	/* Look for the table name in the hash table */
770
	fold = ut_fold_dulint(table_id);
771
772
	HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold,
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
773
		    dict_table_t*, table, ut_ad(table->cached),
774
		    !ut_dulint_cmp(table->id, table_id));
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
775
	if (table == NULL) {
776
		table = dict_load_table_on_id(table_id);
777
	}
778
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
779
	ut_ad(!table || table->cached);
780
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
781
	/* TODO: should get the type information from MySQL */
782
783
	return(table);
784
}
785