47 #include <drizzled/error.h>
48 #include <drizzled/errmsg_print.h>
49 #include <drizzled/internal/m_string.h>
50 #include <drizzled/internal/my_sys.h>
51 #include <drizzled/plugin.h>
53 #include <drizzled/data_home.h>
54 #include <drizzled/catalog/local.h>
55 #include <drizzled/error.h>
56 #include <drizzled/field.h>
57 #include <drizzled/charset.h>
58 #include <drizzled/session.h>
59 #include <drizzled/current_session.h>
60 #include <drizzled/table.h>
61 #include <drizzled/field/blob.h>
62 #include <drizzled/field/varstring.h>
63 #include <drizzled/plugin/xa_storage_engine.h>
64 #include <drizzled/plugin/daemon.h>
65 #include <drizzled/memory/multi_malloc.h>
66 #include <drizzled/pthread_globals.h>
67 #include <drizzled/named_savepoint.h>
68 #include <drizzled/session/table_messages.h>
69 #include <drizzled/transaction_services.h>
72 #include <drizzled/statistics_variables.h>
73 #include <drizzled/system_variables.h>
74 #include <drizzled/session/times.h>
75 #include <drizzled/session/transactions.h>
76 #include <drizzled/typelib.h>
78 #include <boost/algorithm/string.hpp>
79 #include <boost/program_options.hpp>
80 #include <boost/scoped_array.hpp>
81 #include <boost/filesystem.hpp>
84 #include <drizzled/internal/my_sys.h>
86 namespace po= boost::program_options;
87 namespace fs=boost::filesystem;
111 #include "create_replication.h"
124 #include "ha_innodb.h"
125 #include "data_dictionary.h"
126 #include "replication_dictionary.h"
127 #include "internal_dictionary.h"
134 #include <plugin/innobase/handler/status_function.h>
135 #include <plugin/innobase/handler/replication_log.h>
137 #include <google/protobuf/io/zero_copy_stream.h>
138 #include <google/protobuf/io/zero_copy_stream_impl.h>
139 #include <google/protobuf/io/coded_stream.h>
140 #include <google/protobuf/text_format.h>
142 #include <boost/thread/mutex.hpp>
152 static boost::condition_variable commit_cond;
153 static boost::mutex commit_cond_m;
154 static bool innodb_inited = 0;
156 #define INSIDE_HA_INNOBASE_CC
160 #if defined MYSQL_DYNAMIC_PLUGIN && defined __WIN__
161 # undef current_session
162 # define current_session NULL
163 # define EQ_CURRENT_SESSION(session) TRUE
165 # define EQ_CURRENT_SESSION(session) ((session) == current_session)
168 static plugin::XaStorageEngine* innodb_engine_ptr= NULL;
189 (1 << UNIV_PAGE_SIZE_SHIFT_MAX),
191 static page_size_constraint innobase_page_size;
193 (1 << UNIV_PAGE_SIZE_SHIFT_MAX),
195 static log_block_size_constraint innobase_log_block_size;
197 static io_capacity_constraint innodb_io_capacity;
199 static purge_batch_constraint innodb_purge_batch_size;
201 static purge_threads_constraint innodb_n_purge_threads;
203 static trinary_constraint innodb_flush_log_at_trx_commit;
205 static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
209 static io_threads_constraint innobase_read_io_threads;
210 static io_threads_constraint innobase_write_io_threads;
213 static concurrency_constraint innobase_commit_concurrency;
214 static concurrency_constraint innobase_thread_concurrency;
218 static log_file_constraint innobase_log_file_size;
227 static old_blocks_constraint innobase_old_blocks_pct;
234 static read_ahead_threshold_constraint innodb_read_ahead_threshold;
239 static binary_constraint ibuf_active_contract;
242 static ibuf_accel_rate_constraint ibuf_accel_rate;
244 static binary_constraint flush_neighbor_pages;
246 static string sysvar_transaction_log_use_replicator;
249 static rollback_segments_constraint innobase_rollback_segments;
255 std::string innobase_data_home_dir;
256 std::string innobase_data_file_path;
257 std::string innobase_log_group_home_dir;
258 static string innobase_file_format_name;
259 static string innobase_change_buffering;
261 static string read_ahead;
262 static string adaptive_flushing_method;
267 static string innobase_file_format_max;
272 static trinary_constraint innobase_fast_shutdown;
286 static my_bool innobase_file_format_check = TRUE;
287 static my_bool innobase_use_doublewrite = TRUE;
288 static my_bool innobase_use_checksums = TRUE;
289 static my_bool innobase_rollback_on_timeout = FALSE;
290 static my_bool innobase_create_status_file = FALSE;
291 static bool innobase_use_replication_log;
292 static bool support_xa;
293 static bool strict_mode;
295 static lock_wait_constraint lock_wait_timeout;
297 static char* internal_innobase_data_file_path = NULL;
309 static string innodb_stats_method;
316 #define INNOBASE_WAKE_INTERVAL 32
317 static ulong innobase_active_counter = 0;
322 bool nw_panic = FALSE;
349 static TYPELIB read_ahead_typelib = {
350 array_elements(read_ahead_names) - 1,
"read_ahead_typelib",
366 static TYPELIB adaptive_flushing_method_typelib = {
367 array_elements(adaptive_flushing_method_names) - 1,
368 "adaptive_flushing_method_typelib",
374 static const char innobase_index_reserve_name[]=
"GEN_CLUST_INDEX";
378 static const char* ha_innobase_exts[] = {
383 #define DEFAULT_FILE_EXTENSION ".dfe" // Deep Fried Elephant
392 plugin::XaStorageEngine(name_arg,
394 HTON_CAN_INDEX_BLOBS |
395 HTON_PRIMARY_KEY_IN_READ_INDEX |
396 HTON_PARTIAL_COLUMN_READ |
397 HTON_TABLE_SCAN_ON_INDEX |
398 HTON_HAS_FOREIGN_KEYS |
399 HTON_HAS_DOES_TRANSACTIONS)
401 table_definition_ext= plugin::DEFAULT_DEFINITION_FILE_EXT;
402 addAlias(
"INNOBASE");
408 srv_fast_shutdown = (ulint) innobase_fast_shutdown;
411 innobase_open_tables = NULL;
416 free(internal_innobase_data_file_path);
424 virtual int doStartTransaction(
Session *session, start_transaction_option_t options);
425 virtual void doStartStatement(
Session *session);
426 virtual void doEndStatement(
Session *session);
436 virtual int doSetSavepoint(
Session* session,
438 virtual int doRollbackToSavepoint(
Session* session,
440 virtual int doReleaseSavepoint(
Session* session,
442 virtual int doXaCommit(
Session* session,
bool all)
444 return doCommit(session, all);
446 virtual int doXaRollback(
Session *session,
bool all)
448 return doRollback(session, all);
450 virtual uint64_t doGetCurrentTransactionId(
Session *session);
451 virtual uint64_t doGetNewTransactionId(
Session *session);
452 virtual int doCommit(
Session* session,
bool all);
453 virtual int doRollback(
Session* session,
bool all);
528 stat_print_fn *stat_print,
529 enum ha_stat_type stat_type);
533 doReleaseTemporaryLatches(
539 const char** bas_ext()
const {
540 return(ha_innobase_exts);
543 UNIV_INTERN
int doCreateTable(
Session &session,
550 UNIV_INTERN
virtual bool get_error_message(
int error,
String *buf)
const;
552 UNIV_INTERN uint32_t max_supported_keys()
const;
553 UNIV_INTERN uint32_t max_supported_key_length()
const;
554 UNIV_INTERN uint32_t max_supported_key_part_length()
const;
557 UNIV_INTERN uint32_t index_flags(
enum ha_key_alg)
const
559 return (HA_READ_NEXT |
574 drizzled::identifier::table::vector &set_of_identifiers);
575 bool validateCreateTableOption(
const std::string &key,
const std::string &state);
576 void dropTemporarySchema();
581 bool InnobaseEngine::validateCreateTableOption(
const std::string &key,
const std::string &state)
583 if (boost::iequals(key,
"ROW_FORMAT"))
585 if (boost::iequals(state,
"COMPRESSED"))
588 if (boost::iequals(state,
"COMPACT"))
591 if (boost::iequals(state,
"DYNAMIC"))
594 if (boost::iequals(state,
"REDUNDANT"))
603 drizzled::identifier::table::vector &set_of_identifiers)
605 CachedDirectory::Entries entries= directory.
getEntries();
607 std::string search_string(schema_identifier.getSchemaName());
609 boost::algorithm::to_lower(search_string);
611 if (search_string.compare(
"data_dictionary") == 0)
614 catalog::local_identifier(),
615 schema_identifier.getSchemaName(),
616 "SYS_REPLICATION_LOG"));
619 for (CachedDirectory::Entries::iterator entry_iter= entries.begin();
620 entry_iter != entries.end(); ++entry_iter)
623 const string *filename= &entry->filename;
625 assert(filename->size());
627 const char *ext= strchr(filename->c_str(),
'.');
629 if (ext == NULL || system_charset_info->strcasecmp(ext, DEFAULT_FILE_EXTENSION) ||
637 path+= entry->filename;
640 if (StorageEngine::readTableFile(path, definition))
647 set_of_identifiers.push_back(identifier);
655 string proto_path(identifier.getPath());
656 proto_path.append(DEFAULT_FILE_EXTENSION);
658 if (session.getMessageCache().doesTableMessageExist(identifier))
661 std::string search_string(identifier.getPath());
662 boost::algorithm::to_lower(search_string);
664 if (search_string.compare(
"data_dictionary/sys_replication_log") == 0)
667 if (access(proto_path.c_str(), F_OK))
675 int InnobaseEngine::doGetTableDefinition(
Session &session,
679 string proto_path(identifier.getPath());
680 proto_path.append(DEFAULT_FILE_EXTENSION);
683 if (session.getMessageCache().getTableMessage(identifier, table_proto))
686 if (read_replication_log_table_message(identifier.getTableName().c_str(), &table_proto) == 0)
689 if (access(proto_path.c_str(), F_OK))
694 if (StorageEngine::readTableFile(proto_path, table_proto))
708 const char* format_name);
718 const char* format_max);
720 static const char innobase_engine_name[]=
"InnoDB";
732 {
"buffer_pool_pages_data",
734 {
"buffer_pool_pages_dirty",
736 {
"buffer_pool_pages_flushed",
738 {
"buffer_pool_pages_free",
741 {
"buffer_pool_pages_latched",
742 (
char*) &
export_vars.innodb_buffer_pool_pages_latched, SHOW_LONG},
744 {
"buffer_pool_pages_misc",
746 {
"buffer_pool_pages_total",
748 {
"buffer_pool_read_ahead",
750 {
"buffer_pool_read_ahead_evicted",
752 {
"buffer_pool_read_requests",
754 {
"buffer_pool_reads",
756 {
"buffer_pool_wait_free",
758 {
"buffer_pool_write_requests",
762 {
"data_pending_fsyncs",
764 {
"data_pending_reads",
766 {
"data_pending_writes",
776 {
"dblwr_pages_written",
780 {
"have_atomic_builtins",
784 {
"log_write_requests",
790 {
"os_log_pending_fsyncs",
792 {
"os_log_pending_writes",
804 {
"row_lock_current_waits",
808 {
"row_lock_time_avg",
810 {
"row_lock_time_max",
822 {NULL, NULL, SHOW_LONG}
826 plugin::TableFunction::Generator(fields)
829 status_var_ptr= innodb_status_variables;
832 bool InnodbStatusTool::Generator::populate()
834 if (status_var_ptr->name)
836 std::ostringstream oss;
838 const char *value= status_var_ptr->value;
841 push(status_var_ptr->name);
843 switch (status_var_ptr->type)
846 oss << *(int64_t*) value;
847 return_value= oss.str();
850 oss << *(int64_t*) value;
851 return_value= oss.str();
854 return_value= *(
bool*) value ?
"ON" :
"OFF";
861 if (return_value.length())
903 if (UNIV_LIKELY(!srv_thread_concurrency)) {
920 if (UNIV_LIKELY(!trx->declared_to_be_inside_innodb)) {
939 if (trx->has_search_latch) {
943 if (trx->declared_to_be_inside_innodb) {
977 return(session->getSqlCommand() == SQLCOM_SELECT);
1008 return((ulong)lock_wait_timeout.get());
1021 in_session->times.utime_after_lock+= value;
1033 return *(
trx_t**) session->getEngineData(innodb_engine_ptr);
1040 char *data=
new char[message.ByteSize()];
1042 message.SerializeToArray(data, message.ByteSize());
1046 uint64_t trx_id= message.transaction_context().transaction_id();
1047 uint32_t seg_id= message.segment_id();
1048 uint64_t end_timestamp= message.transaction_context().end_timestamp();
1049 bool is_end_segment= message.end_segment();
1052 string server_uuid= session.getServerUUID();
1053 string originating_server_uuid= session.getOriginatingServerUUID();
1054 uint64_t originating_commit_id= session.getOriginatingCommitID();
1055 bool use_originating_server_uuid= session.isOriginatingServerUUIDSet();
1057 ulint error= insert_replication_message(data, message.ByteSize(), trx, trx_id,
1058 end_timestamp, is_end_segment, seg_id, server_uuid.c_str(),
1059 use_originating_server_uuid, originating_server_uuid.c_str(),
1060 originating_commit_id);
1066 return plugin::SUCCESS;
1081 assert(
this == innodb_engine_ptr);
1083 if (!innodb_inited) {
1106 innobase_active_counter++;
1108 if ((innobase_active_counter % INNOBASE_WAKE_INTERVAL) == 0) {
1130 case DB_INTERRUPTED:
1131 my_error(ER_QUERY_INTERRUPTED, MYF(0));
1134 case DB_FOREIGN_EXCEED_MAX_CASCADE:
1135 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1136 HA_ERR_ROW_IS_REFERENCED,
1137 "InnoDB: Cannot delete/update "
1138 "rows with cascading foreign key "
1139 "constraints that exceed max "
1140 "depth of %d. Please "
1141 "drop extra constraints and try "
1149 case DB_DUPLICATE_KEY:
1156 return(HA_ERR_FOUND_DUPP_KEY);
1158 case DB_FOREIGN_DUPLICATE_KEY:
1159 return(HA_ERR_FOREIGN_DUPLICATE_KEY);
1161 case DB_MISSING_HISTORY:
1162 return(HA_ERR_TABLE_DEF_CHANGED);
1164 case DB_RECORD_NOT_FOUND:
1165 return(HA_ERR_NO_ACTIVE_RECORD);
1174 return(HA_ERR_LOCK_DEADLOCK);
1176 case DB_LOCK_WAIT_TIMEOUT:
1183 return(HA_ERR_LOCK_WAIT_TIMEOUT);
1185 case DB_NO_REFERENCED_ROW:
1186 return(HA_ERR_NO_REFERENCED_ROW);
1188 case DB_ROW_IS_REFERENCED:
1189 return(HA_ERR_ROW_IS_REFERENCED);
1191 case DB_CANNOT_ADD_CONSTRAINT:
1192 case DB_CHILD_NO_INDEX:
1193 case DB_PARENT_NO_INDEX:
1194 return(HA_ERR_CANNOT_ADD_FOREIGN);
1196 case DB_CANNOT_DROP_CONSTRAINT:
1198 return(HA_ERR_ROW_IS_REFERENCED);
1202 case DB_COL_APPEARS_TWICE_IN_INDEX:
1204 return(HA_ERR_CRASHED);
1206 case DB_OUT_OF_FILE_SPACE:
1207 return(HA_ERR_RECORD_FILE_FULL);
1209 case DB_TABLE_IS_BEING_USED:
1210 return(HA_ERR_WRONG_COMMAND);
1212 case DB_TABLE_NOT_FOUND:
1213 return(HA_ERR_NO_SUCH_TABLE);
1215 case DB_TOO_BIG_RECORD:
1216 my_error(ER_TOO_BIG_ROWSIZE, MYF(0),
1218 return(HA_ERR_TO_BIG_ROW);
1220 case DB_NO_SAVEPOINT:
1221 return(HA_ERR_NO_SAVEPOINT);
1223 case DB_LOCK_TABLE_FULL:
1230 return(HA_ERR_LOCK_TABLE_FULL);
1232 case DB_PRIMARY_KEY_IS_NULL:
1233 return(ER_PRIMARY_CANT_HAVE_NULL);
1235 case DB_TOO_MANY_CONCURRENT_TRXS:
1249 #ifdef HA_ERR_TOO_MANY_CONCURRENT_TRXS
1250 return(HA_ERR_TOO_MANY_CONCURRENT_TRXS);
1252 return(HA_ERR_RECORD_FILE_FULL);
1254 case DB_UNSUPPORTED:
1255 return(HA_ERR_UNSUPPORTED);
1271 drizzled::identifier::user::ptr user_identifier(in_session->user());
1274 "Drizzle thread %"PRIu64
", query id %"PRIu64
", %s, %s, %s ",
1276 static_cast<uint64_t>(in_session->
getQueryId()),
1277 getServerHostname().c_str(),
1278 user_identifier->address().c_str(),
1279 user_identifier->username().c_str()
1281 fprintf(f,
"\n%s", in_session->getQueryString()->c_str());
1300 cs = all_charsets[cset];
1302 *mbminlen = cs->mbminlen;
1303 *mbmaxlen = cs->mbmaxlen;
1304 ut_ad(*mbminlen < DATA_MBMAX);
1305 ut_ad(*mbmaxlen < DATA_MBMAX);
1308 *mbminlen = *mbmaxlen = 0;
1323 strncpy(to, from, len);
1337 strncpy(to, from, len);
1350 return(system_charset_info->strcasecmp(a, b));
1359 const char* path_name)
1361 const char* name = path_name + drizzled::internal::dirname_length(path_name);
1363 return((name) ? name :
"null");
1374 system_charset_info->casedn_str(a);
1383 return static_cast<const charset_info_st*
>(cs)->isspace(char_to_test);
1386 #if defined (__WIN__) && defined (MYSQL_DYNAMIC_PLUGIN)
1406 TCHAR path_buf[MAX_PATH - 14];
1410 char filename[MAX_PATH];
1411 DWORD fileaccess = GENERIC_READ
1414 DWORD fileshare = FILE_SHARE_READ
1416 | FILE_SHARE_DELETE;
1417 DWORD filecreate = CREATE_ALWAYS;
1419 FILE_ATTRIBUTE_NORMAL
1420 | FILE_FLAG_DELETE_ON_CLOSE
1421 | FILE_ATTRIBUTE_TEMPORARY
1422 | FILE_FLAG_SEQUENTIAL_SCAN;
1424 tmpdir = my_tmpdir(&mysql_tmpdir_list);
1431 ret = GetTempPath(
sizeof(path_buf), path_buf);
1432 if (ret >
sizeof(path_buf) || (ret == 0)) {
1434 _dosmaperr(GetLastError());
1442 if (!GetTempFileName(tmpdir,
"ib", 0, filename)) {
1444 _dosmaperr(GetLastError());
1449 osfh = CreateFile(filename, fileaccess, fileshare, NULL,
1450 filecreate, fileattrib, NULL);
1451 if (osfh == INVALID_HANDLE_VALUE) {
1454 _dosmaperr(GetLastError());
1460 fd = _open_osfhandle((intptr_t) osfh, 0);
1461 }
while (fd == -1 && errno == EINTR);
1466 _dosmaperr(GetLastError());
1483 int fd = ::drizzled::tmpfile(
"ib");
1496 my_error(EE_OUT_OF_FILERESOURCES,
1497 MYF(ME_BELL+ME_WAITTANG),
1500 internal::my_close(fd, MYF(MY_WME));
1557 uint64_t next_value;
1560 ut_a(increment > 0);
1564 if (offset > increment) {
1568 if (max_value <= current) {
1569 next_value = max_value;
1570 }
else if (offset <= 1) {
1573 if (max_value - current <= increment) {
1574 next_value = max_value;
1576 next_value = current + increment;
1578 }
else if (max_value > current) {
1579 if (current > offset) {
1580 next_value = ((current - offset) / increment) + 1;
1582 next_value = ((offset - current) / increment) + 1;
1585 ut_a(increment > 0);
1586 ut_a(next_value > 0);
1589 if (increment > (max_value / next_value)) {
1591 next_value = max_value;
1593 next_value *= increment;
1595 ut_a(max_value >= next_value);
1598 if (max_value - next_value <= offset) {
1599 next_value = max_value;
1601 next_value += offset;
1605 next_value = max_value;
1608 ut_a(next_value <= max_value);
1624 trx->check_foreigns = !session_test_options(
1625 session, OPTION_NO_FOREIGN_KEY_CHECKS);
1627 trx->check_unique_secondary = !session_test_options(
1628 session, OPTION_RELAXED_UNIQUE_CHECKS);
1644 assert(session != NULL);
1645 assert(EQ_CURRENT_SESSION(session));
1669 ut_ad(EQ_CURRENT_SESSION(session));
1673 }
else if (UNIV_UNLIKELY(trx->magic_n != TRX_MAGIC_N)) {
1689 :
Cursor(engine_arg, table_arg),
1744 char nz[NAME_LEN + 1];
1746 boost::scoped_array<char> nz2(
new char[nz2_size]);
1756 if (UNIV_UNLIKELY(idlen > (
sizeof nz) - 1)) {
1757 idlen = (
sizeof nz) - 1;
1760 memcpy(nz,
id, idlen);
1764 idlen = identifier::Table::filename_to_tablename(nz, nz2.get(), nz2_size);
1768 if (UNIV_UNLIKELY(!session)) {
1771 q = get_quote_char_for_identifier();
1775 if (UNIV_UNLIKELY(idlen > buflen)) {
1778 memcpy(buf, s, idlen);
1779 return(buf + idlen);
1790 for (; idlen; idlen--) {
1792 if (UNIV_UNLIKELY(c == q)) {
1793 if (UNIV_UNLIKELY(buflen < 3)) {
1801 if (UNIV_UNLIKELY(buflen < 2)) {
1831 const char* bufend = buf + buflen;
1834 const char* catalog_skip= (
const char*) memchr(
id,
'/', idlen);
1837 idlen = idlen - (catalog_skip - id);
1838 id = catalog_skip + 1;
1840 const char* slash = (
const char*) memchr(
id,
'/', idlen);
1849 if (UNIV_LIKELY(s < bufend)) {
1858 const char temp_index_suffix[]=
"--temporary--";
1862 if (s - buf + (
sizeof temp_index_suffix - 1) < buflen) {
1863 memcpy(s, temp_index_suffix,
1864 sizeof temp_index_suffix - 1);
1865 s +=
sizeof temp_index_suffix - 1;
1916 void align_value(T& value,
size_t align_val= 1024)
1918 value= value - (value % align_val);
1921 static void auto_extend_update(
Session *, sql_var_t)
1923 srv_auto_extend_increment= innodb_auto_extend_increment.get();
1926 static void io_capacity_update(
Session *, sql_var_t)
1928 srv_io_capacity= innodb_io_capacity.get();
1931 static void purge_batch_update(
Session *, sql_var_t)
1933 srv_purge_batch_size= innodb_purge_batch_size.get();
1936 static void purge_threads_update(
Session *, sql_var_t)
1938 srv_n_purge_threads= innodb_n_purge_threads.get();
1941 static void innodb_adaptive_hash_index_update(
Session *, sql_var_t)
1951 static void innodb_old_blocks_pct_update(
Session *, sql_var_t)
1956 static void innodb_thread_concurrency_update(
Session *, sql_var_t)
1958 srv_thread_concurrency= innobase_thread_concurrency.get();
1961 static void innodb_rollback_segments_update(
Session *, sql_var_t)
1963 srv_rollback_segments= innobase_rollback_segments.get();
1967 static void innodb_sync_spin_loops_update(
Session *, sql_var_t)
1969 srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1972 static void innodb_spin_wait_delay_update(
Session *, sql_var_t)
1974 srv_spin_wait_delay= innodb_spin_wait_delay.get();
1977 static void innodb_thread_sleep_delay_update(
Session *, sql_var_t)
1979 srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1982 static void innodb_read_ahead_threshold_update(
Session *, sql_var_t)
1984 srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1987 static void auto_lru_dump_update(
Session *, sql_var_t)
1992 static void ibuf_active_contract_update(
Session *, sql_var_t)
1994 srv_ibuf_active_contract= ibuf_active_contract.get();
1997 static void ibuf_accel_rate_update(
Session *, sql_var_t)
1999 srv_ibuf_accel_rate= ibuf_accel_rate.get();
2002 static void checkpoint_age_target_update(
Session *, sql_var_t)
2004 srv_checkpoint_age_target= checkpoint_age_target.get();
2007 static void flush_neighbor_pages_update(
Session *, sql_var_t)
2009 srv_flush_neighbor_pages= flush_neighbor_pages.get();
2014 uint64_t new_value= var->getInteger();
2016 if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
2017 (innobase_commit_concurrency.get() != 0 && new_value == 0))
2019 push_warning_printf(session,
2020 DRIZZLE_ERROR::WARN_LEVEL_WARN,
2022 _(
"Once InnoDB is running, innodb_commit_concurrency "
2023 "must not change between zero and nonzero."));
2040 const char *file_format_input = var->value->
str_value.ptr();
2041 if (file_format_input == NULL)
2044 if (file_format_input != NULL) {
2051 innobase_file_format_name =
2063 innodb_stats_method_validate(
2068 const char *stats_method_input = var->value->
str_value.ptr();
2070 if (stats_method_input == NULL)
2076 use < UT_ARR_SIZE(innodb_stats_method_names);
2079 innodb_stats_method_names[use]))
2081 srv_innodb_stats_method= use;
2082 innodb_stats_method= innodb_stats_method_names[use];
2102 const char *change_buffering_input = var->value->
str_value.ptr();
2104 if (change_buffering_input == NULL)
2110 use < UT_ARR_SIZE(innobase_change_buffering_values);
2113 innobase_change_buffering_values[use]))
2135 const char *file_format_input = var->value->
str_value.ptr();
2136 if (file_format_input == NULL)
2139 if (file_format_input != NULL) {
2147 if (format_id >= 0) {
2148 innobase_file_format_max.assign(
2152 const char *name_buff;
2156 errmsg_printf(error::WARN,
2157 " [Info] InnoDB: the file format in the system "
2158 "tablespace is now set to %s.\n", name_buff);
2159 innobase_file_format_max= name_buff;
2164 push_warning_printf(session,
2165 DRIZZLE_ERROR::WARN_LEVEL_WARN,
2167 "InnoDB: invalid innodb_file_format_max "
2168 "value; can be any format up to %s "
2169 "or equivalent id of %d",
2189 const char *read_ahead_input = var->value->
str_value.ptr();
2190 int res = read_ahead_typelib.find_type(read_ahead_input, TYPELIB::e_none);
2193 srv_read_ahead = res - 1;
2211 const char *adaptive_flushing_method_input = var->value->
str_value.ptr();
2212 int res = adaptive_flushing_method_typelib.find_type(adaptive_flushing_method_input, TYPELIB::e_none);
2215 srv_adaptive_flushing_method = res - 1;
2237 srv_auto_extend_increment= innodb_auto_extend_increment.get();
2238 srv_io_capacity= innodb_io_capacity.get();
2239 srv_purge_batch_size= innodb_purge_batch_size.get();
2240 srv_n_purge_threads= innodb_n_purge_threads.get();
2241 srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2242 srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2243 srv_max_purge_lag= innodb_max_purge_lag.get();
2244 srv_stats_sample_pages= innodb_stats_sample_pages.get();
2245 srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2246 srv_replication_delay= innodb_replication_delay.get();
2247 srv_thread_concurrency= innobase_thread_concurrency.get();
2248 srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2249 srv_spin_wait_delay= innodb_spin_wait_delay.get();
2250 srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2251 srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
2253 srv_ibuf_max_size= ibuf_max_size.get();
2254 srv_ibuf_active_contract= ibuf_active_contract.get();
2255 srv_ibuf_accel_rate= ibuf_accel_rate.get();
2256 srv_checkpoint_age_target= checkpoint_age_target.get();
2257 srv_flush_neighbor_pages= flush_neighbor_pages.get();
2258 srv_rollback_segments= innobase_rollback_segments.get();
2260 srv_read_ahead = read_ahead_typelib.find_type_or_exit(vm[
"read-ahead"].as<string>().c_str(),
2261 "read_ahead_typelib") + 1;
2263 srv_adaptive_flushing_method = adaptive_flushing_method_typelib.find_type_or_exit(vm[
"adaptive-flushing-method"].as<string>().c_str(),
2264 "adaptive_flushing_method_typelib") + 1;
2268 innobase_use_checksums= not vm.count(
"disable-checksums");
2269 innobase_use_doublewrite= not vm.count(
"disable-doublewrite");
2270 srv_adaptive_flushing= not vm.count(
"disable-adaptive-flushing");
2271 srv_use_sys_malloc= not vm.count(
"use-internal-malloc");
2272 srv_use_native_aio= not vm.count(
"disable-native-aio");
2273 support_xa= not vm.count(
"disable-xa");
2277 innobase_data_home_dir= vm.count(
"data-home-dir") ? vm[
"data-home-dir"].as<
string>() : getDataHome().file_string();
2279 if (vm.count(
"data-file-path"))
2281 innobase_data_file_path= vm[
"data-file-path"].as<
string>();
2285 innodb_engine_ptr= actuall_engine_ptr=
new InnobaseEngine(innobase_engine_name);
2287 ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)DRIZZLE_TYPE_VARCHAR);
2290 static const char test_filename[] =
"-@";
2291 const size_t test_tablename_size=
sizeof test_filename
2293 boost::scoped_array test_tablename(
new char[test_tablename_size]);
2294 if ((test_tablename_size) - 1
2295 != filename_to_tablename(test_filename, test_tablename.get(),
2296 test_tablename_size)
2297 || strncmp(test_tablename.get(),
2300 || strcmp(test_tablename.get()
2303 errmsg_printf(error::ERROR,
"tablename encoding has been changed");
2309 srv_page_size_shift = 0;
2311 uint32_t page_size = innobase_page_size.get();
2312 uint32_t log_block_size = innobase_log_block_size.get();
2314 if (innobase_page_size != (1 << 14)) {
2317 errmsg_printf(error::WARN,
2318 "InnoDB: Warning: innodb_page_size has been changed from default value 16384. (###EXPERIMENTAL### operation)\n");
2319 for (n_shift = 12; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) {
2320 if (innobase_page_size == (1UL << n_shift)) {
2321 srv_page_size_shift = n_shift;
2322 srv_page_size = (1 << srv_page_size_shift);
2323 errmsg_printf(error::WARN,
2324 "InnoDB: The universal page size of the database is set to %lu.\n",
2330 srv_page_size_shift = 14;
2331 srv_page_size = (1 << srv_page_size_shift);
2334 if (!srv_page_size_shift) {
2335 errmsg_printf(error::ERROR,
2336 "InnoDB: Error: %"PRIu32
" is not a valid value for innodb_page_size.\n"
2337 "InnoDB: Error: Valid values are 4096, 8192, and 16384 (default=16384).\n",
2342 srv_log_block_size = 0;
2343 if (log_block_size != (1 << 9)) {
2346 errmsg_printf(error::WARN,
2347 "InnoDB: Warning: innodb_log_block_size has been changed from default value 512. (###EXPERIMENTAL### operation)\n");
2348 for (n_shift = 9; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) {
2349 if (log_block_size == (1UL << n_shift)) {
2350 srv_log_block_size = (1 << n_shift);
2351 errmsg_printf(error::WARN,
"InnoDB: The log block size is set to %"PRIu32
".\n",
2352 srv_log_block_size);
2357 srv_log_block_size = 512;
2360 if (!srv_log_block_size) {
2361 errmsg_printf(error::ERROR,
2362 "InnoDB: Error: %"PRIu32
" is not a valid value for innodb_log_block_size.\n"
2363 "InnoDB: Error: A valid value for innodb_log_block_size is\n"
2364 "InnoDB: Error: a power of 2 from 512 to 16384.\n",
2379 srv_data_home = (
char *)innobase_data_home_dir.c_str();
2385 if (innobase_data_file_path.empty())
2387 innobase_data_file_path= std::string(
"ibdata1:10M:autoextend");
2393 internal_innobase_data_file_path = strdup(innobase_data_file_path.c_str());
2396 internal_innobase_data_file_path);
2398 errmsg_printf(error::ERROR,
"InnoDB: syntax error in innodb_data_file_path");
2402 free(internal_innobase_data_file_path);
2410 if (vm.count(
"log-group-home-dir"))
2412 innobase_log_group_home_dir= vm[
"log-group-home-dir"].as<
string>();
2416 innobase_log_group_home_dir= getDataHome().file_string();
2422 if (ret == FALSE || innobase_mirrored_log_groups.get() != 1) {
2423 errmsg_printf(error::ERROR, _(
"syntax error in innodb_log_group_home_dir, or a "
2424 "wrong number of mirrored log groups"));
2426 goto mem_free_and_error;
2431 if (vm.count(
"file-format"))
2434 vm[
"file-format"].as<string>().c_str());
2438 errmsg_printf(error::ERROR,
"InnoDB: wrong innodb_file_format.");
2440 goto mem_free_and_error;
2449 innobase_file_format_name =
2453 if (!innobase_file_format_check)
2467 errmsg_printf(error::ERROR, _(
"InnoDB: invalid innodb_file_format_max value: "
2468 "should be any value up to %s or its equivalent numeric id"),
2470 goto mem_free_and_error;
2473 if (vm.count(
"change-buffering"))
2478 use < UT_ARR_SIZE(innobase_change_buffering_values);
2481 innobase_change_buffering.c_str(),
2482 innobase_change_buffering_values[use])) {
2484 goto innobase_change_buffering_inited_ok;
2488 errmsg_printf(error::ERROR,
"InnoDB: invalid value innodb_change_buffering=%s",
2489 vm[
"change-buffering"].as<string>().c_str());
2490 goto mem_free_and_error;
2493 innobase_change_buffering_inited_ok:
2494 ut_a((ulint)
ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
2495 innobase_change_buffering = innobase_change_buffering_values[
ibuf_use];
2499 if (vm.count(
"flush-method") != 0)
2501 srv_file_flush_method_str = (
char *)vm[
"flush-method"].as<string>().c_str();
2504 srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
2505 srv_n_log_files = (ulint) innobase_log_files_in_group;
2506 srv_log_file_size = (ulint) innobase_log_file_size;
2508 srv_log_buffer_size = (ulint) innobase_log_buffer_size;
2513 srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
2515 srv_n_read_io_threads = (ulint) innobase_read_io_threads;
2516 srv_n_write_io_threads = (ulint) innobase_write_io_threads;
2518 srv_read_ahead &= 3;
2519 srv_adaptive_flushing_method %= 3;
2521 srv_force_recovery = (ulint) innobase_force_recovery;
2523 srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
2524 srv_use_checksums = (ibool) innobase_use_checksums;
2526 #ifdef HAVE_LARGE_PAGES
2527 if ((os_use_large_pages = (ibool) my_use_large_pages))
2528 os_large_page_size = (ulint) opt_large_page_size;
2535 srv_max_n_open_files = (ulint) innobase_open_files;
2536 srv_innodb_status = (ibool) innobase_create_status_file;
2538 srv_print_verbose_log =
true;
2543 data_mysql_default_charset_coll = (ulint)default_charset_info->number;
2553 if (err != DB_SUCCESS)
2555 goto mem_free_and_error;
2558 err = dict_create_sys_replication_log();
2560 if (err != DB_SUCCESS) {
2561 goto mem_free_and_error;
2571 actuall_engine_ptr->dropTemporarySchema();
2574 context.add(innodb_engine_ptr);
2575 context.add(
new CmpTool(
false));
2576 context.add(
new CmpTool(
true));
2592 if (innobase_use_replication_log)
2595 context.add(replication_logger);
2596 ReplicationLog::setup(replication_logger, sysvar_transaction_log_use_replicator);
2601 vm.count(
"flush-method") ? vm[
"flush-method"].as<
string>() :
""));
2612 context.registerVariable(
new sys_var_bool_ptr(
"adaptive-flushing", &srv_adaptive_flushing));
2613 context.registerVariable(
new sys_var_bool_ptr(
"status-file", &innobase_create_status_file));
2618 context.registerVariable(
new sys_var_bool_ptr(
"strict_mode", &strict_mode));
2623 innodb_auto_extend_increment,
2624 auto_extend_update));
2627 io_capacity_update));
2629 innodb_purge_batch_size,
2630 purge_batch_update));
2632 innodb_n_purge_threads,
2633 purge_threads_update));
2636 innobase_file_format_name,
2639 innobase_change_buffering,
2642 innobase_file_format_max,
2649 innodb_flush_log_at_trx_commit));
2651 innodb_max_dirty_pages_pct));
2656 innodb_stats_method,
2657 innodb_stats_method_validate));
2660 innobase_commit_concurrency,
2661 innodb_commit_concurrency_validate));
2663 innodb_concurrency_tickets));
2673 innobase_old_blocks_pct,
2674 innodb_old_blocks_pct_update));
2680 innobase_thread_concurrency,
2681 innodb_thread_concurrency_update));
2683 innodb_read_ahead_threshold,
2684 innodb_read_ahead_threshold_update));
2686 buffer_pool_restore_at_startup,
2687 auto_lru_dump_update));
2691 ibuf_active_contract,
2692 ibuf_active_contract_update));
2695 ibuf_accel_rate_update));
2697 checkpoint_age_target,
2698 checkpoint_age_target_update));
2700 flush_neighbor_pages,
2701 flush_neighbor_pages_update));
2706 adaptive_flushing_method,
2713 sysvar_transaction_log_use_replicator));
2716 innobase_rollback_segments,
2717 innodb_rollback_segments_update));
2736 assert(
this == innodb_engine_ptr);
2770 start_transaction_option_t options)
2772 assert(
this == innodb_engine_ptr);
2786 if (options == START_TRANS_OPT_WITH_CONS_SNAPSHOT)
2806 assert(
this == innodb_engine_ptr);
2813 if (trx->has_search_latch) {
2825 const uint32_t commit_concurrency= innobase_commit_concurrency.get();
2826 if (commit_concurrency)
2830 boost::mutex::scoped_lock scopedLock(commit_cond_m);
2837 commit_cond.wait(scopedLock);
2841 trx->mysql_log_file_name = NULL;
2842 trx->mysql_log_offset = 0;
2847 trx->flush_log_later = TRUE;
2849 trx->flush_log_later = FALSE;
2851 if (commit_concurrency)
2853 boost::mutex::scoped_lock scopedLock(commit_cond_m);
2855 commit_cond.notify_one();
2876 if (! session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
2880 commit(session, TRUE);
2887 if (trx->declared_to_be_inside_innodb) {
2897 if (trx->isolation_level <= TRX_ISO_READ_COMMITTED &&
2898 trx->global_read_view)
2922 assert(
this == innodb_engine_ptr);
2947 if (trx->isolation_level <= TRX_ISO_READ_COMMITTED &&
2948 trx->global_read_view)
2997 ib_int64_t mysql_binlog_cache_pos;
3001 assert(
this == innodb_engine_ptr);
3012 &mysql_binlog_cache_pos);
3030 assert(
this == innodb_engine_ptr);
3051 assert(
this == innodb_engine_ptr);
3086 assert(
this == innodb_engine_ptr);
3091 assert(session->getKilled() != Session::NOT_KILLED ||
3095 if (session->getKilled() != Session::NOT_KILLED &&
3098 global_system_variables.log_warnings)
3100 errmsg_printf(error::WARN,
3101 "Drizzle is closing a connection during a KILL operation\n"
3102 "that has an active InnoDB transaction. %llu row modifications will "
3165 return(&key_map_full);
3188 uint64_t max_value = 0;
3190 switch(field->key_type()) {
3192 case HA_KEYTYPE_BINARY:
3193 max_value = 0xFFULL;
3196 case HA_KEYTYPE_ULONG_INT:
3197 max_value = 0xFFFFFFFFULL;
3199 case HA_KEYTYPE_LONG_INT:
3200 max_value = 0x7FFFFFFFULL;
3203 case HA_KEYTYPE_ULONGLONG:
3204 max_value = 0xFFFFFFFFFFFFFFFFULL;
3206 case HA_KEYTYPE_LONGLONG:
3207 max_value = 0x7FFFFFFFFFFFFFFFULL;
3209 case HA_KEYTYPE_DOUBLE:
3211 max_value = 0x20000000000000ULL;
3243 key_part = key_info->key_part;
3244 key_end = key_part + key_info->key_parts;
3245 innodb_idx_fld = index_info->
fields;
3254 for (; key_part != key_end; ++key_part) {
3257 ulint mtype = innodb_idx_fld->
col->
mtype;
3265 while (mtype == DATA_SYS) {
3268 if (innodb_idx_fld >= innodb_idx_fld_end) {
3273 if (col_type != mtype) {
3307 ulint mysql_num_index;
3314 mysql_num_index = table->getShare()->keys;
3323 if (UNIV_UNLIKELY(ib_num_index < mysql_num_index)) {
3338 index_mapping = (
dict_index_t**) realloc(index_mapping,
3340 sizeof(*index_mapping));
3342 if (!index_mapping) {
3345 errmsg_printf(error::ERROR,
"InnoDB: fail to allocate memory for "
3346 "index translation table. Number of Index:%lu, array size:%lu",
3359 for (ulint count = 0; count < mysql_num_index; count++) {
3364 ib_table, table->
key_info[count].name);
3366 if (!index_mapping[count]) {
3367 errmsg_printf(error::ERROR,
"Cannot find index %s in InnoDB index dictionary.",
3376 errmsg_printf(error::ERROR,
"Found index %s whose column info does not match that of MySQL.",
3389 free(index_mapping);
3393 index_mapping = NULL;
3440 if (field != NULL) {
3449 errmsg_printf(error::ERROR,
"InnoDB: Unable to determine the AUTOINC column name");
3464 }
else if (field == NULL) {
3467 my_error(ER_AUTOINC_READ_FAILED, MYF(0));
3470 const char* col_name;
3471 uint64_t read_auto_inc;
3486 uint64_t col_max_value;
3497 case DB_RECORD_NOT_FOUND:
3499 errmsg_printf(error::ERROR,
"InnoDB: MySQL and InnoDB data dictionaries are out of sync.\n"
3500 "InnoDB: Unable to find the AUTOINC column %s in the InnoDB table %s.\n"
3501 "InnoDB: We set the next AUTOINC column value to 0,\n"
3502 "InnoDB: in effect disabling the AUTOINC next value generation.\n"
3503 "InnoDB: You can either set the next AUTOINC value explicitly using ALTER TABLE\n"
3504 "InnoDB: or fix the data dictionary by recreating the table.\n",
3533 uint test_if_locked)
3541 session= getTable()->
in_use;
3546 if (session != NULL) {
3552 std::string search_string(identifier.getSchemaName());
3553 boost::algorithm::to_lower(search_string);
3555 if (search_string.compare(
"data_dictionary") == 0)
3557 std::string table_name(identifier.getTableName());
3558 boost::algorithm::to_upper(table_name);
3577 upd_and_key_val_buff_len =
3578 getTable()->getShare()->sizeStoredRecord()
3579 + getTable()->getShare()->max_key_length
3580 + MAX_REF_PARTS * 3;
3582 upd_buff.resize(upd_and_key_val_buff_len);
3584 if (
upd_buff.size() < upd_and_key_val_buff_len)
3596 if (search_string.compare(
"data_dictionary") == 0)
3598 std::string table_name(identifier.getTableName());
3599 boost::algorithm::to_upper(table_name);
3604 ib_table =
dict_table_get(identifier.getKeyPath().c_str(), TRUE);
3605 if (ib_table == NULL
3608 std::string table_path_no_catalog(identifier.getKeyPath());
3609 table_path_no_catalog.erase(0, drizzled::catalog::local_identifier().getPath().length()+1);
3616 if (NULL == ib_table) {
3617 errmsg_printf(error::ERROR,
"Cannot find or open table %s from\n"
3618 "the internal data dictionary of InnoDB "
3619 "though the .frm file for the\n"
3620 "table exists. Maybe you have deleted and "
3621 "recreated InnoDB data\n"
3622 "files but have forgotten to delete the "
3623 "corresponding .frm files\n"
3624 "of InnoDB tables, or you have moved .frm "
3625 "files to another database?\n"
3626 "or, the table contains indexes that this "
3627 "version of the engine\n"
3628 "doesn't support.\n"
3629 "See " REFMAN
"innodb-troubleshooting.html\n"
3630 "how you can resolve the problem.\n",
3631 identifier.getKeyPath().c_str());
3637 return(HA_ERR_NO_SUCH_TABLE);
3640 if (ib_table->
ibd_file_missing && ! session->doing_tablespace_operation()) {
3641 errmsg_printf(error::ERROR,
"MySQL is trying to open a table handle but "
3642 "the .ibd file for\ntable %s does not exist.\n"
3643 "Have you deleted the .ibd file from the "
3644 "database directory under\nthe MySQL datadir, "
3645 "or have you used DISCARD TABLESPACE?\n"
3646 "See " REFMAN
"innodb-troubleshooting.html\n"
3647 "how you can resolve the problem.\n",
3648 identifier.getKeyPath().c_str());
3655 return(HA_ERR_NO_SUCH_TABLE);
3666 primary_key = getTable()->getShare()->getPrimaryKey();
3667 key_used_on_scan = primary_key;
3670 errmsg_printf(error::ERROR,
"Build InnoDB index translation table for"
3671 " Table %s failed", identifier.getKeyPath().c_str());
3684 if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) {
3685 errmsg_printf(error::ERROR,
"Table %s has a primary key in "
3686 "InnoDB data dictionary, but not "
3687 "in MySQL!", identifier.getTableName().c_str());
3693 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3695 "InnoDB: Table %s has a "
3696 "primary key in InnoDB data "
3697 "dictionary, but not in "
3698 "MySQL!", identifier.getTableName().c_str());
3720 for (ulint i = 0; i < getTable()->getShare()->keys; i++) {
3725 getTable()->
key_info[i].key_length;
3739 if (primary_key != MAX_KEY) {
3740 errmsg_printf(error::ERROR,
3741 "Table %s has no primary key in InnoDB data "
3742 "dictionary, but has one in MySQL! If you "
3743 "created the table with a MySQL version < "
3744 "3.23.54 and did not define a primary key, "
3745 "but defined a unique key with all non-NULL "
3746 "columns, then MySQL internally treats that "
3747 "key as the primary key. You can fix this "
3748 "error by dump + DROP + CREATE + reimport "
3749 "of the table.", identifier.getTableName().c_str());
3755 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3757 "InnoDB: Table %s has no "
3758 "primary key in InnoDB data "
3759 "dictionary, but has one in "
3760 "MySQL!", identifier.getTableName().c_str());
3775 if (key_used_on_scan != MAX_KEY) {
3776 errmsg_printf(error::WARN,
3777 "Table %s key_used_on_scan is %lu even "
3778 "though there is no primary key inside "
3779 "InnoDB.", identifier.getTableName().c_str(), (ulong) key_used_on_scan);
3784 stats.block_size = 16 * 1024;
3793 char changed_file_format_max[100];
3794 strcpy(changed_file_format_max, innobase_file_format_max.c_str());
3797 innobase_file_format_max= changed_file_format_max;
3801 if (
prebuilt->
table != NULL && getTable()->found_next_number_field != NULL) {
3817 info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
3824 InnobaseEngine::max_supported_key_part_length()
const
3839 session= getTable()->
in_use;
3840 if (session != NULL) {
3870 return((uint) (field->
ptr - table->getInsertRecord()));
3892 null_offset = (uint) ((
char*) field->
null_ptr
3893 - (
char*) table->getInsertRecord());
3895 if (record[null_offset] & field->
null_bit) {
3916 null_offset = (uint) ((
char*) field->
null_ptr
3917 - (
char*) table->getInsertRecord());
3919 record[null_offset] = record[null_offset] | field->
null_bit;
3932 uint charset_number,
3933 const unsigned char* a,
3934 unsigned int a_length,
3936 const unsigned char* b,
3937 unsigned int b_length);
3945 uint charset_number,
3946 const unsigned char* a,
3947 unsigned int a_length,
3948 const unsigned char* b,
3949 unsigned int b_length)
3952 enum_field_types mysql_tp;
3955 assert(a_length != UNIV_SQL_NULL);
3956 assert(b_length != UNIV_SQL_NULL);
3958 mysql_tp = (enum_field_types) mysql_type;
3962 case DRIZZLE_TYPE_BLOB:
3963 case DRIZZLE_TYPE_VARCHAR:
3969 if (charset_number == default_charset_info->number) {
3970 charset = default_charset_info;
3972 charset = get_charset(charset_number);
3974 if (charset == NULL) {
3975 errmsg_printf(error::ERROR,
"InnoDB needs charset %lu for doing "
3976 "a comparison, but MySQL cannot "
3977 "find that charset.",
3978 (ulong) charset_number);
3988 ret = charset->coll->strnncollsp(charset,
3993 }
else if (ret > 0) {
4014 ulint* unsigned_flag,
4021 const class Field* field =
reinterpret_cast<const class
Field*
>(f);
4027 assert((ulint)DRIZZLE_TYPE_DOUBLE < 256);
4029 if (field->flags & UNSIGNED_FLAG) {
4031 *unsigned_flag = DATA_UNSIGNED;
4036 if (field->real_type() == DRIZZLE_TYPE_ENUM)
4042 *unsigned_flag = DATA_UNSIGNED;
4049 switch (field->type()) {
4052 case DRIZZLE_TYPE_VARCHAR:
4053 if (field->binary()) {
4054 return(DATA_BINARY);
4056 return(DATA_VARMYSQL);
4058 case DRIZZLE_TYPE_DECIMAL:
4059 case DRIZZLE_TYPE_MICROTIME:
4060 return(DATA_FIXBINARY);
4061 case DRIZZLE_TYPE_LONG:
4062 case DRIZZLE_TYPE_LONGLONG:
4063 case DRIZZLE_TYPE_DATETIME:
4064 case DRIZZLE_TYPE_TIME:
4065 case DRIZZLE_TYPE_DATE:
4066 case DRIZZLE_TYPE_TIMESTAMP:
4067 case DRIZZLE_TYPE_ENUM:
4069 case DRIZZLE_TYPE_DOUBLE:
4070 return(DATA_DOUBLE);
4071 case DRIZZLE_TYPE_BLOB:
4073 case DRIZZLE_TYPE_BOOLEAN:
4074 case DRIZZLE_TYPE_UUID:
4075 return(DATA_FIXBINARY);
4076 case DRIZZLE_TYPE_IPV6:
4077 return(DATA_FIXBINARY);
4078 case DRIZZLE_TYPE_NULL:
4095 ut_a(val < 256 * 256);
4097 buf[0] = (byte)(val & 0xFF);
4098 buf[1] = (byte)(val / 256);
4109 const unsigned char* buf)
4111 return (uint) ((ulint)(buf[0]) + 256 * ((ulint)(buf[1])));
4125 const unsigned char* record)
4129 KeyPartInfo* end = key_part + key_info->key_parts;
4130 char* buff_start = buff;
4131 enum_field_types mysql_type;
4160 bzero(buff, buff_len);
4162 for (; key_part != end; key_part++) {
4165 if (key_part->null_bit) {
4166 if (record[key_part->null_offset]
4167 & key_part->null_bit) {
4176 field = key_part->field;
4177 mysql_type = field->type();
4179 if (mysql_type == DRIZZLE_TYPE_VARCHAR) {
4189 key_len = key_part->length;
4192 buff += key_len + 2;
4196 cs = field->charset();
4211 if (len > 0 && cs->mbmaxlen > 1) {
4212 true_len = (ulint) cs->cset->well_formed_len(*cs,
str_ref(data, len), (uint) (key_len / cs->mbmaxlen), &error);
4218 if (true_len > key_len) {
4228 memcpy(buff, data, true_len);
4238 }
else if (mysql_type == DRIZZLE_TYPE_BLOB) {
4245 const byte* blob_data;
4247 ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
4249 key_len = key_part->length;
4252 buff += key_len + 2;
4257 cs = field->charset();
4264 true_len = blob_len;
4267 == key_part->offset);
4272 if (blob_len > 0 && cs->mbmaxlen > 1) {
4273 true_len = (ulint) cs->cset->well_formed_len(*cs,
str_ref(blob_data, blob_len), (uint) (key_len / cs->mbmaxlen), &error);
4280 if (true_len > key_len) {
4288 (byte*)buff, true_len);
4291 memcpy(buff, blob_data, true_len);
4305 const unsigned char* src_start;
4308 key_len = key_part->length;
4316 src_start = record + key_part->offset;
4324 memcpy(buff, src_start, true_len);
4329 if (true_len < key_len) {
4330 ulint pad_len = key_len - true_len;
4331 ut_a(!(pad_len % cs->mbminlen));
4333 cs->cset->fill(cs, buff, pad_len,
4340 ut_a(buff <= buff_start + buff_len);
4342 return((uint)(buff - buff_start));
4365 ulint n_requested_fields = 0;
4366 ibool fetch_all_in_key = FALSE;
4367 ibool fetch_primary_key_cols = FALSE;
4370 ulint mysql_prefix_len = 0;
4377 templ_type = ROW_MYSQL_WHOLE_ROW;
4380 if (templ_type == ROW_MYSQL_REC_FIELDS) {
4382 == ROW_RETRIEVE_ALL_COLS) {
4395 fetch_all_in_key = TRUE;
4397 templ_type = ROW_MYSQL_WHOLE_ROW;
4400 == ROW_RETRIEVE_PRIMARY_KEY) {
4408 fetch_primary_key_cols = TRUE;
4412 clust_index = dict_table_get_first_index(prebuilt->
table);
4414 if (templ_type == ROW_MYSQL_REC_FIELDS) {
4415 index = prebuilt->
index;
4417 index = clust_index;
4420 if (index == clust_index) {
4428 n_fields = (ulint)table->getShare()->sizeFields();
4442 for (i = 0; i < n_fields; i++)
4446 field = table->getField(i);
4448 if (UNIV_LIKELY(templ_type == ROW_MYSQL_REC_FIELDS)) {
4451 register const ibool index_contains_field =
4461 if (index_contains_field && fetch_all_in_key) {
4467 if (field->isReadSet() || field->isWriteSet())
4471 assert(table->isReadSet(i) == field->isReadSet());
4472 assert(table->isWriteSet(i) == field->isWriteSet());
4474 if (fetch_primary_key_cols
4487 n_requested_fields++;
4493 if (index == clust_index) {
4506 - (
char*) table->getInsertRecord());
4517 if (mysql_prefix_len < templ->mysql_col_offset
4525 if (templ->
mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
4534 if (templ->
type == DATA_BLOB) {
4547 for (i = 0; i < n_requested_fields; i++) {
4567 ulint error = DB_SUCCESS;
4571 return(ulong(error));
4587 return(ulong(DB_SUCCESS));
4604 return(ulong(DB_SUCCESS));
4615 unsigned char* record)
4618 int error_result= 0;
4619 ibool auto_inc_used= FALSE;
4624 errmsg_printf(error::ERROR,
"The transaction object for the table handle is at "
4625 "%p, but for the current thread it is at %p",
4628 fputs(
"InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
4631 "InnoDB: Dump of 200 bytes around ha_data: ",
4640 if ((sql_command == SQLCOM_ALTER_TABLE
4641 || sql_command == SQLCOM_CREATE_INDEX
4642 || sql_command == SQLCOM_DROP_INDEX)
4654 enum lock_mode mode;
4706 if (getTable()->next_number_field && record == getTable()->getInsertRecord()) {
4712 if ((error = update_auto_increment())) {
4718 error_result = ER_AUTOINC_READ_FAILED;
4720 my_error(ER_AUTOINC_READ_FAILED, MYF(0));
4729 error_result = (int) error;
4733 auto_inc_used = TRUE;
4752 if (auto_inc_used) {
4755 uint64_t col_max_value;
4768 getTable()->next_number_field);
4773 case DB_DUPLICATE_KEY:
4780 switch (sql_command) {
4783 & (TRX_DUP_IGNORE | TRX_DUP_REPLACE))) {
4785 goto set_max_autoinc;
4789 case SQLCOM_REPLACE:
4790 case SQLCOM_INSERT_SELECT:
4791 case SQLCOM_REPLACE_SELECT:
4792 goto set_max_autoinc;
4810 if (auto_inc <= col_max_value) {
4821 need, offset, col_max_value);
4826 if (err != DB_SUCCESS) {
4845 return(error_result);
4857 unsigned char* old_row,
4858 unsigned char* new_row,
4861 unsigned char* upd_buff,
4866 unsigned char* original_upd_buff = upd_buff;
4867 enum_field_types field_mysql_type;
4872 const byte* new_mysql_row_col;
4878 ulint n_changed = 0;
4883 n_fields = table->getShare()->sizeFields();
4884 clust_index = dict_table_get_first_index(prebuilt->
table);
4887 buf = (byte*) upd_buff;
4889 for (i = 0; i < n_fields; i++) {
4890 Field *field= table->getField(i);
4897 new_mysql_row_col = n_ptr;
4900 o_len = col_pack_len;
4901 n_len = col_pack_len;
4906 field_mysql_type = field->type();
4921 if (field_mysql_type == DRIZZLE_TYPE_VARCHAR) {
4945 o_len = UNIV_SQL_NULL;
4950 n_len = UNIV_SQL_NULL;
4954 if (o_len != n_len || (o_len != UNIV_SQL_NULL &&
4955 0 != memcmp(o_ptr, n_ptr, o_len))) {
4958 ufield = uvect->
fields + n_changed;
4966 if (n_len != UNIV_SQL_NULL) {
4982 &prebuilt->
table->
cols[i], clust_index);
4990 ut_a(buf <= (byte*)original_upd_buff + buff_len);
5007 const unsigned char* old_row,
5008 unsigned char* new_row)
5026 &
upd_buff[0], (ulint)upd_and_key_val_buff_len,
5034 if (getTable()->found_next_number_field)
5037 uint64_t col_max_value;
5044 getTable()->found_next_number_field);
5046 uint64_t current_autoinc;
5048 if (autoinc_error == DB_SUCCESS
5049 && auto_inc <= col_max_value && auto_inc != 0
5050 && auto_inc >= current_autoinc)
5060 auto_inc, need, offset, col_max_value);
5082 if (error == DB_SUCCESS
5083 && getTable()->next_number_field
5084 && new_row == getTable()->getInsertRecord()
5086 && (trx->
duplicates & (TRX_DUP_IGNORE | TRX_DUP_REPLACE))
5087 == TRX_DUP_IGNORE) {
5090 uint64_t col_max_value;
5097 getTable()->next_number_field);
5099 if (auto_inc <= col_max_value && auto_inc != 0) {
5108 auto_inc, need, offset, col_max_value);
5127 error = HA_ERR_RECORD_IS_THE_SAME;
5145 const unsigned char* record)
5196 case ROW_READ_WITH_LOCKS:
5199 > TRX_ISO_READ_COMMITTED) {
5203 case ROW_READ_TRY_SEMI_CONSISTENT:
5206 case ROW_READ_DID_SEMI_CONSISTENT:
5238 ||
prebuilt->
trx->isolation_level <= TRX_ISO_READ_COMMITTED)) {
5267 active_index=MAX_KEY;
5278 enum ha_rkey_function find_flag)
5280 switch (find_flag) {
5281 case HA_READ_KEY_EXACT:
5283 return(PAGE_CUR_GE);
5284 case HA_READ_KEY_OR_NEXT:
5285 return(PAGE_CUR_GE);
5286 case HA_READ_KEY_OR_PREV:
5287 return(PAGE_CUR_LE);
5288 case HA_READ_AFTER_KEY:
5290 case HA_READ_BEFORE_KEY:
5292 case HA_READ_PREFIX:
5293 return(PAGE_CUR_GE);
5294 case HA_READ_PREFIX_LAST:
5295 return(PAGE_CUR_LE);
5296 case HA_READ_PREFIX_LAST_OR_PREV:
5297 return(PAGE_CUR_LE);
5311 case HA_READ_MBR_CONTAIN:
5312 case HA_READ_MBR_INTERSECT:
5313 case HA_READ_MBR_WITHIN:
5314 case HA_READ_MBR_DISJOINT:
5315 case HA_READ_MBR_EQUAL:
5316 return(PAGE_CUR_UNSUPP);
5322 my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0),
"this functionality");
5324 return(PAGE_CUR_UNSUPP);
5395 const unsigned char* key_ptr,
5405 enum ha_rkey_function find_flag)
5409 ulint match_mode = 0;
5415 ha_statistic_increment(&system_status_var::ha_read_key_count);
5419 if (UNIV_UNLIKELY(index == NULL)) {
5421 return(HA_ERR_CRASHED);
5425 return(HA_ERR_TABLE_DEF_CHANGED);
5433 ROW_MYSQL_REC_FIELDS);
5443 (ulint)upd_and_key_val_buff_len,
5459 if (find_flag == HA_READ_KEY_EXACT) {
5463 }
else if (find_flag == HA_READ_PREFIX
5464 || find_flag == HA_READ_PREFIX_LAST) {
5469 last_match_mode = (uint) match_mode;
5471 if (mode != PAGE_CUR_UNSUPP) {
5481 ret = DB_UNSUPPORTED;
5487 getTable()->status = 0;
5489 case DB_RECORD_NOT_FOUND:
5490 error = HA_ERR_KEY_NOT_FOUND;
5491 getTable()->status = STATUS_NOT_FOUND;
5493 case DB_END_OF_INDEX:
5494 error = HA_ERR_KEY_NOT_FOUND;
5495 getTable()->status = STATUS_NOT_FOUND;
5501 getTable()->status = STATUS_NOT_FOUND;
5517 const unsigned char* key_ptr,
5522 return(
index_read(buf, key_ptr, key_len, HA_READ_PREFIX_LAST));
5538 ha_statistic_increment(&system_status_var::ha_read_key_count);
5540 if (keynr != MAX_KEY && getTable()->getShare()->sizeKeys() > 0)
5552 errmsg_printf(error::ERROR,
5553 "InnoDB could not find "
5554 "index %s key no %u for "
5555 "table %s through its "
5556 "index translation table",
5557 key ? key->name :
"NULL",
5570 errmsg_printf(error::ERROR,
5571 "Innodb could not find key n:o %u with name %s "
5572 "from dict cache for table %s",
5573 keynr, getTable()->getShare()->getTableMessage()->indexes(keynr).name().c_str(),
5594 active_index = keynr;
5599 errmsg_printf(error::WARN,
"InnoDB: change_active_index(%u) failed",
5609 push_warning_printf(
user_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
5610 HA_ERR_TABLE_DEF_CHANGED,
5611 "InnoDB: insufficient history for index %u",
5648 const unsigned char* key,
5652 enum ha_rkey_function find_flag)
5659 return(
index_read(buf, key, key_len, find_flag));
5684 (byte*)buf, 0,
prebuilt, match_mode, direction);
5691 getTable()->status = 0;
5693 case DB_RECORD_NOT_FOUND:
5694 error = HA_ERR_END_OF_FILE;
5695 getTable()->status = STATUS_NOT_FOUND;
5697 case DB_END_OF_INDEX:
5698 error = HA_ERR_END_OF_FILE;
5699 getTable()->status = STATUS_NOT_FOUND;
5704 getTable()->status = STATUS_NOT_FOUND;
5722 ha_statistic_increment(&system_status_var::ha_read_next_count);
5735 const unsigned char* ,
5738 ha_statistic_increment(&system_status_var::ha_read_next_count);
5753 ha_statistic_increment(&system_status_var::ha_read_prev_count);
5770 ha_statistic_increment(&system_status_var::ha_read_first_count);
5772 error =
index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
5776 if (error == HA_ERR_KEY_NOT_FOUND) {
5777 error = HA_ERR_END_OF_FILE;
5795 ha_statistic_increment(&system_status_var::ha_read_last_count);
5797 error =
index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
5801 if (error == HA_ERR_KEY_NOT_FOUND) {
5802 error = HA_ERR_END_OF_FILE;
5864 ha_statistic_increment(&system_status_var::ha_read_rnd_next_count);
5869 if (error == HA_ERR_KEY_NOT_FOUND) {
5870 error = HA_ERR_END_OF_FILE;
5895 uint keynr = active_index;
5897 ha_statistic_increment(&system_status_var::ha_read_rnd_count);
5941 const unsigned char* record)
5953 len = DATA_ROW_ID_LEN;
5965 errmsg_printf(error::ERROR,
"Stored ref len is %lu, but table ref len is %lu",
5980 const char* table_name,
5981 const char* path_of_temp_table,
5997 ulint nulls_allowed;
5998 ulint unsigned_type;
6000 ulint long_true_varchar;
6004 n_cols = form->getShare()->sizeFields();
6011 if (path_of_temp_table) {
6016 for (i = 0; i < n_cols; i++) {
6017 field = form->getField(i);
6023 push_warning_printf(
6025 DRIZZLE_ERROR::WARN_LEVEL_WARN,
6026 ER_CANT_CREATE_TABLE,
6027 "Error creating table '%s' with "
6028 "column '%s'. Please check its "
6029 "column type and try to re-create "
6030 "the table with an appropriate "
6039 nulls_allowed = DATA_NOT_NULL;
6042 if (field->binary()) {
6043 binary_type = DATA_BINARY_TYPE;
6052 charset_no = (ulint)field->charset()->number;
6054 if (UNIV_UNLIKELY(charset_no >= 256)) {
6057 push_warning_printf(
6059 DRIZZLE_ERROR::WARN_LEVEL_ERROR,
6060 ER_CANT_CREATE_TABLE,
6061 "In InnoDB, charset-collation codes"
6062 " must be below 256."
6063 " Unsupported code %lu.",
6064 (ulong) charset_no);
6065 return(ER_CANT_CREATE_TABLE);
6069 ut_a(field->type() < 256);
6078 long_true_varchar = 0;
6080 if (field->type() == DRIZZLE_TYPE_VARCHAR) {
6084 long_true_varchar = DATA_LONG_TRUE_VARCHAR;
6091 my_error(ER_WRONG_COLUMN_NAME, MYF(0), field->
field_name);
6105 (ulint)field->type()
6106 | nulls_allowed | unsigned_type
6107 | binary_type | long_true_varchar,
6114 if (error == DB_DUPLICATE_KEY) {
6117 buf,
sizeof buf - 1, table_name, strlen(table_name),
6121 my_error(ER_TABLE_EXISTS_ERROR, MYF(0), buf);
6140 const char* table_name,
6155 ulint* field_lengths;
6159 n_fields = key->key_parts;
6166 if (key_num == form->getShare()->getPrimaryKey()) {
6170 if (key->flags & HA_NOSAME ) {
6178 ind_type, n_fields);
6180 field_lengths = (ulint*) malloc(
sizeof(ulint) * n_fields);
6182 for (i = 0; i < n_fields; i++) {
6183 key_part = key->key_part + i;
6192 for (j = 0; j < form->getShare()->sizeFields(); j++)
6195 field = form->getField(j);
6206 ut_a(j < form->getShare()->sizeFields());
6209 &is_unsigned, key_part->field);
6211 if (DATA_BLOB == col_type
6213 && field->type() != DRIZZLE_TYPE_VARCHAR)
6214 || (field->type() == DRIZZLE_TYPE_VARCHAR
6218 prefix_len = key_part->length;
6220 if (col_type == DATA_INT
6221 || col_type == DATA_FLOAT
6222 || col_type == DATA_DOUBLE
6223 || col_type == DATA_DECIMAL) {
6224 errmsg_printf(error::ERROR,
6225 "MySQL is trying to create a column "
6226 "prefix index field, on an "
6227 "inappropriate data type. Table "
6228 "name %s, column name %s.",
6238 field_lengths[i] = key_part->length;
6241 (
char*) key_part->field->
field_name, prefix_len);
6251 free(field_lengths);
6265 const char* table_name)
6274 innobase_index_reserve_name,
6293 create_options_are_valid(
6300 ibool kbs_specified = FALSE;
6304 ut_ad(session != NULL);
6307 if (!(SessionVAR(session, strict_mode))) {
6333 ib_int64_t auto_inc_value;
6338 bool lex_identified_temp_table= (create_proto.type() == message::Table::TEMPORARY);
6342 std::string search_string(identifier.getSchemaName());
6343 boost::algorithm::to_lower(search_string);
6345 if (search_string.compare(
"data_dictionary") == 0)
6347 return HA_WRONG_CREATE_OPTION;
6350 if (form.getShare()->sizeFields() > 1000) {
6354 return(HA_ERR_TO_BIG_ROW);
6369 srv_lower_case_table_names = TRUE;
6375 row_mysql_lock_data_dictionary(trx);
6381 #if 0 // Since we validate the options before this stage, we no longer need to do this.
6383 if (! create_options_are_valid(&session, form, create_proto)) {
6384 error = ER_ILLEGAL_HA_CREATE_OPTION;
6392 size_t num_engine_options= create_proto.engine().options_size();
6393 for (
size_t x= 0; x < num_engine_options; ++x)
6395 if (boost::iequals(create_proto.engine().options(x).name(),
"ROW_FORMAT"))
6397 if (boost::iequals(create_proto.engine().options(x).state(),
"COMPRESSED"))
6401 else if (boost::iequals(create_proto.engine().options(x).state(),
"COMPACT"))
6405 else if (boost::iequals(create_proto.engine().options(x).state(),
"DYNAMIC"))
6409 else if (boost::iequals(create_proto.engine().options(x).state(),
"REDUNDANT"))
6426 iflags= (DICT_TF_ZSSIZE_MAX - 1)
6436 push_warning_printf(
6438 DRIZZLE_ERROR::WARN_LEVEL_WARN,
6439 ER_ILLEGAL_HA_CREATE_OPTION,
6440 "InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.");
6444 push_warning_printf(
6446 DRIZZLE_ERROR::WARN_LEVEL_WARN,
6447 ER_ILLEGAL_HA_CREATE_OPTION,
6448 "InnoDB: ROW_FORMAT=compressed requires innodb_file_format > Antelope.");
6455 primary_key_no= (form.getShare()->hasPrimaryKey() ?
6456 (int) form.getShare()->getPrimaryKey() :
6462 assert(primary_key_no == -1 || primary_key_no == 0);
6466 if (innobase_index_name_is_reserved(trx, form.
key_info,
6467 form.getShare()->keys)) {
6472 if (lex_identified_temp_table)
6476 lex_identified_temp_table ? identifier.getKeyPath().c_str() : NULL,
6479 session.setXaId(trx->
id);
6487 if (form.getShare()->sizeKeys() == 0 || primary_key_no == -1) {
6498 if (primary_key_no != -1) {
6500 if ((error =
create_index(trx, &form, iflags, identifier.getKeyPath().c_str(),
6501 (uint) primary_key_no))) {
6506 for (i = 0; i < form.getShare()->sizeKeys(); i++) {
6507 if (i != (uint) primary_key_no) {
6509 if ((error =
create_index(trx, &form, iflags, identifier.getKeyPath().c_str(),
6516 stmt= session.getQueryStringCopy(stmt_len);
6519 string generated_create_table;
6520 const char *query= stmt;
6522 if (session.getSqlCommand() == SQLCOM_CREATE_TABLE)
6524 message::transformTableDefinitionToSql(create_proto,
6525 generated_create_table,
6526 message::DRIZZLE,
true);
6527 query= generated_create_table.c_str();
6531 query, strlen(query),
6532 identifier.getKeyPath().c_str(),
6533 lex_identified_temp_table);
6536 case DB_PARENT_NO_INDEX:
6537 push_warning_printf(
6538 &session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
6539 HA_ERR_CANNOT_ADD_FOREIGN,
6540 "Create table '%s' with foreign key constraint"
6541 " failed. There is no index in the referenced"
6542 " table where the referenced columns appear"
6543 " as the first columns.\n", identifier.getKeyPath().c_str());
6546 case DB_CHILD_NO_INDEX:
6547 push_warning_printf(
6548 &session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
6549 HA_ERR_CANNOT_ADD_FOREIGN,
6550 "Create table '%s' with foreign key constraint"
6551 " failed. There is no index in the referencing"
6552 " table where referencing columns appear"
6553 " as the first columns.\n", identifier.getKeyPath().c_str());
6574 innobase_table =
dict_table_get(identifier.getKeyPath().c_str(), FALSE);
6576 assert(innobase_table != 0);
6578 if (innobase_table) {
6582 char changed_file_format_max[100];
6583 strcpy(changed_file_format_max, innobase_file_format_max.c_str());
6586 innobase_file_format_max= changed_file_format_max;
6596 if ((create_proto.options().has_auto_increment_value()
6597 || session.getSqlCommand() == SQLCOM_ALTER_TABLE
6598 || session.getSqlCommand() == SQLCOM_CREATE_INDEX)
6599 && create_proto.options().auto_increment_value() != 0) {
6610 auto_inc_value = create_proto.options().auto_increment_value();
6624 if (lex_identified_temp_table)
6626 session.getMessageCache().storeTableMessage(identifier, create_proto);
6630 StorageEngine::writeDefinitionFromPath(identifier, create_proto);
6691 if (
user_session->getSqlCommand() != SQLCOM_TRUNCATE) {
6696 return(errno=HA_ERR_WRONG_COMMAND);
6702 if (error == DB_ERROR) {
6731 ut_a(identifier.getPath().length() < 1000);
6733 std::string search_string(identifier.getSchemaName());
6734 boost::algorithm::to_lower(search_string);
6736 if (search_string.compare(
"data_dictionary") == 0)
6738 return HA_ERR_TABLE_READONLY;
6753 srv_lower_case_table_names = TRUE;
6758 session.getSqlCommand()
6764 std::string table_path_no_catalog(identifier.getKeyPath());
6765 table_path_no_catalog.erase(0, drizzled::catalog::local_identifier().getPath().length()+1);
6767 session.getSqlCommand()
6771 session.setXaId(trx->
id);
6788 if (error != ENOENT)
6791 if (error == 0 || error == ENOENT)
6793 if (identifier.getType() == message::Table::TEMPORARY)
6795 session.getMessageCache().removeTableMessage(identifier);
6796 ulint sql_command = session.getSqlCommand();
6800 if ((sql_command == SQLCOM_ALTER_TABLE
6801 || sql_command == SQLCOM_CREATE_INDEX
6802 || sql_command == SQLCOM_DROP_INDEX))
6804 string path(identifier.getPath());
6806 path.append(DEFAULT_FILE_EXTENSION);
6808 (void)internal::my_delete(path.c_str(), MYF(0));
6813 string path(identifier.getPath());
6815 path.append(DEFAULT_FILE_EXTENSION);
6817 (void)internal::my_delete(path.c_str(), MYF(0));
6837 string schema_path(identifier.getPath());
6838 Session* session = current_session;
6843 assert(
this == innodb_engine_ptr);
6856 schema_path.append(
"/");
6881 void InnobaseEngine::dropTemporarySchema()
6883 string schema_path(GLOBAL_TEMPORARY_EXT);
6890 trx->check_foreigns =
false;
6891 trx->check_unique_secondary =
false;
6919 ibool lock_and_commit)
6924 srv_lower_case_table_names = TRUE;
6929 if (lock_and_commit) {
6930 row_mysql_lock_data_dictionary(trx);
6935 if (error != DB_SUCCESS) {
6936 FILE* ef = dict_foreign_err_file;
6938 fputs(
"InnoDB: Renaming table ", ef);
6942 fputs(
" failed!\n", ef);
6945 if (lock_and_commit) {
6964 if (to.getType() == message::Table::TEMPORARY && from.getType() == message::Table::TEMPORARY)
6966 session.getMessageCache().renameTableMessage(from, to);
6988 session.setXaId(trx->
id);
7010 if (error == (
int) DB_DUPLICATE_KEY) {
7011 my_error(ER_TABLE_EXISTS_ERROR, to);
7020 plugin::StorageEngine::renameDefinitionFromPath(to, from);
7041 unsigned char* key_val_buff2 = (
unsigned char*) malloc(
7042 getTable()->getShare()->sizeStoredRecord()
7043 + getTable()->getShare()->max_key_length + 100);
7044 ulint buff2_len = getTable()->getShare()->sizeStoredRecord()
7045 + getTable()->getShare()->max_key_length + 100;
7062 active_index = keynr;
7064 key = &getTable()->
key_info[active_index];
7071 if (UNIV_UNLIKELY(!index)) {
7072 n_rows = HA_POS_ERROR;
7077 n_rows = HA_ERR_TABLE_DEF_CHANGED;
7092 (ulint)upd_and_key_val_buff_len,
7094 (byte*) (min_key ? min_key->key :
7095 (
const unsigned char*) 0),
7096 (ulint) (min_key ? min_key->length : 0),
7100 range_end, (byte*) key_val_buff2,
7102 (byte*) (max_key ? max_key->key :
7103 (
const unsigned char*) 0),
7104 (ulint) (max_key ? max_key->length : 0),
7112 if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) {
7119 n_rows = HA_POS_ERROR;
7125 free(key_val_buff2);
7139 return((ha_rows) n_rows);
7153 uint64_t local_data_file_length;
7154 ulint stat_n_leaf_pages;
7163 "calculating upper bound for table rows";
7174 ut_a(stat_n_leaf_pages > 0);
7176 local_data_file_length =
7177 ((uint64_t) stat_n_leaf_pages) * UNIV_PAGE_SIZE;
7185 estimate = 2 * local_data_file_length /
7190 return((ha_rows) estimate);
7224 double time_for_scan;
7226 if (index != getTable()->getShare()->getPrimaryKey()) {
7228 return(Cursor::read_time(index, ranges, rows));
7233 return((
double) rows);
7243 return(time_for_scan);
7246 return(ranges + (
double) rows / (
double) total_rows * time_for_scan);
7280 if (index->
table != ib_table) {
7282 ind = dict_table_get_first_index(index->
table);
7284 while (index != ind) {
7285 ind = dict_table_get_next_index(ind);
7299 if (index->
table != ib_table) {
7301 ind = dict_table_get_first_index(index->
table);
7303 while (index != ind) {
7304 ind = dict_table_get_next_index(ind);
7327 errmsg_printf(error::ERROR,
7328 "Cannot find index %s in InnoDB index "
7329 "translation table.", index->
name);
7335 for (i = 0; i < table->getShare()->keys; i++) {
7337 ib_table, table->
key_info[i].name);
7344 errmsg_printf(error::ERROR,
7345 "Cannot find matching index number for index %s "
7346 "in InnoDB index list.", index->
name);
7364 ha_rows rec_per_key;
7372 rec_per_key = records;
7373 }
else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
7374 ib_int64_t num_null;
7378 num_null = records - index->stat_n_non_null_key_vals[i];
7385 num_null = (num_null < 0) ? 0 : num_null;
7396 rec_per_key = (ha_rows)(
7397 (records - num_null)
7402 rec_per_key = (ha_rows)
7406 return(rec_per_key);
7420 ha_rows rec_per_key;
7443 if (flag & HA_STATUS_TIME) {
7456 fs::path get_status_path(catalog::local_identifier().getPath());
7457 get_status_path /= ib_table->
name;
7458 fs::change_extension(get_status_path,
"dfe");
7464 stats.create_time = (ulong) stat_info.
ctime;
7468 if (flag & HA_STATUS_VARIABLE) {
7491 if (n_rows == 0 && !(flag & HA_STATUS_TIME)) {
7499 if (
user_session->getSqlCommand() == SQLCOM_TRUNCATE) {
7512 stats.records = (ha_rows)n_rows;
7514 stats.data_file_length = ((uint64_t)
7517 stats.index_file_length = ((uint64_t)
7528 if (flag & HA_STATUS_NO_LOCK) {
7533 }
else if (UNIV_UNLIKELY
7537 stats.delete_length = 0;
7543 if (avail_space == ULLINT_UNDEFINED) {
7546 session= getTable()->
in_use;
7549 push_warning_printf(
7551 DRIZZLE_ERROR::WARN_LEVEL_WARN,
7553 "InnoDB: Trying to get the free "
7554 "space for table %s but its "
7555 "tablespace has been discarded or "
7556 "the .ibd file is missing. Setting "
7557 "the free space to zero.",
7560 stats.delete_length = 0;
7562 stats.delete_length = avail_space * 1024;
7566 stats.check_time = 0;
7568 if (stats.records == 0) {
7569 stats.mean_rec_length = 0;
7571 stats.mean_rec_length = (ulong) (stats.data_file_length / stats.records);
7575 if (flag & HA_STATUS_CONST) {
7582 if (getTable()->getShare()->keys != num_innodb_index) {
7583 errmsg_printf(error::ERROR,
"Table %s contains %lu "
7584 "indexes inside InnoDB, which "
7585 "is different from the number of "
7586 "indexes %u defined in the MySQL ",
7587 ib_table->
name, num_innodb_index,
7588 getTable()->getShare()->keys);
7593 for (i = 0; i < getTable()->getShare()->sizeKeys(); i++) {
7602 if (index == NULL) {
7603 errmsg_printf(error::ERROR,
"Table %s contains fewer "
7604 "indexes inside InnoDB than "
7605 "are defined in the MySQL "
7606 ".frm file. Have you mixed up "
7607 ".frm files from different "
7608 "installations? See "
7610 "innodb-troubleshooting.html\n",
7615 for (j = 0; j < getTable()->
key_info[i].key_parts; j++) {
7617 if (j + 1 > index->
n_uniq) {
7618 errmsg_printf(error::ERROR,
7619 "Index %s of %s has %lu columns unique inside InnoDB, but MySQL is asking "
7620 "statistics for %lu columns. Have you mixed up .frm files from different "
7622 "See " REFMAN
"innodb-troubleshooting.html\n",
7637 rec_per_key = rec_per_key / 2;
7639 if (rec_per_key == 0) {
7643 getTable()->
key_info[i].rec_per_key[j]=
7644 rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
7645 (ulong) rec_per_key;
7656 if (flag & HA_STATUS_ERRKEY) {
7665 errkey = (
unsigned int)
7694 info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
7712 ulint n_rows_in_table = ULINT_UNDEFINED;
7714 ulint old_isolation_level;
7716 assert(session == getTable()->in_use);
7729 errmsg_printf(error::ERROR,
"InnoDB: Error:\n"
7730 "InnoDB: MySQL is trying to use a table handle"
7731 " but the .ibd file for\n"
7732 "InnoDB: table %s does not exist.\n"
7733 "InnoDB: Have you deleted the .ibd file"
7734 " from the database directory under\n"
7735 "InnoDB: the MySQL datadir, or have you"
7736 " used DISCARD TABLESPACE?\n"
7737 "InnoDB: Please refer to\n"
7738 "InnoDB: " REFMAN
"innodb-troubleshooting.html\n"
7739 "InnoDB: how you can resolve the problem.\n",
7741 return(HA_ADMIN_CORRUPT);
7746 old_isolation_level =
prebuilt->
trx->isolation_level;
7753 prebuilt->
trx->isolation_level = TRX_ISO_REPEATABLE_READ;
7756 mutex_enter(&kernel_mutex);
7757 srv_fatal_semaphore_wait_threshold += 7200;
7758 mutex_exit(&kernel_mutex);
7762 index = dict_table_get_next_index(index)) {
7764 fputs(
"Validating index ", stderr);
7771 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7773 "InnoDB: The B-tree of"
7774 " index '%-.200s' is corrupted.",
7788 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7789 HA_ERR_TABLE_DEF_CHANGED,
7790 "InnoDB: Insufficient history for"
7806 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7808 "InnoDB: The B-tree of"
7809 " index '%-.200s' is corrupted.",
7819 fprintf(stderr,
"%lu entries in index %s\n", n_rows,
7824 n_rows_in_table = n_rows;
7825 }
else if (n_rows != n_rows_in_table) {
7826 push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7828 "InnoDB: Index '%-.200s'"
7829 " contains %lu entries,"
7833 (ulong) n_rows_in_table);
7839 prebuilt->
trx->isolation_level = old_isolation_level;
7844 if (!btr_search_validate()) {
7845 push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7847 "InnoDB: The adaptive hash index is corrupted.");
7852 mutex_enter(&kernel_mutex);
7853 srv_fatal_semaphore_wait_threshold -= 7200;
7854 mutex_exit(&kernel_mutex);
7858 my_error(ER_QUERY_INTERRUPTED, MYF(0));
7861 return(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
7873 const char* comment)
7875 uint length = (uint) strlen(comment);
7883 if (length > 64000 - 3) {
7884 return((
char*)comment);
7899 mutex_enter(&srv_dict_tmpfile_mutex);
7900 rewind(srv_dict_tmpfile);
7902 fprintf(srv_dict_tmpfile,
"InnoDB free: %llu kB",
7908 flen = ftell(srv_dict_tmpfile);
7911 }
else if (length + flen + 3 > 64000) {
7912 flen = 64000 - 3 - length;
7918 str = (
char*) malloc(length + flen + 3);
7921 char* pos = str + length;
7923 memcpy(str, comment, length);
7927 rewind(srv_dict_tmpfile);
7928 flen = (uint) fread(pos, 1, flen, srv_dict_tmpfile);
7932 mutex_exit(&srv_dict_tmpfile_mutex);
7936 return(str ? str : (
char*) comment);
7968 mutex_enter(&srv_dict_tmpfile_mutex);
7969 rewind(srv_dict_tmpfile);
7976 flen = ftell(srv_dict_tmpfile);
7984 str = (
char*) malloc(flen + 1);
7987 rewind(srv_dict_tmpfile);
7988 flen = (uint) fread(str, 1, flen, srv_dict_tmpfile);
7992 mutex_exit(&srv_dict_tmpfile_mutex);
8009 while (foreign != NULL)
8012 char uname[NAME_LEN + 1];
8013 char db_name[NAME_LEN + 1];
8014 const char *tmp_buff;
8017 tmp_buff = foreign->
id;
8019 while (tmp_buff[i] !=
'/')
8028 while (tmp_buff[i] !=
'/')
8030 db_name[i]= tmp_buff[i];
8034 ulen= identifier::Table::filename_to_tablename(db_name, uname,
sizeof(uname));
8039 ulen= identifier::Table::filename_to_tablename(tmp_buff, uname,
sizeof(uname));
8054 tmp_buff=
"CASCADE";
8056 tmp_buff=
"SET NULL";
8058 tmp_buff=
"NO ACTION";
8060 tmp_buff=
"RESTRICT";
8064 tmp_buff=
"CASCADE";
8066 tmp_buff=
"SET NULL";
8068 tmp_buff=
"NO ACTION";
8070 tmp_buff=
"RESTRICT";
8078 tmp_foreign_id, tmp_referenced_db, tmp_referenced_table,
8079 tmp_update_method, tmp_delete_method, tmp_referenced_key_name,
8080 tmp_foreign_fields, tmp_referenced_fields);
8106 "determining if there are foreign key constraints";
8156 enum ha_extra_function operation)
8163 switch (operation) {
8164 case HA_EXTRA_FLUSH:
8169 case HA_EXTRA_RESET_STATE:
8172 case HA_EXTRA_NO_KEYREAD:
8175 case HA_EXTRA_KEYREAD:
8178 case HA_EXTRA_KEYREAD_PRESERVE_FIELDS:
8188 case HA_EXTRA_IGNORE_DUP_KEY:
8191 case HA_EXTRA_WRITE_CAN_REPLACE:
8194 case HA_EXTRA_WRITE_CANNOT_REPLACE:
8197 case HA_EXTRA_NO_IGNORE_DUP_KEY:
8199 ~(TRX_DUP_IGNORE | TRX_DUP_REPLACE);
8234 enum_tx_isolation iso)
8237 case ISO_REPEATABLE_READ:
return(TRX_ISO_REPEATABLE_READ);
8238 case ISO_READ_COMMITTED:
return(TRX_ISO_READ_COMMITTED);
8239 case ISO_SERIALIZABLE:
return(TRX_ISO_SERIALIZABLE);
8240 case ISO_READ_UNCOMMITTED:
return(TRX_ISO_READ_UNCOMMITTED);
8241 default:
ut_a(0);
return(0);
8266 if (lock_type == F_WRLCK) {
8274 if (lock_type != F_UNLCK) {
8277 if (trx->isolation_level == TRX_ISO_SERIALIZABLE
8279 && session_test_options(session,
8280 OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
8306 trx->mysql_n_tables_locked++;
8316 trx->mysql_n_tables_locked= 0;
8328 plugin::StorageEngine* engine,
8330 stat_print_fn *stat_print)
8333 static const char truncated_msg[] =
"... truncated...\n";
8334 const long MAX_STATUS_SIZE = 1048576;
8335 ulint trx_list_start = ULINT_UNDEFINED;
8336 ulint trx_list_end = ULINT_UNDEFINED;
8338 assert(engine == innodb_engine_ptr);
8347 long flen, usable_len;
8350 mutex_enter(&srv_monitor_file_mutex);
8351 rewind(srv_monitor_file);
8353 &trx_list_start, &trx_list_end);
8354 flen = ftell(srv_monitor_file);
8361 if (flen > MAX_STATUS_SIZE) {
8362 usable_len = MAX_STATUS_SIZE;
8363 srv_truncated_status_writes++;
8371 if (!(str = (
char*) malloc(usable_len + 1))) {
8372 mutex_exit(&srv_monitor_file_mutex);
8376 rewind(srv_monitor_file);
8377 if (flen < MAX_STATUS_SIZE) {
8379 flen = (long) fread(str, 1, flen, srv_monitor_file);
8380 }
else if (trx_list_end < (ulint) flen
8381 && trx_list_start < trx_list_end
8382 && trx_list_start + (flen - trx_list_end)
8383 < MAX_STATUS_SIZE -
sizeof truncated_msg - 1) {
8385 long len = (long) fread(str, 1, trx_list_start, srv_monitor_file);
8386 memcpy(str + len, truncated_msg,
sizeof truncated_msg - 1);
8387 len +=
sizeof truncated_msg - 1;
8388 usable_len = (MAX_STATUS_SIZE - 1) - len;
8389 fseek(srv_monitor_file, flen - usable_len, SEEK_SET);
8390 len += (long) fread(str + len, 1, usable_len, srv_monitor_file);
8394 flen = (long) fread(str, 1, MAX_STATUS_SIZE - 1, srv_monitor_file);
8397 mutex_exit(&srv_monitor_file_mutex);
8399 stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
8400 STRING_WITH_LEN(
""), str, flen);
8414 plugin::StorageEngine* engine,
8417 stat_print_fn* stat_print)
8420 char buf1[IO_SIZE], buf2[IO_SIZE];
8423 ulint block_mutex_oswait_count = 0;
8424 ulint block_lock_oswait_count = 0;
8428 ulint rw_lock_count= 0;
8429 ulint rw_lock_count_spin_loop= 0;
8430 ulint rw_lock_count_spin_rounds= 0;
8431 ulint rw_lock_count_os_wait= 0;
8432 ulint rw_lock_count_os_yield= 0;
8433 uint64_t rw_lock_wait_time= 0;
8435 uint engine_name_len= strlen(innobase_engine_name), buf1len, buf2len;
8436 assert(engine == innodb_engine_ptr);
8448 block_mutex = mutex;
8453 if (mutex->mutex_type != 1) {
8454 if (mutex->count_using > 0) {
8455 buf1len= my_snprintf(buf1,
sizeof(buf1),
8457 buf2len= my_snprintf(buf2,
sizeof(buf2),
8458 "count=%lu, spin_waits=%lu,"
8459 " spin_rounds=%lu, "
8460 "os_waits=%lu, os_yields=%lu,"
8461 " os_wait_times=%lu",
8463 mutex->count_spin_loop,
8464 mutex->count_spin_rounds,
8466 mutex->count_os_yield,
8467 (ulong) (mutex->lspent_time/1000));
8469 if (stat_print(session, innobase_engine_name,
8470 engine_name_len, buf1, buf1len,
8477 rw_lock_count += mutex->count_using;
8478 rw_lock_count_spin_loop += mutex->count_spin_loop;
8479 rw_lock_count_spin_rounds += mutex->count_spin_rounds;
8481 rw_lock_count_os_yield += mutex->count_os_yield;
8482 rw_lock_wait_time += mutex->lspent_time;
8485 buf1len= snprintf(buf1,
sizeof(buf1),
"%s:%lu",
8487 (ulong) mutex->
cline);
8488 buf2len= snprintf(buf2,
sizeof(buf2),
"os_waits=%lu",
8491 if (stat_print(session, innobase_engine_name,
8492 engine_name_len, buf1, buf1len,
8501 buf1len = snprintf(buf1,
sizeof buf1,
8504 (ulong) block_mutex->
cline);
8505 buf2len = snprintf(buf2,
sizeof buf2,
8507 (ulong) block_mutex_oswait_count);
8509 if (stat_print(session, innobase_engine_name,
8510 strlen(innobase_engine_name), buf1, buf1len,
8519 mutex_enter(&rw_lock_list_mutex);
8533 buf1len = snprintf(buf1,
sizeof buf1,
"%s:%lu",
8535 (ulong) lock->
cline);
8536 buf2len = snprintf(buf2,
sizeof buf2,
"os_waits=%lu",
8539 if (stat_print(session, innobase_engine_name,
8540 strlen(innobase_engine_name), buf1, buf1len,
8542 mutex_exit(&rw_lock_list_mutex);
8548 buf1len = snprintf(buf1,
sizeof buf1,
8551 (ulong) block_lock->
cline);
8552 buf2len = snprintf(buf2,
sizeof buf2,
8554 (ulong) block_lock_oswait_count);
8556 if (stat_print(session, innobase_engine_name,
8557 strlen(innobase_engine_name), buf1, buf1len,
8559 mutex_exit(&rw_lock_list_mutex);
8564 mutex_exit(&rw_lock_list_mutex);
8567 buf2len = snprintf(buf2,
sizeof buf2,
8568 "count=%lu, spin_waits=%lu, spin_rounds=%lu, "
8569 "os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
8570 (ulong) rw_lock_count,
8571 (ulong) rw_lock_count_spin_loop,
8572 (ulong) rw_lock_count_spin_rounds,
8573 (ulong) rw_lock_count_os_wait,
8574 (ulong) rw_lock_count_os_yield,
8575 (ulong) (rw_lock_wait_time / 1000));
8577 if (stat_print(session, innobase_engine_name, engine_name_len,
8578 STRING_WITH_LEN(
"rw_lock_mutexes"), buf2, buf2len)) {
8586 bool InnobaseEngine::show_status(
Session* session,
8587 stat_print_fn* stat_print,
8588 enum ha_stat_type stat_type)
8590 assert(
this == innodb_engine_ptr);
8592 switch (stat_type) {
8593 case HA_ENGINE_STATUS:
8595 case HA_ENGINE_MUTEX:
8614 HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
8626 innobase_open_tables, fold, share);
8628 thr_lock_init(&share->
lock);
8649 HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
8654 ut_a(share2 == share);
8661 innobase_open_tables, fold, share);
8692 enum thr_lock_type lock_type)
8704 assert(EQ_CURRENT_SESSION(session));
8705 const uint32_t sql_command = session->getSqlCommand();
8707 if (sql_command == SQLCOM_DROP_TABLE) {
8713 }
else if (lock_type == TL_READ_WITH_SHARED_LOCKS
8714 || lock_type == TL_READ_NO_INSERT
8715 || (lock_type != TL_IGNORE
8716 && sql_command != SQLCOM_SELECT)) {
8736 ulint isolation_level;
8738 isolation_level = trx->isolation_level;
8741 || isolation_level <= TRX_ISO_READ_COMMITTED)
8742 && isolation_level != TRX_ISO_SERIALIZABLE
8743 && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
8744 && (sql_command == SQLCOM_INSERT_SELECT
8745 || sql_command == SQLCOM_REPLACE_SELECT
8746 || sql_command == SQLCOM_UPDATE
8747 || sql_command == SQLCOM_CREATE_TABLE
8748 || sql_command == SQLCOM_SET_OPTION)) {
8762 }
else if (sql_command == SQLCOM_CHECKSUM) {
8772 }
else if (lock_type != TL_IGNORE) {
8781 if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) {
8789 if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
8790 && lock_type <= TL_WRITE)
8791 && ! session->doing_tablespace_operation()
8792 && sql_command != SQLCOM_TRUNCATE
8793 && sql_command != SQLCOM_CREATE_TABLE) {
8795 lock_type = TL_WRITE_ALLOW_WRITE;
8805 if (lock_type == TL_READ_NO_INSERT) {
8807 lock_type = TL_READ;
8810 lock.type = lock_type;
8866 if (auto_inc == 0) {
8868 errmsg_printf(error::ERROR,
" InnoDB: AUTOINC next value generation is disabled for '%s'\n", innodb_table->
name);
8889 uint64_t nb_desired_values,
8890 uint64_t *first_value,
8891 uint64_t *nb_reserved_values)
8895 uint64_t autoinc = 0;
8902 if (error != DB_SUCCESS) {
8903 *first_value = (~(uint64_t) 0);
8933 if (nb_desired_values == 0) {
8938 set_if_bigger(*first_value, autoinc);
8941 set_if_bigger(*first_value, autoinc);
8943 }
else if (*first_value > col_max_value && trx->
n_autoinc_rows > 0) {
8955 uint64_t next_value;
8957 current = *first_value > col_max_value ? autoinc : *first_value;
8958 need = *nb_reserved_values * increment;
8966 *first_value = (~(
unsigned long long) 0);
9002 if (error != DB_SUCCESS) {
9023 InnobaseEngine::get_error_message(
int,
String *buf)
const
9028 system_charset_info);
9042 const unsigned char* ref1,
9044 const unsigned char* ref2)
9047 enum_field_types mysql_type;
9058 return(memcmp(ref1, ref2, DATA_ROW_ID_LEN));
9064 key_part = getTable()->
key_info[getTable()->getShare()->getPrimaryKey()].key_part;
9066 key_part_end = key_part
9067 + getTable()->
key_info[getTable()->getShare()->getPrimaryKey()].key_parts;
9069 for (; key_part != key_part_end; ++key_part) {
9070 field = key_part->field;
9071 mysql_type = field->type();
9073 if (mysql_type == DRIZZLE_TYPE_BLOB) {
9083 result = ((
Field_blob*)field)->cmp( ref1, len1,
9086 result = field->key_cmp(ref1, ref2);
9094 ref1 += key_part->store_length;
9095 ref2 += key_part->store_length;
9122 charset = get_charset((uint) charset_id);
9125 ut_ad(charset->mbmaxlen);
9129 n_chars = prefix_len / charset->mbmaxlen;
9136 if (charset->mbmaxlen > 1) {
9155 char_length = my_charpos(charset, str,
9156 str + data_len, (
int) n_chars);
9157 if (char_length > data_len) {
9158 char_length = data_len;
9161 if (data_len < prefix_len) {
9162 char_length = data_len;
9164 char_length = prefix_len;
9168 return(char_length);
9194 InnobaseEngine::doEndStatement(
9223 assert(
this == innodb_engine_ptr);
9233 session->get_xid(reinterpret_cast<DrizzleXid*>(&trx->
xid));
9242 || (!session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
9274 uint64_t InnobaseEngine::doGetCurrentTransactionId(
Session *session)
9280 uint64_t InnobaseEngine::doGetNewTransactionId(
Session *session)
9291 mutex_enter(&kernel_mutex);
9293 mutex_exit(&kernel_mutex);
9295 uint64_t transaction_id= trx->
id;
9297 return transaction_id;
9309 assert(
this == innodb_engine_ptr);
9311 if (len == 0 || xid_list == NULL) {
9330 assert(
this == innodb_engine_ptr);
9355 assert(
this == innodb_engine_ptr);
9374 const char* format_name)
9379 ut_a(format_name != NULL);
9383 format_id = (uint) strtoul(format_name, &endp, 10);
9386 if (*endp ==
'\0' && *format_name !=
'\0') {
9418 const char* format_max)
9426 return((
int) format_id);
9436 context(
"disable-checksums",
9437 "Disable InnoDB checksums validation.");
9438 context(
"data-home-dir",
9439 po::value<string>(),
9440 "The common part for InnoDB table spaces.");
9441 context(
"disable-doublewrite",
9442 "Disable InnoDB doublewrite buffer.");
9443 context(
"io-capacity",
9444 po::value<io_capacity_constraint>(&innodb_io_capacity)->default_value(200),
9445 "Number of IOPs the server can do. Tunes the background IO rate");
9446 context(
"fast-shutdown",
9447 po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
9448 "Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).");
9449 context(
"purge-batch-size",
9450 po::value<purge_batch_constraint>(&innodb_purge_batch_size)->default_value(20),
9451 "Number of UNDO log pages to purge in one batch from the history list.");
9452 context(
"purge-threads",
9453 po::value<purge_threads_constraint>(&innodb_n_purge_threads)->default_value(1),
9454 "Purge threads can be either 0 or 1. Default is 1.");
9455 context(
"file-per-table",
9457 "Stores each InnoDB table to an .ibd file in the database dir.");
9458 context(
"file-format-max",
9459 po::value<string>(&innobase_file_format_max)->default_value(
"Antelope"),
9460 "The highest file format in the tablespace.");
9461 context(
"file-format-check",
9462 po::value<bool>(&innobase_file_format_check)->default_value(
true)->zero_tokens(),
9463 "Whether to perform system file format check.");
9464 context(
"file-format",
9465 po::value<string>(&innobase_file_format_name)->default_value(
"Antelope"),
9466 "File format to use for new tables in .ibd files.");
9467 context(
"flush-log-at-trx-commit",
9468 po::value<trinary_constraint>(&innodb_flush_log_at_trx_commit)->default_value(1),
9469 "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).");
9470 context(
"flush-method",
9471 po::value<string>(),
9472 "With which method to flush data.");
9473 context(
"log-group-home-dir",
9474 po::value<string>(),
9475 "Path to InnoDB log files.");
9476 context(
"max-dirty-pages-pct",
9477 po::value<max_dirty_pages_constraint>(&innodb_max_dirty_pages_pct)->default_value(75),
9478 "Percentage of dirty pages allowed in bufferpool.");
9479 context(
"disable-adaptive-flushing",
9480 "Do not attempt flushing dirty pages to avoid IO bursts at checkpoints.");
9481 context(
"max-purge-lag",
9482 po::value<uint64_constraint>(&innodb_max_purge_lag)->default_value(0),
9483 "Desired maximum length of the purge queue (0 = no limit)");
9484 context(
"status-file",
9485 po::value<bool>(&innobase_create_status_file)->default_value(
false)->zero_tokens(),
9486 "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file");
9487 context(
"disable-stats-on-metadata",
9488 "Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9489 context(
"stats-sample-pages",
9490 po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9491 "The number of index pages to sample when calculating statistics (default 8)");
9492 context(
"disable-adaptive-hash-index",
9493 "Enable InnoDB adaptive hash index (enabled by default)");
9494 context(
"replication-delay",
9495 po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9496 "Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9497 context(
"additional-mem-pool-size",
9498 po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9499 "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9500 context(
"autoextend-increment",
9501 po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(64L),
9502 "Data file autoextend increment in megabytes");
9503 context(
"buffer-pool-size",
9504 po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9505 "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9506 context(
"buffer-pool-instances",
9507 po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9508 "Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9510 context(
"commit-concurrency",
9511 po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9512 "Helps in performance tuning in heavily concurrent environments.");
9513 context(
"concurrency-tickets",
9514 po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9515 "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9516 context(
"read-io-threads",
9517 po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9518 "Number of background read I/O threads in InnoDB.");
9519 context(
"write-io-threads",
9520 po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9521 "Number of background write I/O threads in InnoDB.");
9522 context(
"force-recovery",
9523 po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9524 "Helps to save your data in case the disk image of the database becomes corrupt.");
9525 context(
"log-buffer-size",
9526 po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9527 "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9528 context(
"log-file-size",
9529 po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9530 "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9531 context(
"page-size",
9532 po::value<page_size_constraint>(&innobase_page_size)->default_value(1 << 14),
9533 "###EXPERIMENTAL###: The universal page size of the database. Changing for created database is not supported. Use on your own risk!");
9534 context(
"log-block-size",
9535 po::value<log_block_size_constraint>(&innobase_log_block_size)->default_value(1 << 9),
9536 "###EXPERIMENTAL###: The log block size of the transaction log file. Changing for created log file is not supported. Use on your own risk!");
9537 context(
"log-files-in-group",
9538 po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9539 "Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9540 context(
"mirrored-log-groups",
9541 po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9542 "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9543 context(
"open-files",
9544 po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9545 "How many files at the maximum InnoDB keeps open at the same time.");
9546 context(
"sync-spin-loops",
9547 po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9548 "Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9549 context(
"spin-wait-delay",
9550 po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9551 "Maximum delay between polling for a spin lock (6 by default)");
9552 context(
"thread-concurrency",
9553 po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9554 "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9555 context(
"thread-sleep-delay",
9556 po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9557 "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9558 context(
"data-file-path",
9559 po::value<string>(),
9560 "Path to individual files and their sizes.");
9562 po::value<string>()->default_value(INNODB_VERSION_STR),
9564 context(
"use-internal-malloc",
9565 "Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9566 context(
"disable-native-aio",
9567 _(
"Do not use Native AIO library for IO, even if available"));
9568 context(
"change-buffering",
9569 po::value<string>(&innobase_change_buffering),
9570 "Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9571 context(
"read-ahead-threshold",
9572 po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
9573 "Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9574 context(
"auto-lru-dump",
9575 po::value<uint32_constraint>(&buffer_pool_restore_at_startup)->default_value(0),
9576 "Time in seconds between automatic buffer pool dumps. "
9577 "0 (the default) disables automatic dumps.");
9578 context(
"ibuf-max-size",
9579 po::value<uint64_constraint>(&ibuf_max_size)->default_value(UINT64_MAX),
9580 "The maximum size of the insert buffer (in bytes).");
9581 context(
"ibuf-active-contract",
9582 po::value<binary_constraint>(&ibuf_active_contract)->default_value(1),
9583 "Enable/Disable active_contract of insert buffer. 0:disable 1:enable");
9584 context(
"ibuf-accel-rate",
9585 po::value<ibuf_accel_rate_constraint>(&ibuf_accel_rate)->default_value(100),
9586 "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)");
9587 context(
"checkpoint-age-target",
9588 po::value<uint32_constraint>(&checkpoint_age_target)->default_value(0),
9589 "Control soft limit of checkpoint age. (0 : not control)");
9590 context(
"flush-neighbor-pages",
9591 po::value<binary_constraint>(&flush_neighbor_pages)->default_value(1),
9592 "Enable/Disable flushing also neighbor pages. 0:disable 1:enable");
9593 context(
"read-ahead",
9594 po::value<string>(&read_ahead)->default_value(
"linear"),
9595 "Control read ahead activity (none, random, [linear], both). [from 1.0.5: random read ahead is ignored]");
9596 context(
"adaptive-flushing-method",
9597 po::value<string>(&adaptive_flushing_method)->default_value(
"estimate"),
9598 "Choose method of innodb_adaptive_flushing. (native, [estimate], keep_average)");
9599 context(
"disable-xa",
9600 "Disable InnoDB support for the XA two-phase commit");
9601 context(
"disable-table-locks",
9602 "Disable InnoDB locking in LOCK TABLES");
9603 context(
"strict-mode",
9604 po::value<bool>(&strict_mode)->default_value(
false)->zero_tokens(),
9605 "Use strict mode when evaluating create options.");
9606 context(
"replication-log",
9607 po::value<bool>(&innobase_use_replication_log)->default_value(
false)->zero_tokens(),
9608 _(
"Enable internal replication log."));
9609 context(
"use-replicator",
9610 po::value<string>(&sysvar_transaction_log_use_replicator)->default_value(DEFAULT_USE_REPLICATOR),
9611 _(
"Name of the replicator plugin to use (default='default_replicator')"));
9612 context(
"lock-wait-timeout",
9613 po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9614 _(
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9615 context(
"old-blocks-pct",
9616 po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9617 _(
"Percentage of the buffer pool to reserve for 'old' blocks."));
9618 context(
"old-blocks-time",
9620 _(
"ove blocks to the 'new' end of the buffer pool if the first access"
9621 " was at least this many milliseconds ago."
9622 " The timeout is disabled if 0 (the default)."));
9623 context(
"stats-method",
9624 po::value<string>(&innodb_stats_method),
9625 "Specifies how InnoDB index statistics collection code should "
9626 "treat NULLs. Possible values are NULLS_EQUAL (default), "
9627 "NULLS_UNEQUAL and NULLS_IGNORED");
9628 context(
"rollback-segments",
9629 po::value<rollback_segments_constraint>(&innobase_rollback_segments)->default_value(128),
9630 "Number of UNDO logs to use");
9636 DRIZZLE_DECLARE_PLUGIN
9642 "InnoDB storage engine: transactional, row-level locking, foreign keys",
9648 DRIZZLE_DECLARE_PLUGIN_END;
9658 res= Cursor::read_range_first(start_key, end_key, eq_range_arg, sorted);
9667 int res= Cursor::read_range_next();
9679 innobase_index_name_is_reserved(
9691 for (key_num = 0; key_num < num_of_keys; key_num++) {
9692 key = &key_info[key_num];
9695 innobase_index_reserve_name) == 0) {
9698 DRIZZLE_ERROR::WARN_LEVEL_WARN,
9699 ER_WRONG_NAME_FOR_INDEX,
9700 "Cannot Create Index with name "
9701 "'%s'. The name is reserved "
9702 "for the system default primary "
9704 innobase_index_reserve_name);
9706 my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
9707 innobase_index_reserve_name);
9716 #ifdef UNIV_COMPILE_TEST_FUNCS
9718 typedef struct innobase_convert_name_test_struct {
9726 const char* expected;
9727 } innobase_convert_name_test_t;
9730 test_innobase_convert_name()
9735 innobase_convert_name_test_t test_input[] = {
9736 {buf,
sizeof(buf),
"abcd", 4, NULL, TRUE,
"\"abcd\""},
9737 {buf, 7,
"abcd", 4, NULL, TRUE,
"\"abcd\""},
9738 {buf, 6,
"abcd", 4, NULL, TRUE,
"\"abcd\""},
9739 {buf, 5,
"abcd", 4, NULL, TRUE,
"\"abc\""},
9740 {buf, 4,
"abcd", 4, NULL, TRUE,
"\"ab\""},
9742 {buf,
sizeof(buf),
"ab@0060cd", 9, NULL, TRUE,
"\"ab`cd\""},
9743 {buf, 9,
"ab@0060cd", 9, NULL, TRUE,
"\"ab`cd\""},
9744 {buf, 8,
"ab@0060cd", 9, NULL, TRUE,
"\"ab`cd\""},
9745 {buf, 7,
"ab@0060cd", 9, NULL, TRUE,
"\"ab`cd\""},
9746 {buf, 6,
"ab@0060cd", 9, NULL, TRUE,
"\"ab`c\""},
9747 {buf, 5,
"ab@0060cd", 9, NULL, TRUE,
"\"ab`\""},
9748 {buf, 4,
"ab@0060cd", 9, NULL, TRUE,
"\"ab\""},
9750 {buf,
sizeof(buf),
"ab\"cd", 5, NULL, TRUE,
9751 "\"#mysql50#ab\"\"cd\""},
9752 {buf, 17,
"ab\"cd", 5, NULL, TRUE,
9753 "\"#mysql50#ab\"\"cd\""},
9754 {buf, 16,
"ab\"cd", 5, NULL, TRUE,
9755 "\"#mysql50#ab\"\"c\""},
9756 {buf, 15,
"ab\"cd", 5, NULL, TRUE,
9757 "\"#mysql50#ab\"\"\""},
9758 {buf, 14,
"ab\"cd", 5, NULL, TRUE,
9760 {buf, 13,
"ab\"cd", 5, NULL, TRUE,
9762 {buf, 12,
"ab\"cd", 5, NULL, TRUE,
9764 {buf, 11,
"ab\"cd", 5, NULL, TRUE,
9766 {buf, 10,
"ab\"cd", 5, NULL, TRUE,
9769 {buf,
sizeof(buf),
"ab/cd", 5, NULL, TRUE,
"\"ab\".\"cd\""},
9770 {buf, 9,
"ab/cd", 5, NULL, TRUE,
"\"ab\".\"cd\""},
9771 {buf, 8,
"ab/cd", 5, NULL, TRUE,
"\"ab\".\"c\""},
9772 {buf, 7,
"ab/cd", 5, NULL, TRUE,
"\"ab\".\"\""},
9773 {buf, 6,
"ab/cd", 5, NULL, TRUE,
"\"ab\"."},
9774 {buf, 5,
"ab/cd", 5, NULL, TRUE,
"\"ab\"."},
9775 {buf, 4,
"ab/cd", 5, NULL, TRUE,
"\"ab\""},
9776 {buf, 3,
"ab/cd", 5, NULL, TRUE,
"\"a\""},
9777 {buf, 2,
"ab/cd", 5, NULL, TRUE,
"\"\""},
9781 {buf, 0,
"ab/cd", 5, NULL, TRUE,
""},
9784 for (i = 0; i <
sizeof(test_input) /
sizeof(test_input[0]); i++) {
9790 fprintf(stderr,
"TESTING %lu, %s, %lu, %s\n",
9791 test_input[i].buflen,
9793 test_input[i].idlen,
9794 test_input[i].expected);
9798 test_input[i].buflen,
9800 test_input[i].idlen,
9801 test_input[i].session,
9802 test_input[i].file_id);
9804 res_len = (size_t) (end - test_input[i].buf);
9806 if (res_len != strlen(test_input[i].expected)) {
9808 fprintf(stderr,
"unexpected len of the result: %u, "
9809 "expected: %u\n", (
unsigned) res_len,
9810 (
unsigned) strlen(test_input[i].expected));
9814 if (memcmp(test_input[i].buf,
9815 test_input[i].expected,
9816 strlen(test_input[i].expected)) != 0
9819 fprintf(stderr,
"unexpected result: %.*s, "
9820 "expected: %s\n", (
int) res_len,
9822 test_input[i].expected);
9827 fprintf(stderr,
"OK: res: %.*s\n\n", (
int) res_len,
9830 fprintf(stderr,
"FAILED\n\n");
UNIV_INTERN ulint trx_savepoint_for_mysql(trx_t *trx, const char *savepoint_name, ib_int64_t binlog_cache_pos)
#define UT_LIST_GET_LEN(BASE)
UNIV_INTERN ulint trx_release_savepoint_for_mysql(trx_t *trx, const char *savepoint_name)
virtual uint32_t pack_length() const
UNIV_INTERN int doEndTableScan()
static trx_t * check_trx_exists(Session *session)
ulint innodb_row_lock_current_waits
UNIV_INTERN ibool dtype_is_string_type(ulint mtype)
UNIV_INTERN int trx_recover_for_mysql(XID *xid_list, ulint len)
static const char * read_ahead_names[]
UNIV_INTERN ulint row_search_for_mysql(byte *buf, ulint mode, row_prebuilt_t *prebuilt, ulint match_mode, ulint direction)
UNIV_INTERN ibool thd_is_select(const drizzled::Session *session)
UNIV_INTERN void srv_conc_enter_innodb(trx_t *trx)
static uint innobase_read_from_2_little_endian(const unsigned char *buf)
UNIV_INTERN int index_next_same(unsigned char *buf, const unsigned char *key, uint keylen)
ibool srv_locks_unsafe_for_binlog
UNIV_INTERN int doUpdateRecord(const unsigned char *old_data, unsigned char *new_data)
UNIV_INTERN void dict_mem_index_add_field(dict_index_t *index, const char *name, ulint prefix_len)
UNIV_INTERN void trx_free_for_mysql(trx_t *trx)
UNIV_INTERN ulint innobase_get_autoinc(uint64_t *value)
UNIV_INLINE trx_id_t trx_sys_get_new_trx_id(void)
UNIV_INTERN void dict_print_info_on_foreign_keys(ibool create_table_format, FILE *file, trx_t *trx, dict_table_t *table)
#define UT_LIST_GET_NEXT(NAME, N)
UNIV_INTERN ulint trx_commit_complete_for_mysql(trx_t *trx)
UNIV_INTERN int discard_or_import_tablespace(bool discard)
UNIV_INLINE void trx_start_if_not_started(trx_t *trx)
UNIV_INTERN bool primary_key_is_clustered()
UNIV_INTERN void innobase_convert_from_table_id(const void *, char *to, const char *from, ulint len)
unsigned clust_index_was_generated
ulint innodb_os_log_fsyncs
ulint innodb_dblwr_writes
static int innobase_rollback_trx(trx_t *trx)
UNIV_INTERN int reset_auto_increment(uint64_t value)
UNIV_INTERN int trx_rollback_for_mysql(trx_t *trx)
#define DICT_TF_FORMAT_MIN
void * memdup(const void *, size_t)
Duplicate the provided block into memory allocated from within the specified Root.
static const char * innodb_stats_method_names[]
#define DICT_TF_FORMAT_SHIFT
UNIV_INTERN ibool srv_parse_log_group_home_dirs(char *str)
UNIV_INTERN read_view_t * trx_assign_read_view(trx_t *trx)
UNIV_INTERN int row_create_table_for_mysql(dict_table_t *table, trx_t *trx)
UNIV_INTERN ulint dict_index_calc_min_rec_len(const dict_index_t *index)
UNIV_INTERN int innobase_start_or_create_for_mysql(void)
bool hasModifiedNonTransData() const
static dict_index_t * innobase_index_lookup(INNOBASE_SHARE *share, uint keynr)
UNIV_INTERN const char * trx_sys_file_format_max_get(void)
ulint innodb_rows_updated
UNIV_INTERN int index_read(unsigned char *buf, const unsigned char *key, uint key_len, enum ha_rkey_function find_flag)
#define DICT_FOREIGN_ON_DELETE_NO_ACTION
ulint innodb_buffer_pool_pages_total
virtual int doXaRollbackXid(::drizzled::XID *xid)
ulint innodb_buffer_pool_read_ahead_evicted
UNIV_INTERN ulint row_search_max_autoinc(dict_index_t *index, const char *col_name, ib_uint64_t *value)
int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted)
UNIV_INTERN ulint innobase_set_max_autoinc(uint64_t auto_inc)
UNIV_INTERN int doStartIndexScan(uint index, bool sorted)
unsigned templ_contains_blob
static const char * adaptive_flushing_method_names[]
static int create_table_def(trx_t *trx, Table *form, const char *table_name, const char *path_of_temp_table, ulint flags)
UNIV_INTERN ~ha_innobase()
#define buf_pool_is_block_lock(l)
UNIV_INLINE dtuple_t * dtuple_create(mem_heap_t *heap, ulint n_fields)
session_id_t getSessionId() const
ulint innodb_buffer_pool_reads
UNIV_INTERN int index_last(unsigned char *buf)
ulint innodb_row_lock_time_avg
UNIV_INTERN ibool btr_validate_index(dict_index_t *index, trx_t *trx)
static void innobase_release_stat_resources(trx_t *trx)
UNIV_INTERN double read_time(uint index, uint ranges, ha_rows rows)
uint buf_LRU_old_threshold_ms
static int create_index(trx_t *trx, Table *form, ulint flags, const char *table_name, uint key_num)
UNIV_INTERN void position(const unsigned char *record)
TODO: Rename this file - func.h is stupid.
UNIV_INTERN void try_semi_consistent_read(bool yes)
UNIV_INTERN void srv_active_wake_master_thread(void)
ibool row_rollback_on_timeout
virtual int doReleaseSavepoint(Session *session, drizzled::NamedSavepoint &savepoint)
UNIV_INTERN int rnd_pos(unsigned char *buf, unsigned char *pos)
UNIV_INLINE ulint dict_col_get_mbmaxlen(const dict_col_t *col)
UNIV_INTERN void ut_print_buf(FILE *file, const void *buf, ulint len)
static void innobase_commit_low(trx_t *trx)
ulint innodb_row_lock_waits
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION
UNIV_INTERN upd_t * row_get_prebuilt_update_vector(row_prebuilt_t *prebuilt)
UNIV_INTERN int index_first(unsigned char *buf)
UNIV_INTERN ibool lock_is_table_exclusive(dict_table_t *table, trx_t *trx)
UNIV_INTERN int general_fetch(unsigned char *buf, uint32_t direction, uint32_t match_mode)
UNIV_INTERN int innobase_shutdown_for_mysql(void)
UNIV_INLINE ibool dict_table_is_comp(const dict_table_t *table)
UNIV_INTERN int doOpen(const drizzled::identifier::Table &identifier, int mode, uint test_if_locked)
UNIV_INTERN int index_read_idx(unsigned char *buf, uint index, const unsigned char *key, uint key_len, enum ha_rkey_function find_flag)
UNIV_INTERN plugin::TransactionalStorageEngine * getTransactionalEngine()
UNIV_INTERN void thd_set_lock_wait_time(drizzled::Session *in_session, ulint value)
UNIV_INLINE ulint dict_col_get_clust_pos(const dict_col_t *col, const dict_index_t *clust_index)
UNIV_INTERN ibool trx_sys_file_format_max_upgrade(const char **name, ulint format_id)
UNIV_INTERN void srv_free_paths_and_sizes(void)
ulint innodb_data_pending_reads
UNIV_INTERN dict_index_t * dict_mem_index_create(const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields)
UNIV_INTERN void dict_mem_table_free(dict_table_t *table)
static int innodb_file_format_name_validate(Session *, set_var *var)
UNIV_INTERN hash_table_t * hash_create(ulint n)
An Proxy Wrapper around boost::program_options::variables_map.
UNIV_INTERN bool was_semi_consistent_read()
#define DICT_FOREIGN_ON_UPDATE_CASCADE
UNIV_INTERN void innobase_mysql_print_thd(FILE *f, drizzled::Session *in_session, uint)
UNIV_INTERN ulint dict_index_get_nth_col_pos(const dict_index_t *index, ulint n)
ulint innodb_buffer_pool_read_ahead
UNIV_INTERN ulong thd_lock_wait_timeout(drizzled::Session *)
UNIV_INTERN int index_prev(unsigned char *buf)
UNIV_INTERN ibool thd_is_replication_slave_thread(drizzled::Session *)
static bool innodb_show_status(plugin::StorageEngine *engine, Session *session, stat_print_fn *stat_print)
const Entries & getEntries() const
#define DICT_FOREIGN_ON_DELETE_SET_NULL
ulint mysql_null_byte_offset
UNIV_INTERN int doDeleteRecord(const unsigned char *buf)
#define DICT_TF_FORMAT_ZIP
static unsigned int innobase_get_mysql_key_number_for_index(INNOBASE_SHARE *share, const drizzled::Table *table, dict_table_t *ib_table, const dict_index_t *index)
#define mem_heap_free(heap)
ulint innodb_os_log_pending_writes
Field * found_next_number_field
UNIV_INTERN ibool thd_supports_xa(drizzled::Session *)
UNIV_INTERN ibool row_merge_is_index_usable(const trx_t *trx, const dict_index_t *index)
const char * getPath() const
UNIV_INTERN void row_mysql_prebuilt_free_blob_heap(row_prebuilt_t *prebuilt)
UNIV_INTERN void srv_conc_exit_innodb(trx_t *trx)
ulint innodb_data_written
#define DICT_TF_ZSSIZE_SHIFT
UNIV_INTERN void dict_update_statistics(dict_table_t *table, ibool only_calc_if_missing_stats)
static int read_ahead_validate(Session *, set_var *var)
static int innobase_init(module::Context &context)
UNIV_INTERN byte * row_mysql_store_col_in_innobase_format(dfield_t *dfield, byte *buf, ibool row_format_col, const byte *mysql_data, ulint col_len, ulint comp)
UNIV_INTERN int doRenameTable(Session &, const identifier::Table &from, const identifier::Table &to)
UNIV_INTERN ulint trx_commit_for_mysql(trx_t *trx)
UNIV_INLINE void dict_col_copy_type(const dict_col_t *col, dtype_t *type)
constrained_check< uint32_t, 95, 5 > old_blocks_constraint
static void innodb_srv_conc_enter_innodb(trx_t *trx)
UNIV_INTERN void row_unlock_table_autoinc_for_mysql(trx_t *trx)
UNIV_INTERN void btr_search_disable(void)
UNIV_INLINE void dfield_copy_data(dfield_t *field1, const dfield_t *field2)
ibool btr_search_fully_disabled
UNIV_INTERN void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index, ulint n_fields)
UNIV_INLINE ulint dict_col_get_mbminlen(const dict_col_t *col)
static int innodb_file_format_max_validate(Session *session, set_var *var)
char * referenced_table_name
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)
unsigned n_user_defined_cols
static int adaptive_flushing_method_validate(Session *, set_var *var)
drizzled::plugin::ReplicationReturnCode apply(drizzled::Session &, const drizzled::message::Transaction &to_apply)
UNIV_INTERN dict_index_t * innobase_get_index(uint keynr)
static uint innobase_file_format_name_lookup(const char *format_name)
virtual int doRollbackToSavepoint(Session *session, drizzled::NamedSavepoint &savepoint)
UNIV_INTERN int row_table_add_foreign_constraints(trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks)
ulint innodb_os_log_written
#define DICT_MAX_INDEX_COL_LEN
DICT_MAX_INDEX_COL_LEN is measured in bytes and is the maximum indexed column length (or indexed pref...
UNIV_INTERN char * mem_heap_strdup(mem_heap_t *heap, const char *str)
UNIV_INTERN ibool trx_is_interrupted(trx_t *trx)
uint32_t srv_auto_lru_dump
UNIV_INTERN int row_discard_tablespace_for_mysql(const char *name, trx_t *trx)
UNIV_INTERN ibool dict_index_contains_col_or_prefix(const dict_index_t *index, ulint n)
ulint innodb_dblwr_pages_written
UNIV_INTERN dict_index_t * dict_table_get_index_on_name(dict_table_t *table, const char *name)
static ibool innobase_build_index_translation(const Table *table, dict_table_t *ib_table, INNOBASE_SHARE *share)
UNIV_INTERN void dict_table_autoinc_update_if_greater(dict_table_t *table, ib_uint64_t value)
UNIV_INTERN uint64_t innobase_peek_autoinc()
UNIV_INTERN const byte * row_mysql_read_blob_ref(ulint *len, const byte *ref, ulint col_len)
UNIV_INTERN void hash_table_free(hash_table_t *table)
UNIV_INTERN double scan_time()
unsigned mysql_has_locked
UNIV_INTERN ha_innobase(plugin::StorageEngine &engine, Table &table_arg)
#define DICT_FOREIGN_ON_DELETE_CASCADE
unsigned need_to_access_clustered
ibool innodb_have_atomic_builtins
UNIV_INTERN ulint get_innobase_type_from_mysql_type(ulint *unsigned_flag, const void *f)
ulint innodb_buffer_pool_pages_dirty
lex_string_t * make_lex_string(lex_string_t *, str_ref)
dict_index_t ** index_mapping
UNIV_INTERN ib_int64_t btr_estimate_n_rows_in_range(dict_index_t *index, const dtuple_t *tuple1, ulint mode1, const dtuple_t *tuple2, ulint mode2)
const char ** referenced_col_names
UNIV_INTERN ulint row_check_index_for_mysql(row_prebuilt_t *prebuilt, const dict_index_t *index, ulint *n_rows)
UNIV_INTERN int get_foreign_key_list(Session *session, List< ForeignKeyInfo > *f_key_list)
UNIV_INTERN void log_buffer_flush_to_disk(void)
const char * innobase_basename(const char *path_name)
static char * innobase_convert_identifier(char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool file_id)
ulint innodb_buffer_pool_read_requests
UNIV_INTERN ullint fsp_get_available_space_in_free_extents(ulint space)
ulint innodb_rows_deleted
UNIV_INTERN ibool os_file_get_status(const char *path, os_file_stat_t *stat_info)
static int calc_row_difference(upd_t *uvect, unsigned char *old_row, unsigned char *new_row, Table *table, unsigned char *upd_buff, ulint buff_len, row_prebuilt_t *prebuilt, Session *)
#define DICT_TF_FORMAT_MAX
static void innobase_active_small(void)
UNIV_INTERN void trx_search_latch_release_if_reserved(trx_t *trx)
ulint innodb_buffer_pool_write_requests
UNIV_INLINE ulint dict_table_get_format(const dict_table_t *table)
UNIV_INTERN int doStartTableScan(bool scan)
UNIV_INTERN int convert_error_code_to_mysql(int error, ulint flags, Session *session)
UNIV_INTERN int extra(enum ha_extra_function operation)
UNIV_INTERN void dtuple_set_n_fields(dtuple_t *tuple, ulint n_fields)
UNIV_INTERN int rnd_next(unsigned char *buf)
UNIV_INTERN ibool trx_is_strict(trx_t *trx)
UNIV_INTERN ibool os_file_set_eof(FILE *file)
ulint innobase_get_at_most_n_mbchars(ulint charset_id, ulint prefix_len, ulint data_len, const char *str)
UNIV_INTERN ulint innobase_raw_format(const char *data, ulint data_len, ulint, char *buf, ulint buf_size)
ulint innodb_data_pending_fsyncs
UNIV_INTERN void row_sel_convert_mysql_key_to_innobase(dtuple_t *tuple, byte *buf, ulint buf_len, dict_index_t *index, const byte *key_ptr, ulint key_len, trx_t *trx)
UNIV_INTERN const char * index_type(uint key_number)
UNIV_INTERN void row_prebuilt_free(row_prebuilt_t *prebuilt, ibool dict_locked)
UNIV_INTERN int external_lock(Session *session, int lock_type)
UNIV_INTERN ulint trx_rollback_to_savepoint_for_mysql(trx_t *trx, const char *savepoint_name, ib_int64_t *mysql_binlog_cache_pos)
UNIV_INTERN ulint innobase_reset_autoinc(uint64_t auto_inc)
UNIV_INTERN char * update_table_comment(const char *comment)
UNIV_INTERN int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
ib_int64_t * stat_n_diff_key_vals
virtual bool flush_logs()
UNIV_INTERN int doEndIndexScan()
UNIV_INTERN dict_table_t * dict_mem_table_create(const char *name, ulint space, ulint n_cols, ulint flags)
query_id_t getQueryId() const
UNIV_INLINE ulint dict_index_is_clust(const dict_index_t *index) __attribute__((pure))
ulint innodb_data_pending_writes
#define DICT_FK_MAX_RECURSIVE_LOAD
UNIV_INTERN THR_LOCK_DATA ** store_lock(Session *session, THR_LOCK_DATA **to, enum thr_lock_type lock_type)
UNIV_INTERN int row_unlock_for_mysql(row_prebuilt_t *prebuilt, ibool has_latches_on_recs)
UNIV_INTERN int info(uint)
UNIV_INTERN int row_truncate_table_for_mysql(dict_table_t *table, trx_t *trx)
ulint stat_sum_of_other_index_sizes
std::vector< unsigned char > key_val_buff
static void reset_template(row_prebuilt_t *prebuilt)
mysql_row_templ_t * mysql_template
UNIV_INTERN void dict_table_autoinc_initialize(dict_table_t *table, ib_uint64_t value)
static ulong commit_threads
virtual int doXaRecover(::drizzled::XID *xid_list, size_t len)
UNIV_INTERN void ut_print_name(FILE *f, struct trx_struct *trx, ibool table_id, const char *name)
ulint stat_clustered_index_size
Defines the interface to the CachedDirectory class.
ulint hint_need_to_fetch_extra_cols
ib_uint64_t autoinc_increment
ulint innodb_pages_created
ulint innodb_pages_written
#define mem_heap_create(N)
UNIV_INTERN int check(Session *session)
ulint innodb_buffer_pool_pages_misc
virtual int doXaPrepare(Session *session, bool all)
static void set_field_in_record_to_null(Table *table, Field *field, char *record)
virtual int close_connection(Session *session)
UNIV_INTERN int innobase_mysql_cmp(int mysql_type, uint charset_number, const unsigned char *a, unsigned int a_length, const unsigned char *b, unsigned int b_length)
ulint innodb_row_lock_time_max
UNIV_INTERN int change_active_index(uint32_t keynr)
static void innobase_write_to_2_little_endian(byte *buf, ulint val)
#define buf_pool_is_block_mutex(m)
UNIV_INTERN uint32_t max_supported_keys() const
UNIV_INTERN void dict_mem_table_add_col(dict_table_t *table, mem_heap_t *heap, const char *name, ulint mtype, ulint prtype, ulint len)
ulint innodb_buffer_pool_pages_free
UNIV_INLINE ulint ut_str_sql_format(const char *str, ulint str_len, char *buf, ulint buf_size)
UNIV_INTERN int close(void)
#define DICT_TF2_SHIFT
Additional table flags.
UNIV_INTERN void unlock_row()
UNIV_INTERN int doInsertRecord(unsigned char *buf)
UNIV_INTERN int index_read_last(unsigned char *buf, const unsigned char *key, uint key_len)
UNIV_INTERN ib_uint64_t dict_table_autoinc_read(const dict_table_t *table)
UNIV_INTERN int innobase_mysql_tmpfile(void)
#define UT_LIST_GET_FIRST(BASE)
static boost::mutex innobase_share_mutex
static ulint innobase_map_isolation_level(enum_tx_isolation iso)
UNIV_INTERN void srv_conc_force_exit_innodb(trx_t *trx)
ulint innodb_buffer_pool_pages_flushed
Field * next_number_field
virtual int doCommit(Session *session, bool all)
ut_list_base_node_t mutex_list
my_bool srv_file_per_table
UNIV_INTERN int row_import_tablespace_for_mysql(const char *name, trx_t *trx)
UNIV_INTERN row_prebuilt_t * row_create_prebuilt(dict_table_t *table)
row_prebuilt_t * prebuilt
static ulint convert_search_mode_to_innobase(enum ha_rkey_function find_flag)
UNIV_INTERN int index_next(unsigned char *buf)
UNIV_INLINE const dict_index_t * trx_get_error_info(const trx_t *trx)
UNIV_INTERN int delete_all_rows()
virtual int doRollback(Session *session, bool all)
UNIV_INTERN trx_t * trx_get_trx_by_xid(const XID *xid)
static void build_template(row_prebuilt_t *prebuilt, Session *, Table *table, uint templ_type)
UNIV_INTERN trx_t * trx_allocate_for_mysql(void)
ulint srv_max_file_format_at_startup
UNIV_INTERN int trx_rollback_last_sql_stat_for_mysql(trx_t *trx)
byte row_id[DATA_ROW_ID_LEN]
UNIV_INTERN int row_update_for_mysql(byte *mysql_rec, row_prebuilt_t *prebuilt)
UNIV_INTERN ibool thd_has_edited_nontrans_tables(drizzled::Session *session)
#define DICT_FOREIGN_ON_UPDATE_SET_NULL
static uint field_in_record_is_null(Table *table, Field *field, char *record)
UNIV_INTERN int row_lock_table_for_mysql(row_prebuilt_t *prebuilt, dict_table_t *table, ulint mode)
UNIV_INTERN void trx_mark_sql_stat_end(trx_t *trx)
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST)
UNIV_INTERN void dict_table_stats_lock(const dict_table_t *table, ulint latch_mode)
UNIV_INTERN void innobase_initialize_autoinc()
unsigned ibd_file_missing
virtual UNIV_INTERN void get_auto_increment(uint64_t offset, uint64_t increment, uint64_t nb_desired_values, uint64_t *first_value, uint64_t *nb_reserved_values)
ib_uint64_t autoinc_last_value
UNIV_INTERN void dict_table_stats_unlock(const dict_table_t *table, ulint latch_mode)
UNIV_INTERN char * innobase_convert_name(char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool table_id)
UNIV_INLINE ulint ut_fold_string(const char *str) __attribute__((pure))
UNIV_INTERN int innobase_strcasecmp(const char *a, const char *b)
std::vector< unsigned char > upd_buff
UNIV_INTERN trx_t * innobase_trx_allocate(Session *session)
innodb_idx_translate_t idx_trans_tbl
UNIV_INLINE ulint dict_index_get_n_unique(const dict_index_t *index)
static uint get_field_offset(Table *table, Field *field)
ibool keep_other_fields_on_keyread
UNIV_INTERN void innobase_casedn_str(char *a)
UNIV_INLINE ulint dtype_get_charset_coll(ulint prtype)
UNIV_INTERN uint store_key_val_for_row(uint keynr, char *buff, uint buff_len, const unsigned char *record)
UNIV_INTERN void dict_table_decrement_handle_count(dict_table_t *table, ibool dict_locked)
UNIV_INTERN int row_create_index_for_mysql(dict_index_t *index, trx_t *trx, const ulint *field_lengths)
static ibool innobase_match_index_columns(const KeyInfo *key_info, const dict_index_t *index_info)
ib_int64_t innodb_row_lock_time
UNIV_INTERN uint referenced_by_foreign_key()
UNIV_INLINE void dfield_set_null(dfield_t *field)
UNIV_INTERN void innobase_get_cset_width(ulint cset, ulint *mbminlen, ulint *mbmaxlen)
static const std::string srv_mysql50_table_name_prefix("#mysql50#")
ulint innodb_rows_inserted
UNIV_INTERN void ut_print_timestamp(FILE *file)
virtual int doXaCommitXid(::drizzled::XID *xid)
static void innodb_srv_conc_exit_innodb(trx_t *trx)
UNIV_INTERN const char * trx_sys_file_format_id_to_name(const ulint id)
ulint innodb_buffer_pool_pages_data
UNIV_INTERN void dict_table_autoinc_lock(dict_table_t *table)
static trx_t *& session_to_trx(Session *session)
static uint64_t innobase_next_autoinc(uint64_t current, uint64_t increment, uint64_t offset, uint64_t max_value)
UNIV_INTERN ulint row_rename_table_for_mysql(const char *old_name, const char *new_name, trx_t *trx, ibool commit)
ulint mysql_null_bit_mask
virtual int doStartTransaction(Session *session, start_transaction_option_t options)
drizzled::Session * mysql_thd
UNIV_INTERN void free_foreign_key_create_info(char *str)
UNIV_INTERN void mem_analyze_corruption(void *ptr)
static int innobase_file_format_validate_and_set(const char *format_max)
UNIV_INTERN int row_insert_for_mysql(byte *mysql_rec, row_prebuilt_t *prebuilt)
char table_name[FN_REFLEN]
UNIV_INTERN const key_map * keys_to_use_for_scanning()
ulint innodb_os_log_pending_fsyncs
UNIV_INTERN dict_table_t * lock_get_src_table(trx_t *trx, dict_table_t *dest, enum lock_mode *mode)
void markTransactionForRollback(bool all)
static bool innodb_mutex_show_status(plugin::StorageEngine *engine, Session *session, stat_print_fn *stat_print)
const char * dir_path_of_temp_table
UNIV_INTERN ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key)
UNIV_INTERN uint32_t max_supported_key_length() const
UNIV_INTERN const byte * row_mysql_read_true_varchar(ulint *len, const byte *field, ulint lenlen)
static const char * innobase_change_buffering_values[IBUF_USE_COUNT]
UNIV_INTERN ibool dict_table_is_referenced_by_foreign_key(const dict_table_t *table)
#define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)
ulint innodb_buffer_pool_wait_free
UNIV_INTERN dict_table_t * dict_table_get(const char *table_name, ibool inc_mysql_count)
static int innodb_change_buffering_validate(Session *, set_var *var)
UNIV_INTERN void srv_export_innodb_status(void)
static INNOBASE_SHARE * get_share(const char *table_name)
UNIV_INTERN void dict_table_autoinc_unlock(dict_table_t *table)
UNIV_INTERN ulint buf_LRU_old_ratio_update(uint old_pct, ibool adjust)
static ha_rows innodb_rec_per_key(dict_index_t *index, ulint i, ha_rows records)
UNIV_INTERN ibool srv_printf_innodb_monitor(FILE *file, ibool nowait, ulint *trx_start, ulint *trx_end)
UNIV_INLINE ulint page_get_free_space_of_empty(ulint comp) __attribute__((const ))
static void innobase_trx_init(Session *session, trx_t *trx)
UNIV_INTERN ibool srv_parse_data_file_paths_and_sizes(char *str)
ulint innodb_log_write_requests
UNIV_INTERN ulint trx_prepare_for_mysql(trx_t *trx)
UNIV_INTERN void read_view_close_for_mysql(trx_t *trx)
UNIV_INTERN ibool dict_col_name_is_reserved(const char *name)
UNIV_INTERN void innobase_convert_from_id(const void *, char *to, const char *from, ulint len)
UNIV_INTERN bool can_switch_engines()
UNIV_INTERN char * get_foreign_key_create_info()
UNIV_INTERN byte * row_mysql_store_true_var_len(byte *dest, ulint len, ulint lenlen)
UNIV_INTERN int doDropTable(Session &session, const identifier::Table &identifier)
UNIV_INTERN void row_update_prebuilt_trx(row_prebuilt_t *prebuilt, trx_t *trx)
UNIV_INTERN int doCreateTable(Session &session, Table &form, const identifier::Table &identifier, const message::Table &)
UNIV_INTERN ulint dtype_form_prtype(ulint old_prtype, ulint charset_coll)
UNIV_INTERN int analyze(Session *session)
UNIV_INTERN ulint innobase_lock_autoinc()
const char ** foreign_col_names
UNIV_INTERN int row_drop_database_for_mysql(const char *name, trx_t *trx)
UNIV_INTERN void update_session(Session *session)
#define DICT_TF2_TEMPORARY
UNIV_INTERN void row_mysql_unlock_data_dictionary(trx_t *trx)
ulint stored_select_lock_type
UNIV_INTERN int row_drop_table_for_mysql(const char *name, trx_t *trx, ibool drop_db)
static int create_clustered_index_when_no_primary(trx_t *trx, ulint flags, const char *table_name)
ulint srv_buf_pool_instances
virtual void doStartStatement(Session *session)
#define TEMP_INDEX_PREFIX
UNIV_INTERN int row_lock_table_autoinc_for_mysql(row_prebuilt_t *prebuilt)
UNIV_INTERN ibool row_table_got_default_clust_index(const dict_table_t *table)
UNIV_INLINE int ut_strcmp(const char *str1, const char *str2)
UNIV_INTERN void btr_search_enable(void)
bool doDropSchema(const identifier::Schema &identifier)
UNIV_INTERN ibool trx_sys_file_format_max_set(ulint format_id, const char **name)
UNIV_INTERN ha_rows estimate_rows_upper_bound()
dict_index_t * referenced_index
static int innobase_rename_table(trx_t *trx, const identifier::Table &from, const identifier::Table &to, ibool lock_and_commit)
virtual int doReleaseTemporaryLatches(Session *session)
UNIV_INTERN ibool dict_table_col_in_clustered_key(const dict_table_t *table, ulint n)
virtual int doSetSavepoint(Session *session, drizzled::NamedSavepoint &savepoint)
static uint64_t innobase_get_int_col_max_value(const Field *field)