summaryrefslogtreecommitdiff
path: root/storage/innobase/ut
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-03-26 00:03:13 +0200
committerMichael Widenius <monty@askmonty.org>2013-03-26 00:03:13 +0200
commit068c61978e3a81836d52b8caf11e044290159ad1 (patch)
tree2cbca861ab2cebe3bd99379ca9668bb483ca0d2a /storage/innobase/ut
parent35bc8f9f4353b64da215e52ff6f1612a8ce66f43 (diff)
downloadmariadb-git-068c61978e3a81836d52b8caf11e044290159ad1.tar.gz
Temporary commit of 10.0-merge
Diffstat (limited to 'storage/innobase/ut')
-rw-r--r--storage/innobase/ut/ut0crc32.cc10
-rw-r--r--storage/innobase/ut/ut0mem.cc7
-rw-r--r--storage/innobase/ut/ut0rbt.cc2
-rw-r--r--storage/innobase/ut/ut0ut.cc98
-rw-r--r--storage/innobase/ut/ut0vec.cc4
-rw-r--r--storage/innobase/ut/ut0wqueue.cc2
6 files changed, 94 insertions, 29 deletions
diff --git a/storage/innobase/ut/ut0crc32.cc b/storage/innobase/ut/ut0crc32.cc
index 538879dd9e2..695035d6ae8 100644
--- a/storage/innobase/ut/ut0crc32.cc
+++ b/storage/innobase/ut/ut0crc32.cc
@@ -79,11 +79,11 @@ mysys/my_perf.c, contributed by Facebook under the following license.
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
-#include <string.h> /* memcmp() */
-
#include "univ.i"
#include "ut0crc32.h"
+#include <string.h>
+
ib_ut_crc32_t ut_crc32;
/* Precalculated table used to generate the CRC32 if the CPU does not
@@ -92,7 +92,7 @@ static ib_uint32_t ut_crc32_slice8_table[8][256];
static ibool ut_crc32_slice8_table_initialized = FALSE;
/* Flag that tells whether the CPU supports CRC32 or not */
-static ibool ut_crc32_sse2_enabled = FALSE;
+UNIV_INTERN bool ut_crc32_sse2_enabled = false;
/********************************************************************//**
Initializes the table that is used to generate the CRC32 if the CPU does
@@ -315,8 +315,4 @@ ut_crc32_init()
ut_crc32_slice8_table_init();
ut_crc32 = ut_crc32_slice8;
}
-
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: CPU %s crc32 instructions\n",
- ut_crc32_sse2_enabled ? "supports" : "does not support");
}
diff --git a/storage/innobase/ut/ut0mem.cc b/storage/innobase/ut/ut0mem.cc
index 42ad180d373..2bb5d9ce332 100644
--- a/storage/innobase/ut/ut0mem.cc
+++ b/storage/innobase/ut/ut0mem.cc
@@ -35,9 +35,6 @@ Created 5/11/1994 Heikki Tuuri
#include <stdlib.h>
-/** This struct is placed first in every allocated memory block */
-typedef struct ut_mem_block_struct ut_mem_block_t;
-
/** The total amount of memory currently allocated from the operating
system with os_mem_alloc_large() or malloc(). Does not count malloc()
if srv_use_sys_malloc is set. Protected by ut_list_mutex. */
@@ -52,14 +49,14 @@ UNIV_INTERN mysql_pfs_key_t ut_list_mutex_key;
#endif
/** Dynamically allocated memory block */
-struct ut_mem_block_struct{
+struct ut_mem_block_t{
UT_LIST_NODE_T(ut_mem_block_t) mem_block_list;
/*!< mem block list node */
ulint size; /*!< size of allocated memory */
ulint magic_n;/*!< magic number (UT_MEM_MAGIC_N) */
};
-/** The value of ut_mem_block_struct::magic_n. Used in detecting
+/** The value of ut_mem_block_t::magic_n. Used in detecting
memory corruption. */
#define UT_MEM_MAGIC_N 1601650166
diff --git a/storage/innobase/ut/ut0rbt.cc b/storage/innobase/ut/ut0rbt.cc
index b21543a679d..e93844af600 100644
--- a/storage/innobase/ut/ut0rbt.cc
+++ b/storage/innobase/ut/ut0rbt.cc
@@ -773,7 +773,7 @@ rbt_create_arg_cmp(
size_t sizeof_value, /*!< in: sizeof data item */
ib_rbt_arg_compare
compare, /*!< in: fn to compare items */
- const void* cmp_arg) /*!< in: compare fn arg */
+ void* cmp_arg) /*!< in: compare fn arg */
{
ib_rbt_t* tree;
diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc
index 2268cfd2493..3c94d96c3ac 100644
--- a/storage/innobase/ut/ut0ut.cc
+++ b/storage/innobase/ut/ut0ut.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2012, Oracle and/or its affiliates. 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
@@ -28,6 +28,7 @@ Created 5/11/1994 Heikki Tuuri
#ifndef UNIV_INNOCHECKSUM
#include "ut0sort.h"
+#include "os0thread.h" /* thread-ID */
#ifdef UNIV_NONINL
#include "ut0ut.ic"
@@ -218,18 +219,25 @@ ut_print_timestamp(
/*===============*/
FILE* file) /*!< in: file where to print */
{
+ ulint thread_id = 0;
+
+#ifndef UNIV_INNOCHECKSUM
+ thread_id = os_thread_pf(os_thread_get_curr_id());
+#endif
+
#ifdef __WIN__
SYSTEMTIME cal_tm;
GetLocalTime(&cal_tm);
- fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
- (int) cal_tm.wYear % 100,
+ fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %lx",
+ (int) cal_tm.wYear,
(int) cal_tm.wMonth,
(int) cal_tm.wDay,
(int) cal_tm.wHour,
(int) cal_tm.wMinute,
- (int) cal_tm.wSecond);
+ (int) cal_tm.wSecond,
+ thread_id);
#else
struct tm* cal_tm_ptr;
time_t tm;
@@ -243,13 +251,14 @@ ut_print_timestamp(
time(&tm);
cal_tm_ptr = localtime(&tm);
#endif
- fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
- cal_tm_ptr->tm_year % 100,
+ fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %lx",
+ cal_tm_ptr->tm_year + 1900,
cal_tm_ptr->tm_mon + 1,
cal_tm_ptr->tm_mday,
cal_tm_ptr->tm_hour,
cal_tm_ptr->tm_min,
- cal_tm_ptr->tm_sec);
+ cal_tm_ptr->tm_sec,
+ thread_id);
#endif
}
@@ -515,7 +524,7 @@ void
ut_print_name(
/*==========*/
FILE* f, /*!< in: output stream */
- trx_t* trx, /*!< in: transaction */
+ const trx_t* trx, /*!< in: transaction */
ibool table_id,/*!< in: TRUE=print a table name,
FALSE=print other identifier */
const char* name) /*!< in: name to print */
@@ -533,7 +542,7 @@ void
ut_print_namel(
/*===========*/
FILE* f, /*!< in: output stream */
- trx_t* trx, /*!< in: transaction (NULL=no quotes) */
+ const trx_t* trx, /*!< in: transaction (NULL=no quotes) */
ibool table_id,/*!< in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /*!< in: name to print */
@@ -553,6 +562,50 @@ ut_print_namel(
}
/**********************************************************************//**
+Formats a table or index name, quoted as an SQL identifier. If the name
+contains a slash '/', the result will contain two identifiers separated by
+a period (.), as in SQL database_name.identifier.
+@return pointer to 'formatted' */
+UNIV_INTERN
+char*
+ut_format_name(
+/*===========*/
+ const char* name, /*!< in: table or index name, must be
+ '\0'-terminated */
+ ibool is_table, /*!< in: if TRUE then 'name' is a table
+ name */
+ char* formatted, /*!< out: formatted result, will be
+ '\0'-terminated */
+ ulint formatted_size) /*!< out: no more than this number of
+ bytes will be written to 'formatted' */
+{
+ switch (formatted_size) {
+ case 1:
+ formatted[0] = '\0';
+ /* FALL-THROUGH */
+ case 0:
+ return(formatted);
+ }
+
+ char* end;
+
+ end = innobase_convert_name(formatted, formatted_size,
+ name, strlen(name), NULL, is_table);
+
+ /* If the space in 'formatted' was completely used, then sacrifice
+ the last character in order to write '\0' at the end. */
+ if ((ulint) (end - formatted) == formatted_size) {
+ end--;
+ }
+
+ ut_a((ulint) (end - formatted) < formatted_size);
+
+ *end = '\0';
+
+ return(formatted);
+}
+
+/**********************************************************************//**
Catenate files. */
UNIV_INTERN
void
@@ -648,7 +701,7 @@ UNIV_INTERN
const char*
ut_strerr(
/*======*/
- enum db_err num) /*!< in: error number */
+ dberr_t num) /*!< in: error number */
{
switch (num) {
case DB_SUCCESS:
@@ -703,10 +756,12 @@ ut_strerr(
return("Cannot drop constraint");
case DB_NO_SAVEPOINT:
return("No such savepoint");
- case DB_TABLESPACE_ALREADY_EXISTS:
+ case DB_TABLESPACE_EXISTS:
return("Tablespace already exists");
case DB_TABLESPACE_DELETED:
- return("No such tablespace");
+ return("Tablespace deleted or being deleted");
+ case DB_TABLESPACE_NOT_FOUND:
+ return("Tablespace not found");
case DB_LOCK_TABLE_FULL:
return("Lock structs have exhausted the buffer pool");
case DB_FOREIGN_DUPLICATE_KEY:
@@ -717,8 +772,8 @@ ut_strerr(
return("Too many concurrent transactions");
case DB_UNSUPPORTED:
return("Unsupported");
- case DB_PRIMARY_KEY_IS_NULL:
- return("Primary key is NULL");
+ case DB_INVALID_NULL:
+ return("NULL value encountered in NOT NULL column");
case DB_STATS_DO_NOT_EXIST:
return("Persistent statistics do not exist");
case DB_FAIL:
@@ -745,6 +800,21 @@ ut_strerr(
return("Undo record too big");
case DB_END_OF_INDEX:
return("End of index");
+ case DB_IO_ERROR:
+ return("I/O error");
+ case DB_TABLE_IN_FK_CHECK:
+ return("Table is being used in foreign key check");
+ case DB_DATA_MISMATCH:
+ return("data mismatch");
+ case DB_SCHEMA_NOT_LOCKED:
+ return("schema not locked");
+ case DB_NOT_FOUND:
+ return("not found");
+ case DB_ONLINE_LOG_TOO_BIG:
+ return("Log size exceeded during online index creation");
+ case DB_DICT_CHANGED:
+ return("Table dictionary has changed");
+
/* do not add default: in order to produce a warning if new code
is added to the enum but not added here */
}
diff --git a/storage/innobase/ut/ut0vec.cc b/storage/innobase/ut/ut0vec.cc
index 8ac5d9dc5d3..5842d9f1c0e 100644
--- a/storage/innobase/ut/ut0vec.cc
+++ b/storage/innobase/ut/ut0vec.cc
@@ -44,12 +44,14 @@ ib_vector_create(
ut_a(size > 0);
- vec = static_cast<ib_vector_t*>(allocator->mem_malloc(allocator, sizeof(*vec)));
+ vec = static_cast<ib_vector_t*>(
+ allocator->mem_malloc(allocator, sizeof(*vec)));
vec->used = 0;
vec->total = size;
vec->allocator = allocator;
vec->sizeof_value = sizeof_value;
+
vec->data = static_cast<void*>(
allocator->mem_malloc(allocator, vec->sizeof_value * size));
diff --git a/storage/innobase/ut/ut0wqueue.cc b/storage/innobase/ut/ut0wqueue.cc
index 6d410524fe7..d1ba36b3b00 100644
--- a/storage/innobase/ut/ut0wqueue.cc
+++ b/storage/innobase/ut/ut0wqueue.cc
@@ -40,7 +40,7 @@ ib_wqueue_create(void)
mutex_create(PFS_NOT_INSTRUMENTED, &wq->mutex, SYNC_WORK_QUEUE);
wq->items = ib_list_create();
- wq->event = os_event_create(NULL);
+ wq->event = os_event_create();
return(wq);
}