~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.cc

  • Committer: Brian Aker
  • Date: 2010-03-01 17:04:10 UTC
  • mfrom: (1309.1.23 build)
  • Revision ID: brian@gaz-20100301170410-ph8eb1hdf9rqks51
Merge up build to staging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
}
124
124
 
125
125
#include "ha_innodb.h"
126
 
#include "i_s.h"
 
126
#include "data_dictionary.h"
127
127
#include "handler0vars.h"
128
128
 
129
129
#include <iostream>
166
166
 
167
167
static plugin::XaStorageEngine* innodb_engine_ptr= NULL;
168
168
static plugin::TableFunction* status_table_function_ptr= NULL;
 
169
static plugin::TableFunction* cmp_tool= NULL;
 
170
static plugin::TableFunction* cmp_reset_tool= NULL;
 
171
static plugin::TableFunction* cmp_mem_tool= NULL;
 
172
static plugin::TableFunction* cmp_mem_reset_tool= NULL;
 
173
static plugin::TableFunction* innodb_trx_tool= NULL;
 
174
static plugin::TableFunction* innodb_locks_tool= NULL;
 
175
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
169
176
 
170
177
static const long AUTOINC_OLD_STYLE_LOCKING = 0;
171
178
static const long AUTOINC_NEW_STYLE_LOCKING = 1;
338
345
 
339
346
  /*********************************************************************
340
347
  Removes all tables in the named database inside InnoDB. */
341
 
  virtual
342
 
  void
343
 
  drop_database(
 
348
  bool
 
349
  doDropSchema(
344
350
  /*===================*/
345
351
                        /* out: error number */
346
 
        char*   path);  /* in: database path; inside InnoDB the name
 
352
        const std::string       &schema_name);  /* in: database path; inside InnoDB the name
347
353
                        of the last directory in the path is used as
348
354
                        the database name: for example, in 'mysql/data/test'
349
355
                        the database name is 'test' */
1947
1953
        pthread_cond_init(&commit_cond, NULL);
1948
1954
        innodb_inited= 1;
1949
1955
 
1950
 
#if 0
1951
 
        if (innodb_locks_init() ||
1952
 
                innodb_trx_init() ||
1953
 
                innodb_lock_waits_init() ||
1954
 
                i_s_cmp_init() ||
1955
 
                i_s_cmp_reset_init() ||
1956
 
                i_s_cmpmem_init() ||
1957
 
                i_s_cmpmem_reset_init())
1958
 
                goto error;
1959
 
#endif
1960
 
 
1961
1956
        status_table_function_ptr= new InnodbStatusTool;
1962
1957
 
1963
1958
        registry.add(innodb_engine_ptr);
1964
1959
 
1965
1960
        registry.add(status_table_function_ptr);
1966
1961
 
1967
 
#if 0
1968
 
        registry.add(innodb_trx_schema_table);
1969
 
        registry.add(innodb_locks_schema_table);
1970
 
        registry.add(innodb_lock_waits_schema_table);   
1971
 
        registry.add(innodb_cmp_schema_table);
1972
 
        registry.add(innodb_cmp_reset_schema_table);
1973
 
        registry.add(innodb_cmpmem_schema_table);
1974
 
        registry.add(innodb_cmpmem_reset_schema_table);
1975
 
#endif
 
1962
        cmp_tool= new(std::nothrow)CmpTool(false);
 
1963
        registry.add(cmp_tool);
 
1964
 
 
1965
        cmp_reset_tool= new(std::nothrow)CmpTool(true);
 
1966
        registry.add(cmp_reset_tool);
 
1967
 
 
1968
        cmp_mem_tool= new(std::nothrow)CmpmemTool(false);
 
1969
        registry.add(cmp_mem_tool);
 
1970
 
 
1971
        cmp_mem_reset_tool= new(std::nothrow)CmpmemTool(true);
 
1972
        registry.add(cmp_mem_reset_tool);
 
1973
 
 
1974
        innodb_trx_tool= new(std::nothrow)InnodbTrxTool("INNODB_TRX");
 
1975
        registry.add(innodb_trx_tool);
 
1976
 
 
1977
        innodb_locks_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCKS");
 
1978
        registry.add(innodb_locks_tool);
 
1979
 
 
1980
        innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
 
1981
        registry.add(innodb_lock_waits_tool);
1976
1982
 
1977
1983
        /* Get the current high water mark format. */
1978
1984
        innobase_file_format_check = (char*) trx_sys_file_format_max_get();
1990
1996
innobase_deinit(plugin::Registry &registry)
1991
1997
{
1992
1998
        int     err= 0;
1993
 
#if 0
1994
 
        i_s_common_deinit(registry);
1995
 
#endif
1996
1999
 
1997
2000
        registry.remove(status_table_function_ptr);
1998
2001
        delete status_table_function_ptr;
1999
2002
 
 
2003
        registry.remove(cmp_tool);
 
2004
        delete cmp_tool;
 
2005
 
 
2006
        registry.remove(cmp_reset_tool);
 
2007
        delete cmp_reset_tool;
 
2008
 
 
2009
        registry.remove(cmp_mem_tool);
 
2010
        delete cmp_mem_tool;
 
2011
 
 
2012
        registry.remove(cmp_mem_reset_tool);
 
2013
        delete cmp_mem_reset_tool;
 
2014
 
 
2015
        registry.remove(innodb_trx_tool);
 
2016
        delete innodb_trx_tool;
 
2017
 
 
2018
        registry.remove(innodb_locks_tool);
 
2019
        delete innodb_locks_tool;
 
2020
 
 
2021
        registry.remove(innodb_lock_waits_tool);
 
2022
        delete innodb_lock_waits_tool;
 
2023
 
2000
2024
        registry.remove(innodb_engine_ptr);
2001
2025
        delete innodb_engine_ptr;
2002
2026
 
5969
5993
 
5970
5994
/*****************************************************************//**
5971
5995
Removes all tables in the named database inside InnoDB. */
5972
 
void
5973
 
InnobaseEngine::drop_database(
 
5996
bool
 
5997
InnobaseEngine::doDropSchema(
5974
5998
/*===================*/
5975
 
        char*   path)   /*!< in: database path; inside InnoDB the name
 
5999
                             const std::string &schema_name)
 
6000
                /*!< in: database path; inside InnoDB the name
5976
6001
                        of the last directory in the path is used as
5977
6002
                        the database name: for example, in 'mysql/data/test'
5978
6003
                        the database name is 'test' */
5979
6004
{
5980
 
        ulint   len             = 0;
5981
6005
        trx_t*  trx;
5982
 
        char*   ptr;
5983
6006
        int     error;
5984
 
        char*   namebuf;
 
6007
        string schema_path(schema_name);
5985
6008
        Session*        session         = current_session;
5986
6009
 
5987
6010
        /* Get the transaction associated with the current session, or create one
6000
6023
                trx_search_latch_release_if_reserved(parent_trx);
6001
6024
        }
6002
6025
 
6003
 
        ptr = strchr(path, '\0') - 2;
6004
 
 
6005
 
        while (ptr >= path && *ptr != '\\' && *ptr != '/') {
6006
 
                ptr--;
6007
 
                len++;
6008
 
        }
6009
 
 
6010
 
        ptr++;
6011
 
        namebuf = (char*) malloc((uint) len + 2);
6012
 
 
6013
 
        memcpy(namebuf, ptr, len);
6014
 
        namebuf[len] = '/';
6015
 
        namebuf[len + 1] = '\0';
6016
 
#ifdef  __WIN__
6017
 
        innobase_casedn_str(namebuf);
6018
 
#endif
6019
 
#if defined __WIN__ && !defined MYSQL_SERVER
6020
 
        /* In the Windows plugin, thd = current_thd is always NULL */
6021
 
        trx = trx_allocate_for_mysql();
6022
 
        trx->mysql_thd = NULL;
6023
 
        trx->mysql_query_str = NULL;
6024
 
#else
 
6026
        schema_path.append("/");
6025
6027
        trx = innobase_trx_allocate(session);
6026
 
#endif
6027
 
        error = row_drop_database_for_mysql(namebuf, trx);
6028
 
        free(namebuf);
 
6028
        error = row_drop_database_for_mysql(schema_path.c_str(), trx);
6029
6029
 
6030
6030
        /* Flush the log to reduce probability that the .frm files and
6031
6031
        the InnoDB data dictionary get out-of-sync if the user runs
6040
6040
 
6041
6041
        innobase_commit_low(trx);
6042
6042
        trx_free_for_mysql(trx);
 
6043
 
 
6044
        return false; // We are just a listener since we lack control over DDL, so we give no positive acknowledgement. 
6043
6045
}
6044
6046
/*********************************************************************//**
6045
6047
Renames an InnoDB table.