2009-02-17 08:15:06 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1995, 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
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
|
|
|
@file fsp/fsp0fsp.c
|
2005-10-27 07:29:40 +00:00
|
|
|
File space management
|
|
|
|
|
|
|
|
Created 11/29/1995 Heikki Tuuri
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
#include "fsp0fsp.h"
|
|
|
|
|
|
|
|
#ifdef UNIV_NONINL
|
|
|
|
#include "fsp0fsp.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "buf0buf.h"
|
|
|
|
#include "fil0fil.h"
|
|
|
|
#include "mtr0log.h"
|
|
|
|
#include "ut0byte.h"
|
2009-03-23 14:21:34 +00:00
|
|
|
#include "page0page.h"
|
2006-11-27 13:44:32 +00:00
|
|
|
#include "page0zip.h"
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifdef UNIV_HOTBACKUP
|
|
|
|
# include "fut0lst.h"
|
|
|
|
#else /* UNIV_HOTBACKUP */
|
|
|
|
# include "sync0sync.h"
|
|
|
|
# include "fut0fut.h"
|
|
|
|
# include "srv0srv.h"
|
|
|
|
# include "ibuf0ibuf.h"
|
|
|
|
# include "btr0btr.h"
|
|
|
|
# include "btr0sea.h"
|
|
|
|
# include "dict0boot.h"
|
|
|
|
# include "log0log.h"
|
|
|
|
#endif /* UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
#include "dict0mem.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define FSP_HEADER_OFFSET FIL_PAGE_DATA /* Offset of the space header
|
|
|
|
within a file page */
|
|
|
|
|
|
|
|
/* The data structures in files are defined just as byte strings in C */
|
|
|
|
typedef byte fsp_header_t;
|
2006-02-23 19:25:29 +00:00
|
|
|
typedef byte xdes_t;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* SPACE HEADER
|
2005-10-27 07:29:40 +00:00
|
|
|
============
|
|
|
|
|
|
|
|
File space header data structure: this data structure is contained in the
|
|
|
|
first page of a space. The space for this header is reserved in every extent
|
|
|
|
descriptor page, but used only in the first. */
|
|
|
|
|
|
|
|
/*-------------------------------------*/
|
|
|
|
#define FSP_SPACE_ID 0 /* space id */
|
|
|
|
#define FSP_NOT_USED 4 /* this field contained a value up to
|
|
|
|
which we know that the modifications
|
|
|
|
in the database have been flushed to
|
|
|
|
the file space; not used now */
|
|
|
|
#define FSP_SIZE 8 /* Current size of the space in
|
|
|
|
pages */
|
|
|
|
#define FSP_FREE_LIMIT 12 /* Minimum page number for which the
|
|
|
|
free list has not been initialized:
|
|
|
|
the pages >= this limit are, by
|
|
|
|
definition, free; note that in a
|
|
|
|
single-table tablespace where size
|
|
|
|
< 64 pages, this number is 64, i.e.,
|
|
|
|
we have initialized the space
|
|
|
|
about the first extent, but have not
|
|
|
|
physically allocted those pages to the
|
|
|
|
file */
|
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
|
|
|
#define FSP_SPACE_FLAGS 16 /* table->flags & ~DICT_TF_COMPACT */
|
2005-10-27 07:29:40 +00:00
|
|
|
#define FSP_FRAG_N_USED 20 /* number of used pages in the
|
|
|
|
FSP_FREE_FRAG list */
|
|
|
|
#define FSP_FREE 24 /* list of free extents */
|
|
|
|
#define FSP_FREE_FRAG (24 + FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of partially free extents not
|
|
|
|
belonging to any segment */
|
|
|
|
#define FSP_FULL_FRAG (24 + 2 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of full extents not belonging
|
|
|
|
to any segment */
|
|
|
|
#define FSP_SEG_ID (24 + 3 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* 8 bytes which give the first unused
|
|
|
|
segment id */
|
|
|
|
#define FSP_SEG_INODES_FULL (32 + 3 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of pages containing segment
|
|
|
|
headers, where all the segment inode
|
|
|
|
slots are reserved */
|
|
|
|
#define FSP_SEG_INODES_FREE (32 + 4 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of pages containing segment
|
|
|
|
headers, where not all the segment
|
|
|
|
header slots are reserved */
|
|
|
|
/*-------------------------------------*/
|
|
|
|
/* File space header size */
|
|
|
|
#define FSP_HEADER_SIZE (32 + 5 * FLST_BASE_NODE_SIZE)
|
|
|
|
|
|
|
|
#define FSP_FREE_ADD 4 /* this many free extents are added
|
|
|
|
to the free list from above
|
|
|
|
FSP_FREE_LIMIT at a time */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* FILE SEGMENT INODE
|
|
|
|
==================
|
|
|
|
|
|
|
|
Segment inode which is created for each segment in a tablespace. NOTE: in
|
|
|
|
purge we assume that a segment having only one currently used page can be
|
|
|
|
freed in a few steps, so that the freeing cannot fill the file buffer with
|
|
|
|
bufferfixed file pages. */
|
|
|
|
|
|
|
|
typedef byte fseg_inode_t;
|
|
|
|
|
|
|
|
#define FSEG_INODE_PAGE_NODE FSEG_PAGE_DATA
|
|
|
|
/* the list node for linking
|
|
|
|
segment inode pages */
|
|
|
|
|
|
|
|
#define FSEG_ARR_OFFSET (FSEG_PAGE_DATA + FLST_NODE_SIZE)
|
|
|
|
/*-------------------------------------*/
|
|
|
|
#define FSEG_ID 0 /* 8 bytes of segment id: if this is
|
|
|
|
ut_dulint_zero, it means that the
|
|
|
|
header is unused */
|
|
|
|
#define FSEG_NOT_FULL_N_USED 8
|
|
|
|
/* number of used segment pages in
|
|
|
|
the FSEG_NOT_FULL list */
|
|
|
|
#define FSEG_FREE 12
|
|
|
|
/* list of free extents of this
|
|
|
|
segment */
|
|
|
|
#define FSEG_NOT_FULL (12 + FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of partially free extents */
|
|
|
|
#define FSEG_FULL (12 + 2 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* list of full extents */
|
|
|
|
#define FSEG_MAGIC_N (12 + 3 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* magic number used in debugging */
|
|
|
|
#define FSEG_FRAG_ARR (16 + 3 * FLST_BASE_NODE_SIZE)
|
|
|
|
/* array of individual pages
|
|
|
|
belonging to this segment in fsp
|
|
|
|
fragment extent lists */
|
|
|
|
#define FSEG_FRAG_ARR_N_SLOTS (FSP_EXTENT_SIZE / 2)
|
|
|
|
/* number of slots in the array for
|
|
|
|
the fragment pages */
|
|
|
|
#define FSEG_FRAG_SLOT_SIZE 4 /* a fragment page slot contains its
|
|
|
|
page number within space, FIL_NULL
|
|
|
|
means that the slot is not in use */
|
|
|
|
/*-------------------------------------*/
|
2006-08-29 09:30:31 +00:00
|
|
|
#define FSEG_INODE_SIZE \
|
|
|
|
(16 + 3 * FLST_BASE_NODE_SIZE \
|
|
|
|
+ FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE)
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
#define FSP_SEG_INODES_PER_PAGE(zip_size) \
|
|
|
|
(((zip_size ? zip_size : UNIV_PAGE_SIZE) \
|
2006-08-29 09:30:31 +00:00
|
|
|
- FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE)
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Number of segment inodes which fit on a
|
|
|
|
single page */
|
|
|
|
|
|
|
|
#define FSEG_MAGIC_N_VALUE 97937874
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#define FSEG_FILLFACTOR 8 /* If this value is x, then if
|
|
|
|
the number of unused but reserved
|
|
|
|
pages in a segment is less than
|
|
|
|
reserved pages * 1/x, and there are
|
|
|
|
at least FSEG_FRAG_LIMIT used pages,
|
|
|
|
then we allow a new empty extent to
|
|
|
|
be added to the segment in
|
|
|
|
fseg_alloc_free_page. Otherwise, we
|
|
|
|
use unused pages of the segment. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#define FSEG_FRAG_LIMIT FSEG_FRAG_ARR_N_SLOTS
|
|
|
|
/* If the segment has >= this many
|
|
|
|
used pages, it may be expanded by
|
|
|
|
allocating extents to the segment;
|
|
|
|
until that only individual fragment
|
|
|
|
pages are allocated from the space */
|
|
|
|
|
|
|
|
#define FSEG_FREE_LIST_LIMIT 40 /* If the reserved size of a segment
|
|
|
|
is at least this many extents, we
|
|
|
|
allow extents to be put to the free
|
|
|
|
list of the extent: at most
|
|
|
|
FSEG_FREE_LIST_MAX_LEN many */
|
|
|
|
#define FSEG_FREE_LIST_MAX_LEN 4
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* EXTENT DESCRIPTOR
|
|
|
|
=================
|
|
|
|
|
|
|
|
File extent descriptor data structure: contains bits to tell which pages in
|
|
|
|
the extent are free and which contain old tuple version to clean. */
|
|
|
|
|
|
|
|
/*-------------------------------------*/
|
|
|
|
#define XDES_ID 0 /* The identifier of the segment
|
|
|
|
to which this extent belongs */
|
|
|
|
#define XDES_FLST_NODE 8 /* The list node data structure
|
|
|
|
for the descriptors */
|
|
|
|
#define XDES_STATE (FLST_NODE_SIZE + 8)
|
|
|
|
/* contains state information
|
|
|
|
of the extent */
|
|
|
|
#define XDES_BITMAP (FLST_NODE_SIZE + 12)
|
|
|
|
/* Descriptor bitmap of the pages
|
|
|
|
in the extent */
|
|
|
|
/*-------------------------------------*/
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#define XDES_BITS_PER_PAGE 2 /* How many bits are there per page */
|
|
|
|
#define XDES_FREE_BIT 0 /* Index of the bit which tells if
|
|
|
|
the page is free */
|
|
|
|
#define XDES_CLEAN_BIT 1 /* NOTE: currently not used!
|
|
|
|
Index of the bit which tells if
|
|
|
|
there are old versions of tuples
|
|
|
|
on the page */
|
|
|
|
/* States of a descriptor */
|
|
|
|
#define XDES_FREE 1 /* extent is in free list of space */
|
|
|
|
#define XDES_FREE_FRAG 2 /* extent is in free fragment list of
|
|
|
|
space */
|
|
|
|
#define XDES_FULL_FRAG 3 /* extent is in full fragment list of
|
|
|
|
space */
|
|
|
|
#define XDES_FSEG 4 /* extent belongs to a segment */
|
|
|
|
|
2007-05-29 08:48:16 +00:00
|
|
|
/* File extent data structure size in bytes. */
|
2006-08-29 09:30:31 +00:00
|
|
|
#define XDES_SIZE \
|
2007-05-29 08:48:16 +00:00
|
|
|
(XDES_BITMAP + UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE))
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Offset of the descriptor array on a descriptor page */
|
|
|
|
#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns an extent to the free list of a space. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_free_extent(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset in the extent */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees an extent of a segment to the space free list. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_free_extent(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset in the extent */
|
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates the number of pages reserved by a segment, and how
|
2009-05-25 05:30:14 +00:00
|
|
|
many pages are currently used.
|
|
|
|
@return number of reserved pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_n_reserved_pages_low(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* header, /*!< in: segment inode */
|
|
|
|
ulint* used, /*!< out: number of pages used (<= reserved) */
|
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Marks a page used. The page must reside within the extents of the given
|
|
|
|
segment. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_mark_page_used(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode,/*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns the first extent descriptor for a segment. We think of the extent
|
|
|
|
lists of the segment catenated in the order FSEG_FULL -> FSEG_NOT_FULL
|
2009-05-25 05:30:14 +00:00
|
|
|
-> FSEG_FREE.
|
|
|
|
@return the first extent descriptor, or NULL if none */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
xdes_t*
|
|
|
|
fseg_get_first_extent(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Puts new extents to the free list if
|
|
|
|
there are free extents above the free limit. If an extent happens
|
|
|
|
to contain an extent descriptor page, the extent is put to
|
|
|
|
the FSP_FREE_FRAG list with the page marked as used. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_fill_free_list(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool init_space, /*!< in: TRUE if this is a single-table
|
2005-10-27 07:29:40 +00:00
|
|
|
tablespace and we are only initing
|
|
|
|
the tablespace's first extent
|
|
|
|
descriptor page and ibuf bitmap page;
|
|
|
|
then we do not allocate more extents */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
fsp_header_t* header, /*!< in: space header */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize file space
|
2009-05-25 05:30:14 +00:00
|
|
|
fragmentation.
|
|
|
|
@return the allocated page number, FIL_NULL if no page could be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page_low(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode, /*!< in: segment inode */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction, /*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the file space size stored in the header page.
|
|
|
|
@return tablespace size stored in the space header */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fsp_get_size_low(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page) /*!< in: header page (page 0 in the tablespace) */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return(mach_read_from_4(page + FSP_HEADER_OFFSET + FSP_SIZE));
|
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets a pointer to the space header and x-locks its page.
|
|
|
|
@return pointer to the space header, page x-locked */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
fsp_header_t*
|
|
|
|
fsp_get_space_header(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint id, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
fsp_header_t* header;
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
|
|
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
|
|
|
ut_ad(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
|
|
|
ut_ad(id || !zip_size);
|
|
|
|
|
|
|
|
block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
|
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(id == mach_read_from_4(FSP_SPACE_ID + header));
|
|
|
|
ut_ad(zip_size == dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(FSP_SPACE_FLAGS + header)));
|
2005-10-27 07:29:40 +00:00
|
|
|
return(header);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets a descriptor bit of a page.
|
|
|
|
@return TRUE if free */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
xdes_get_bit(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
|
|
ulint offset, /*!< in: page offset within extent:
|
2005-10-27 07:29:40 +00:00
|
|
|
0 ... FSP_EXTENT_SIZE - 1 */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint index;
|
|
|
|
ulint byte_index;
|
|
|
|
ulint bit_index;
|
|
|
|
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT));
|
|
|
|
ut_ad(offset < FSP_EXTENT_SIZE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
index = bit + XDES_BITS_PER_PAGE * offset;
|
|
|
|
|
|
|
|
byte_index = index / 8;
|
|
|
|
bit_index = index % 8;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
return(ut_bit_get_nth(mtr_read_ulint(descr + XDES_BITMAP + byte_index,
|
|
|
|
MLOG_1BYTE, mtr),
|
|
|
|
bit_index));
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Sets a descriptor bit of a page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
xdes_set_bit(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
|
|
ulint offset, /*!< in: page offset within extent:
|
2005-10-27 07:29:40 +00:00
|
|
|
0 ... FSP_EXTENT_SIZE - 1 */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool val, /*!< in: bit value */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint index;
|
|
|
|
ulint byte_index;
|
|
|
|
ulint bit_index;
|
|
|
|
ulint descr_byte;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT));
|
|
|
|
ut_ad(offset < FSP_EXTENT_SIZE);
|
|
|
|
|
|
|
|
index = bit + XDES_BITS_PER_PAGE * offset;
|
|
|
|
|
|
|
|
byte_index = index / 8;
|
|
|
|
bit_index = index % 8;
|
|
|
|
|
|
|
|
descr_byte = mtr_read_ulint(descr + XDES_BITMAP + byte_index,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_1BYTE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
descr_byte = ut_bit_set_nth(descr_byte, bit_index, val);
|
|
|
|
|
|
|
|
mlog_write_ulint(descr + XDES_BITMAP + byte_index, descr_byte,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_1BYTE, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Looks for a descriptor bit having the desired value. Starts from hint
|
|
|
|
and scans upward; at the end of the extent the search is wrapped to
|
2009-05-25 05:30:14 +00:00
|
|
|
the start of the extent.
|
|
|
|
@return bit index of the bit, ULINT_UNDEFINED if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_find_bit(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
|
|
ibool val, /*!< in: desired bit value */
|
|
|
|
ulint hint, /*!< in: hint of which bit position would be desirable */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(descr && mtr);
|
|
|
|
ut_ad(val <= TRUE);
|
|
|
|
ut_ad(hint < FSP_EXTENT_SIZE);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = hint; i < FSP_EXTENT_SIZE; i++) {
|
|
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < hint; i++) {
|
|
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Looks for a descriptor bit having the desired value. Scans the extent in
|
2009-05-25 05:30:14 +00:00
|
|
|
a direction opposite to xdes_find_bit.
|
|
|
|
@return bit index of the bit, ULINT_UNDEFINED if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_find_bit_downward(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
|
|
ibool val, /*!< in: desired bit value */
|
|
|
|
ulint hint, /*!< in: hint of which bit position would be desirable */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(descr && mtr);
|
|
|
|
ut_ad(val <= TRUE);
|
|
|
|
ut_ad(hint < FSP_EXTENT_SIZE);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = hint + 1; i > 0; i--) {
|
|
|
|
if (val == xdes_get_bit(descr, bit, i - 1, mtr)) {
|
|
|
|
|
|
|
|
return(i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = FSP_EXTENT_SIZE - 1; i > hint; i--) {
|
|
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the number of used pages in a descriptor.
|
|
|
|
@return number of pages used */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_get_n_used(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
ulint count = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(descr && mtr);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
|
|
if (FALSE == xdes_get_bit(descr, XDES_FREE_BIT, i, mtr)) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return(count);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns true if extent contains no used pages.
|
|
|
|
@return TRUE if totally free */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
xdes_is_free(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
if (0 == xdes_get_n_used(descr, mtr)) {
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns true if extent contains no free pages.
|
|
|
|
@return TRUE if full */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
xdes_is_full(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
if (FSP_EXTENT_SIZE == xdes_get_n_used(descr, mtr)) {
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Sets the state of an xdes. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
xdes_set_state(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
ulint state, /*!< in: state to set */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(descr && mtr);
|
|
|
|
ut_ad(state >= XDES_FREE);
|
|
|
|
ut_ad(state <= XDES_FSEG);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(descr + XDES_STATE, state, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the state of an xdes.
|
|
|
|
@return state */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_get_state(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-08-09 08:55:00 +00:00
|
|
|
ulint state;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(descr && mtr);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-09 08:55:00 +00:00
|
|
|
state = mtr_read_ulint(descr + XDES_STATE, MLOG_4BYTES, mtr);
|
|
|
|
ut_ad(state - 1 < XDES_FSEG);
|
|
|
|
return(state);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Inits an extent descriptor to the free and clean state. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
xdes_init(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr, /*!< in: descriptor */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
|
|
|
|
ut_ad(descr && mtr);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad((XDES_SIZE - XDES_BITMAP) % 4 == 0);
|
|
|
|
|
|
|
|
for (i = XDES_BITMAP; i < XDES_SIZE; i += 4) {
|
|
|
|
mlog_write_ulint(descr + i, 0xFFFFFFFFUL, MLOG_4BYTES, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
xdes_set_state(descr, XDES_FREE, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Calculates the page where the descriptor of a page resides.
|
|
|
|
@return descriptor page offset */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_calc_descriptor_page(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size, /*!< in: compressed page size in bytes;
|
2006-06-06 07:42:04 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset) /*!< in: page offset */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2009-05-25 10:52:20 +00:00
|
|
|
#ifndef DOXYGEN /* Doxygen gets confused of these */
|
|
|
|
# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET \
|
2006-06-06 07:42:04 +00:00
|
|
|
+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
|
2009-05-25 10:52:20 +00:00
|
|
|
# error
|
|
|
|
# endif
|
|
|
|
# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
|
2006-06-07 10:41:58 +00:00
|
|
|
+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
|
2009-05-25 10:52:20 +00:00
|
|
|
# error
|
|
|
|
# endif
|
|
|
|
#endif /* !DOXYGEN */
|
2008-03-05 09:41:51 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
return(ut_2pow_round(offset, UNIV_PAGE_SIZE));
|
|
|
|
} else {
|
2006-06-14 11:19:08 +00:00
|
|
|
ut_ad(zip_size > XDES_ARR_OFFSET
|
2006-08-29 09:30:31 +00:00
|
|
|
+ (zip_size / FSP_EXTENT_SIZE) * XDES_SIZE);
|
2006-06-06 07:42:04 +00:00
|
|
|
return(ut_2pow_round(offset, zip_size));
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Calculates the descriptor index within a descriptor page.
|
|
|
|
@return descriptor index */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_calc_descriptor_index(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size, /*!< in: compressed page size in bytes;
|
2006-06-06 07:42:04 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset) /*!< in: page offset */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2008-03-05 09:41:51 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
return(ut_2pow_remainder(offset, UNIV_PAGE_SIZE)
|
2006-08-29 09:30:31 +00:00
|
|
|
/ FSP_EXTENT_SIZE);
|
2006-06-06 07:42:04 +00:00
|
|
|
} else {
|
|
|
|
return(ut_2pow_remainder(offset, zip_size) / FSP_EXTENT_SIZE);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets pointer to a the extent descriptor of a page. The page where the extent
|
|
|
|
descriptor resides is x-locked. If the page offset is equal to the free limit
|
|
|
|
of the space, adds new extents from above the free limit to the space free
|
|
|
|
list, if not free limit == space size. This adding is necessary to make the
|
2009-05-25 05:30:14 +00:00
|
|
|
descriptor defined, as they are uninitialized above the free limit.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return pointer to the extent descriptor, NULL if the page does not
|
|
|
|
exist in the space or if the offset exceeds the free limit */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
xdes_t*
|
|
|
|
xdes_get_descriptor_with_space_hdr(
|
|
|
|
/*===============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fsp_header_t* sp_header,/*!< in: space header, x-latched */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset, /*!< in: page offset;
|
2005-10-27 07:29:40 +00:00
|
|
|
if equal to the free limit,
|
|
|
|
we try to add new extents to
|
|
|
|
the space free list */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint limit;
|
|
|
|
ulint size;
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint descr_page_no;
|
|
|
|
page_t* descr_page;
|
|
|
|
|
|
|
|
ut_ad(mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
|
2006-08-29 09:30:31 +00:00
|
|
|
MTR_MEMO_X_LOCK));
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_S_FIX)
|
|
|
|
|| mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(page_offset(sp_header) == FSP_HEADER_OFFSET);
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Read free limit and space size */
|
2006-06-06 07:42:04 +00:00
|
|
|
limit = mach_read_from_4(sp_header + FSP_FREE_LIMIT);
|
|
|
|
size = mach_read_from_4(sp_header + FSP_SIZE);
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(sp_header + FSP_SPACE_FLAGS));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* If offset is >= size or > limit, return NULL */
|
|
|
|
|
|
|
|
if ((offset >= size) || (offset > limit)) {
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If offset is == limit, fill free list of the space. */
|
|
|
|
|
|
|
|
if (offset == limit) {
|
|
|
|
fsp_fill_free_list(FALSE, space, sp_header, mtr);
|
|
|
|
}
|
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
descr_page_no = xdes_calc_descriptor_page(zip_size, offset);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (descr_page_no == 0) {
|
|
|
|
/* It is on the space header page */
|
|
|
|
|
2006-10-09 16:22:47 +00:00
|
|
|
descr_page = page_align(sp_header);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, descr_page_no,
|
|
|
|
RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
descr_page = buf_block_get_frame(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(descr_page + XDES_ARR_OFFSET
|
2006-08-29 09:30:31 +00:00
|
|
|
+ XDES_SIZE * xdes_calc_descriptor_index(zip_size, offset));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets pointer to a the extent descriptor of a page. The page where the
|
|
|
|
extent descriptor resides is x-locked. If the page offset is equal to
|
|
|
|
the free limit of the space, adds new extents from above the free limit
|
|
|
|
to the space free list, if not free limit == space size. This adding
|
|
|
|
is necessary to make the descriptor defined, as they are uninitialized
|
2009-05-25 05:30:14 +00:00
|
|
|
above the free limit.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return pointer to the extent descriptor, NULL if the page does not
|
|
|
|
exist in the space or if the offset exceeds the free limit */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
xdes_t*
|
|
|
|
xdes_get_descriptor(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset, /*!< in: page offset; if equal to the free limit,
|
2005-10-27 07:29:40 +00:00
|
|
|
we try to add new extents to the space free list */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
fsp_header_t* sp_header;
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
sp_header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
return(xdes_get_descriptor_with_space_hdr(sp_header, space, offset,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets pointer to a the extent descriptor if the file address
|
|
|
|
of the descriptor list node is known. The page where the
|
2009-05-25 05:30:14 +00:00
|
|
|
extent descriptor resides is x-locked.
|
|
|
|
@return pointer to the extent descriptor */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
xdes_t*
|
|
|
|
xdes_lst_get_descriptor(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
fil_addr_t lst_node,/*!< in: file address of the list node
|
2005-10-27 07:29:40 +00:00
|
|
|
contained in the descriptor */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
|
|
|
|
ut_ad(mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
|
2006-08-29 09:30:31 +00:00
|
|
|
MTR_MEMO_X_LOCK));
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fut_get_ptr(space, zip_size, lst_node, RW_X_LATCH, mtr)
|
|
|
|
- XDES_FLST_NODE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(descr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns page offset of the first page in extent described by a descriptor.
|
|
|
|
@return offset of the first page in extent */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
xdes_get_offset(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
xdes_t* descr) /*!< in: extent descriptor */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(descr);
|
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
return(page_get_page_no(page_align(descr))
|
2006-10-09 16:22:47 +00:00
|
|
|
+ ((page_offset(descr) - XDES_ARR_OFFSET) / XDES_SIZE)
|
2006-08-29 09:30:31 +00:00
|
|
|
* FSP_EXTENT_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Inits a file page whose prior contents should be ignored. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_init_file_page_low(
|
2006-02-23 19:25:29 +00:00
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block) /*!< in: pointer to a page */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-04-25 07:12:32 +00:00
|
|
|
page_t* page = buf_block_get_frame(block);
|
2006-11-23 13:26:01 +00:00
|
|
|
page_zip_des_t* page_zip= buf_block_get_page_zip(block);
|
2006-04-25 07:12:32 +00:00
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2006-04-25 07:12:32 +00:00
|
|
|
block->check_index_page_at_flush = FALSE;
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-04-25 07:12:32 +00:00
|
|
|
|
|
|
|
if (UNIV_LIKELY_NULL(page_zip)) {
|
|
|
|
memset(page, 0, UNIV_PAGE_SIZE);
|
2006-11-27 13:44:32 +00:00
|
|
|
memset(page_zip->data, 0, page_zip_get_size(page_zip));
|
2006-11-23 13:26:01 +00:00
|
|
|
mach_write_to_4(page + FIL_PAGE_OFFSET,
|
|
|
|
buf_block_get_page_no(block));
|
2006-10-10 12:26:37 +00:00
|
|
|
mach_write_to_4(page
|
|
|
|
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
2006-11-23 13:26:01 +00:00
|
|
|
buf_block_get_space(block));
|
|
|
|
memcpy(page_zip->data + FIL_PAGE_OFFSET,
|
|
|
|
page + FIL_PAGE_OFFSET, 4);
|
|
|
|
memcpy(page_zip->data + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
|
|
|
page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 4);
|
2006-04-25 07:12:32 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_BASIC_LOG_DEBUG
|
|
|
|
memset(page, 0xff, UNIV_PAGE_SIZE);
|
|
|
|
#endif
|
2006-11-23 13:26:01 +00:00
|
|
|
mach_write_to_4(page + FIL_PAGE_OFFSET, buf_block_get_page_no(block));
|
2006-04-25 07:12:32 +00:00
|
|
|
memset(page + FIL_PAGE_LSN, 0, 8);
|
2006-11-23 13:26:01 +00:00
|
|
|
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
|
|
|
buf_block_get_space(block));
|
2006-10-10 12:26:37 +00:00
|
|
|
memset(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 0, 8);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Inits a file page whose prior contents should be ignored. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_init_file_page(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: pointer to a page */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page_low(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
mlog_write_initial_log_record(buf_block_get_frame(block),
|
|
|
|
MLOG_INIT_FILE_PAGE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Parses a redo log record of a file page init.
|
|
|
|
@return end of log record or NULL */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
byte*
|
|
|
|
fsp_parse_init_file_page(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
byte* ptr, /*!< in: buffer */
|
|
|
|
byte* end_ptr __attribute__((unused)), /*!< in: buffer end */
|
|
|
|
buf_block_t* block) /*!< in: block or NULL */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(ptr && end_ptr);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
|
|
|
fsp_init_file_page_low(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes the fsp system. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_init(void)
|
|
|
|
/*==========*/
|
|
|
|
{
|
|
|
|
/* Does nothing at the moment */
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2006-06-14 06:29:41 +00:00
|
|
|
Writes the space id and compressed page size to a tablespace header.
|
|
|
|
This function is used past the buffer pool when we in fil0fil.c create
|
|
|
|
a new single-table tablespace. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
2006-06-14 06:29:41 +00:00
|
|
|
fsp_header_init_fields(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page, /*!< in/out: first page in the space */
|
|
|
|
ulint space_id, /*!< in: space id */
|
|
|
|
ulint flags) /*!< in: tablespace flags (FSP_SPACE_FLAGS):
|
2008-03-18 10:10:51 +00:00
|
|
|
0, or table->flags if newer than COMPACT */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2008-03-18 10:10:51 +00:00
|
|
|
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
|
|
|
|
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
|
|
|
|
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
|
|
|
|
format, the tablespace flags should equal table->flags. */
|
|
|
|
ut_a(flags != DICT_TF_COMPACT);
|
|
|
|
|
2006-06-14 06:29:41 +00:00
|
|
|
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page,
|
|
|
|
space_id);
|
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
|
|
|
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page,
|
|
|
|
flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes the space header of a new created space and creates also the
|
|
|
|
insert buffer tree root if space == 0. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_header_init(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint size, /*!< in: current size in blocks */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
page_t* page;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2006-10-12 11:05:22 +00:00
|
|
|
block = buf_page_create(space, 0, zip_size, mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The prior contents of the file page should be ignored */
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page(block, mtr);
|
|
|
|
page = buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_FSP_HDR,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_2BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
header = FSP_HEADER_OFFSET + page;
|
|
|
|
|
|
|
|
mlog_write_ulint(header + FSP_SPACE_ID, space, MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(header + FSP_NOT_USED, 0, MLOG_4BYTES, mtr);
|
|
|
|
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, size, MLOG_4BYTES, mtr);
|
|
|
|
mlog_write_ulint(header + FSP_FREE_LIMIT, 0, MLOG_4BYTES, mtr);
|
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
|
|
|
mlog_write_ulint(header + FSP_SPACE_FLAGS, flags,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, 0, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
flst_init(header + FSP_FREE, mtr);
|
|
|
|
flst_init(header + FSP_FREE_FRAG, mtr);
|
|
|
|
flst_init(header + FSP_FULL_FRAG, mtr);
|
|
|
|
flst_init(header + FSP_SEG_INODES_FULL, mtr);
|
|
|
|
flst_init(header + FSP_SEG_INODES_FREE, mtr);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_dulint(header + FSP_SEG_ID, ut_dulint_create(0, 1), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (space == 0) {
|
|
|
|
fsp_fill_free_list(FALSE, space, header, mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
|
|
|
|
0, 0, ut_dulint_add(DICT_IBUF_ID_MIN, space),
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
fsp_fill_free_list(TRUE, space, header, mtr);
|
|
|
|
}
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the space id from the first page of a tablespace.
|
|
|
|
@return space id, ULINT UNDEFINED if error */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fsp_header_get_space_id(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page) /*!< in: first page of a tablespace */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint fsp_id;
|
|
|
|
ulint id;
|
|
|
|
|
|
|
|
fsp_id = mach_read_from_4(FSP_HEADER_OFFSET + page + FSP_SPACE_ID);
|
|
|
|
|
|
|
|
id = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
|
|
|
|
|
|
|
if (id != fsp_id) {
|
2006-02-23 19:25:29 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error: space id in fsp header %lu,"
|
|
|
|
" but in the page header %lu\n",
|
2006-02-23 19:25:29 +00:00
|
|
|
(ulong) fsp_id, (ulong) id);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the space flags from the first page of a tablespace.
|
|
|
|
@return flags */
|
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
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
fsp_header_get_flags(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page) /*!< in: first page of a tablespace */
|
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
|
|
|
{
|
|
|
|
ut_ad(!page_offset(page));
|
|
|
|
|
|
|
|
return(mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the compressed page size from the first page of a tablespace.
|
|
|
|
@return compressed page size in bytes, or 0 if uncompressed */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2006-04-25 07:12:32 +00:00
|
|
|
ulint
|
|
|
|
fsp_header_get_zip_size(
|
2007-01-18 09:59:00 +00:00
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page) /*!< in: first page of a tablespace */
|
2006-04-25 07:12:32 +00:00
|
|
|
{
|
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
|
|
|
ulint flags = fsp_header_get_flags(page);
|
|
|
|
|
|
|
|
return(dict_table_flags_to_zip_size(flags));
|
2006-04-25 07:12:32 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Increases the space size field of a space. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_header_inc_size(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint size_inc,/*!< in: size increment in pages */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
ulint size;
|
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
|
|
|
ulint flags;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
header = fsp_get_space_header(space,
|
|
|
|
dict_table_flags_to_zip_size(flags),
|
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, size + size_inc, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-03-05 12:40:29 +00:00
|
|
|
Gets the current free limit of the system tablespace. The free limit
|
|
|
|
means the place of the first page which has never been put to the the
|
|
|
|
free list for allocation. The space above that address is initialized
|
2009-05-25 05:30:14 +00:00
|
|
|
to zero. Sets also the global variable log_fsp_current_free_limit.
|
|
|
|
@return free limit in megabytes */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
2008-03-05 12:40:29 +00:00
|
|
|
fsp_header_get_free_limit(void)
|
|
|
|
/*===========================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
ulint limit;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2008-03-05 12:40:29 +00:00
|
|
|
mtr_x_lock(fil_space_get_latch(0, NULL), &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-03-05 12:40:29 +00:00
|
|
|
header = fsp_get_space_header(0, 0, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, &mtr);
|
|
|
|
|
2008-03-05 12:40:29 +00:00
|
|
|
limit /= ((1024 * 1024) / UNIV_PAGE_SIZE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
log_fsp_current_free_limit_set_and_checkpoint(limit);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
return(limit);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-03-05 12:40:29 +00:00
|
|
|
Gets the size of the system tablespace from the tablespace header. If
|
|
|
|
we do not have an auto-extending data file, this should be equal to
|
|
|
|
the size of the data files. If there is an auto-extending data file,
|
2009-05-25 05:30:14 +00:00
|
|
|
this can be smaller.
|
|
|
|
@return size in pages */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
2008-03-05 12:40:29 +00:00
|
|
|
fsp_header_get_tablespace_size(void)
|
|
|
|
/*================================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
ulint size;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2008-03-05 12:40:29 +00:00
|
|
|
mtr_x_lock(fil_space_get_latch(0, NULL), &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-03-05 12:40:29 +00:00
|
|
|
header = fsp_get_space_header(0, 0, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
return(size);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Tries to extend a single-table tablespace so that a page would fit in the
|
2009-05-25 05:30:14 +00:00
|
|
|
data file.
|
|
|
|
@return TRUE if success */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
fsp_try_extend_data_file_with_pages(
|
|
|
|
/*================================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
ulint page_no, /*!< in: page number */
|
|
|
|
fsp_header_t* header, /*!< in: space header */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ibool success;
|
|
|
|
ulint actual_size;
|
|
|
|
ulint size;
|
|
|
|
|
|
|
|
ut_a(space != 0);
|
|
|
|
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(page_no >= size);
|
|
|
|
|
|
|
|
success = fil_extend_space_to_desired_size(&actual_size, space,
|
2006-08-29 09:30:31 +00:00
|
|
|
page_no + 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
/* actual_size now has the space size in pages; it may be less than
|
|
|
|
we wanted if we ran out of disk space */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(header + FSP_SIZE, actual_size, MLOG_4BYTES, mtr);
|
|
|
|
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Tries to extend the last data file of a tablespace if it is auto-extending.
|
|
|
|
@return FALSE if not auto-extending */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
fsp_try_extend_data_file(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint* actual_increase,/*!< out: actual increase in pages, where
|
2005-10-27 07:29:40 +00:00
|
|
|
we measure the tablespace size from
|
|
|
|
what the header field says; it may be
|
|
|
|
the actual file size rounded down to
|
|
|
|
megabyte */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
fsp_header_t* header, /*!< in: space header */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint size;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint new_size;
|
|
|
|
ulint old_size;
|
|
|
|
ulint size_increase;
|
|
|
|
ulint actual_size;
|
|
|
|
ibool success;
|
|
|
|
|
|
|
|
*actual_increase = 0;
|
|
|
|
|
|
|
|
if (space == 0 && !srv_auto_extend_last_data_file) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(header + FSP_SPACE_FLAGS));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
old_size = size;
|
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
if (space == 0) {
|
|
|
|
if (!srv_last_file_size_max) {
|
|
|
|
size_increase = SRV_AUTO_EXTEND_INCREMENT;
|
|
|
|
} else {
|
|
|
|
if (srv_last_file_size_max
|
2006-08-29 09:30:31 +00:00
|
|
|
< srv_data_file_sizes[srv_n_data_files - 1]) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
fprintf(stderr,
|
2006-09-22 10:22:03 +00:00
|
|
|
"InnoDB: Error: Last data file size"
|
|
|
|
" is %lu, max size allowed %lu\n",
|
|
|
|
(ulong) srv_data_file_sizes[
|
|
|
|
srv_n_data_files - 1],
|
2006-06-13 19:27:40 +00:00
|
|
|
(ulong) srv_last_file_size_max);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
size_increase = srv_last_file_size_max
|
2006-08-29 09:30:31 +00:00
|
|
|
- srv_data_file_sizes[srv_n_data_files - 1];
|
2006-06-13 19:27:40 +00:00
|
|
|
if (size_increase > SRV_AUTO_EXTEND_INCREMENT) {
|
|
|
|
size_increase = SRV_AUTO_EXTEND_INCREMENT;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-06-13 19:27:40 +00:00
|
|
|
/* We extend single-table tablespaces first one extent
|
|
|
|
at a time, but for bigger tablespaces more. It is not
|
|
|
|
enough to extend always by one extent, because some
|
|
|
|
extents are frag page extents. */
|
|
|
|
ulint extent_size; /* one megabyte, in pages */
|
|
|
|
|
|
|
|
if (!zip_size) {
|
|
|
|
extent_size = FSP_EXTENT_SIZE;
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-06-13 19:27:40 +00:00
|
|
|
extent_size = FSP_EXTENT_SIZE
|
2006-08-29 09:30:31 +00:00
|
|
|
* UNIV_PAGE_SIZE / zip_size;
|
2006-06-13 19:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (size < extent_size) {
|
|
|
|
/* Let us first extend the file to extent_size */
|
2006-09-19 10:14:07 +00:00
|
|
|
success = fsp_try_extend_data_file_with_pages(
|
|
|
|
space, extent_size - 1, header, mtr);
|
2006-06-13 19:27:40 +00:00
|
|
|
if (!success) {
|
2006-09-19 10:14:07 +00:00
|
|
|
new_size = mtr_read_ulint(header + FSP_SIZE,
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
*actual_increase = new_size - old_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
return(FALSE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-06-13 19:27:40 +00:00
|
|
|
size = extent_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < 32 * extent_size) {
|
|
|
|
size_increase = extent_size;
|
|
|
|
} else {
|
|
|
|
/* Below in fsp_fill_free_list() we assume
|
|
|
|
that we add at most FSP_FREE_ADD extents at
|
|
|
|
a time */
|
|
|
|
size_increase = FSP_FREE_ADD * extent_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (size_increase == 0) {
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
success = fil_extend_space_to_desired_size(&actual_size, space,
|
2006-08-29 09:30:31 +00:00
|
|
|
size + size_increase);
|
2005-10-27 07:29:40 +00:00
|
|
|
/* We ignore any fragments of a full megabyte when storing the size
|
|
|
|
to the space header */
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
new_size = ut_calc_align_down(actual_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
(1024 * 1024) / UNIV_PAGE_SIZE);
|
2006-06-07 10:41:58 +00:00
|
|
|
} else {
|
|
|
|
new_size = ut_calc_align_down(actual_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
(1024 * 1024) / zip_size);
|
2006-06-07 10:41:58 +00:00
|
|
|
}
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, new_size, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
*actual_increase = new_size - old_size;
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Puts new extents to the free list if there are free extents above the free
|
|
|
|
limit. If an extent happens to contain an extent descriptor page, the extent
|
|
|
|
is put to the FSP_FREE_FRAG list with the page marked as used. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_fill_free_list(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool init_space, /*!< in: TRUE if this is a single-table
|
2005-10-27 07:29:40 +00:00
|
|
|
tablespace and we are only initing
|
|
|
|
the tablespace's first extent
|
|
|
|
descriptor page and ibuf bitmap page;
|
|
|
|
then we do not allocate more extents */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
fsp_header_t* header, /*!< in: space header */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint limit;
|
|
|
|
ulint size;
|
2006-05-30 09:04:57 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_t* descr;
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint count = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint frag_n_used;
|
|
|
|
ulint actual_increase;
|
|
|
|
ulint i;
|
|
|
|
mtr_t ibuf_mtr;
|
|
|
|
|
|
|
|
ut_ad(header && mtr);
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(page_offset(header) == FSP_HEADER_OFFSET);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Check if we can fill free list from above the free list limit */
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, mtr);
|
|
|
|
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(FSP_SPACE_FLAGS + header));
|
2006-06-07 11:23:21 +00:00
|
|
|
ut_a(ut_is_2pow(zip_size));
|
2006-06-07 10:41:58 +00:00
|
|
|
ut_a(zip_size <= UNIV_PAGE_SIZE);
|
|
|
|
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
2006-05-30 09:04:57 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (space == 0 && srv_auto_extend_last_data_file
|
2006-08-29 09:30:31 +00:00
|
|
|
&& size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Try to increase the last data file size */
|
|
|
|
fsp_try_extend_data_file(&actual_increase, space, header, mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (space != 0 && !init_space
|
2006-08-29 09:30:31 +00:00
|
|
|
&& size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Try to increase the .ibd file size */
|
|
|
|
fsp_try_extend_data_file(&actual_increase, space, header, mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = limit;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
while ((init_space && i < 1)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| ((i + FSP_EXTENT_SIZE <= size) && (count < FSP_FREE_ADD))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-20 11:32:26 +00:00
|
|
|
ibool init_xdes;
|
|
|
|
if (zip_size) {
|
2006-06-21 11:14:11 +00:00
|
|
|
init_xdes = ut_2pow_remainder(i, zip_size) == 0;
|
2006-06-20 11:32:26 +00:00
|
|
|
} else {
|
2006-06-21 11:14:11 +00:00
|
|
|
init_xdes = ut_2pow_remainder(i, UNIV_PAGE_SIZE) == 0;
|
2006-06-20 11:32:26 +00:00
|
|
|
}
|
2006-06-07 10:41:58 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(header + FSP_FREE_LIMIT, i + FSP_EXTENT_SIZE,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Update the free limit info in the log system and make
|
|
|
|
a checkpoint */
|
|
|
|
if (space == 0) {
|
2006-06-07 10:41:58 +00:00
|
|
|
ut_a(!zip_size);
|
2006-09-19 10:14:07 +00:00
|
|
|
log_fsp_current_free_limit_set_and_checkpoint(
|
|
|
|
(i + FSP_EXTENT_SIZE)
|
|
|
|
/ ((1024 * 1024) / UNIV_PAGE_SIZE));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
if (UNIV_UNLIKELY(init_xdes)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* We are going to initialize a new descriptor page
|
|
|
|
and a new ibuf bitmap page: the prior contents of the
|
|
|
|
pages should be ignored. */
|
|
|
|
|
|
|
|
if (i > 0) {
|
2006-10-12 11:05:22 +00:00
|
|
|
block = buf_page_create(
|
2006-09-19 10:14:07 +00:00
|
|
|
space, i, zip_size, mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
buf_page_get(space, zip_size, i,
|
|
|
|
RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block,
|
|
|
|
SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page(block, mtr);
|
|
|
|
mlog_write_ulint(buf_block_get_frame(block)
|
|
|
|
+ FIL_PAGE_TYPE,
|
2006-08-29 09:30:31 +00:00
|
|
|
FIL_PAGE_TYPE_XDES,
|
|
|
|
MLOG_2BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the ibuf bitmap page in a separate
|
|
|
|
mini-transaction because it is low in the latching
|
|
|
|
order, and we must be able to release its latch
|
|
|
|
before returning from the fsp routine */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&ibuf_mtr);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
block = buf_page_create(space,
|
2006-08-29 09:30:31 +00:00
|
|
|
i + FSP_IBUF_BITMAP_OFFSET,
|
|
|
|
zip_size, &ibuf_mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
buf_page_get(space, zip_size,
|
|
|
|
i + FSP_IBUF_BITMAP_OFFSET,
|
2006-08-29 09:30:31 +00:00
|
|
|
RW_X_LATCH, &ibuf_mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page(block, &ibuf_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
ibuf_bitmap_page_init(block, &ibuf_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&ibuf_mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, i,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_init(descr, mtr);
|
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
#if UNIV_PAGE_SIZE % FSP_EXTENT_SIZE
|
|
|
|
# error "UNIV_PAGE_SIZE % FSP_EXTENT_SIZE != 0"
|
|
|
|
#endif
|
2006-06-07 10:41:58 +00:00
|
|
|
#if PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE
|
|
|
|
# error "PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE != 0"
|
2006-02-17 14:19:39 +00:00
|
|
|
#endif
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
if (UNIV_UNLIKELY(init_xdes)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The first page in the extent is a descriptor page
|
|
|
|
and the second is an ibuf bitmap page: mark them
|
|
|
|
used */
|
|
|
|
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, 0, FALSE, mtr);
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT,
|
2006-08-29 09:30:31 +00:00
|
|
|
FSP_IBUF_BITMAP_OFFSET, FALSE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
|
|
|
|
|
|
flst_add_last(header + FSP_FREE_FRAG,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
frag_n_used + 2, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
flst_add_last(header + FSP_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
i += FSP_EXTENT_SIZE;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a new free extent.
|
|
|
|
@return extent descriptor, NULL if cannot be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
xdes_t*
|
|
|
|
fsp_alloc_free_extent(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint hint, /*!< in: hint of which extent would be desirable: any
|
2005-10-27 07:29:40 +00:00
|
|
|
page offset in the extent goes; the hint must not
|
|
|
|
be > FSP_FREE_LIMIT */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
fil_addr_t first;
|
|
|
|
xdes_t* descr;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
|
|
|
|
|
|
|
|
if (descr && (xdes_get_state(descr, mtr) == XDES_FREE)) {
|
|
|
|
/* Ok, we can take this extent */
|
2006-02-23 19:25:29 +00:00
|
|
|
} else {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Take the first extent in the free list */
|
|
|
|
first = flst_get_first(header + FSP_FREE, mtr);
|
|
|
|
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
|
|
fsp_fill_free_list(FALSE, space, header, mtr);
|
|
|
|
|
|
|
|
first = flst_get_first(header + FSP_FREE, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
|
|
|
|
|
|
return(NULL); /* No free extents left */
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
flst_remove(header + FSP_FREE, descr + XDES_FLST_NODE, mtr);
|
|
|
|
|
|
|
|
return(descr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a single free page from a space. The page is marked as used.
|
|
|
|
@return the page offset, FIL_NULL if no page could be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fsp_alloc_free_page(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
fil_addr_t first;
|
|
|
|
xdes_t* descr;
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint free;
|
|
|
|
ulint frag_n_used;
|
|
|
|
ulint page_no;
|
|
|
|
ulint space_size;
|
|
|
|
ibool success;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Get the hinted descriptor */
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
|
|
|
|
|
|
|
|
if (descr && (xdes_get_state(descr, mtr) == XDES_FREE_FRAG)) {
|
|
|
|
/* Ok, we can take this extent */
|
|
|
|
} else {
|
|
|
|
/* Else take the first extent in free_frag list */
|
|
|
|
first = flst_get_first(header + FSP_FREE_FRAG, mtr);
|
|
|
|
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
|
|
/* There are no partially full fragments: allocate
|
|
|
|
a free extent and add it to the FREE_FRAG list. NOTE
|
|
|
|
that the allocation may have as a side-effect that an
|
|
|
|
extent containing a descriptor page is added to the
|
|
|
|
FREE_FRAG list. But we will allocate our page from the
|
|
|
|
the free extent anyway. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fsp_alloc_free_extent(space, zip_size,
|
|
|
|
hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (descr == NULL) {
|
|
|
|
/* No free space left */
|
|
|
|
|
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
|
|
flst_add_last(header + FSP_FREE_FRAG,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
first, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the hint */
|
|
|
|
hint = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now we have in descr an extent with at least one free page. Look
|
|
|
|
for a free page in the extent. */
|
|
|
|
|
|
|
|
free = xdes_find_bit(descr, XDES_FREE_BIT, TRUE,
|
2006-08-29 09:30:31 +00:00
|
|
|
hint % FSP_EXTENT_SIZE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (free == ULINT_UNDEFINED) {
|
|
|
|
|
|
|
|
ut_print_buf(stderr, ((byte*)descr) - 500, 1000);
|
2008-08-06 08:10:21 +00:00
|
|
|
putc('\n', stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
page_no = xdes_get_offset(descr) + free;
|
|
|
|
|
|
|
|
space_size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
|
|
|
|
if (space_size <= page_no) {
|
2006-02-23 19:25:29 +00:00
|
|
|
/* It must be that we are extending a single-table tablespace
|
2005-10-27 07:29:40 +00:00
|
|
|
whose size is still < 64 pages */
|
|
|
|
|
|
|
|
ut_a(space != 0);
|
|
|
|
if (page_no >= FSP_EXTENT_SIZE) {
|
2006-02-23 19:25:29 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error: trying to extend a"
|
|
|
|
" single-table tablespace %lu\n"
|
|
|
|
"InnoDB: by single page(s) though the"
|
|
|
|
" space size %lu. Page no %lu.\n",
|
|
|
|
(ulong) space, (ulong) space_size,
|
|
|
|
(ulong) page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
success = fsp_try_extend_data_file_with_pages(space, page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
header, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!success) {
|
|
|
|
/* No disk space left */
|
2006-02-23 19:25:29 +00:00
|
|
|
return(FIL_NULL);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, free, FALSE, mtr);
|
|
|
|
|
|
|
|
/* Update the FRAG_N_USED field */
|
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
frag_n_used++;
|
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (xdes_is_full(descr, mtr)) {
|
|
|
|
/* The fragment is full: move it to another list */
|
|
|
|
flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(descr, XDES_FULL_FRAG, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_add_last(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES,
|
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the allocated page to the buffer pool, so that it can
|
|
|
|
be obtained immediately with buf_page_get without need for a disk
|
|
|
|
read. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
buf_page_create(space, page_no, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Prior contents of the page should be ignored */
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page(block, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(page_no);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a single page of a space. The page is marked as free and clean. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_free_page(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint state;
|
|
|
|
ulint frag_n_used;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
/* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
|
|
|
|
|
|
|
|
state = xdes_get_state(descr, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (state != XDES_FREE_FRAG && state != XDES_FULL_FRAG) {
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error: File space extent descriptor"
|
|
|
|
" of page %lu has state %lu\n",
|
|
|
|
(ulong) page,
|
|
|
|
(ulong) state);
|
2005-10-27 07:29:40 +00:00
|
|
|
fputs("InnoDB: Dump of descriptor: ", stderr);
|
|
|
|
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
|
|
|
|
putc('\n', stderr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (state == XDES_FREE) {
|
|
|
|
/* We put here some fault tolerance: if the page
|
|
|
|
is already free, return without doing anything! */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error: File space extent descriptor"
|
|
|
|
" of page %lu says it is free\n"
|
|
|
|
"InnoDB: Dump of descriptor: ", (ulong) page);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
|
|
|
|
putc('\n', stderr);
|
|
|
|
|
|
|
|
/* We put here some fault tolerance: if the page
|
|
|
|
is already free, return without doing anything! */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
xdes_set_bit(descr, XDES_CLEAN_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
|
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (state == XDES_FULL_FRAG) {
|
|
|
|
/* The fragment was full: move it to another list */
|
|
|
|
flst_remove(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
|
|
flst_add_last(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
frag_n_used + FSP_EXTENT_SIZE - 1,
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
ut_a(frag_n_used > 0);
|
|
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used - 1,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
/* The extent has become free: move it to another list */
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns an extent to the free list of a space. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_free_extent(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset in the extent */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
xdes_t* descr;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
|
|
|
|
|
|
|
|
if (xdes_get_state(descr, mtr) == XDES_FREE) {
|
|
|
|
|
|
|
|
ut_print_buf(stderr, (byte*)descr - 500, 1000);
|
2008-08-06 08:10:21 +00:00
|
|
|
putc('\n', stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdes_init(descr, mtr);
|
|
|
|
|
|
|
|
flst_add_last(header + FSP_FREE, descr + XDES_FLST_NODE, mtr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the nth inode slot on an inode page.
|
|
|
|
@return segment inode */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
fseg_inode_t*
|
|
|
|
fsp_seg_inode_page_get_nth_inode(
|
|
|
|
/*=============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page, /*!< in: segment inode page */
|
|
|
|
ulint i, /*!< in: inode index on page */
|
2006-08-29 09:30:31 +00:00
|
|
|
ulint zip_size __attribute__((unused)),
|
2009-05-25 05:30:14 +00:00
|
|
|
/*!< in: compressed page size, or 0 */
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr_t* mtr __attribute__((unused)))
|
2009-05-25 05:30:14 +00:00
|
|
|
/*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-06-07 10:41:58 +00:00
|
|
|
ut_ad(i < FSP_SEG_INODES_PER_PAGE(zip_size));
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(page + FSEG_ARR_OFFSET + FSEG_INODE_SIZE * i);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Looks for a used segment inode on a segment inode page.
|
|
|
|
@return segment inode index, or ULINT_UNDEFINED if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fsp_seg_inode_page_find_used(
|
|
|
|
/*=========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page, /*!< in: segment inode page */
|
|
|
|
ulint zip_size,/*!< in: compressed page size, or 0 */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
for (i = 0; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
page, i, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-18 11:01:58 +00:00
|
|
|
if (!ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* This is used */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Looks for an unused segment inode on a segment inode page.
|
|
|
|
@return segment inode index, or ULINT_UNDEFINED if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fsp_seg_inode_page_find_free(
|
|
|
|
/*=========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page, /*!< in: segment inode page */
|
|
|
|
ulint i, /*!< in: search forward starting from this index */
|
|
|
|
ulint zip_size,/*!< in: compressed page size, or 0 */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
for (; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
page, i, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-18 11:01:58 +00:00
|
|
|
if (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* This is unused */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a new file segment inode page.
|
|
|
|
@return TRUE if could be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
fsp_alloc_seg_inode_page(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fsp_header_t* space_header, /*!< in: space header */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fseg_inode_t* inode;
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
page_t* page;
|
|
|
|
ulint page_no;
|
|
|
|
ulint space;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint i;
|
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET);
|
2008-09-24 18:29:19 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(space_header));
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
page_no = fsp_alloc_free_page(space, zip_size, 0, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
|
|
|
|
block->check_index_page_at_flush = FALSE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
page = buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_2BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
for (i = 0; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(page, i,
|
|
|
|
zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a new file segment inode.
|
|
|
|
@return segment inode, or NULL if not enough space */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
fseg_inode_t*
|
|
|
|
fsp_alloc_seg_inode(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fsp_header_t* space_header, /*!< in: space header */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint page_no;
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
page_t* page;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ibool success;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET);
|
2008-09-24 18:29:19 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (flst_get_len(space_header + FSP_SEG_INODES_FREE, mtr) == 0) {
|
|
|
|
/* Allocate a new segment inode page */
|
|
|
|
|
|
|
|
success = fsp_alloc_seg_inode_page(space_header, mtr);
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
page_no = flst_get_first(space_header + FSP_SEG_INODES_FREE, mtr).page;
|
|
|
|
|
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
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
2006-10-12 11:05:22 +00:00
|
|
|
block = buf_page_get(page_get_space_id(page_align(space_header)),
|
2007-01-18 09:59:00 +00:00
|
|
|
zip_size, page_no, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
page = buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
n = fsp_seg_inode_page_find_free(page, 0, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(n != ULINT_UNDEFINED);
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(page, n, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (ULINT_UNDEFINED == fsp_seg_inode_page_find_free(page, n + 1,
|
2006-08-29 09:30:31 +00:00
|
|
|
zip_size, mtr)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* There are no other unused headers left on the page: move it
|
|
|
|
to another list */
|
|
|
|
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return(inode);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a file segment inode. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fsp_free_seg_inode(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr) /*!< in: mini-transaction handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
page_t* page;
|
|
|
|
fsp_header_t* space_header;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-09 16:22:47 +00:00
|
|
|
page = page_align(inode);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
if (ULINT_UNDEFINED
|
|
|
|
== fsp_seg_inode_page_find_free(page, 0, zip_size, mtr)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Move the page to another list */
|
|
|
|
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
|
|
|
|
mlog_write_ulint(inode + FSEG_MAGIC_N, 0, MLOG_4BYTES, mtr);
|
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
if (ULINT_UNDEFINED
|
|
|
|
== fsp_seg_inode_page_find_used(page, zip_size, mtr)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* There are no other used headers left on the page: free it */
|
|
|
|
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_page(space, zip_size, page_get_page_no(page), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the file segment inode, page x-latched.
|
|
|
|
@return segment inode, page x-latched */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
fseg_inode_t*
|
|
|
|
fseg_inode_get(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fil_addr_t inode_addr;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
|
|
|
|
inode_addr.page = mach_read_from_4(header + FSEG_HDR_PAGE_NO);
|
|
|
|
inode_addr.boffset = mach_read_from_2(header + FSEG_HDR_OFFSET);
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(space == mach_read_from_4(header + FSEG_HDR_SPACE));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(inode);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the page number from the nth fragment page slot.
|
|
|
|
@return page number, FIL_NULL if not in use */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
fseg_get_nth_frag_page_no(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint n, /*!< in: slot index */
|
|
|
|
mtr_t* mtr __attribute__((unused))) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
return(mach_read_from_4(inode + FSEG_FRAG_ARR
|
2006-08-29 09:30:31 +00:00
|
|
|
+ n * FSEG_FRAG_SLOT_SIZE));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Sets the page number in the nth fragment page slot. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
fseg_set_nth_frag_page_no(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint n, /*!< in: slot index */
|
|
|
|
ulint page_no,/*!< in: page number to set */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_ulint(inode + FSEG_FRAG_ARR + n * FSEG_FRAG_SLOT_SIZE,
|
2006-08-29 09:30:31 +00:00
|
|
|
page_no, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Finds a fragment page slot which is free.
|
|
|
|
@return slot index; ULINT_UNDEFINED if none found */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_find_free_frag_page_slot(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
ulint page_no;
|
|
|
|
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
|
|
page_no = fseg_get_nth_frag_page_no(inode, i, mtr);
|
|
|
|
|
|
|
|
if (page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Finds a fragment page slot which is used and last in the array.
|
|
|
|
@return slot index; ULINT_UNDEFINED if none found */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_find_last_used_frag_page_slot(
|
|
|
|
/*===============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
ulint page_no;
|
|
|
|
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
2006-09-19 10:14:07 +00:00
|
|
|
page_no = fseg_get_nth_frag_page_no(
|
|
|
|
inode, FSEG_FRAG_ARR_N_SLOTS - i - 1, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (page_no != FIL_NULL) {
|
|
|
|
|
|
|
|
return(FSEG_FRAG_ARR_N_SLOTS - i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ULINT_UNDEFINED);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Calculates reserved fragment page slots.
|
|
|
|
@return number of fragment pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_get_n_frag_pages(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
ulint count = 0;
|
|
|
|
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
|
|
if (FIL_NULL != fseg_get_nth_frag_page_no(inode, i, mtr)) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Creates a new segment.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return the block where the segment header is placed, x-latched, NULL
|
|
|
|
if could not create segment because of lack of space */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_create_general(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page where the segment header is placed: if
|
2005-10-27 07:29:40 +00:00
|
|
|
this is != 0, the page must belong to another segment,
|
|
|
|
if this is 0, a new page will be allocated and it
|
|
|
|
will belong to the created segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint byte_offset, /*!< in: byte offset of the created segment header
|
2005-10-27 07:29:40 +00:00
|
|
|
on the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool has_done_reservation, /*!< in: TRUE if the caller has already
|
2005-10-27 07:29:40 +00:00
|
|
|
done the reservation for the pages with
|
|
|
|
fsp_reserve_free_extents (at least 2 extents: one for
|
|
|
|
the inode and the other for the segment) then there is
|
|
|
|
no need to do the check for this individual
|
|
|
|
operation */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
fsp_header_t* space_header;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
dulint seg_id;
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block = 0; /* remove warning */
|
|
|
|
fseg_header_t* header = 0; /* remove warning */
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_t* latch;
|
|
|
|
ibool success;
|
|
|
|
ulint n_reserved;
|
|
|
|
ulint i;
|
|
|
|
|
|
|
|
ut_ad(mtr);
|
2007-12-20 22:09:22 +00:00
|
|
|
ut_ad(byte_offset + FSEG_HEADER_SIZE
|
|
|
|
<= UNIV_PAGE_SIZE - FIL_PAGE_DATA_END);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2007-01-18 09:59:00 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page != 0) {
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
header = byte_offset + buf_block_get_frame(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
2007-01-18 09:59:00 +00:00
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_x_lock(latch, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (rw_lock_get_x_lock_count(latch) == 1) {
|
|
|
|
/* This thread did not own the latch before this call: free
|
|
|
|
excess pages from the insert buffer free list */
|
|
|
|
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
if (space == IBUF_SPACE_ID) {
|
|
|
|
ibuf_free_excess_pages();
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if (!has_done_reservation) {
|
2005-10-27 07:29:40 +00:00
|
|
|
success = fsp_reserve_free_extents(&n_reserved, space, 2,
|
2006-08-29 09:30:31 +00:00
|
|
|
FSP_NORMAL, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!success) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
inode = fsp_alloc_seg_inode(space_header, mtr);
|
|
|
|
|
|
|
|
if (inode == NULL) {
|
|
|
|
|
|
|
|
goto funct_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the next segment id from space header and increment the
|
|
|
|
value in space header */
|
|
|
|
|
|
|
|
seg_id = mtr_read_dulint(space_header + FSP_SEG_ID, mtr);
|
|
|
|
|
|
|
|
mlog_write_dulint(space_header + FSP_SEG_ID, ut_dulint_add(seg_id, 1),
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_dulint(inode + FSEG_ID, seg_id, mtr);
|
|
|
|
mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
flst_init(inode + FSEG_FREE, mtr);
|
|
|
|
flst_init(inode + FSEG_NOT_FULL, mtr);
|
|
|
|
flst_init(inode + FSEG_FULL, mtr);
|
|
|
|
|
|
|
|
mlog_write_ulint(inode + FSEG_MAGIC_N, FSEG_MAGIC_N_VALUE,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
|
|
fseg_set_nth_frag_page_no(inode, i, FIL_NULL, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page == 0) {
|
2007-01-18 09:59:00 +00:00
|
|
|
page = fseg_alloc_free_page_low(space, zip_size,
|
|
|
|
inode, 0, FSP_UP, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page == FIL_NULL) {
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto funct_exit;
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
header = byte_offset + buf_block_get_frame(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE,
|
2006-08-29 09:30:31 +00:00
|
|
|
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_OFFSET,
|
2006-10-09 16:22:47 +00:00
|
|
|
page_offset(inode), MLOG_2BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_PAGE_NO,
|
2006-10-12 07:02:36 +00:00
|
|
|
page_get_page_no(page_align(inode)),
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_SPACE, space, MLOG_4BYTES, mtr);
|
|
|
|
|
|
|
|
funct_exit:
|
2006-02-23 19:25:29 +00:00
|
|
|
if (!has_done_reservation) {
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
fil_space_release_free_extents(space, n_reserved);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
return(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Creates a new segment.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return the block where the segment header is placed, x-latched, NULL
|
|
|
|
if could not create segment because of lack of space */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_create(
|
|
|
|
/*========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page where the segment header is placed: if
|
2005-10-27 07:29:40 +00:00
|
|
|
this is != 0, the page must belong to another segment,
|
|
|
|
if this is 0, a new page will be allocated and it
|
|
|
|
will belong to the created segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint byte_offset, /*!< in: byte offset of the created segment header
|
2005-10-27 07:29:40 +00:00
|
|
|
on the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return(fseg_create_general(space, page, byte_offset, FALSE, mtr));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates the number of pages reserved by a segment, and how many pages are
|
2009-05-25 05:30:14 +00:00
|
|
|
currently used.
|
|
|
|
@return number of reserved pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_n_reserved_pages_low(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint* used, /*!< out: number of pages used (<= reserved) */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint ret;
|
|
|
|
|
|
|
|
ut_ad(inode && used && mtr);
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
*used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr)
|
|
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FULL, mtr)
|
|
|
|
+ fseg_get_n_frag_pages(inode, mtr);
|
|
|
|
|
|
|
|
ret = fseg_get_n_frag_pages(inode, mtr)
|
|
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FREE, mtr)
|
|
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_NOT_FULL, mtr)
|
|
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FULL, mtr);
|
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates the number of pages reserved by a segment, and how many pages are
|
2009-05-25 05:30:14 +00:00
|
|
|
currently used.
|
|
|
|
@return number of reserved pages */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_n_reserved_pages(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
ulint* used, /*!< out: number of pages used (<= reserved) */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint ret;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
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
|
|
|
rw_lock_t* latch;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(header));
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
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
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2007-01-18 18:29:12 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(latch, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ret = fseg_n_reserved_pages_low(inode, used, mtr);
|
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Tries to fill the free list of a segment with consecutive free extents.
|
|
|
|
This happens if the segment is big enough to allow extents in the free list,
|
|
|
|
the free list is empty, and the extents can be allocated consecutively from
|
|
|
|
the hint onward. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_fill_free_list(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint hint, /*!< in: hint which extent would be good as
|
2005-10-27 07:29:40 +00:00
|
|
|
the first extent */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint i;
|
|
|
|
dulint seg_id;
|
|
|
|
ulint reserved;
|
|
|
|
ulint used;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(inode && mtr);
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
|
|
|
|
|
|
|
|
if (reserved < FSEG_FREE_LIST_LIMIT * FSP_EXTENT_SIZE) {
|
|
|
|
|
|
|
|
/* The segment is too small to allow extents in free list */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
|
|
/* Free list is not empty */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < FSEG_FREE_LIST_MAX_LEN; i++) {
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
if ((descr == NULL)
|
|
|
|
|| (XDES_FREE != xdes_get_state(descr, mtr))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* We cannot allocate the desired extent: stop */
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(descr, XDES_FSEG, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
|
|
|
|
mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
|
|
|
|
|
|
|
|
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
|
|
|
|
hint += FSP_EXTENT_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a free extent for the segment: looks first in the free list of the
|
|
|
|
segment, then tries to allocate from the space free list. NOTE that the extent
|
2009-05-25 05:30:14 +00:00
|
|
|
returned still resides in the segment free list, it is not yet taken off it!
|
2009-05-25 08:09:45 +00:00
|
|
|
@return allocated extent, still placed in the segment free list, NULL
|
|
|
|
if could not be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
xdes_t*
|
|
|
|
fseg_alloc_free_extent(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
dulint seg_id;
|
2006-02-23 19:25:29 +00:00
|
|
|
fil_addr_t first;
|
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
2008-09-24 18:29:19 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
|
|
/* Segment free list is not empty, allocate from it */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
first = flst_get_first(inode + FSEG_FREE, mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
/* Segment free list was empty, allocate from space */
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fsp_alloc_free_extent(space, zip_size, 0, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (descr == NULL) {
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(descr, XDES_FSEG, mtr);
|
|
|
|
mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
|
|
|
|
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Try to fill the segment free list */
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_fill_free_list(inode, space, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
xdes_get_offset(descr) + FSP_EXTENT_SIZE,
|
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(descr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize file space
|
2009-05-25 05:30:14 +00:00
|
|
|
fragmentation.
|
|
|
|
@return the allocated page number, FIL_NULL if no page could be allocated */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page_low(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode, /*!< in: segment inode */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction, /*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* space_header;
|
|
|
|
ulint space_size;
|
|
|
|
dulint seg_id;
|
|
|
|
ulint used;
|
|
|
|
ulint reserved;
|
|
|
|
xdes_t* descr; /* extent of the hinted page */
|
|
|
|
ulint ret_page; /* the allocated page offset, FIL_NULL
|
|
|
|
if could not be allocated */
|
|
|
|
xdes_t* ret_descr; /* the extent of the allocated page */
|
|
|
|
ibool frag_page_allocated = FALSE;
|
|
|
|
ibool success;
|
|
|
|
ulint n;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR));
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
|
|
|
|
== FSEG_MAGIC_N_VALUE);
|
|
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
2005-10-27 07:29:40 +00:00
|
|
|
seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
|
|
|
|
|
2007-05-18 11:01:58 +00:00
|
|
|
ut_ad(!ut_dulint_is_zero(seg_id));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(space_header, space,
|
2006-08-29 09:30:31 +00:00
|
|
|
hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (descr == NULL) {
|
|
|
|
/* Hint outside space or too high above free limit: reset
|
|
|
|
hint */
|
|
|
|
hint = 0;
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* In the big if-else below we look for ret_page and ret_descr */
|
2006-02-23 19:25:29 +00:00
|
|
|
/*-------------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
if ((xdes_get_state(descr, mtr) == XDES_FSEG)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
|
|
|
|
mtr), seg_id))
|
|
|
|
&& (xdes_get_bit(descr, XDES_FREE_BIT,
|
|
|
|
hint % FSP_EXTENT_SIZE, mtr) == TRUE)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* 1. We can take the hinted page
|
|
|
|
=================================*/
|
|
|
|
ret_descr = descr;
|
|
|
|
ret_page = hint;
|
2006-08-29 09:30:31 +00:00
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if ((xdes_get_state(descr, mtr) == XDES_FREE)
|
|
|
|
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
|
|
|
|
&& (used >= FSEG_FRAG_LIMIT)) {
|
|
|
|
|
|
|
|
/* 2. We allocate the free extent from space and can take
|
|
|
|
=========================================================
|
|
|
|
the hinted page
|
|
|
|
===============*/
|
2007-01-18 09:59:00 +00:00
|
|
|
ret_descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(ret_descr == descr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
xdes_set_state(ret_descr, XDES_FSEG, mtr);
|
|
|
|
mlog_write_dulint(ret_descr + XDES_ID, seg_id, mtr);
|
|
|
|
flst_add_last(seg_inode + FSEG_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
ret_descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Try to fill the segment free list */
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_fill_free_list(seg_inode, space, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
hint + FSP_EXTENT_SIZE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ret_page = hint;
|
2006-08-29 09:30:31 +00:00
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if ((direction != FSP_NO_DIR)
|
|
|
|
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
|
|
|
|
&& (used >= FSEG_FRAG_LIMIT)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (!!(ret_descr
|
2007-01-18 09:59:00 +00:00
|
|
|
= fseg_alloc_free_extent(seg_inode,
|
|
|
|
space, zip_size, mtr)))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* 3. We take any free extent (which was already assigned above
|
|
|
|
===============================================================
|
|
|
|
in the if-condition to ret_descr) and take the lowest or
|
|
|
|
========================================================
|
|
|
|
highest page in it, depending on the direction
|
|
|
|
==============================================*/
|
2006-02-23 19:25:29 +00:00
|
|
|
ret_page = xdes_get_offset(ret_descr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (direction == FSP_DOWN) {
|
|
|
|
ret_page += FSP_EXTENT_SIZE - 1;
|
|
|
|
}
|
2006-08-29 09:30:31 +00:00
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if ((xdes_get_state(descr, mtr) == XDES_FSEG)
|
2006-02-23 19:25:29 +00:00
|
|
|
&& (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr), seg_id))
|
2006-02-23 19:25:29 +00:00
|
|
|
&& (!xdes_is_full(descr, mtr))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* 4. We can take the page from the same extent as the
|
|
|
|
======================================================
|
|
|
|
hinted page (and the extent already belongs to the
|
|
|
|
==================================================
|
|
|
|
segment)
|
|
|
|
========*/
|
|
|
|
ret_descr = descr;
|
2006-08-29 09:30:31 +00:00
|
|
|
ret_page = xdes_get_offset(ret_descr)
|
|
|
|
+ xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE,
|
2005-10-27 07:29:40 +00:00
|
|
|
hint % FSP_EXTENT_SIZE, mtr);
|
2006-08-29 09:30:31 +00:00
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if (reserved - used > 0) {
|
|
|
|
/* 5. We take any unused page from the segment
|
|
|
|
==============================================*/
|
|
|
|
fil_addr_t first;
|
|
|
|
|
|
|
|
if (flst_get_len(seg_inode + FSEG_NOT_FULL, mtr) > 0) {
|
|
|
|
first = flst_get_first(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if (flst_get_len(seg_inode + FSEG_FREE, mtr) > 0) {
|
|
|
|
first = flst_get_first(seg_inode + FSEG_FREE, mtr);
|
|
|
|
} else {
|
|
|
|
ut_error;
|
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
ret_descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
first, mtr);
|
2006-08-29 09:30:31 +00:00
|
|
|
ret_page = xdes_get_offset(ret_descr)
|
|
|
|
+ xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE,
|
|
|
|
0, mtr);
|
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if (used < FSEG_FRAG_LIMIT) {
|
|
|
|
/* 6. We allocate an individual page from the space
|
|
|
|
===================================================*/
|
2007-01-18 09:59:00 +00:00
|
|
|
ret_page = fsp_alloc_free_page(space, zip_size, hint, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ret_descr = NULL;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
frag_page_allocated = TRUE;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (ret_page != FIL_NULL) {
|
|
|
|
/* Put the page in the fragment page array of the
|
|
|
|
segment */
|
|
|
|
n = fseg_find_free_frag_page_slot(seg_inode, mtr);
|
|
|
|
ut_a(n != FIL_NULL);
|
|
|
|
|
|
|
|
fseg_set_nth_frag_page_no(seg_inode, n, ret_page,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-08-29 09:30:31 +00:00
|
|
|
/*-----------------------------------------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
/* 7. We allocate a new extent and take its first page
|
|
|
|
======================================================*/
|
2007-01-18 09:59:00 +00:00
|
|
|
ret_descr = fseg_alloc_free_extent(seg_inode,
|
|
|
|
space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (ret_descr == NULL) {
|
|
|
|
ret_page = FIL_NULL;
|
|
|
|
} else {
|
|
|
|
ret_page = xdes_get_offset(ret_descr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (ret_page == FIL_NULL) {
|
|
|
|
/* Page could not be allocated */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (space != 0) {
|
|
|
|
space_size = fil_space_get_size(space);
|
|
|
|
|
|
|
|
if (space_size <= ret_page) {
|
2006-02-23 19:25:29 +00:00
|
|
|
/* It must be that we are extending a single-table
|
2005-10-27 07:29:40 +00:00
|
|
|
tablespace whose size is still < 64 pages */
|
|
|
|
|
|
|
|
if (ret_page >= FSP_EXTENT_SIZE) {
|
2006-02-23 19:25:29 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error (2): trying to extend"
|
|
|
|
" a single-table tablespace %lu\n"
|
|
|
|
"InnoDB: by single page(s) though"
|
|
|
|
" the space size %lu. Page no %lu.\n",
|
2005-10-27 07:29:40 +00:00
|
|
|
(ulong) space, (ulong) space_size,
|
|
|
|
(ulong) ret_page);
|
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
success = fsp_try_extend_data_file_with_pages(
|
|
|
|
space, ret_page, space_header, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!success) {
|
|
|
|
/* No disk space left */
|
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!frag_page_allocated) {
|
|
|
|
/* Initialize the allocated page to buffer pool, so that it
|
|
|
|
can be obtained immediately with buf_page_get without need
|
|
|
|
for a disk read */
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
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
|
|
|
ulint zip_size = dict_table_flags_to_zip_size(
|
|
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_create(space, ret_page, zip_size, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
if (UNIV_UNLIKELY(block != buf_page_get(space, zip_size,
|
|
|
|
ret_page, RW_X_LATCH,
|
|
|
|
mtr))) {
|
|
|
|
ut_error;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The prior contents of the page should be ignored */
|
2006-10-12 11:05:22 +00:00
|
|
|
fsp_init_file_page(block, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* At this point we know the extent and the page offset.
|
|
|
|
The extent is still in the appropriate list (FSEG_NOT_FULL
|
|
|
|
or FSEG_FREE), and the page is not yet marked as used. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_ad(xdes_get_descriptor(space, zip_size, ret_page, mtr)
|
|
|
|
== ret_descr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(xdes_get_bit(ret_descr, XDES_FREE_BIT,
|
2006-08-29 09:30:31 +00:00
|
|
|
ret_page % FSP_EXTENT_SIZE, mtr) == TRUE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_mark_page_used(seg_inode, space, zip_size, ret_page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buf_reset_check_index_page_at_flush(space, ret_page);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
return(ret_page);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize file space
|
2009-05-25 05:30:14 +00:00
|
|
|
fragmentation.
|
|
|
|
@return allocated page offset, FIL_NULL if no page could be allocated */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page_general(
|
|
|
|
/*=========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header,/*!< in: segment header */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction,/*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool has_done_reservation, /*!< in: TRUE if the caller has
|
2005-10-27 07:29:40 +00:00
|
|
|
already done the reservation for the page
|
|
|
|
with fsp_reserve_free_extents, then there
|
|
|
|
is no need to do the check for this individual
|
|
|
|
page */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_t* latch;
|
|
|
|
ibool success;
|
|
|
|
ulint page_no;
|
|
|
|
ulint n_reserved;
|
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(seg_header));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2007-01-18 09:59:00 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
2007-01-18 09:59:00 +00:00
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (rw_lock_get_x_lock_count(latch) == 1) {
|
|
|
|
/* This thread did not own the latch before this call: free
|
|
|
|
excess pages from the insert buffer free list */
|
|
|
|
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
if (space == IBUF_SPACE_ID) {
|
|
|
|
ibuf_free_excess_pages();
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fseg_inode_get(seg_header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (!has_done_reservation) {
|
|
|
|
success = fsp_reserve_free_extents(&n_reserved, space, 2,
|
2006-08-29 09:30:31 +00:00
|
|
|
FSP_NORMAL, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!success) {
|
|
|
|
return(FIL_NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
page_no = fseg_alloc_free_page_low(space, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
inode, hint, direction, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!has_done_reservation) {
|
|
|
|
fil_space_release_free_extents(space, n_reserved);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(page_no);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize file space
|
2009-05-25 05:30:14 +00:00
|
|
|
fragmentation.
|
|
|
|
@return allocated page offset, FIL_NULL if no page could be allocated */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header,/*!< in: segment header */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction,/*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
return(fseg_alloc_free_page_general(seg_header, hint, direction,
|
2006-08-29 09:30:31 +00:00
|
|
|
FALSE, mtr));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Checks that we have at least 2 frag pages free in the first extent of a
|
|
|
|
single-table tablespace, and they are also physically initialized to the data
|
|
|
|
file. That is we have already extended the data file so that those pages are
|
|
|
|
inside the data file. If not, this function extends the tablespace with
|
2009-05-25 05:30:14 +00:00
|
|
|
pages.
|
|
|
|
@return TRUE if there were >= 3 free pages, or we were able to extend */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
fsp_reserve_free_pages(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id, must be != 0 */
|
|
|
|
fsp_header_t* space_header, /*!< in: header of that space,
|
2005-10-27 07:29:40 +00:00
|
|
|
x-latched */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint size, /*!< in: size of the tablespace in pages,
|
2005-10-27 07:29:40 +00:00
|
|
|
must be < FSP_EXTENT_SIZE / 2 */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint n_used;
|
|
|
|
|
|
|
|
ut_a(space != 0);
|
|
|
|
ut_a(size < FSP_EXTENT_SIZE / 2);
|
|
|
|
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(space_header, space, 0,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
n_used = xdes_get_n_used(descr, mtr);
|
|
|
|
|
|
|
|
ut_a(n_used <= size);
|
|
|
|
|
|
|
|
if (size >= n_used + 2) {
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(fsp_try_extend_data_file_with_pages(space, n_used + 1,
|
2006-08-29 09:30:31 +00:00
|
|
|
space_header, mtr));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Reserves free pages from a tablespace. All mini-transactions which may
|
|
|
|
use several pages from the tablespace should call this function beforehand
|
|
|
|
and reserve enough free extents so that they certainly will be able
|
|
|
|
to do their operation, like a B-tree page split, fully. Reservations
|
|
|
|
must be released with function fil_space_release_free_extents!
|
|
|
|
|
|
|
|
The alloc_type below has the following meaning: FSP_NORMAL means an
|
|
|
|
operation which will probably result in more space usage, like an
|
|
|
|
insert in a B-tree; FSP_UNDO means allocation to undo logs: if we are
|
|
|
|
deleting rows, then this allocation will in the long run result in
|
|
|
|
less space usage (after a purge); FSP_CLEANING means allocation done
|
|
|
|
in a physical record delete (like in a purge) or other cleaning operation
|
|
|
|
which will result in less space usage in the long run. We prefer the latter
|
|
|
|
two types of allocation: when space is scarce, FSP_NORMAL allocations
|
|
|
|
will not succeed, but the latter two allocations will succeed, if possible.
|
|
|
|
The purpose is to avoid dead end where the database is full but the
|
|
|
|
user cannot free any space because these freeing operations temporarily
|
|
|
|
reserve some space.
|
|
|
|
|
|
|
|
Single-table tablespaces whose size is < 32 pages are a special case. In this
|
|
|
|
function we would liberally reserve several 64 page extents for every page
|
|
|
|
split or merge in a B-tree. But we do not want to waste disk space if the table
|
|
|
|
only occupies < 32 pages. That is why we apply different rules in that special
|
2009-05-25 05:30:14 +00:00
|
|
|
case, just ensuring that there are 3 free pages available.
|
|
|
|
@return TRUE if we were able to make the reservation */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fsp_reserve_free_extents(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint* n_reserved,/*!< out: number of extents actually reserved; if we
|
2005-10-27 07:29:40 +00:00
|
|
|
return TRUE and the tablespace size is < 64 pages,
|
|
|
|
then this can be 0, otherwise it is n_ext */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint n_ext, /*!< in: number of extents to reserve */
|
|
|
|
ulint alloc_type,/*!< in: FSP_NORMAL, FSP_UNDO, or FSP_CLEANING */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* space_header;
|
|
|
|
rw_lock_t* latch;
|
|
|
|
ulint n_free_list_ext;
|
|
|
|
ulint free_limit;
|
|
|
|
ulint size;
|
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
|
|
|
ulint flags;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_free;
|
|
|
|
ulint n_free_up;
|
|
|
|
ulint reserve;
|
|
|
|
ibool success;
|
|
|
|
ulint n_pages_added;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
ut_ad(mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
*n_reserved = n_ext;
|
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
2007-01-18 09:59:00 +00:00
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
try_again:
|
|
|
|
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (size < FSP_EXTENT_SIZE / 2) {
|
|
|
|
/* Use different rules for small single-table tablespaces */
|
|
|
|
*n_reserved = 0;
|
|
|
|
return(fsp_reserve_free_pages(space, space_header, size, mtr));
|
|
|
|
}
|
|
|
|
|
|
|
|
n_free_list_ext = flst_get_len(space_header + FSP_FREE, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Below we play safe when counting free extents above the free limit:
|
|
|
|
some of them will contain extent descriptor pages, and therefore
|
|
|
|
will not be free extents */
|
|
|
|
|
|
|
|
n_free_up = (size - free_limit) / FSP_EXTENT_SIZE;
|
|
|
|
|
|
|
|
if (n_free_up > 0) {
|
|
|
|
n_free_up--;
|
2006-06-07 10:41:58 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
n_free_up -= n_free_up
|
2006-08-29 09:30:31 +00:00
|
|
|
/ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE);
|
2006-06-07 10:41:58 +00:00
|
|
|
} else {
|
|
|
|
n_free_up -= n_free_up
|
2006-08-29 09:30:31 +00:00
|
|
|
/ (zip_size / FSP_EXTENT_SIZE);
|
2006-06-07 10:41:58 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_free = n_free_list_ext + n_free_up;
|
|
|
|
|
|
|
|
if (alloc_type == FSP_NORMAL) {
|
|
|
|
/* We reserve 1 extent + 0.5 % of the space size to undo logs
|
|
|
|
and 1 extent + 0.5 % to cleaning operations; NOTE: this source
|
|
|
|
code is duplicated in the function below! */
|
|
|
|
|
|
|
|
reserve = 2 + ((size / FSP_EXTENT_SIZE) * 2) / 200;
|
|
|
|
|
|
|
|
if (n_free <= reserve + n_ext) {
|
|
|
|
|
|
|
|
goto try_to_extend;
|
|
|
|
}
|
|
|
|
} else if (alloc_type == FSP_UNDO) {
|
|
|
|
/* We reserve 0.5 % of the space size to cleaning operations */
|
|
|
|
|
|
|
|
reserve = 1 + ((size / FSP_EXTENT_SIZE) * 1) / 200;
|
|
|
|
|
|
|
|
if (n_free <= reserve + n_ext) {
|
|
|
|
|
|
|
|
goto try_to_extend;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ut_a(alloc_type == FSP_CLEANING);
|
|
|
|
}
|
|
|
|
|
|
|
|
success = fil_space_reserve_free_extents(space, n_free, n_ext);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
try_to_extend:
|
|
|
|
success = fsp_try_extend_data_file(&n_pages_added, space,
|
2006-08-29 09:30:31 +00:00
|
|
|
space_header, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (success && n_pages_added > 0) {
|
|
|
|
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
This function should be used to get information on how much we still
|
|
|
|
will be able to insert new data to the database without running out the
|
|
|
|
tablespace. Only free extents are taken into account and we also subtract
|
2009-05-25 05:30:14 +00:00
|
|
|
the safety margin required by the above function fsp_reserve_free_extents.
|
|
|
|
@return available space in kB */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2007-08-01 11:18:43 +00:00
|
|
|
ullint
|
2005-10-27 07:29:40 +00:00
|
|
|
fsp_get_available_space_in_free_extents(
|
|
|
|
/*====================================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space) /*!< in: space id */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* space_header;
|
|
|
|
ulint n_free_list_ext;
|
|
|
|
ulint free_limit;
|
|
|
|
ulint size;
|
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
|
|
|
ulint flags;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_free;
|
|
|
|
ulint n_free_up;
|
|
|
|
ulint reserve;
|
|
|
|
rw_lock_t* latch;
|
|
|
|
mtr_t mtr;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex));
|
2007-01-18 18:29:12 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
space_header = fsp_get_space_header(space, zip_size, &mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_free_list_ext = flst_get_len(space_header + FSP_FREE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
if (size < FSP_EXTENT_SIZE) {
|
2006-02-23 19:25:29 +00:00
|
|
|
ut_a(space != 0); /* This must be a single-table
|
|
|
|
tablespace */
|
|
|
|
|
|
|
|
return(0); /* TODO: count free frag pages and
|
|
|
|
return a value based on that */
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Below we play safe when counting free extents above the free limit:
|
|
|
|
some of them will contain extent descriptor pages, and therefore
|
|
|
|
will not be free extents */
|
|
|
|
|
|
|
|
n_free_up = (size - free_limit) / FSP_EXTENT_SIZE;
|
|
|
|
|
|
|
|
if (n_free_up > 0) {
|
|
|
|
n_free_up--;
|
2006-06-07 10:41:58 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
n_free_up -= n_free_up
|
2006-08-29 09:30:31 +00:00
|
|
|
/ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE);
|
2006-06-07 10:41:58 +00:00
|
|
|
} else {
|
|
|
|
n_free_up -= n_free_up
|
2006-08-29 09:30:31 +00:00
|
|
|
/ (zip_size / FSP_EXTENT_SIZE);
|
2006-06-07 10:41:58 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_free = n_free_list_ext + n_free_up;
|
|
|
|
|
|
|
|
/* We reserve 1 extent + 0.5 % of the space size to undo logs
|
|
|
|
and 1 extent + 0.5 % to cleaning operations; NOTE: this source
|
|
|
|
code is duplicated in the function above! */
|
|
|
|
|
|
|
|
reserve = 2 + ((size / FSP_EXTENT_SIZE) * 2) / 200;
|
|
|
|
|
|
|
|
if (reserve > n_free) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
if (!zip_size) {
|
2007-08-01 11:18:43 +00:00
|
|
|
return((ullint) (n_free - reserve)
|
|
|
|
* FSP_EXTENT_SIZE
|
2006-08-29 09:30:31 +00:00
|
|
|
* (UNIV_PAGE_SIZE / 1024));
|
2006-06-07 10:41:58 +00:00
|
|
|
} else {
|
2007-08-01 11:18:43 +00:00
|
|
|
return((ullint) (n_free - reserve)
|
|
|
|
* FSP_EXTENT_SIZE
|
2006-08-29 09:30:31 +00:00
|
|
|
* (zip_size / 1024));
|
2006-06-07 10:41:58 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Marks a page used. The page must reside within the extents of the given
|
|
|
|
segment. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_mark_page_used(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode,/*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint not_full_n_used;
|
|
|
|
|
|
|
|
ut_ad(seg_inode && mtr);
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr)
|
|
|
|
== mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
|
|
|
/* We move the extent from the free list to the
|
|
|
|
NOT_FULL list */
|
|
|
|
flst_remove(seg_inode + FSEG_FREE, descr + XDES_FLST_NODE,
|
2006-08-29 09:30:31 +00:00
|
|
|
mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_add_last(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ut_ad(xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
== TRUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
/* We mark the page as used */
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, FALSE, mtr);
|
|
|
|
|
|
|
|
not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
not_full_n_used++;
|
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (xdes_is_full(descr, mtr)) {
|
|
|
|
/* We move the extent from the NOT_FULL list to the
|
|
|
|
FULL list */
|
|
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_add_last(seg_inode + FSEG_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
not_full_n_used - FSP_EXTENT_SIZE,
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a single page of a segment. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_free_page_low(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint not_full_n_used;
|
|
|
|
ulint state;
|
|
|
|
dulint descr_id;
|
|
|
|
dulint seg_id;
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(seg_inode && mtr);
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
|
|
|
|
== FSEG_MAGIC_N_VALUE);
|
|
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Drop search system page hash index if the page is found in
|
|
|
|
the pool and is hashed */
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
btr_search_drop_page_hash_when_freed(space, zip_size, page);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(descr);
|
|
|
|
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
|
|
|
|
fputs("InnoDB: Dump of the tablespace extent descriptor: ",
|
2006-08-29 09:30:31 +00:00
|
|
|
stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_print_buf(stderr, descr, 40);
|
|
|
|
|
|
|
|
fprintf(stderr, "\n"
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Serious error! InnoDB is trying to"
|
|
|
|
" free page %lu\n"
|
|
|
|
"InnoDB: though it is already marked as free"
|
|
|
|
" in the tablespace!\n"
|
|
|
|
"InnoDB: The tablespace free space info is corrupt.\n"
|
|
|
|
"InnoDB: You may need to dump your"
|
|
|
|
" InnoDB tables and recreate the whole\n"
|
|
|
|
"InnoDB: database!\n", (ulong) page);
|
|
|
|
crash:
|
|
|
|
fputs("InnoDB: Please refer to\n"
|
2009-04-16 12:02:27 +00:00
|
|
|
"InnoDB: " REFMAN "forcing-recovery.html\n"
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: about forcing recovery.\n", stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_error;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
state = xdes_get_state(descr, mtr);
|
|
|
|
|
|
|
|
if (state != XDES_FSEG) {
|
|
|
|
/* The page is in the fragment pages of the segment */
|
|
|
|
|
|
|
|
for (i = 0;; i++) {
|
|
|
|
if (fseg_get_nth_frag_page_no(seg_inode, i, mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
== page) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
fseg_set_nth_frag_page_no(seg_inode, i,
|
2006-08-29 09:30:31 +00:00
|
|
|
FIL_NULL, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_page(space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* If we get here, the page is in some extent of the segment */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr_id = mtr_read_dulint(descr + XDES_ID, mtr);
|
|
|
|
seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
|
2006-08-29 09:30:31 +00:00
|
|
|
#if 0
|
2005-10-27 07:29:40 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: InnoDB is freeing space %lu page %lu,\n"
|
|
|
|
"InnoDB: which belongs to descr seg %lu %lu\n"
|
|
|
|
"InnoDB: segment %lu %lu.\n",
|
|
|
|
(ulong) space, (ulong) page,
|
|
|
|
(ulong) ut_dulint_get_high(descr_id),
|
|
|
|
(ulong) ut_dulint_get_low(descr_id),
|
|
|
|
(ulong) ut_dulint_get_high(seg_id),
|
|
|
|
(ulong) ut_dulint_get_low(seg_id));
|
|
|
|
#endif /* 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
if (0 != ut_dulint_cmp(descr_id, seg_id)) {
|
|
|
|
fputs("InnoDB: Dump of the tablespace extent descriptor: ",
|
2006-08-29 09:30:31 +00:00
|
|
|
stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_print_buf(stderr, descr, 40);
|
|
|
|
fputs("\nInnoDB: Dump of the segment inode: ", stderr);
|
|
|
|
ut_print_buf(stderr, seg_inode, 40);
|
|
|
|
putc('\n', stderr);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Serious error: InnoDB is trying to"
|
|
|
|
" free space %lu page %lu,\n"
|
|
|
|
"InnoDB: which does not belong to"
|
|
|
|
" segment %lu %lu but belongs\n"
|
|
|
|
"InnoDB: to segment %lu %lu.\n",
|
|
|
|
(ulong) space, (ulong) page,
|
|
|
|
(ulong) ut_dulint_get_high(descr_id),
|
|
|
|
(ulong) ut_dulint_get_low(descr_id),
|
|
|
|
(ulong) ut_dulint_get_high(seg_id),
|
|
|
|
(ulong) ut_dulint_get_low(seg_id));
|
2005-10-27 07:29:40 +00:00
|
|
|
goto crash;
|
|
|
|
}
|
|
|
|
|
|
|
|
not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (xdes_is_full(descr, mtr)) {
|
|
|
|
/* The fragment is full: move it to another list */
|
|
|
|
flst_remove(seg_inode + FSEG_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_add_last(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
not_full_n_used + FSP_EXTENT_SIZE - 1,
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
ut_a(not_full_n_used > 0);
|
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
not_full_n_used - 1, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
xdes_set_bit(descr, XDES_CLEAN_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
/* The extent has become free: free it to space */
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a single page of a segment. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_free_page(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header, /*!< in: segment header */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_inode_t* seg_inode;
|
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
|
|
|
rw_lock_t* latch;
|
|
|
|
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
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
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2007-01-18 18:29:12 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(latch, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
seg_inode = fseg_inode_get(seg_header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
|
|
|
buf_page_set_file_page_was_freed(space, page);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees an extent of a segment to the space free list. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_free_extent(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* seg_inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page, /*!< in: a page in the extent */
|
|
|
|
mtr_t* mtr) /*!< in: mtr handle */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint first_page_in_extent;
|
|
|
|
xdes_t* descr;
|
|
|
|
ulint not_full_n_used;
|
|
|
|
ulint descr_n_used;
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(seg_inode && mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_state(descr, mtr) == XDES_FSEG);
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr),
|
|
|
|
mtr_read_dulint(seg_inode + FSEG_ID, mtr)));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
first_page_in_extent = page - (page % FSP_EXTENT_SIZE);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
|
|
if (FALSE == xdes_get_bit(descr, XDES_FREE_BIT, i, mtr)) {
|
|
|
|
|
|
|
|
/* Drop search system page hash index if the page is
|
|
|
|
found in the pool and is hashed */
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
btr_search_drop_page_hash_when_freed(
|
2007-01-18 09:59:00 +00:00
|
|
|
space, zip_size, first_page_in_extent + i);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xdes_is_full(descr, mtr)) {
|
|
|
|
flst_remove(seg_inode + FSEG_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if (xdes_is_free(descr, mtr)) {
|
|
|
|
flst_remove(seg_inode + FSEG_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
descr + XDES_FLST_NODE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
not_full_n_used = mtr_read_ulint(
|
|
|
|
seg_inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr_n_used = xdes_get_n_used(descr, mtr);
|
|
|
|
ut_a(not_full_n_used >= descr_n_used);
|
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
not_full_n_used - descr_n_used,
|
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
|
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
buf_page_set_file_page_was_freed(space,
|
2006-08-29 09:30:31 +00:00
|
|
|
first_page_in_extent + i);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees part of a segment. This function can be used to free a segment by
|
|
|
|
repeatedly calling this function in different mini-transactions. Doing
|
|
|
|
the freeing in a single mini-transaction might result in too big a
|
2009-05-25 05:30:14 +00:00
|
|
|
mini-transaction.
|
|
|
|
@return TRUE if freeing completed */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_free_step(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in, own: segment header; NOTE: if the header
|
2005-10-27 07:29:40 +00:00
|
|
|
resides on the first page of the frag list
|
|
|
|
of the segment, this pointer becomes obsolete
|
|
|
|
after the last freeing step */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint n;
|
|
|
|
ulint page;
|
|
|
|
xdes_t* descr;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2006-10-12 07:02:36 +00:00
|
|
|
ulint header_page;
|
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
|
|
|
rw_lock_t* latch;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(header));
|
|
|
|
header_page = page_get_page_no(page_align(header));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
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
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2007-01-18 18:29:12 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(latch, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_get_descriptor(space, zip_size, header_page, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Check that the header resides on a page which has not been
|
|
|
|
freed yet */
|
|
|
|
|
|
|
|
ut_a(descr);
|
2006-10-12 07:02:36 +00:00
|
|
|
ut_a(xdes_get_bit(descr, XDES_FREE_BIT,
|
|
|
|
header_page % FSP_EXTENT_SIZE, mtr) == FALSE);
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (descr != NULL) {
|
|
|
|
/* Free the extent held by the segment */
|
|
|
|
page = xdes_get_offset(descr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_free_extent(inode, space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free a frag page */
|
|
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
|
|
/* Freeing completed: free the segment inode */
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_free_page_low(inode, space, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
fseg_get_nth_frag_page_no(inode, n, mtr), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
|
|
/* Freeing completed: free the segment inode */
|
2007-01-18 09:59:00 +00:00
|
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees part of a segment. Differs from fseg_free_step because this function
|
2009-05-25 05:30:14 +00:00
|
|
|
leaves the header page unfreed.
|
|
|
|
@return TRUE if freeing completed, except the header page */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_free_step_not_header(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header which must reside on
|
2005-10-27 07:29:40 +00:00
|
|
|
the first fragment page of the segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint n;
|
|
|
|
ulint page;
|
|
|
|
xdes_t* descr;
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no;
|
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
|
|
|
rw_lock_t* latch;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(header));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
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
|
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
2007-01-18 18:29:12 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(latch, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (descr != NULL) {
|
|
|
|
/* Free the extent held by the segment */
|
|
|
|
page = xdes_get_offset(descr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_free_extent(inode, space, zip_size, page, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free a frag page */
|
|
|
|
|
|
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
page_no = fseg_get_nth_frag_page_no(inode, n, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
if (page_no == page_get_page_no(page_align(header))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
fseg_free_page_low(inode, space, zip_size, page_no, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a segment. The freeing is performed in several mini-transactions,
|
|
|
|
so that there is no danger of bufferfixing too many buffer pages. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_free(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page_no,/*!< in: page number where the segment header is
|
2005-10-27 07:29:40 +00:00
|
|
|
placed */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset) /*!< in: byte offset of the segment header on that
|
2005-10-27 07:29:40 +00:00
|
|
|
page */
|
|
|
|
{
|
|
|
|
mtr_t mtr;
|
|
|
|
ibool finished;
|
|
|
|
fseg_header_t* header;
|
|
|
|
fil_addr_t addr;
|
|
|
|
|
|
|
|
addr.page = page_no;
|
|
|
|
addr.boffset = offset;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fut_get_ptr(space, zip_size, addr, RW_X_LATCH, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
finished = fseg_free_step(header, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
if (finished) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns the first extent descriptor for a segment. We think of the extent
|
|
|
|
lists of the segment catenated in the order FSEG_FULL -> FSEG_NOT_FULL
|
2009-05-25 05:30:14 +00:00
|
|
|
-> FSEG_FREE.
|
|
|
|
@return the first extent descriptor, or NULL if none */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
xdes_t*
|
|
|
|
fseg_get_first_extent(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fil_addr_t first;
|
|
|
|
xdes_t* descr;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(inode && mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_ad(space == page_get_space_id(page_align(inode)));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
first = fil_addr_null;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (flst_get_len(inode + FSEG_FULL, mtr) > 0) {
|
|
|
|
|
|
|
|
first = flst_get_first(inode + FSEG_FULL, mtr);
|
|
|
|
|
|
|
|
} else if (flst_get_len(inode + FSEG_NOT_FULL, mtr) > 0) {
|
|
|
|
|
|
|
|
first = flst_get_first(inode + FSEG_NOT_FULL, mtr);
|
|
|
|
|
|
|
|
} else if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
|
|
|
|
|
|
first = flst_get_first(inode + FSEG_FREE, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (first.page == FIL_NULL) {
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
}
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(descr);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates a segment.
|
|
|
|
@return TRUE if ok */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
fseg_validate_low(
|
|
|
|
/*==============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr2) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint space;
|
|
|
|
dulint seg_id;
|
|
|
|
mtr_t mtr;
|
|
|
|
xdes_t* descr;
|
|
|
|
fil_addr_t node_addr;
|
|
|
|
ulint n_used = 0;
|
|
|
|
ulint n_used2 = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr2, inode, MTR_MEMO_PAGE_X_FIX));
|
2008-09-26 09:09:43 +00:00
|
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(inode));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2);
|
2005-10-27 07:29:40 +00:00
|
|
|
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr2);
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_validate(inode + FSEG_FREE, mtr2);
|
|
|
|
flst_validate(inode + FSEG_NOT_FULL, mtr2);
|
|
|
|
flst_validate(inode + FSEG_FULL, mtr2);
|
|
|
|
|
|
|
|
/* Validate FSEG_FREE list */
|
|
|
|
node_addr = flst_get_first(inode + FSEG_FREE, mtr2);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == 0);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
|
|
seg_id));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate FSEG_NOT_FULL list */
|
|
|
|
|
|
|
|
node_addr = flst_get_first(inode + FSEG_NOT_FULL, mtr2);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) > 0);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
|
|
seg_id));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
n_used2 += xdes_get_n_used(descr, &mtr);
|
|
|
|
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate FSEG_FULL list */
|
|
|
|
|
|
|
|
node_addr = flst_get_first(inode + FSEG_FULL, mtr2);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
|
|
seg_id));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(n_used == n_used2);
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates a segment.
|
|
|
|
@return TRUE if ok */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_validate(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ibool ret;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(header));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
ret = fseg_validate_low(inode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Writes info of a segment. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
fseg_print_low(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_inode_t* inode, /*!< in: segment inode */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint space;
|
|
|
|
ulint seg_id_low;
|
|
|
|
ulint seg_id_high;
|
|
|
|
ulint n_used;
|
|
|
|
ulint n_frag;
|
|
|
|
ulint n_free;
|
|
|
|
ulint n_not_full;
|
|
|
|
ulint n_full;
|
|
|
|
ulint reserved;
|
|
|
|
ulint used;
|
|
|
|
ulint page_no;
|
2006-02-23 19:25:29 +00:00
|
|
|
dulint d_var;
|
|
|
|
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(inode));
|
|
|
|
page_no = page_get_page_no(page_align(inode));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
d_var = mtr_read_dulint(inode + FSEG_ID, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
seg_id_low = ut_dulint_get_low(d_var);
|
|
|
|
seg_id_high = ut_dulint_get_high(d_var);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
n_frag = fseg_get_n_frag_pages(inode, mtr);
|
|
|
|
n_free = flst_get_len(inode + FSEG_FREE, mtr);
|
|
|
|
n_not_full = flst_get_len(inode + FSEG_NOT_FULL, mtr);
|
|
|
|
n_full = flst_get_len(inode + FSEG_FULL, mtr);
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"SEGMENT id %lu %lu space %lu; page %lu;"
|
|
|
|
" res %lu used %lu; full ext %lu\n"
|
|
|
|
"fragm pages %lu; free extents %lu;"
|
|
|
|
" not full extents %lu: pages %lu\n",
|
|
|
|
(ulong) seg_id_high, (ulong) seg_id_low,
|
|
|
|
(ulong) space, (ulong) page_no,
|
2005-10-27 07:29:40 +00:00
|
|
|
(ulong) reserved, (ulong) used, (ulong) n_full,
|
|
|
|
(ulong) n_frag, (ulong) n_free, (ulong) n_not_full,
|
2006-02-23 19:25:29 +00:00
|
|
|
(ulong) n_used);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 12:29:16 +00:00
|
|
|
#ifdef UNIV_BTR_PRINT
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Writes info of a segment. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_print(
|
|
|
|
/*=======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fseg_inode_t* inode;
|
|
|
|
ulint space;
|
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
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 07:02:36 +00:00
|
|
|
space = page_get_space_id(page_align(header));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
fseg_print_low(inode, mtr);
|
|
|
|
}
|
2008-03-06 12:29:16 +00:00
|
|
|
#endif /* UNIV_BTR_PRINT */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates the file space system and its segments.
|
|
|
|
@return TRUE if ok */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fsp_validate(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space) /*!< in: space id */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
fseg_inode_t* seg_inode;
|
|
|
|
page_t* seg_inode_page;
|
2007-01-18 09:59:00 +00:00
|
|
|
rw_lock_t* latch;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint size;
|
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
|
|
|
ulint flags;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint free_limit;
|
|
|
|
ulint frag_n_used;
|
|
|
|
mtr_t mtr;
|
|
|
|
mtr_t mtr2;
|
|
|
|
xdes_t* descr;
|
|
|
|
fil_addr_t node_addr;
|
|
|
|
fil_addr_t next_node_addr;
|
|
|
|
ulint descr_count = 0;
|
|
|
|
ulint n_used = 0;
|
|
|
|
ulint n_used2 = 0;
|
|
|
|
ulint n_full_frag_pages;
|
|
|
|
ulint n;
|
|
|
|
ulint seg_inode_len_free;
|
|
|
|
ulint seg_inode_len_full;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2007-01-18 09:59:00 +00:00
|
|
|
ut_a(ut_is_2pow(zip_size));
|
|
|
|
ut_a(zip_size <= UNIV_PAGE_SIZE);
|
|
|
|
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Start first a mini-transaction mtr2 to lock out all other threads
|
|
|
|
from the fsp system */
|
|
|
|
mtr_start(&mtr2);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr2);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
n_full_frag_pages = FSP_EXTENT_SIZE
|
|
|
|
* flst_get_len(header + FSP_FULL_FRAG, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-05-29 08:48:16 +00:00
|
|
|
if (UNIV_UNLIKELY(free_limit > size)) {
|
|
|
|
|
|
|
|
ut_a(space != 0);
|
|
|
|
ut_a(size < FSP_EXTENT_SIZE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_validate(header + FSP_FREE, &mtr);
|
|
|
|
flst_validate(header + FSP_FREE_FRAG, &mtr);
|
|
|
|
flst_validate(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
/* Validate FSP_FREE list */
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
node_addr = flst_get_first(header + FSP_FREE, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr_count++;
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == 0);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FREE);
|
|
|
|
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate FSP_FREE_FRAG list */
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
node_addr = flst_get_first(header + FSP_FREE_FRAG, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr_count++;
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) > 0);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FREE_FRAG);
|
|
|
|
|
|
|
|
n_used += xdes_get_n_used(descr, &mtr);
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate FSP_FULL_FRAG list */
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
node_addr = flst_get_first(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
descr_count++;
|
2007-01-18 09:59:00 +00:00
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
|
|
node_addr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
|
|
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FULL_FRAG);
|
|
|
|
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Validate segments */
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
seg_inode_len_full = flst_get_len(header + FSP_SEG_INODES_FULL, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
n = 0;
|
|
|
|
do {
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode_page = fut_get_ptr(
|
2007-01-18 09:59:00 +00:00
|
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
- FSEG_INODE_PAGE_NODE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
seg_inode_page, n, zip_size, &mtr);
|
2007-05-18 11:01:58 +00:00
|
|
|
ut_a(!ut_dulint_is_zero(
|
|
|
|
mach_read_from_8(seg_inode + FSEG_ID)));
|
2006-02-23 19:25:29 +00:00
|
|
|
fseg_validate_low(seg_inode, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
descr_count += flst_get_len(seg_inode + FSEG_FREE,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
descr_count += flst_get_len(seg_inode + FSEG_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
descr_count += flst_get_len(seg_inode + FSEG_NOT_FULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
n_used2 += fseg_get_n_frag_pages(seg_inode, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
next_node_addr = flst_get_next_addr(
|
|
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = next_node_addr;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
|
|
|
|
|
|
|
|
seg_inode_len_free = flst_get_len(header + FSP_SEG_INODES_FREE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
n = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
do {
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode_page = fut_get_ptr(
|
2007-01-18 09:59:00 +00:00
|
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
- FSEG_INODE_PAGE_NODE;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
seg_inode_page, n, zip_size, &mtr);
|
2007-05-18 11:01:58 +00:00
|
|
|
if (!ut_dulint_is_zero(
|
|
|
|
mach_read_from_8(seg_inode + FSEG_ID))) {
|
2006-02-23 19:25:29 +00:00
|
|
|
fseg_validate_low(seg_inode, &mtr);
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
descr_count += flst_get_len(
|
|
|
|
seg_inode + FSEG_FREE, &mtr);
|
|
|
|
descr_count += flst_get_len(
|
|
|
|
seg_inode + FSEG_FULL, &mtr);
|
|
|
|
descr_count += flst_get_len(
|
|
|
|
seg_inode + FSEG_NOT_FULL, &mtr);
|
|
|
|
n_used2 += fseg_get_n_frag_pages(
|
|
|
|
seg_inode, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
next_node_addr = flst_get_next_addr(
|
|
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = next_node_addr;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(descr_count * FSP_EXTENT_SIZE == free_limit);
|
2006-06-07 10:41:58 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
ut_a(n_used + n_full_frag_pages
|
2006-08-29 09:30:31 +00:00
|
|
|
== n_used2 + 2 * ((free_limit + (UNIV_PAGE_SIZE - 1))
|
|
|
|
/ UNIV_PAGE_SIZE)
|
|
|
|
+ seg_inode_len_full + seg_inode_len_free);
|
2006-06-07 10:41:58 +00:00
|
|
|
} else {
|
|
|
|
ut_a(n_used + n_full_frag_pages
|
2006-08-29 09:30:31 +00:00
|
|
|
== n_used2 + 2 * ((free_limit + (zip_size - 1))
|
|
|
|
/ zip_size)
|
|
|
|
+ seg_inode_len_full + seg_inode_len_free);
|
2006-06-07 10:41:58 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(frag_n_used == n_used);
|
|
|
|
|
|
|
|
mtr_commit(&mtr2);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints info of a file space. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_print(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space) /*!< in: space id */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
fsp_header_t* header;
|
|
|
|
fseg_inode_t* seg_inode;
|
|
|
|
page_t* seg_inode_page;
|
2007-01-18 09:59:00 +00:00
|
|
|
rw_lock_t* latch;
|
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
|
|
|
ulint flags;
|
2006-06-07 10:41:58 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint size;
|
|
|
|
ulint free_limit;
|
|
|
|
ulint frag_n_used;
|
|
|
|
fil_addr_t node_addr;
|
|
|
|
fil_addr_t next_node_addr;
|
|
|
|
ulint n_free;
|
|
|
|
ulint n_free_frag;
|
|
|
|
ulint n_full_frag;
|
|
|
|
ulint seg_id_low;
|
|
|
|
ulint seg_id_high;
|
|
|
|
ulint n;
|
|
|
|
ulint n_segs = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
dulint d_var;
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t mtr;
|
|
|
|
mtr_t mtr2;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2007-01-18 09:59:00 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Start first a mini-transaction mtr2 to lock out all other threads
|
|
|
|
from the fsp system */
|
|
|
|
|
|
|
|
mtr_start(&mtr2);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
n_free = flst_get_len(header + FSP_FREE, &mtr);
|
|
|
|
n_free_frag = flst_get_len(header + FSP_FREE_FRAG, &mtr);
|
|
|
|
n_full_frag = flst_get_len(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
|
|
|
|
d_var = mtr_read_dulint(header + FSP_SEG_ID, &mtr);
|
|
|
|
|
|
|
|
seg_id_low = ut_dulint_get_low(d_var);
|
|
|
|
seg_id_high = ut_dulint_get_high(d_var);
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"FILE SPACE INFO: id %lu\n"
|
|
|
|
"size %lu, free limit %lu, free extents %lu\n"
|
|
|
|
"not full frag extents %lu: used pages %lu,"
|
|
|
|
" full frag extents %lu\n"
|
|
|
|
"first seg id not used %lu %lu\n",
|
2007-01-18 09:59:00 +00:00
|
|
|
(ulong) space,
|
2005-10-27 07:29:40 +00:00
|
|
|
(ulong) size, (ulong) free_limit, (ulong) n_free,
|
|
|
|
(ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag,
|
|
|
|
(ulong) seg_id_high, (ulong) seg_id_low);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Print segments */
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
n = 0;
|
|
|
|
|
|
|
|
do {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode_page = fut_get_ptr(
|
2007-01-18 09:59:00 +00:00
|
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
- FSEG_INODE_PAGE_NODE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
seg_inode_page, n, zip_size, &mtr);
|
2007-05-18 11:01:58 +00:00
|
|
|
ut_a(!ut_dulint_is_zero(
|
|
|
|
mach_read_from_8(seg_inode + FSEG_ID)));
|
2006-02-23 19:25:29 +00:00
|
|
|
fseg_print_low(seg_inode, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
n_segs++;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
next_node_addr = flst_get_next_addr(
|
|
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = next_node_addr;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
|
2006-06-07 10:41:58 +00:00
|
|
|
n = 0;
|
|
|
|
|
|
|
|
do {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_start(&mtr);
|
2007-01-18 09:59:00 +00:00
|
|
|
mtr_x_lock(latch, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode_page = fut_get_ptr(
|
2007-01-18 09:59:00 +00:00
|
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
2006-08-29 09:30:31 +00:00
|
|
|
- FSEG_INODE_PAGE_NODE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
|
|
seg_inode_page, n, zip_size, &mtr);
|
2007-05-18 11:01:58 +00:00
|
|
|
if (!ut_dulint_is_zero(
|
|
|
|
mach_read_from_8(seg_inode + FSEG_ID))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
fseg_print_low(seg_inode, &mtr);
|
|
|
|
n_segs++;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
next_node_addr = flst_get_next_addr(
|
|
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-06-07 10:41:58 +00:00
|
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
node_addr = next_node_addr;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr2);
|
|
|
|
|
|
|
|
fprintf(stderr, "NUMBER of file segments: %lu\n", (ulong) n_segs);
|
|
|
|
}
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|