mariadb/lock/lock0iter.c
marko 2c2b06ad75 branches/zip: Introduce UNIV_INTERN, a linkage specifier for InnoDB-global
symbols.  Use it for all definitions of non-static variables and functions.

lexyy.c, make_flex.sh: Declare yylex as UNIV_INTERN, not static.  It is
referenced from pars0grm.c.

Actually, according to
	nm .libs/ha_innodb.so|grep -w '[ABCE-TVXYZ]'
the following symbols are still global:

* The vtable for class ha_innodb
* pars0grm.c: The function yyparse() and the variables yychar, yylval, yynerrs

The required changes to the Bison-generated file pars0grm.c will be addressed
in a separate commit, which will add a script similar to make_flex.sh.

The class ha_innodb is renamed from class ha_innobase by a #define.  Thus,
there will be no clash with the builtin InnoDB.  However, there will be some
overhead for invoking virtual methods of class ha_innodb.  Ideas for making
the vtable hidden are welcome.  -fvisibility=hidden is not available in GCC 3.
2008-02-06 14:17:36 +00:00

90 lines
2.3 KiB
C

/******************************************************
Lock queue iterator. Can iterate over table and record
lock queues.
(c) 2007 Innobase Oy
Created July 16, 2007 Vasil Dimov
*******************************************************/
#define LOCK_MODULE_IMPLEMENTATION
#include "univ.i"
#include "lock0iter.h"
#include "lock0lock.h"
#include "lock0priv.h"
#include "ut0dbg.h"
#include "ut0lst.h"
/***********************************************************************
Initialize lock queue iterator so that it starts to iterate from
"lock". bit_no specifies the record number within the heap where the
record is stored. It can be undefined (ULINT_UNDEFINED) in two cases:
1. If the lock is a table lock, thus we have a table lock queue;
2. If the lock is a record lock and it is a wait lock. In this case
bit_no is calculated in this function by using
lock_rec_find_set_bit(). There is exactly one bit set in the bitmap
of a wait lock. */
UNIV_INTERN
void
lock_queue_iterator_reset(
/*======================*/
lock_queue_iterator_t* iter, /* out: iterator */
const lock_t* lock, /* in: lock to start from */
ulint bit_no) /* in: record number in the
heap */
{
iter->current_lock = lock;
if (bit_no != ULINT_UNDEFINED) {
iter->bit_no = bit_no;
} else {
switch (lock_get_type_low(lock)) {
case LOCK_TABLE:
iter->bit_no = ULINT_UNDEFINED;
break;
case LOCK_REC:
iter->bit_no = lock_rec_find_set_bit(lock);
ut_a(iter->bit_no != ULINT_UNDEFINED);
break;
default:
ut_error;
}
}
}
/***********************************************************************
Gets the previous lock in the lock queue, returns NULL if there are no
more locks (i.e. the current lock is the first one). The iterator is
receded (if not-NULL is returned). */
UNIV_INTERN
const lock_t*
lock_queue_iterator_get_prev(
/*=========================*/
/* out: previous lock or NULL */
lock_queue_iterator_t* iter) /* in/out: iterator */
{
const lock_t* prev_lock;
switch (lock_get_type_low(iter->current_lock)) {
case LOCK_REC:
prev_lock = lock_rec_get_prev(
iter->current_lock, iter->bit_no);
break;
case LOCK_TABLE:
prev_lock = UT_LIST_GET_PREV(
un_member.tab_lock.locks, iter->current_lock);
break;
default:
ut_error;
}
if (prev_lock != NULL) {
iter->current_lock = prev_lock;
}
return(prev_lock);
}