summaryrefslogtreecommitdiff
path: root/storage/innobase/handler/ha_innodb.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/handler/ha_innodb.cc')
-rw-r--r--storage/innobase/handler/ha_innodb.cc115
1 files changed, 45 insertions, 70 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 587e16a67cb..359805ff95d 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -117,6 +117,9 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "ha_innodb.h"
#include "i_s.h"
+#include <string>
+#include <sstream>
+
#include <mysql/plugin.h>
#include <mysql/service_wsrep.h>
@@ -2283,10 +2286,11 @@ innobase_next_autoinc(
if (next_value == 0) {
ulonglong next;
- if (current > offset) {
+ if (current >= offset) {
next = (current - offset) / step;
} else {
- next = (offset - current) / step;
+ next = 0;
+ block -= step;
}
ut_a(max_value > next);
@@ -13793,8 +13797,9 @@ ha_innobase::update_table_comment(
const char* comment)/*!< in: table comment defined by user */
{
uint length = (uint) strlen(comment);
- char* str;
+ char* str=0;
long flen;
+ std::string fk_str;
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -13812,50 +13817,40 @@ ha_innobase::update_table_comment(
possible adaptive hash latch to avoid deadlocks of threads */
trx_search_latch_release_if_reserved(prebuilt->trx);
- str = NULL;
-
- /* output the data to a temporary file */
- if (!srv_read_only_mode) {
-
- mutex_enter(&srv_dict_tmpfile_mutex);
+#define SSTR( x ) reinterpret_cast< std::ostringstream & >( \
+ ( std::ostringstream() << std::dec << x ) ).str()
- rewind(srv_dict_tmpfile);
+ fk_str.append("InnoDB free: ");
+ fk_str.append(SSTR(fsp_get_available_space_in_free_extents(
+ prebuilt->table->space)));
- fprintf(srv_dict_tmpfile, "InnoDB free: %llu kB",
- fsp_get_available_space_in_free_extents(
- prebuilt->table->space));
+ fk_str.append(dict_print_info_on_foreign_keys(
+ FALSE, prebuilt->trx,
+ prebuilt->table));
- dict_print_info_on_foreign_keys(
- FALSE, srv_dict_tmpfile, prebuilt->trx,
- prebuilt->table);
+ flen = fk_str.length();
- flen = ftell(srv_dict_tmpfile);
-
- if (flen < 0) {
- flen = 0;
- } else if (length + flen + 3 > 64000) {
- flen = 64000 - 3 - length;
- }
+ 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 */
- str = (char*) my_malloc(length + flen + 3, MYF(0));
+ str = (char*) my_malloc(length + flen + 3, MYF(0));
- if (str) {
- char* pos = str + length;
- if (length) {
- memcpy(str, comment, length);
- *pos++ = ';';
- *pos++ = ' ';
- }
- rewind(srv_dict_tmpfile);
- flen = (uint) fread(pos, 1, flen, srv_dict_tmpfile);
- pos[flen] = 0;
+ if (str) {
+ char* pos = str + length;
+ if (length) {
+ memcpy(str, comment, length);
+ *pos++ = ';';
+ *pos++ = ' ';
}
- mutex_exit(&srv_dict_tmpfile_mutex);
+ memcpy(pos, fk_str.c_str(), flen);
+ pos[flen] = 0;
}
prebuilt->trx->op_info = (char*)"";
@@ -13873,8 +13868,7 @@ char*
ha_innobase::get_foreign_key_create_info(void)
/*==========================================*/
{
- long flen;
- char* str = 0;
+ char* fk_str = 0;
ut_a(prebuilt != NULL);
@@ -13892,38 +13886,22 @@ ha_innobase::get_foreign_key_create_info(void)
trx_search_latch_release_if_reserved(prebuilt->trx);
- if (!srv_read_only_mode) {
- mutex_enter(&srv_dict_tmpfile_mutex);
- rewind(srv_dict_tmpfile);
-
- /* Output the data to a temporary file */
- dict_print_info_on_foreign_keys(
- TRUE, srv_dict_tmpfile, prebuilt->trx,
+ /* Output the data to a temporary file */
+ std::string str = dict_print_info_on_foreign_keys(
+ TRUE, prebuilt->trx,
prebuilt->table);
- prebuilt->trx->op_info = (char*)"";
-
- flen = ftell(srv_dict_tmpfile);
-
- if (flen < 0) {
- flen = 0;
- }
-
- /* Allocate buffer for the string, and
- read the contents of the temporary file */
-
- str = (char*) my_malloc(flen + 1, MYF(0));
+ prebuilt->trx->op_info = (char*)"";
- if (str) {
- rewind(srv_dict_tmpfile);
- flen = (uint) fread(str, 1, flen, srv_dict_tmpfile);
- str[flen] = 0;
- }
+ /* Allocate buffer for the string */
+ fk_str = (char*) my_malloc(str.length() + 1, MYF(0));
- mutex_exit(&srv_dict_tmpfile_mutex);
+ if (fk_str) {
+ memcpy(fk_str, str.c_str(), str.length());
+ fk_str[str.length()]='\0';
}
- return(str);
+ return(fk_str);
}
@@ -15542,10 +15520,7 @@ ha_innobase::get_auto_increment(
current = *first_value;
- /* If the increment step of the auto increment column
- decreases then it is not affecting the immediate
- next value in the series. */
- if (prebuilt->autoinc_increment > increment) {
+ if (prebuilt->autoinc_increment != increment) {
WSREP_DEBUG("autoinc decrease: %llu -> %llu\n"
"THD: %ld, current: %llu, autoinc: %llu",
@@ -15559,7 +15534,7 @@ ha_innobase::get_auto_increment(
}
current = innobase_next_autoinc(
- current, 1, increment, 1, col_max_value);
+ current, 1, increment, offset, col_max_value);
dict_table_autoinc_initialize(prebuilt->table, current);