summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/archive/Makefile.am5
-rw-r--r--storage/archive/azio.c10
-rw-r--r--storage/blackhole/Makefile.am5
-rw-r--r--storage/csv/ha_tina.cc47
-rw-r--r--storage/csv/ha_tina.h1
-rw-r--r--storage/example/Makefile.am5
-rw-r--r--storage/federated/Makefile.am5
-rw-r--r--storage/federated/ha_federated.cc42
-rw-r--r--storage/innobase/Makefile.am3
-rw-r--r--storage/innobase/dict/dict0dict.c6
-rw-r--r--storage/innobase/handler/ha_innodb.cc61
-rw-r--r--storage/innobase/handler/ha_innodb.h2
-rw-r--r--storage/innobase/include/dict0dict.h6
-rw-r--r--storage/innobase/include/dict0mem.h2
-rw-r--r--storage/innobase/include/row0sel.h2
-rw-r--r--storage/innobase/include/univ.i3
-rw-r--r--storage/innobase/row/row0sel.c10
-rw-r--r--storage/myisam/ft_static.c1
-rw-r--r--storage/myisam/ha_myisam.cc86
-rw-r--r--storage/myisam/mi_dynrec.c32
-rw-r--r--storage/myisam/mi_open.c14
-rw-r--r--storage/myisammrg/ha_myisammrg.cc6
-rw-r--r--storage/ndb/include/ndb_version.h.in5
-rw-r--r--storage/ndb/src/common/util/SocketServer.cpp2
-rw-r--r--storage/ndb/src/kernel/blocks/tsman.cpp1
25 files changed, 257 insertions, 105 deletions
diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am
index 4920527e0e9..d092f091798 100644
--- a/storage/archive/Makefile.am
+++ b/storage/archive/Makefile.am
@@ -19,6 +19,7 @@ MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
@@ -33,8 +34,8 @@ noinst_HEADERS = ha_archive.h azlib.h
noinst_PROGRAMS = archive_test archive_reader
EXTRA_LTLIBRARIES = ha_archive.la
-pkglib_LTLIBRARIES = @plugin_archive_shared_target@
-ha_archive_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
+pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
+ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_archive_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_archive_la_SOURCES = ha_archive.cc azio.c
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index cada6c57918..59fbe2182ee 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -225,11 +225,17 @@ int get_byte(s)
if (s->stream.avail_in == 0)
{
errno = 0;
- s->stream.avail_in = my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0));
+ s->stream.avail_in= (uInt) my_read(s->file, (uchar *)s->inbuf,
+ AZ_BUFSIZE_READ, MYF(0));
if (s->stream.avail_in == 0)
{
s->z_eof = 1;
- /* if (ferror(s->file)) s->z_err = Z_ERRNO; */
+ return EOF;
+ }
+ else if (s->stream.avail_in == (uInt) -1)
+ {
+ s->z_eof= 1;
+ s->z_err= Z_ERRNO;
return EOF;
}
s->stream.next_in = s->inbuf;
diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am
index 9dd533dd4fa..db4f67cf847 100644
--- a/storage/blackhole/Makefile.am
+++ b/storage/blackhole/Makefile.am
@@ -19,6 +19,7 @@ MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
@@ -32,8 +33,8 @@ DEFS = @DEFS@
noinst_HEADERS = ha_blackhole.h
EXTRA_LTLIBRARIES = ha_blackhole.la
-pkglib_LTLIBRARIES = @plugin_blackhole_shared_target@
-ha_blackhole_la_LDFLAGS=-module -rpath $(MYSQLLIBdir)
+pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
+ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
ha_blackhole_la_CXXFLAGS=$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_blackhole_la_SOURCES=ha_blackhole.cc
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index c9fab79a4c5..f8dd778045f 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -56,6 +56,7 @@ TODO:
#define META_BUFFER_SIZE sizeof(uchar) + sizeof(uchar) + sizeof(ulonglong) \
+ sizeof(ulonglong) + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(uchar)
#define TINA_CHECK_HEADER 254 // The number we use to determine corruption
+#define BLOB_MEMROOT_ALLOC_SIZE 8192
/* The file extension */
#define CSV_EXT ".CSV" // The data file
@@ -597,6 +598,8 @@ int ha_tina::find_current_row(uchar *buf)
bool read_all;
DBUG_ENTER("ha_tina::find_current_row");
+ free_root(&blobroot, MYF(MY_MARK_BLOCKS_FREE));
+
/*
We do not read further then local_saved_data_file_length in order
not to conflict with undergoing concurrent insert.
@@ -684,6 +687,22 @@ int ha_tina::find_current_row(uchar *buf)
if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(),
CHECK_FIELD_WARN))
goto err;
+ if ((*field)->flags & BLOB_FLAG)
+ {
+ Field_blob *blob= *(Field_blob**) field;
+ uchar *src, *tgt;
+ uint length, packlength;
+
+ packlength= blob->pack_length_no_ptr();
+ length= blob->get_length(blob->ptr);
+ memcpy_fixed(&src, blob->ptr + packlength, sizeof(char*));
+ if (src)
+ {
+ tgt= (uchar*) alloc_root(&blobroot, length);
+ bmove(tgt, src, length);
+ memcpy_fixed(blob->ptr + packlength, &tgt, sizeof(char*));
+ }
+ }
}
}
next_position= end_offset + eoln_len;
@@ -914,9 +933,10 @@ int ha_tina::open_update_temp_file_if_needed()
int ha_tina::update_row(const uchar * old_data, uchar * new_data)
{
int size;
+ int rc= -1;
DBUG_ENTER("ha_tina::update_row");
- ha_statistic_increment(&SSV::ha_read_rnd_next_count);
+ ha_statistic_increment(&SSV::ha_update_count);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time();
@@ -931,20 +951,23 @@ int ha_tina::update_row(const uchar * old_data, uchar * new_data)
The temp_file_length is used to calculate new data file length.
*/
if (chain_append())
- DBUG_RETURN(-1);
+ goto err;
if (open_update_temp_file_if_needed())
- DBUG_RETURN(-1);
+ goto err;
if (my_write(update_temp_file, (uchar*)buffer.ptr(), size,
MYF(MY_WME | MY_NABP)))
- DBUG_RETURN(-1);
+ goto err;
temp_file_length+= size;
+ rc= 0;
/* UPDATE should never happen on the log tables */
DBUG_ASSERT(!share->is_log_table);
- DBUG_RETURN(0);
+err:
+ DBUG_PRINT("info",("rc = %d", rc));
+ DBUG_RETURN(rc);
}
@@ -1050,6 +1073,8 @@ int ha_tina::rnd_init(bool scan)
records_is_known= 0;
chain_ptr= chain;
+ init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0);
+
DBUG_RETURN(0);
}
@@ -1115,7 +1140,7 @@ void ha_tina::position(const uchar *record)
int ha_tina::rnd_pos(uchar * buf, uchar *pos)
{
DBUG_ENTER("ha_tina::rnd_pos");
- ha_statistic_increment(&SSV::ha_read_rnd_next_count);
+ ha_statistic_increment(&SSV::ha_read_rnd_count);
current_position= (off_t)my_get_ptr(pos,ref_length);
DBUG_RETURN(find_current_row(buf));
}
@@ -1179,6 +1204,7 @@ int ha_tina::rnd_end()
off_t file_buffer_start= 0;
DBUG_ENTER("ha_tina::rnd_end");
+ free_root(&blobroot, MYF(0));
records_is_known= 1;
if ((chain_ptr - chain) > 0)
@@ -1350,6 +1376,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
/* set current position to the beginning of the file */
current_position= next_position= 0;
+ init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0);
+
/* Read the file row-by-row. If everything is ok, repair is not needed. */
while (!(rc= find_current_row(buf)))
{
@@ -1358,6 +1386,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
current_position= next_position;
}
+ free_root(&blobroot, MYF(0));
+
my_free((char*)buf, MYF(0));
if (rc == HA_ERR_END_OF_FILE)
@@ -1535,6 +1565,9 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
local_saved_data_file_length= share->saved_data_file_length;
/* set current position to the beginning of the file */
current_position= next_position= 0;
+
+ init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0);
+
/* Read the file row-by-row. If everything is ok, repair is not needed. */
while (!(rc= find_current_row(buf)))
{
@@ -1542,6 +1575,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
count--;
current_position= next_position;
}
+
+ free_root(&blobroot, MYF(0));
my_free((char*)buf, MYF(0));
thd_proc_info(thd, old_proc_info);
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index 5ce09783b9b..5b4381396fc 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -82,6 +82,7 @@ class ha_tina: public handler
uint32 chain_size;
uint local_data_file_version; /* Saved version of the data file used */
bool records_is_known;
+ MEM_ROOT blobroot;
private:
bool get_write_pos(off_t *end_pos, tina_set *closest_hole);
diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am
index 73016d24b57..4b2f165377c 100644
--- a/storage/example/Makefile.am
+++ b/storage/example/Makefile.am
@@ -19,6 +19,7 @@ MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
@@ -32,8 +33,8 @@ DEFS = @DEFS@
noinst_HEADERS = ha_example.h
EXTRA_LTLIBRARIES = ha_example.la
-pkglib_LTLIBRARIES = @plugin_example_shared_target@
-ha_example_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
+pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
+ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_example_la_SOURCES = ha_example.cc
diff --git a/storage/federated/Makefile.am b/storage/federated/Makefile.am
index 287b2cb1696..64ea0207017 100644
--- a/storage/federated/Makefile.am
+++ b/storage/federated/Makefile.am
@@ -19,6 +19,7 @@ MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
@@ -32,8 +33,8 @@ DEFS = @DEFS@
noinst_HEADERS = ha_federated.h
EXTRA_LTLIBRARIES = ha_federated.la
-pkglib_LTLIBRARIES = @plugin_federated_shared_target@
-ha_federated_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
+pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
+ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_federated_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_federated_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_federated_la_SOURCES = ha_federated.cc
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 091a26f6f36..5702b2f3514 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -794,9 +794,9 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table,
goto error;
/*
Found that if the string is:
-user:@hostname:port/db/table
-Then password is a null string, so set to NULL
- */
+ user:@hostname:port/db/table
+ Then password is a null string, so set to NULL
+ */
if ((share->password[0] == '\0'))
share->password= NULL;
}
@@ -833,14 +833,21 @@ Then password is a null string, so set to NULL
if ((strchr(share->table_name, '/')))
goto error;
+ /*
+ If hostname is omitted, we set it to NULL. According to
+ mysql_real_connect() manual:
+ The value of host may be either a hostname or an IP address.
+ If host is NULL or the string "localhost", a connection to the
+ local host is assumed.
+ */
if (share->hostname[0] == '\0')
share->hostname= NULL;
-
}
+
if (!share->port)
{
- if (strcmp(share->hostname, my_localhost) == 0)
- share->socket= (char *) MYSQL_UNIX_ADDR;
+ if (!share->hostname || strcmp(share->hostname, my_localhost) == 0)
+ share->socket= (char*) MYSQL_UNIX_ADDR;
else
share->port= MYSQL_PORT;
}
@@ -1292,10 +1299,21 @@ bool ha_federated::create_where_from_key(String *to,
{
if (*ptr++)
{
+ /*
+ We got "IS [NOT] NULL" condition against nullable column. We
+ distinguish between "IS NOT NULL" and "IS NULL" by flag. For
+ "IS NULL", flag is set to HA_READ_KEY_EXACT.
+ */
if (emit_key_part_name(&tmp, key_part) ||
- tmp.append(STRING_WITH_LEN(" IS NULL ")))
+ (ranges[i]->flag == HA_READ_KEY_EXACT ?
+ tmp.append(STRING_WITH_LEN(" IS NULL ")) :
+ tmp.append(STRING_WITH_LEN(" IS NOT NULL "))))
goto err;
- continue;
+ /*
+ We need to adjust pointer and length to be prepared for next
+ key part. As well as check if this was last key part.
+ */
+ goto prepare_for_next_key_part;
}
}
@@ -1403,12 +1421,18 @@ bool ha_federated::create_where_from_key(String *to,
if (tmp.append(STRING_WITH_LEN(") ")))
goto err;
+prepare_for_next_key_part:
if (store_length >= length)
break;
DBUG_PRINT("info", ("remainder %d", remainder));
DBUG_ASSERT(remainder > 1);
length-= store_length;
- ptr+= store_length;
+ /*
+ For nullable columns, null-byte is already skipped before, that is
+ ptr was incremented by 1. Since store_length still counts null-byte,
+ we need to subtract 1 from store_length.
+ */
+ ptr+= store_length - test(key_part->null_bit);
if (tmp.append(STRING_WITH_LEN(" AND ")))
goto err;
diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am
index 30e056d68fb..563522cd032 100644
--- a/storage/innobase/Makefile.am
+++ b/storage/innobase/Makefile.am
@@ -19,6 +19,7 @@ MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/storage/innobase/include \
@@ -160,7 +161,7 @@ libinnobase_a_CFLAGS = $(AM_CFLAGS)
EXTRA_LTLIBRARIES = ha_innodb.la
pkglib_LTLIBRARIES = @plugin_innobase_shared_target@
-ha_innodb_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
+ha_innodb_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_innodb_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_innodb_la_SOURCES = $(libinnobase_a_SOURCES)
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index 8aba5ac1c85..10cef688705 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -429,7 +429,7 @@ void
dict_table_autoinc_initialize(
/*==========================*/
dict_table_t* table, /* in: table */
- ib_longlong value) /* in: next value to assign to a row */
+ ib_ulonglong value) /* in: next value to assign to a row */
{
ut_ad(mutex_own(&table->autoinc_mutex));
@@ -441,7 +441,7 @@ dict_table_autoinc_initialize(
Reads the next autoinc value (== autoinc counter value), 0 if not yet
initialized. */
-ib_longlong
+ib_ulonglong
dict_table_autoinc_read(
/*====================*/
/* out: value for a new row, or 0 */
@@ -470,7 +470,7 @@ dict_table_autoinc_update(
/*======================*/
dict_table_t* table, /* in: table */
- ib_longlong value) /* in: value which was assigned to a row */
+ ib_ulonglong value) /* in: value which was assigned to a row */
{
if (table->autoinc_inited && value > table->autoinc) {
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index f81804c0701..d81f0721025 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -3545,7 +3545,19 @@ no_commit:
if (auto_inc > prebuilt->last_value) {
set_max_autoinc:
ut_a(prebuilt->table->autoinc_increment > 0);
- auto_inc += prebuilt->table->autoinc_increment;
+
+ ulonglong have;
+ ulonglong need;
+
+ /* Check for overflow conditions. */
+ need = prebuilt->table->autoinc_increment;
+ have = ~0x0ULL - auto_inc;
+
+ if (have < need) {
+ need = have;
+ }
+
+ auto_inc += need;
err = innobase_set_max_autoinc(auto_inc);
@@ -5105,8 +5117,15 @@ ha_innobase::create(
DBUG_ASSERT(innobase_table != 0);
- if ((create_info->used_fields & HA_CREATE_USED_AUTO) &&
- (create_info->auto_increment_value != 0)) {
+ /* Note: We can't call update_thd() as prebuilt will not be
+ setup at this stage and so we use thd. */
+
+ /* We need to copy the AUTOINC value from the old table if
+ this is an ALTER TABLE. */
+
+ if (((create_info->used_fields & HA_CREATE_USED_AUTO)
+ || thd_sql_command(thd) == SQLCOM_ALTER_TABLE)
+ && create_info->auto_increment_value != 0) {
/* Query was ALTER TABLE...AUTO_INCREMENT = x; or
CREATE TABLE ...AUTO_INCREMENT = x; Find out a table
@@ -5856,7 +5875,7 @@ ha_innobase::info(
}
if (flag & HA_STATUS_AUTO && table->found_next_number_field) {
- longlong auto_inc;
+ ulonglong auto_inc;
int ret;
/* The following function call can the first time fail in
@@ -6207,6 +6226,8 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
foreign->referenced_index->name,
strlen(foreign->referenced_index->name), 1);
}
+ else
+ f_key_info.referenced_key_name= 0;
FOREIGN_KEY_INFO *pf_key_info = (FOREIGN_KEY_INFO *)
thd_memdup(thd, &f_key_info, sizeof(FOREIGN_KEY_INFO));
@@ -7207,9 +7228,9 @@ ha_innobase::innobase_read_and_init_auto_inc(
/*=========================================*/
/* out: 0 or generic MySQL
error code */
- longlong* value) /* out: the autoinc value */
+ ulonglong* value) /* out: the autoinc value */
{
- longlong auto_inc;
+ ulonglong auto_inc;
ibool stmt_start;
int mysql_error = 0;
dict_table_t* innodb_table = prebuilt->table;
@@ -7260,7 +7281,9 @@ ha_innobase::innobase_read_and_init_auto_inc(
index, autoinc_col_name, &auto_inc);
if (error == DB_SUCCESS) {
- ++auto_inc;
+ if (auto_inc < ~0x0ULL) {
+ ++auto_inc;
+ }
dict_table_autoinc_initialize(innodb_table, auto_inc);
} else {
ut_print_timestamp(stderr);
@@ -7313,14 +7336,14 @@ ha_innobase::innobase_get_auto_increment(
error = innobase_autoinc_lock();
if (error == DB_SUCCESS) {
- ib_longlong autoinc;
+ ulonglong autoinc;
/* Determine the first value of the interval */
autoinc = dict_table_autoinc_read(prebuilt->table);
/* We need to initialize the AUTO-INC value, for
that we release all locks.*/
- if (autoinc <= 0) {
+ if (autoinc == 0) {
trx_t* trx;
trx = prebuilt->trx;
@@ -7339,14 +7362,11 @@ ha_innobase::innobase_get_auto_increment(
mysql_error = innobase_read_and_init_auto_inc(
&autoinc);
- if (!mysql_error) {
- /* Should have read the proper value */
- ut_a(autoinc > 0);
- } else {
+ if (mysql_error) {
error = DB_ERROR;
}
} else {
- *value = (ulonglong) autoinc;
+ *value = autoinc;
}
/* A deadlock error during normal processing is OK
and can be ignored. */
@@ -7431,10 +7451,19 @@ ha_innobase::get_auto_increment(
/* With old style AUTOINC locking we only update the table's
AUTOINC counter after attempting to insert the row. */
if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) {
+ ulonglong have;
+ ulonglong need;
+
+ /* Check for overflow conditions. */
+ need = *nb_reserved_values * increment;
+ have = ~0x0ULL - *first_value;
+
+ if (have < need) {
+ need = have;
+ }
/* Compute the last value in the interval */
- prebuilt->last_value = *first_value +
- (*nb_reserved_values * increment);
+ prebuilt->last_value = *first_value + need;
ut_a(prebuilt->last_value >= *first_value);
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index 773884b6584..4ffcdb1e3c2 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -72,7 +72,7 @@ class ha_innobase: public handler
int update_thd(THD* thd);
int change_active_index(uint keynr);
int general_fetch(uchar* buf, uint direction, uint match_mode);
- int innobase_read_and_init_auto_inc(longlong* ret);
+ int innobase_read_and_init_auto_inc(ulonglong* ret);
ulong innobase_autoinc_lock();
ulong innobase_set_max_autoinc(ulonglong auto_inc);
ulong innobase_reset_autoinc(ulonglong auto_inc);
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 2f038b21e8e..f60775c8c2f 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -185,12 +185,12 @@ void
dict_table_autoinc_initialize(
/*==========================*/
dict_table_t* table, /* in: table */
- ib_longlong value); /* in: next value to assign to a row */
+ ib_ulonglong value); /* in: next value to assign to a row */
/************************************************************************
Reads the next autoinc value (== autoinc counter value), 0 if not yet
initialized. */
-ib_longlong
+ib_ulonglong
dict_table_autoinc_read(
/*====================*/
/* out: value for a new row, or 0 */
@@ -204,7 +204,7 @@ dict_table_autoinc_update(
/*======================*/
dict_table_t* table, /* in: table */
- ib_longlong value); /* in: value which was assigned to a row */
+ ib_ulonglong value); /* in: value which was assigned to a row */
/************************************************************************
Release the autoinc lock.*/
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index a05bc513efd..2fe72498989 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -409,7 +409,7 @@ struct dict_table_struct{
/* TRUE if the autoinc counter has been
inited; MySQL gets the init value by executing
SELECT MAX(auto inc column) */
- ib_longlong autoinc;/* autoinc counter value to give to the
+ ib_ulonglong autoinc;/* autoinc counter value to give to the
next inserted row */
ib_longlong autoinc_increment;
diff --git a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h
index 4bde648f18e..a0a4ccb973b 100644
--- a/storage/innobase/include/row0sel.h
+++ b/storage/innobase/include/row0sel.h
@@ -181,7 +181,7 @@ row_search_max_autoinc(
error code */
dict_index_t* index, /* in: index to search */
const char* col_name, /* in: autoinc column name */
- ib_longlong* value); /* out: AUTOINC value read */
+ ib_ulonglong* value); /* out: AUTOINC value read */
/* A structure for caching column values for prefetched rows */
struct sel_buf_struct{
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index 8163ae16e4e..8ab62e655ff 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -212,8 +212,11 @@ typedef long int lint;
#ifdef __WIN__
typedef __int64 ib_longlong;
+typedef unsigned __int64 ib_ulonglong;
#else
+/* Note: longlong and ulonglong come from MySQL headers. */
typedef longlong ib_longlong;
+typedef ulonglong ib_ulonglong;
#endif
typedef unsigned long long int ullint;
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index 29bded114e0..b050838aad2 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -4529,7 +4529,7 @@ row_search_check_if_query_cache_permitted(
Read the AUTOINC column from the current row. If the value is less than
0 and the type is not unsigned then we reset the value to 0. */
static
-ib_longlong
+ib_ulonglong
row_search_autoinc_read_column(
/*===========================*/
/* out: value read from the column */
@@ -4540,7 +4540,7 @@ row_search_autoinc_read_column(
{
ulint len;
const byte* data;
- ib_longlong value;
+ ib_ulonglong value;
mem_heap_t* heap = NULL;
/* Our requirement is that dest should be word aligned. */
byte dest[sizeof(value)];
@@ -4567,7 +4567,7 @@ row_search_autoinc_read_column(
and that dest is word aligned. */
switch (len) {
case 8:
- value = *(ib_longlong*) dest;
+ value = *(ib_ulonglong*) dest;
break;
case 4:
@@ -4595,7 +4595,7 @@ row_search_autoinc_read_column(
mem_heap_free(heap);
}
- if (!unsigned_type && value < 0) {
+ if (!unsigned_type && (ib_longlong) value < 0) {
value = 0;
}
@@ -4634,7 +4634,7 @@ row_search_max_autoinc(
column name can't be found in index */
dict_index_t* index, /* in: index to search */
const char* col_name, /* in: name of autoinc column */
- ib_longlong* value) /* out: AUTOINC value read */
+ ib_ulonglong* value) /* out: AUTOINC value read */
{
ulint i;
ulint n_cols;
diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c
index 610c20eede6..1b6c7458fd7 100644
--- a/storage/myisam/ft_static.c
+++ b/storage/myisam/ft_static.c
@@ -608,7 +608,6 @@ const char *ft_precompiled_stopwords[] = {
"won't",
"wonder",
"would",
- "would",
"wouldn't",
"yes",
"yet",
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 6ea9efb8c49..b8d5a9af8d2 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -398,7 +398,26 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
}
for (j= t1_keyinfo[i].keysegs; j--;)
{
- if (t1_keysegs[j].type != t2_keysegs[j].type ||
+ uint8 t1_keysegs_j__type= t1_keysegs[j].type;
+
+ /*
+ Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is
+ always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of
+ HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM
+ level, we can ignore a mismatch between these types.
+ */
+ if ((t1_keysegs[j].flag & HA_BLOB_PART) &&
+ (t2_keysegs[j].flag & HA_BLOB_PART))
+ {
+ if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2) &&
+ (t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1))
+ t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1; /* purecov: tested */
+ else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2) &&
+ (t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1))
+ t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */
+ }
+
+ if (t1_keysegs_j__type != t2_keysegs[j].type ||
t1_keysegs[j].language != t2_keysegs[j].language ||
t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
t1_keysegs[j].length != t2_keysegs[j].length)
@@ -1860,6 +1879,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
share->avg_row_length);
create_info.data_file_name= ha_create_info->data_file_name;
create_info.index_file_name= ha_create_info->index_file_name;
+ create_info.language= share->table_charset->number;
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= HA_CREATE_TMP_TABLE;
@@ -2079,6 +2099,7 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
*engine_callback,
ulonglong *engine_data)
{
+ DBUG_ENTER("ha_myisam::register_query_cache_table");
/*
No call back function is needed to determine if a cached statement
is valid or not.
@@ -2090,39 +2111,48 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
*/
*engine_data= 0;
- /*
- If a concurrent INSERT has happened just before the currently processed
- SELECT statement, the total size of the table is unknown.
+ if (file->s->concurrent_insert)
+ {
+ /*
+ If a concurrent INSERT has happened just before the currently
+ processed SELECT statement, the total size of the table is
+ unknown.
- To determine if the table size is known, the current thread's snap shot of
- the table size with the actual table size are compared.
+ To determine if the table size is known, the current thread's snap
+ shot of the table size with the actual table size are compared.
- If the table size is unknown the SELECT statement can't be cached.
- */
- ulonglong actual_data_file_length;
- ulonglong current_data_file_length;
+ If the table size is unknown the SELECT statement can't be cached.
- /*
- POSIX visibility rules specify that "2. Whatever memory values a
- thread can see when it unlocks a mutex <...> can also be seen by any
- thread that later locks the same mutex". In this particular case,
- concurrent insert thread had modified the data_file_length in
- MYISAM_SHARE before it has unlocked (or even locked)
- structure_guard_mutex. So, here we're guaranteed to see at least that
- value after we've locked the same mutex. We can see a later value
- (modified by some other thread) though, but it's ok, as we only want
- to know if the variable was changed, the actual new value doesn't matter
- */
- actual_data_file_length= file->s->state.state.data_file_length;
- current_data_file_length= file->save_state.data_file_length;
+ When concurrent inserts are disabled at table open, mi_open()
+ does not assign a get_status() function. In this case the local
+ ("current") status is never updated. We would wrongly think that
+ we cannot cache the statement.
+ */
+ ulonglong actual_data_file_length;
+ ulonglong current_data_file_length;
- if (current_data_file_length != actual_data_file_length)
- {
- /* Don't cache current statement. */
- return FALSE;
+ /*
+ POSIX visibility rules specify that "2. Whatever memory values a
+ thread can see when it unlocks a mutex <...> can also be seen by any
+ thread that later locks the same mutex". In this particular case,
+ concurrent insert thread had modified the data_file_length in
+ MYISAM_SHARE before it has unlocked (or even locked)
+ structure_guard_mutex. So, here we're guaranteed to see at least that
+ value after we've locked the same mutex. We can see a later value
+ (modified by some other thread) though, but it's ok, as we only want
+ to know if the variable was changed, the actual new value doesn't matter
+ */
+ actual_data_file_length= file->s->state.state.data_file_length;
+ current_data_file_length= file->save_state.data_file_length;
+
+ if (current_data_file_length != actual_data_file_length)
+ {
+ /* Don't cache current statement. */
+ DBUG_RETURN(FALSE);
+ }
}
/* It is ok to try to cache current statement. */
- return TRUE;
+ DBUG_RETURN(TRUE);
}
#endif
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 8fe2110932f..3433c26f98b 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -1006,12 +1006,12 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to,
{
if (rec->length > 255 && new_length > 127)
{
- to[0]=(char) ((new_length & 127)+128);
- to[1]=(char) (new_length >> 7);
- to+=2;
- }
- else
- *to++= (char) new_length;
+ to[0]= (uchar) ((new_length & 127) + 128);
+ to[1]= (uchar) (new_length >> 7);
+ to+=2;
+ }
+ else
+ *to++= (uchar) new_length;
memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length;
flag|=bit;
}
@@ -1045,7 +1045,7 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to,
}
if ((bit= bit << 1) >= 256)
{
- *packpos++ = (char) (uchar) flag;
+ *packpos++= (uchar) flag;
bit=1; flag=0;
}
}
@@ -1055,9 +1055,9 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to,
}
}
if (bit != 1)
- *packpos= (char) (uchar) flag;
+ *packpos= (uchar) flag;
if (info->s->calc_checksum)
- *to++=(char) info->checksum;
+ *to++= (uchar) info->checksum;
DBUG_PRINT("exit",("packed length: %d",(int) (to-startpos)));
DBUG_RETURN((uint) (to-startpos));
} /* _mi_rec_pack */
@@ -1128,12 +1128,14 @@ my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *rec_buff,
goto err;
if (rec->length > 255 && new_length > 127)
{
- if (to[0] != (char) ((new_length & 127)+128) ||
- to[1] != (char) (new_length >> 7))
- goto err;
- to+=2;
- }
- else if (*to++ != (char) new_length)
+ /* purecov: begin inspected */
+ if (to[0] != (uchar) ((new_length & 127) + 128) ||
+ to[1] != (uchar) (new_length >> 7))
+ goto err;
+ to+=2;
+ /* purecov: end */
+ }
+ else if (*to++ != (uchar) new_length)
goto err;
to+=new_length;
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 3e267ecf9ca..769106c8e72 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -281,6 +281,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
if (share->options & HA_OPTION_COMPRESS_RECORD)
share->base.max_key_length+=2; /* For safety */
+ /* Add space for node pointer */
+ share->base.max_key_length+= share->base.key_reflength;
+
if (!my_multi_malloc(MY_WME,
&share,sizeof(*share),
&share->state.rec_per_key_part,sizeof(long)*key_parts,
@@ -815,8 +818,17 @@ static void setup_key_functions(register MI_KEYDEF *keyinfo)
keyinfo->get_key= _mi_get_pack_key;
if (keyinfo->seg[0].flag & HA_PACK_KEY)
{ /* Prefix compression */
+ /*
+ _mi_prefix_search() compares end-space against ASCII blank (' ').
+ It cannot be used for character sets, that do not encode the
+ blank character like ASCII does. UCS2 is an example. All
+ character sets with a fixed width > 1 or a mimimum width > 1
+ cannot represent blank like ASCII does. In these cases we have
+ to use _mi_seq_search() for the search.
+ */
if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) ||
- (keyinfo->seg->flag & HA_NULL_PART))
+ (keyinfo->seg->flag & HA_NULL_PART) ||
+ (keyinfo->seg->charset->mbminlen > 1))
keyinfo->bin_search=_mi_seq_search;
else
keyinfo->bin_search=_mi_prefix_search;
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 4c0065c7fbb..ea7021325e3 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1102,6 +1102,12 @@ void ha_myisammrg::append_create_info(String *packet)
packet->append(STRING_WITH_LEN(" INSERT_METHOD="));
packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
}
+ /*
+ There is no sence adding UNION clause in case there is no underlying
+ tables specified.
+ */
+ if (file->open_tables == file->end_table)
+ return;
packet->append(STRING_WITH_LEN(" UNION=("));
current_db= table->s->db.str;
diff --git a/storage/ndb/include/ndb_version.h.in b/storage/ndb/include/ndb_version.h.in
index 6a479433b3b..97072315521 100644
--- a/storage/ndb/include/ndb_version.h.in
+++ b/storage/ndb/include/ndb_version.h.in
@@ -103,11 +103,12 @@ inline
int
ndb_check_prep_copy_frag_version(Uint32 version)
{
+ const Uint32 major = (version >> 16) & 0xFF;
+ const Uint32 minor = (version >> 8) & 0xFF;
+
if (version == NDB_VERSION_D)
return 2;
- const Uint32 major = (version >> 16) & 0xFF;
- const Uint32 minor = (version >> 8) & 0xFF;
if (major >= 6)
{
if (minor == 2)
diff --git a/storage/ndb/src/common/util/SocketServer.cpp b/storage/ndb/src/common/util/SocketServer.cpp
index 51d48ec54f2..47bf562f7d1 100644
--- a/storage/ndb/src/common/util/SocketServer.cpp
+++ b/storage/ndb/src/common/util/SocketServer.cpp
@@ -112,7 +112,7 @@ SocketServer::setup(SocketServer::Service * service,
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
- DBUG_PRINT("error",("getsockopt() - %d - %s",
+ DBUG_PRINT("error",("setsockopt() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock);
DBUG_RETURN(false);
diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp
index 8e68e118f98..ce5797cf209 100644
--- a/storage/ndb/src/kernel/blocks/tsman.cpp
+++ b/storage/ndb/src/kernel/blocks/tsman.cpp
@@ -181,7 +181,6 @@ struct TsmanChunk
Vector<Uint32> bitmask;
};
template class Vector<TsmanChunk>;
-template class Vector<Uint32>;
#endif
void