Drizzled Public API Documentation

global.cc File Reference
#include <config.h>
#include <fcntl.h>
#include <drizzled/error.h>
#include <drizzled/thr_lock.h>
#include <drizzled/session.h>
#include <drizzled/sql_base.h>
#include <drizzled/lock.h>
#include <drizzled/pthread_globals.h>
#include <drizzled/internal/my_sys.h>
#include <drizzled/refresh_version.h>
#include <drizzled/plugin/storage_engine.h>
#include <set>
#include <vector>
#include <algorithm>
#include <functional>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/condition_variable.hpp>

Go to the source code of this file.

Namespaces

namespace  drizzled
 

TODO: Rename this file - func.h is stupid.


namespace  drizzled::locking

Functions

static void drizzled::print_lock_error (int error, const char *)
static void drizzled::reset_lock_data_and_free (DrizzleLock **mysql_lock)
static bool drizzled::locked_named_table (TableList *table_list)
static bool drizzled::must_wait (bool is_not_commit)
void drizzled::locking::broadcast_refresh (void)

Variables

static boost::mutex drizzled::LOCK_global_read_lock
static
boost::condition_variable_any 
drizzled::COND_global_read_lock
static drizzled::error_t drizzled::thr_lock_errno_to_mysql []
volatile uint32_t drizzled::global_read_lock = 0
volatile uint32_t drizzled::global_read_lock_blocks_commit = 0
static volatile uint32_t drizzled::protect_against_global_read_lock = 0
static volatile uint32_t drizzled::waiting_for_read_lock = 0

Detailed Description

Note:
this is out of date, just for historical reference

Locking functions for drizzled.

Because of the new concurrent inserts, we must first get external locks before getting internal locks. If we do it in the other order, the status information is not up to date when called from the lock handler.

GENERAL DESCRIPTION OF LOCKING

When not using LOCK TABLES:

  • For each SQL statement lockTables() is called for all involved tables.
    • lockTables() will call cursor->external_lock(session,locktype) for each table. This is followed by a call to thr_multi_lock() for all tables.
  • When statement is done, we call unlockTables(). This will call DrizzleLock::unlock() followed by table_handler->external_lock(session, F_UNLCK) for each table.
  • Note that unlockTables() may be called several times as MySQL in some cases can free some tables earlier than others.
  • The above is true both for normal and temporary tables.
  • Temporary non transactional tables are never passed to thr_multi_lock() and we never call external_lock(session, F_UNLOCK) on these.

When using LOCK TABLES:

  • LOCK Table will call lockTables() for all tables. lockTables() will call table_handler->external_lock(session,locktype) for each table. This is followed by a call to thr_multi_lock() for all tables.
  • For each statement, we will call table_handler->start_stmt(Session) to inform the table handler that we are using the table.

The tables used can only be tables used in LOCK TABLES or a temporary table.

  • When statement is done, we will call ha_commit_stmt(session);
  • When calling UNLOCK TABLES we call unlockTables() for all tables used in LOCK TABLES

If table_handler->external_lock(session, locktype) fails, we call table_handler->external_lock(session, F_UNLCK) for each table that was locked, excluding one that caused failure. That means handler must cleanup itself in case external_lock() fails.

Todo:
Change to use malloc() ONLY when using LOCK TABLES command or when we are forced to use mysql_lock_merge.

Definition in file global.cc.