summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc170
1 files changed, 100 insertions, 70 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index c9aa08f3992..744bd242fca 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -142,15 +142,16 @@ uint innobase_init_flags = 0;
ulong innobase_cache_size = 0;
ulong innobase_large_page_size = 0;
-/* The default values for the following, type long, start-up parameters
-are declared in mysqld.cc: */
+/* The default values for the following, type long or longlong, start-up
+parameters are declared in mysqld.cc: */
long innobase_mirrored_log_groups, innobase_log_files_in_group,
- innobase_log_file_size, innobase_log_buffer_size,
- innobase_buffer_pool_awe_mem_mb,
- innobase_buffer_pool_size, innobase_additional_mem_pool_size,
- innobase_file_io_threads, innobase_lock_wait_timeout,
- innobase_force_recovery, innobase_open_files;
+ innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb,
+ innobase_additional_mem_pool_size, innobase_file_io_threads,
+ innobase_lock_wait_timeout, innobase_force_recovery,
+ innobase_open_files;
+
+longlong innobase_buffer_pool_size, innobase_log_file_size;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
@@ -812,6 +813,7 @@ ha_innobase::ha_innobase(TABLE *table_arg)
HA_CAN_SQL_HANDLER |
HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX |
+ HA_CAN_GEOMETRY |
HA_TABLE_SCAN_ON_INDEX),
last_dup_key((uint) -1),
start_of_scan(0),
@@ -1209,6 +1211,25 @@ innobase_init(void)
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
+ /* Check that values don't overflow on 32-bit systems. */
+ if (sizeof(ulint) == 4) {
+ if (innobase_buffer_pool_size > UINT_MAX32) {
+ sql_print_error(
+ "innobase_buffer_pool_size can't be over 4GB"
+ " on 32-bit systems");
+
+ goto error;
+ }
+
+ if (innobase_log_file_size > UINT_MAX32) {
+ sql_print_error(
+ "innobase_log_file_size can't be over 4GB"
+ " on 32-bit systems");
+
+ goto error;
+ }
+ }
+
os_innodb_umask = (ulint)my_umask;
/* First calculate the default path for innodb_data_home_dir etc.,
@@ -2177,11 +2198,13 @@ innobase_savepoint(
DBUG_ENTER("innobase_savepoint");
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
- /* In the autocommit state there is no sense to set a
- savepoint: we return immediate success */
- DBUG_RETURN(0);
- }
+ /*
+ In the autocommit mode there is no sense to set a savepoint
+ (unless we are in sub-statement), so SQL layer ensures that
+ this method is never called in such situation.
+ */
+ DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
+ thd->in_sub_stmt);
trx = check_trx_exists(thd);
@@ -2496,6 +2519,12 @@ ha_innobase::open(
DBUG_RETURN(0);
}
+uint
+ha_innobase::max_supported_key_part_length() const
+{
+ return(DICT_MAX_INDEX_COL_LEN - 1);
+}
+
/**********************************************************************
Closes a handle to an InnoDB table. */
@@ -2757,6 +2786,7 @@ get_innobase_type_from_mysql_type(
return(DATA_DOUBLE);
case FIELD_TYPE_DECIMAL:
return(DATA_DECIMAL);
+ case FIELD_TYPE_GEOMETRY:
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_BLOB:
@@ -3007,8 +3037,8 @@ ha_innobase::store_key_val_for_row(
if (key_part->length > 0 && cs->mbmaxlen > 1) {
len = (ulint) cs->cset->well_formed_len(cs,
- src_start,
- src_start + key_part->length,
+ (const char *) src_start,
+ (const char *) src_start + key_part->length,
key_part->length / cs->mbmaxlen,
&error);
} else {
@@ -4651,6 +4681,9 @@ create_index(
0, prefix_len);
}
+ /* Even though we've defined max_supported_key_part_length, we
+ still do our own checking using field_lengths to be absolutely
+ sure we don't create too long indexes. */
error = row_create_index_for_mysql(index, trx, field_lengths);
error = convert_error_code_to_mysql(error, NULL);
@@ -5709,6 +5742,7 @@ ha_innobase::update_table_comment(
uint length = (uint) strlen(comment);
char* str;
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
+ long flen;
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -5728,43 +5762,43 @@ ha_innobase::update_table_comment(
trx_search_latch_release_if_reserved(prebuilt->trx);
str = NULL;
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ /* output the data to a temporary file */
+
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
- /* output the data to a temporary file */
- fprintf(file, "InnoDB free: %lu kB",
+ fprintf(srv_dict_tmpfile, "InnoDB free: %lu kB",
(ulong) fsp_get_available_space_in_free_extents(
prebuilt->table->space));
- dict_print_info_on_foreign_keys(FALSE, file,
+ dict_print_info_on_foreign_keys(FALSE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (length + flen + 3 > 64000) {
- flen = 64000 - 3 - length;
- }
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (length + flen + 3 > 64000) {
+ flen = 64000 - 3 - length;
+ }
- /* allocate buffer for the full string, and
- read the contents of the temporary file */
+ /* allocate buffer for the full string, and
+ read the contents of the temporary file */
- str = my_malloc(length + flen + 3, MYF(0));
+ str = my_malloc(length + flen + 3, MYF(0));
- if (str) {
- char* pos = str + length;
- if (length) {
- memcpy(str, comment, length);
- *pos++ = ';';
- *pos++ = ' ';
- }
- rewind(file);
- flen = (uint) fread(pos, 1, flen, file);
- pos[flen] = 0;
+ if (str) {
+ char* pos = str + length;
+ if (length) {
+ memcpy(str, comment, length);
+ *pos++ = ';';
+ *pos++ = ' ';
}
-
- fclose(file);
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(pos, 1, flen, srv_dict_tmpfile);
+ pos[flen] = 0;
}
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
+
prebuilt->trx->op_info = (char*)"";
return(str ? str : (char*) comment);
@@ -5782,6 +5816,7 @@ ha_innobase::get_foreign_key_create_info(void)
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str = 0;
+ long flen;
ut_a(prebuilt != NULL);
@@ -5791,47 +5826,42 @@ ha_innobase::get_foreign_key_create_info(void)
update_thd(current_thd);
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ prebuilt->trx->op_info = (char*)"getting info on foreign keys";
- prebuilt->trx->op_info = (char*)"getting info on foreign keys";
+ /* In case MySQL calls this in the middle of a SELECT query,
+ release possible adaptive hash latch to avoid
+ deadlocks of threads */
- /* In case MySQL calls this in the middle of a SELECT query,
- release possible adaptive hash latch to avoid
- deadlocks of threads */
+ trx_search_latch_release_if_reserved(prebuilt->trx);
- trx_search_latch_release_if_reserved(prebuilt->trx);
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
- /* output the data to a temporary file */
- dict_print_info_on_foreign_keys(TRUE, file,
+ /* output the data to a temporary file */
+ dict_print_info_on_foreign_keys(TRUE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- prebuilt->trx->op_info = (char*)"";
-
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (flen > 64000 - 1) {
- flen = 64000 - 1;
- }
+ prebuilt->trx->op_info = (char*)"";
- /* allocate buffer for the string, and
- read the contents of the temporary file */
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (flen > 64000 - 1) {
+ flen = 64000 - 1;
+ }
- str = my_malloc(flen + 1, MYF(0));
+ /* allocate buffer for the string, and
+ read the contents of the temporary file */
- if (str) {
- rewind(file);
- flen = (uint) fread(str, 1, flen, file);
- str[flen] = 0;
- }
+ str = my_malloc(flen + 1, MYF(0));
- fclose(file);
- } else {
- /* unable to create temporary file */
- str = my_strdup(
-"/* Error: cannot display foreign key constraints */", MYF(0));
+ if (str) {
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(str, 1, flen, srv_dict_tmpfile);
+ str[flen] = 0;
}
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
+
return(str);
}