2009-02-17 09:04:28 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/**********************************************************************
|
|
|
|
Data dictionary system
|
|
|
|
|
|
|
|
Created 1/8/1996 Heikki Tuuri
|
|
|
|
***********************************************************************/
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#include "data0type.h"
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
2005-10-27 07:29:40 +00:00
|
|
|
#include "dict0load.h"
|
2006-09-19 10:14:07 +00:00
|
|
|
#include "rem0types.h"
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the column data type. */
|
|
|
|
UNIV_INLINE
|
2006-09-19 10:14:07 +00:00
|
|
|
void
|
|
|
|
dict_col_copy_type(
|
|
|
|
/*===============*/
|
|
|
|
const dict_col_t* col, /* in: column */
|
|
|
|
dtype_t* type) /* out: data type */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(col && type);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
type->mtype = col->mtype;
|
|
|
|
type->prtype = col->prtype;
|
|
|
|
type->len = col->len;
|
|
|
|
type->mbminlen = col->mbminlen;
|
|
|
|
type->mbmaxlen = col->mbmaxlen;
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-09-19 10:14:07 +00:00
|
|
|
|
2007-06-06 11:07:37 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
/*************************************************************************
|
|
|
|
Assert that a column and a data type match. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
dict_col_type_assert_equal(
|
|
|
|
/*=======================*/
|
|
|
|
/* out: TRUE */
|
|
|
|
const dict_col_t* col, /* in: column */
|
|
|
|
const dtype_t* type) /* in: data type */
|
|
|
|
{
|
|
|
|
ut_ad(col);
|
|
|
|
ut_ad(type);
|
|
|
|
|
|
|
|
ut_ad(col->mtype == type->mtype);
|
|
|
|
ut_ad(col->prtype == type->prtype);
|
|
|
|
ut_ad(col->len == type->len);
|
2009-03-23 14:21:34 +00:00
|
|
|
# ifndef UNIV_HOTBACKUP
|
2007-06-06 11:07:37 +00:00
|
|
|
ut_ad(col->mbminlen == type->mbminlen);
|
|
|
|
ut_ad(col->mbmaxlen == type->mbmaxlen);
|
2009-03-23 14:21:34 +00:00
|
|
|
# endif /* !UNIV_HOTBACKUP */
|
2007-06-06 11:07:37 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2006-09-19 10:14:07 +00:00
|
|
|
/***************************************************************************
|
|
|
|
Returns the minimum size of the column. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_min_size(
|
|
|
|
/*==================*/
|
|
|
|
/* out: minimum size */
|
|
|
|
const dict_col_t* col) /* in: column */
|
|
|
|
{
|
|
|
|
return(dtype_get_min_size_low(col->mtype, col->prtype, col->len,
|
|
|
|
col->mbminlen, col->mbmaxlen));
|
|
|
|
}
|
|
|
|
/***************************************************************************
|
|
|
|
Returns the maximum size of the column. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_max_size(
|
|
|
|
/*==================*/
|
|
|
|
/* out: maximum size */
|
|
|
|
const dict_col_t* col) /* in: column */
|
|
|
|
{
|
|
|
|
return(dtype_get_max_size_low(col->mtype, col->len));
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-09-19 10:14:07 +00:00
|
|
|
/***************************************************************************
|
|
|
|
Returns the size of a fixed size column, 0 if not a fixed size column. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_fixed_size(
|
|
|
|
/*====================*/
|
|
|
|
/* out: fixed size, or 0 */
|
|
|
|
const dict_col_t* col) /* in: column */
|
|
|
|
{
|
|
|
|
return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
|
|
|
|
col->mbminlen, col->mbmaxlen));
|
|
|
|
}
|
|
|
|
/***************************************************************************
|
|
|
|
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
|
|
|
|
For fixed length types it is the fixed length of the type, otherwise 0. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_sql_null_size(
|
|
|
|
/*=======================*/
|
|
|
|
/* out: SQL null storage size
|
|
|
|
in ROW_FORMAT=REDUNDANT */
|
|
|
|
const dict_col_t* col) /* in: column */
|
|
|
|
{
|
|
|
|
return(dict_col_get_fixed_size(col));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the column number. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_no(
|
|
|
|
/*============*/
|
2006-09-19 10:14:07 +00:00
|
|
|
const dict_col_t* col)
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(col);
|
|
|
|
|
|
|
|
return(col->ind);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the column position in the clustered index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_col_get_clust_pos(
|
|
|
|
/*===================*/
|
2006-09-19 10:14:07 +00:00
|
|
|
const dict_col_t* col, /* in: table column */
|
|
|
|
const dict_index_t* clust_index) /* in: clustered index */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ulint i;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(col);
|
2007-11-22 10:29:02 +00:00
|
|
|
ut_ad(clust_index);
|
|
|
|
ut_ad(dict_index_is_clust(clust_index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
for (i = 0; i < clust_index->n_def; i++) {
|
|
|
|
const dict_field_t* field = &clust_index->fields[i];
|
|
|
|
|
|
|
|
if (!field->prefix_len && field->col == col) {
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2007-08-13 15:57:28 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
Gets the first index on the table (the clustered index). */
|
|
|
|
UNIV_INLINE
|
|
|
|
dict_index_t*
|
|
|
|
dict_table_get_first_index(
|
|
|
|
/*=======================*/
|
2007-08-13 15:57:28 +00:00
|
|
|
/* out: index, NULL if none exists */
|
|
|
|
const dict_table_t* table) /* in: table */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
|
|
|
|
2007-08-13 15:57:28 +00:00
|
|
|
return(UT_LIST_GET_FIRST(((dict_table_t*) table)->indexes));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the next index on the table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
dict_index_t*
|
|
|
|
dict_table_get_next_index(
|
|
|
|
/*======================*/
|
2007-08-13 15:57:28 +00:00
|
|
|
/* out: index, NULL if none left */
|
|
|
|
const dict_index_t* index) /* in: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
|
2007-08-13 15:57:28 +00:00
|
|
|
return(UT_LIST_GET_NEXT(indexes, (dict_index_t*) index));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2007-08-13 15:57:28 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
/************************************************************************
|
|
|
|
Check whether the index is the clustered index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_is_clust(
|
|
|
|
/*================*/
|
|
|
|
/* out: nonzero for clustered index,
|
|
|
|
zero for other indexes */
|
|
|
|
const dict_index_t* index) /* in: index */
|
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
|
|
|
|
return(UNIV_UNLIKELY(index->type & DICT_CLUSTERED));
|
|
|
|
}
|
2007-04-16 09:13:44 +00:00
|
|
|
/************************************************************************
|
|
|
|
Check whether the index is unique. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_is_unique(
|
|
|
|
/*=================*/
|
|
|
|
/* out: nonzero for unique index,
|
|
|
|
zero for other indexes */
|
|
|
|
const dict_index_t* index) /* in: index */
|
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
|
|
|
|
return(UNIV_UNLIKELY(index->type & DICT_UNIQUE));
|
|
|
|
}
|
2006-03-09 17:26:02 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
2008-01-25 08:13:12 +00:00
|
|
|
Check whether the index is the insert buffer tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_is_ibuf(
|
|
|
|
/*===============*/
|
|
|
|
/* out: nonzero for insert buffer,
|
|
|
|
zero for other indexes */
|
|
|
|
const dict_index_t* index) /* in: index */
|
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
|
|
|
|
return(UNIV_UNLIKELY(index->type & DICT_IBUF));
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the number of user-defined columns in a table in the dictionary
|
|
|
|
cache. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_get_n_user_cols(
|
|
|
|
/*=======================*/
|
2007-08-08 09:01:46 +00:00
|
|
|
/* out: number of user-defined
|
|
|
|
(e.g., not ROW_ID)
|
|
|
|
columns of a table */
|
|
|
|
const dict_table_t* table) /* in: table */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(table->n_cols - DATA_N_SYS_COLS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the number of system columns in a table in the dictionary cache. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_get_n_sys_cols(
|
|
|
|
/*======================*/
|
2007-08-08 09:01:46 +00:00
|
|
|
/* out: number of system (e.g.,
|
|
|
|
ROW_ID) columns of a table */
|
|
|
|
const dict_table_t* table __attribute__((unused))) /* in: table */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
|
|
|
ut_ad(table->cached);
|
|
|
|
|
|
|
|
return(DATA_N_SYS_COLS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the number of all columns (also system) in a table in the dictionary
|
|
|
|
cache. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_get_n_cols(
|
|
|
|
/*==================*/
|
2007-08-08 09:01:46 +00:00
|
|
|
/* out: number of columns of a table */
|
|
|
|
const dict_table_t* table) /* in: table */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(table->n_cols);
|
|
|
|
}
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
Gets the nth column of a table. */
|
|
|
|
UNIV_INLINE
|
2006-10-19 07:27:26 +00:00
|
|
|
dict_col_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_table_get_nth_col(
|
|
|
|
/*===================*/
|
2006-09-19 10:14:07 +00:00
|
|
|
/* out: pointer to column object */
|
|
|
|
const dict_table_t* table, /* in: table */
|
|
|
|
ulint pos) /* in: position of column */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(pos < table->n_def);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
return((dict_col_t*) (table->cols) + pos);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the given system column of a table. */
|
|
|
|
UNIV_INLINE
|
2006-10-19 07:27:26 +00:00
|
|
|
dict_col_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_table_get_sys_col(
|
|
|
|
/*===================*/
|
2006-09-19 10:14:07 +00:00
|
|
|
/* out: pointer to column object */
|
|
|
|
const dict_table_t* table, /* in: table */
|
|
|
|
ulint sys) /* in: DATA_ROW_ID, ... */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-19 07:27:26 +00:00
|
|
|
dict_col_t* col;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(sys < DATA_N_SYS_COLS);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
col = dict_table_get_nth_col(table, table->n_cols
|
2006-08-29 09:30:31 +00:00
|
|
|
- DATA_N_SYS_COLS + sys);
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(col->mtype == DATA_SYS);
|
|
|
|
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(col);
|
|
|
|
}
|
2006-10-19 07:27:26 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the given system column number of a table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_get_sys_col_no(
|
|
|
|
/*======================*/
|
2006-10-19 07:27:26 +00:00
|
|
|
/* out: column number */
|
|
|
|
const dict_table_t* table, /* in: table */
|
|
|
|
ulint sys) /* in: DATA_ROW_ID, ... */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
ut_ad(sys < DATA_N_SYS_COLS);
|
|
|
|
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
|
|
|
|
|
|
|
return(table->n_cols - DATA_N_SYS_COLS + sys);
|
|
|
|
}
|
|
|
|
|
2006-02-27 09:33:26 +00:00
|
|
|
/************************************************************************
|
|
|
|
Check whether the table uses the compact page format. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
dict_table_is_comp(
|
|
|
|
/*===============*/
|
|
|
|
/* out: TRUE if table uses the
|
|
|
|
compact page format */
|
|
|
|
const dict_table_t* table) /* in: table */
|
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
|
|
|
|
#if DICT_TF_COMPACT != TRUE
|
|
|
|
#error
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(UNIV_LIKELY(table->flags & DICT_TF_COMPACT));
|
|
|
|
}
|
|
|
|
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
/************************************************************************
|
|
|
|
Determine the file format of a table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_get_format(
|
|
|
|
/*==================*/
|
|
|
|
/* out: file format version */
|
|
|
|
const dict_table_t* table) /* in: table */
|
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
|
|
|
|
return((table->flags & DICT_TF_FORMAT_MASK) >> DICT_TF_FORMAT_SHIFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Determine the file format of a table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
dict_table_set_format(
|
|
|
|
/*==================*/
|
|
|
|
dict_table_t* table, /* in/out: table */
|
|
|
|
ulint format) /* in: file format version */
|
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
|
|
|
|
table->flags = (table->flags & ~DICT_TF_FORMAT_MASK)
|
|
|
|
| (format << DICT_TF_FORMAT_SHIFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Extract the compressed page size from table flags. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_table_flags_to_zip_size(
|
|
|
|
/*=========================*/
|
|
|
|
/* out: compressed page size,
|
|
|
|
or 0 if not compressed */
|
|
|
|
ulint flags) /* in: flags */
|
|
|
|
{
|
|
|
|
ulint zip_size = flags & DICT_TF_ZSSIZE_MASK;
|
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(zip_size)) {
|
|
|
|
zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
|
|
|
|
<< (zip_size >> DICT_TF_ZSSIZE_SHIFT));
|
|
|
|
|
|
|
|
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(zip_size);
|
|
|
|
}
|
|
|
|
|
2006-03-03 08:39:20 +00:00
|
|
|
/************************************************************************
|
|
|
|
Check whether the table uses the compressed compact page format. */
|
|
|
|
UNIV_INLINE
|
2006-04-25 07:12:32 +00:00
|
|
|
ulint
|
|
|
|
dict_table_zip_size(
|
|
|
|
/*================*/
|
|
|
|
/* out: compressed page size,
|
|
|
|
or 0 if not compressed */
|
2006-03-03 08:39:20 +00:00
|
|
|
const dict_table_t* table) /* in: table */
|
|
|
|
{
|
|
|
|
ut_ad(table);
|
|
|
|
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
return(dict_table_flags_to_zip_size(table->flags));
|
2006-03-03 08:39:20 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
Gets the number of fields in the internal representation of an index,
|
|
|
|
including fields added by the dictionary system. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_n_fields(
|
|
|
|
/*====================*/
|
2006-10-19 07:52:28 +00:00
|
|
|
/* out: number of fields */
|
|
|
|
const dict_index_t* index) /* in: an internal
|
|
|
|
representation of index (in
|
|
|
|
the dictionary cache) */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(index->n_fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the number of fields in the internal representation of an index
|
|
|
|
that uniquely determine the position of an index entry in the index, if
|
|
|
|
we do not take multiversioning into account: in the B-tree use the value
|
|
|
|
returned by dict_index_get_n_unique_in_tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_n_unique(
|
|
|
|
/*====================*/
|
2007-09-19 09:49:58 +00:00
|
|
|
/* out: number of fields */
|
|
|
|
const dict_index_t* index) /* in: an internal representation
|
|
|
|
of index (in the dictionary cache) */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
ut_ad(index->cached);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(index->n_uniq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the number of fields in the internal representation of an index
|
|
|
|
which uniquely determine the position of an index entry in the index, if
|
|
|
|
we also take multiversioning into account. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_n_unique_in_tree(
|
|
|
|
/*============================*/
|
2007-09-19 09:49:58 +00:00
|
|
|
/* out: number of fields */
|
|
|
|
const dict_index_t* index) /* in: an internal representation
|
|
|
|
of index (in the dictionary cache) */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
ut_ad(index->cached);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
if (dict_index_is_clust(index)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(dict_index_get_n_unique(index));
|
|
|
|
}
|
|
|
|
|
|
|
|
return(dict_index_get_n_fields(index));
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the number of user-defined ordering fields in the index. In the internal
|
|
|
|
representation of clustered indexes we add the row id to the ordering fields
|
|
|
|
to make a clustered index unique, but this function returns the number of
|
|
|
|
fields the user defined in the index as ordering fields. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_n_ordering_defined_by_user(
|
|
|
|
/*======================================*/
|
2007-09-24 13:29:18 +00:00
|
|
|
/* out: number of fields */
|
|
|
|
const dict_index_t* index) /* in: an internal representation
|
|
|
|
of index (in the dictionary cache) */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return(index->n_user_defined_cols);
|
|
|
|
}
|
|
|
|
|
2006-10-19 07:52:28 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
Gets the nth field of an index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
dict_field_t*
|
|
|
|
dict_index_get_nth_field(
|
|
|
|
/*=====================*/
|
2006-10-19 07:52:28 +00:00
|
|
|
/* out: pointer to field object */
|
|
|
|
const dict_index_t* index, /* in: index */
|
|
|
|
ulint pos) /* in: position of field */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(pos < index->n_def);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
|
2006-10-19 07:52:28 +00:00
|
|
|
return((dict_field_t*) (index->fields) + pos);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-10-19 07:52:28 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Returns the position of a system column in an index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_sys_col_pos(
|
|
|
|
/*=======================*/
|
2006-10-19 07:52:28 +00:00
|
|
|
/* out: position,
|
|
|
|
ULINT_UNDEFINED if not contained */
|
|
|
|
const dict_index_t* index, /* in: index */
|
|
|
|
ulint type) /* in: DATA_ROW_ID, ... */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
|
|
|
ut_ad(!(index->type & DICT_UNIVERSAL));
|
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
if (dict_index_is_clust(index)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
return(dict_col_get_clust_pos(
|
|
|
|
dict_table_get_sys_col(index->table, type),
|
|
|
|
index));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
return(dict_index_get_nth_col_pos(
|
|
|
|
index, dict_table_get_sys_col_no(index->table, type)));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the field column. */
|
|
|
|
UNIV_INLINE
|
2006-09-19 10:14:07 +00:00
|
|
|
const dict_col_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_field_get_col(
|
|
|
|
/*===============*/
|
2006-09-19 10:14:07 +00:00
|
|
|
const dict_field_t* field)
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(field);
|
|
|
|
|
|
|
|
return(field->col);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2006-09-19 10:14:07 +00:00
|
|
|
Gets pointer to the nth column in an index. */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-09-19 10:14:07 +00:00
|
|
|
const dict_col_t*
|
|
|
|
dict_index_get_nth_col(
|
|
|
|
/*===================*/
|
|
|
|
/* out: column */
|
|
|
|
const dict_index_t* index, /* in: index */
|
|
|
|
ulint pos) /* in: position of the field */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-19 07:52:28 +00:00
|
|
|
return(dict_field_get_col(dict_index_get_nth_field(index, pos)));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the column number the nth field in an index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_nth_col_no(
|
|
|
|
/*======================*/
|
2006-09-19 10:14:07 +00:00
|
|
|
/* out: column number */
|
|
|
|
const dict_index_t* index, /* in: index */
|
|
|
|
ulint pos) /* in: position of the field */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
return(dict_col_get_no(dict_index_get_nth_col(index, pos)));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2007-06-08 07:37:07 +00:00
|
|
|
/************************************************************************
|
|
|
|
Returns the minimum data size of an index record. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
dict_index_get_min_size(
|
|
|
|
/*====================*/
|
|
|
|
/* out: minimum data size in bytes */
|
|
|
|
const dict_index_t* index) /* in: index */
|
|
|
|
{
|
|
|
|
ulint n = dict_index_get_n_fields(index);
|
|
|
|
ulint size = 0;
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
size += dict_col_get_min_size(dict_index_get_nth_col(index,
|
|
|
|
n));
|
|
|
|
}
|
|
|
|
|
|
|
|
return(size);
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Gets the space id of the root of the index tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_get_space(
|
|
|
|
/*=================*/
|
2007-09-24 13:29:18 +00:00
|
|
|
/* out: space id */
|
|
|
|
const dict_index_t* index) /* in: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
return(index->space);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Sets the space id of the root of the index tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_set_space(
|
|
|
|
/*=================*/
|
2007-09-24 13:29:18 +00:00
|
|
|
dict_index_t* index, /* in/out: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint space) /* in: space id */
|
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index->space = space;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the page number of the root of the index tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_get_page(
|
|
|
|
/*================*/
|
2007-09-24 13:29:18 +00:00
|
|
|
/* out: page number */
|
|
|
|
const dict_index_t* index) /* in: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
return(index->page);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Sets the page number of the root of index tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_set_page(
|
|
|
|
/*================*/
|
2007-09-24 13:29:18 +00:00
|
|
|
dict_index_t* index, /* in/out: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page) /* in: page number */
|
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index->page = page;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the read-write lock of the index tree. */
|
|
|
|
UNIV_INLINE
|
|
|
|
rw_lock_t*
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_get_lock(
|
|
|
|
/*================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: read-write lock */
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_t* index) /* in: index */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(index);
|
|
|
|
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
return(&(index->lock));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Returns free space reserved for future updates of records. This is
|
|
|
|
relevant only in the case of many consecutive inserts, as updates
|
|
|
|
which make the records bigger might fragment the index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_index_get_space_reserve(void)
|
|
|
|
/*==============================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: number of free bytes on page,
|
|
|
|
reserved for updates */
|
|
|
|
{
|
|
|
|
return(UNIV_PAGE_SIZE / 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Checks if a table is in the dictionary cache. */
|
|
|
|
UNIV_INLINE
|
|
|
|
dict_table_t*
|
|
|
|
dict_table_check_if_in_cache_low(
|
2006-02-23 19:25:29 +00:00
|
|
|
/*=============================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: table, NULL if not found */
|
|
|
|
const char* table_name) /* in: table name */
|
|
|
|
{
|
|
|
|
dict_table_t* table;
|
|
|
|
ulint table_fold;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(table_name);
|
|
|
|
ut_ad(mutex_own(&(dict_sys->mutex)));
|
|
|
|
|
|
|
|
/* Look for the table name in the hash table */
|
|
|
|
table_fold = ut_fold_string(table_name);
|
|
|
|
|
2007-08-01 08:13:22 +00:00
|
|
|
HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
|
branches/zip: In hash table lookups, assert that the traversed items
satisfy some conditions when UNIV_DEBUG is defined.
HASH_SEARCH(): New parameter: ASSERTION. All users will pass an appropriate
ut_ad() or nothing.
dict_table_add_to_columns(): Assert that the table being added to the data
dictionary cache is not already being pointed to by the name_hash and
id_hash tables.
HASH_SEARCH_ALL(): New macro, for use in dict_table_add_to_columns().
dict_mem_table_free(): Set ut_d(table->cached = FALSE), so that we can
check ut_ad(table->cached) when traversing the hash tables, as in
HASH_SEARCH(name_hash, dict_sys->table_hash, ...) and
HASH_SEARCH(id_hash, dict_sys->table_id_hash, ...).
dict_table_get_low(), dict_table_get_on_id_low(): Assert
ut_ad(!table || table->cached).
fil_space_get_by_id(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(hash, fil_system->spaces, ...).
fil_space_get_by_name(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(name_hash, fil_system->name_hash, ...).
buf_buddy_block_free(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->zip_hash, ...).
buf_page_hash_get(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->page_hash, ...).
get_share(), free_share(): Check ut_ad(share->use_count > 0) in
HASH_SEARCH(table_name_hash, innobase_open_tables, ...).
This was posted as rb://75 for tracking down errors similar to Issue #153.
2009-01-13 19:46:22 +00:00
|
|
|
dict_table_t*, table, ut_ad(table->cached),
|
|
|
|
!strcmp(table->name, table_name));
|
2005-10-27 07:29:40 +00:00
|
|
|
return(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Gets a table; loads it to the dictionary cache if necessary. A low-level
|
|
|
|
function. */
|
|
|
|
UNIV_INLINE
|
|
|
|
dict_table_t*
|
|
|
|
dict_table_get_low(
|
|
|
|
/*===============*/
|
|
|
|
/* out: table, NULL if not found */
|
|
|
|
const char* table_name) /* in: table name */
|
|
|
|
{
|
|
|
|
dict_table_t* table;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(table_name);
|
|
|
|
ut_ad(mutex_own(&(dict_sys->mutex)));
|
|
|
|
|
|
|
|
table = dict_table_check_if_in_cache_low(table_name);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (table == NULL) {
|
|
|
|
table = dict_load_table(table_name);
|
|
|
|
}
|
|
|
|
|
branches/zip: In hash table lookups, assert that the traversed items
satisfy some conditions when UNIV_DEBUG is defined.
HASH_SEARCH(): New parameter: ASSERTION. All users will pass an appropriate
ut_ad() or nothing.
dict_table_add_to_columns(): Assert that the table being added to the data
dictionary cache is not already being pointed to by the name_hash and
id_hash tables.
HASH_SEARCH_ALL(): New macro, for use in dict_table_add_to_columns().
dict_mem_table_free(): Set ut_d(table->cached = FALSE), so that we can
check ut_ad(table->cached) when traversing the hash tables, as in
HASH_SEARCH(name_hash, dict_sys->table_hash, ...) and
HASH_SEARCH(id_hash, dict_sys->table_id_hash, ...).
dict_table_get_low(), dict_table_get_on_id_low(): Assert
ut_ad(!table || table->cached).
fil_space_get_by_id(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(hash, fil_system->spaces, ...).
fil_space_get_by_name(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(name_hash, fil_system->name_hash, ...).
buf_buddy_block_free(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->zip_hash, ...).
buf_page_hash_get(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->page_hash, ...).
get_share(), free_share(): Check ut_ad(share->use_count > 0) in
HASH_SEARCH(table_name_hash, innobase_open_tables, ...).
This was posted as rb://75 for tracking down errors similar to Issue #153.
2009-01-13 19:46:22 +00:00
|
|
|
ut_ad(!table || table->cached);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2006-05-08 06:18:59 +00:00
|
|
|
Returns a table object based on table id. */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
dict_table_t*
|
|
|
|
dict_table_get_on_id_low(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: table, NULL if does not exist */
|
2006-05-08 06:18:59 +00:00
|
|
|
dulint table_id) /* in: table id */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
dict_table_t* table;
|
|
|
|
ulint fold;
|
|
|
|
|
|
|
|
ut_ad(mutex_own(&(dict_sys->mutex)));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Look for the table name in the hash table */
|
|
|
|
fold = ut_fold_dulint(table_id);
|
|
|
|
|
2007-08-01 08:13:22 +00:00
|
|
|
HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold,
|
branches/zip: In hash table lookups, assert that the traversed items
satisfy some conditions when UNIV_DEBUG is defined.
HASH_SEARCH(): New parameter: ASSERTION. All users will pass an appropriate
ut_ad() or nothing.
dict_table_add_to_columns(): Assert that the table being added to the data
dictionary cache is not already being pointed to by the name_hash and
id_hash tables.
HASH_SEARCH_ALL(): New macro, for use in dict_table_add_to_columns().
dict_mem_table_free(): Set ut_d(table->cached = FALSE), so that we can
check ut_ad(table->cached) when traversing the hash tables, as in
HASH_SEARCH(name_hash, dict_sys->table_hash, ...) and
HASH_SEARCH(id_hash, dict_sys->table_id_hash, ...).
dict_table_get_low(), dict_table_get_on_id_low(): Assert
ut_ad(!table || table->cached).
fil_space_get_by_id(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(hash, fil_system->spaces, ...).
fil_space_get_by_name(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(name_hash, fil_system->name_hash, ...).
buf_buddy_block_free(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->zip_hash, ...).
buf_page_hash_get(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->page_hash, ...).
get_share(), free_share(): Check ut_ad(share->use_count > 0) in
HASH_SEARCH(table_name_hash, innobase_open_tables, ...).
This was posted as rb://75 for tracking down errors similar to Issue #153.
2009-01-13 19:46:22 +00:00
|
|
|
dict_table_t*, table, ut_ad(table->cached),
|
|
|
|
!ut_dulint_cmp(table->id, table_id));
|
2005-10-27 07:29:40 +00:00
|
|
|
if (table == NULL) {
|
|
|
|
table = dict_load_table_on_id(table_id);
|
|
|
|
}
|
|
|
|
|
branches/zip: In hash table lookups, assert that the traversed items
satisfy some conditions when UNIV_DEBUG is defined.
HASH_SEARCH(): New parameter: ASSERTION. All users will pass an appropriate
ut_ad() or nothing.
dict_table_add_to_columns(): Assert that the table being added to the data
dictionary cache is not already being pointed to by the name_hash and
id_hash tables.
HASH_SEARCH_ALL(): New macro, for use in dict_table_add_to_columns().
dict_mem_table_free(): Set ut_d(table->cached = FALSE), so that we can
check ut_ad(table->cached) when traversing the hash tables, as in
HASH_SEARCH(name_hash, dict_sys->table_hash, ...) and
HASH_SEARCH(id_hash, dict_sys->table_id_hash, ...).
dict_table_get_low(), dict_table_get_on_id_low(): Assert
ut_ad(!table || table->cached).
fil_space_get_by_id(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(hash, fil_system->spaces, ...).
fil_space_get_by_name(): Check ut_ad(space->magic_n == FIL_SPACE_MAGIC_N)
in HASH_SEARCH(name_hash, fil_system->name_hash, ...).
buf_buddy_block_free(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->zip_hash, ...).
buf_page_hash_get(): Check that the blocks are in valid state in
HASH_SEARCH(hash, buf_pool->page_hash, ...).
get_share(), free_share(): Check ut_ad(share->use_count > 0) in
HASH_SEARCH(table_name_hash, innobase_open_tables, ...).
This was posted as rb://75 for tracking down errors similar to Issue #153.
2009-01-13 19:46:22 +00:00
|
|
|
ut_ad(!table || table->cached);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* TODO: should get the type information from MySQL */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(table);
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|