2009-05-27 11:45:59 +02: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
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/**************************************************//**
|
|
|
|
@file include/dict0boot.ic
|
|
|
|
Data dictionary creation and booting
|
|
|
|
|
|
|
|
Created 4/18/1996 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
/**********************************************************************//**
|
|
|
|
Writes the current value of the row id counter to the dictionary header file
|
|
|
|
page. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
dict_hdr_flush_row_id(void);
|
|
|
|
/*=======================*/
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************//**
|
|
|
|
Returns a new row id.
|
|
|
|
@return the new id */
|
|
|
|
UNIV_INLINE
|
2010-06-23 13:06:59 +02:00
|
|
|
row_id_t
|
2009-05-27 11:45:59 +02:00
|
|
|
dict_sys_get_new_row_id(void)
|
|
|
|
/*=========================*/
|
|
|
|
{
|
2010-06-23 13:06:59 +02:00
|
|
|
row_id_t id;
|
2009-05-27 11:45:59 +02:00
|
|
|
|
|
|
|
mutex_enter(&(dict_sys->mutex));
|
|
|
|
|
|
|
|
id = dict_sys->row_id;
|
|
|
|
|
2010-06-23 13:06:59 +02:00
|
|
|
if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) {
|
2009-05-27 11:45:59 +02:00
|
|
|
|
|
|
|
dict_hdr_flush_row_id();
|
|
|
|
}
|
|
|
|
|
2010-06-23 13:06:59 +02:00
|
|
|
dict_sys->row_id++;
|
2009-05-27 11:45:59 +02:00
|
|
|
|
|
|
|
mutex_exit(&(dict_sys->mutex));
|
|
|
|
|
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************//**
|
|
|
|
Reads a row id from a record or other 6-byte stored form.
|
|
|
|
@return row id */
|
|
|
|
UNIV_INLINE
|
2010-06-23 13:06:59 +02:00
|
|
|
row_id_t
|
2009-05-27 11:45:59 +02:00
|
|
|
dict_sys_read_row_id(
|
|
|
|
/*=================*/
|
2010-06-23 13:06:59 +02:00
|
|
|
const byte* field) /*!< in: record field */
|
2009-05-27 11:45:59 +02:00
|
|
|
{
|
|
|
|
#if DATA_ROW_ID_LEN != 6
|
|
|
|
# error "DATA_ROW_ID_LEN != 6"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(mach_read_from_6(field));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************//**
|
|
|
|
Writes a row id to a record or other 6-byte stored form. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
dict_sys_write_row_id(
|
|
|
|
/*==================*/
|
2010-06-23 13:06:59 +02:00
|
|
|
byte* field, /*!< in: record field */
|
|
|
|
row_id_t row_id) /*!< in: row id */
|
2009-05-27 11:45:59 +02:00
|
|
|
{
|
|
|
|
#if DATA_ROW_ID_LEN != 6
|
|
|
|
# error "DATA_ROW_ID_LEN != 6"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mach_write_to_6(field, row_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|