mariadb/include/ha0ha.h
marko 82cfb40dab branches/innodb+: Merge revisions 3544:3575 from branches/zip:
------------------------------------------------------------------------
  r3572 | marko | 2008-12-17 11:19:56 +0200 (Wed, 17 Dec 2008) | 3 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/btr/btr0sea.c
     M /branches/zip/buf/buf0buf.c
     M /branches/zip/buf/buf0lru.c
     M /branches/zip/ha/ha0ha.c
     M /branches/zip/ha/hash0hash.c
     M /branches/zip/include/buf0buf.h
     M /branches/zip/include/ha0ha.h
     M /branches/zip/include/ha0ha.ic
     M /branches/zip/include/hash0hash.h
     M /branches/zip/include/univ.i

  branches/zip: Introduce UNIV_AHI_DEBUG for debugging the adaptive hash
  index without enabling UNIV_DEBUG.
  ------------------------------------------------------------------------
  r3574 | marko | 2008-12-17 12:44:31 +0200 (Wed, 17 Dec 2008) | 2 lines
  Changed paths:
     M /branches/zip/ChangeLog

  branches/zip: ChangeLog: Document recent changes that were not included in
  InnoDB Plugin 1.0.2, except changes to source code comments.
  ------------------------------------------------------------------------
  r3575 | marko | 2008-12-17 14:40:58 +0200 (Wed, 17 Dec 2008) | 12 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/include/row0sel.h
     M /branches/zip/include/row0upd.h
     M /branches/zip/pars/pars0pars.c
     M /branches/zip/row/row0mysql.c
     M /branches/zip/row/row0sel.c
     M /branches/zip/row/row0upd.c

  branches/zip: Remove update-in-place-in-select from the internal SQL
  interpreter.  It was only used for updating the InnoDB internal data
  dictionary when renaming or dropping tables.  It could have caused
  deadlocks after acquiring latches on insert buffer bitmap pages.
  This and r3544 should fix Issue #135.

  Furthermore, the update-in-place-in-select does not account for
  compression failure.  That was not a problem yet, since the InnoDB SQL
  interpreter has so far assumed ROW_FORMAT=REDUNDANT.

  rb://63 approved by Heikki Tuuri
  ------------------------------------------------------------------------
2008-12-17 12:48:23 +00:00

172 lines
5.8 KiB
C

/******************************************************
The hash table with external chains
(c) 1994-1997 Innobase Oy
Created 8/18/1994 Heikki Tuuri
*******************************************************/
#ifndef ha0ha_h
#define ha0ha_h
#include "univ.i"
#include "hash0hash.h"
#include "page0types.h"
#include "buf0types.h"
/*****************************************************************
Looks for an element in a hash table. */
UNIV_INLINE
void*
ha_search_and_get_data(
/*===================*/
/* out: pointer to the data of the first hash
table node in chain having the fold number,
NULL if not found */
hash_table_t* table, /* in: hash table */
ulint fold); /* in: folded value of the searched data */
/*************************************************************
Looks for an element when we know the pointer to the data and updates
the pointer to data if found. */
UNIV_INTERN
void
ha_search_and_update_if_found_func(
/*===============================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data);/* in: new pointer to the data */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_data)
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
UNIV_INTERN
hash_table_t*
ha_create_func(
/*===========*/
/* out, own: created table */
ulint n, /* in: number of array cells */
#ifdef UNIV_SYNC_DEBUG
ulint mutex_level, /* in: level of the mutexes in the latching
order: this is used in the debug version */
#endif /* UNIV_SYNC_DEBUG */
ulint n_mutexes); /* in: number of mutexes to protect the
hash table: must be a power of 2 */
#ifdef UNIV_SYNC_DEBUG
# define ha_create(n_c,n_m,level) ha_create_func(n_c,level,n_m)
#else /* UNIV_SYNC_DEBUG */
# define ha_create(n_c,n_m,level) ha_create_func(n_c,n_m)
#endif /* UNIV_SYNC_DEBUG */
/*****************************************************************
Empties a hash table and frees the memory heaps. */
UNIV_INTERN
void
ha_clear(
/*=====*/
hash_table_t* table); /* in, own: hash table */
/*****************************************************************
Inserts an entry into a hash table. If an entry with the same fold number
is found, its node is updated to point to the new data, and no new node
is inserted. */
UNIV_INTERN
ibool
ha_insert_for_fold_func(
/*====================*/
/* out: TRUE if succeed, FALSE if no more
memory could be allocated */
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of data; if a node with
the same fold value already exists, it is
updated to point to the same data, and no new
node is created! */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data); /* in: data, must not be NULL */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Deletes an entry from a hash table. */
UNIV_INTERN
void
ha_delete(
/*======*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of data */
void* data); /* in: data, must not be NULL and must exist
in the hash table */
/*************************************************************
Looks for an element when we know the pointer to the data and deletes
it from the hash table if found. */
UNIV_INLINE
ibool
ha_search_and_delete_if_found(
/*==========================*/
/* out: TRUE if found */
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data); /* in: pointer to the data */
/*********************************************************************
Removes from the chain determined by fold all nodes whose data pointer
points to the page given. */
UNIV_INTERN
void
ha_remove_all_nodes_to_page(
/*========================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: fold value */
const page_t* page); /* in: buffer page */
/*****************************************************************
Validates a given range of the cells in hash table. */
UNIV_INTERN
ibool
ha_validate(
/*========*/
/* out: TRUE if ok */
hash_table_t* table, /* in: hash table */
ulint start_index, /* in: start index */
ulint end_index); /* in: end index */
/*****************************************************************
Prints info of a hash table. */
UNIV_INTERN
void
ha_print_info(
/*==========*/
FILE* file, /* in: file where to print */
hash_table_t* table); /* in: hash table */
/* The hash table external chain node */
typedef struct ha_node_struct ha_node_t;
struct ha_node_struct {
ha_node_t* next; /* next chain node or NULL if none */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block; /* buffer block containing the data, or NULL */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
};
#ifndef UNIV_NONINL
#include "ha0ha.ic"
#endif
#endif