Skip to content

Commit 857abf1

Browse files
author
Nirbhay Choubey
committed
bzr merge -r4104..4120 codership/5.6/
1 parent 38f048a commit 857abf1

File tree

9 files changed

+158
-66
lines changed

9 files changed

+158
-66
lines changed

sql/mysqld.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5555,7 +5555,6 @@ static my_bool have_committing_connections()
55555555

55565556
if (is_committing_connection(tmp))
55575557
{
5558-
mysql_mutex_unlock(&LOCK_thread_count);
55595558
return TRUE;
55605559
}
55615560
}

sql/sql_admin.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
12001200
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
12011201
FALSE, UINT_MAX, FALSE))
12021202
goto error; /* purecov: inspected */
1203+
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL)
12031204
thd->enable_slow_log= opt_log_slow_admin_statements;
12041205
res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
12051206
mysql_recreate_table(thd, first_table, true) :

sql/sql_parse.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,9 @@ static void wsrep_copy_query(THD *thd)
12111211
{
12121212
thd->wsrep_retry_command = thd->get_command();
12131213
thd->wsrep_retry_query_len = thd->query_length();
1214+
if (thd->wsrep_retry_query) {
1215+
my_free(thd->wsrep_retry_query);
1216+
}
12141217
thd->wsrep_retry_query = (char *)my_malloc(
12151218
thd->wsrep_retry_query_len + 1, MYF(0));
12161219
strncpy(thd->wsrep_retry_query, thd->query(), thd->wsrep_retry_query_len);
@@ -3793,8 +3796,7 @@ case SQLCOM_PREPARE:
37933796
if ((res= insert_precheck(thd, all_tables)))
37943797
break;
37953798
#ifdef WITH_WSREP
3796-
if (lex->sql_command == SQLCOM_INSERT_SELECT &&
3797-
thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED)
3799+
if (thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED)
37983800
{
37993801
thd->wsrep_consistency_check = CONSISTENCY_CHECK_RUNNING;
38003802
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL);

sql/wsrep_mysqld.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) {
132132
sql_print_error("WSREP: %s", msg);
133133
break;
134134
case WSREP_LOG_DEBUG:
135-
sql_print_information ("[Debug] WSREP: %s", msg);
135+
if (wsrep_debug) sql_print_information ("[Debug] WSREP: %s", msg);
136136
default:
137137
break;
138138
}
@@ -794,10 +794,10 @@ void wsrep_filter_new_cluster (int* argc, char* argv[])
794794
{
795795
/* make a copy of the argument to convert possible underscores to hyphens.
796796
* the copy need not to be longer than WSREP_NEW_CLUSTER option */
797-
char arg[sizeof(WSREP_NEW_CLUSTER) + 2]= { 0, };
797+
char arg[sizeof(WSREP_NEW_CLUSTER) + 1]= { 0, };
798798
strncpy(arg, argv[i], sizeof(arg) - 1);
799-
char* underscore;
800-
while (NULL != (underscore= strchr(arg, '_'))) *underscore= '-';
799+
char* underscore(arg);
800+
while (NULL != (underscore= strchr(underscore, '_'))) *underscore= '-';
801801

802802
if (!strcmp(arg, WSREP_NEW_CLUSTER))
803803
{
@@ -904,7 +904,7 @@ wsrep_causal_wait (THD* thd)
904904
switch (ret)
905905
{
906906
case WSREP_NOT_IMPLEMENTED:
907-
msg= "consistent reads by wsrep backend. "
907+
msg= "synchronous reads by wsrep backend. "
908908
"Please unset wsrep_causal_reads variable.";
909909
err= ER_NOT_SUPPORTED_YET;
910910
break;

storage/innobase/handler/ha_innodb.cc

Lines changed: 87 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5642,7 +5642,7 @@ wsrep_innobase_mysql_sort(
56425642
case MYSQL_TYPE_LONG_BLOB:
56435643
case MYSQL_TYPE_VARCHAR:
56445644
{
5645-
uchar tmp_str[REC_VERSION_56_MAX_INDEX_COL_LEN];
5645+
uchar tmp_str[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
56465646
uint tmp_length = REC_VERSION_56_MAX_INDEX_COL_LEN;
56475647

56485648
/* Use the charset number to pick the right charset struct for
@@ -5681,11 +5681,11 @@ wsrep_innobase_mysql_sort(
56815681
} else {
56825682
/* strnxfrm will expand the destination string,
56835683
protocols < 3 truncated the sorted sring
5684-
protocols > 3 gets full sorted sring
5684+
protocols >= 3 gets full sorted sring
56855685
*/
56865686
tmp_length = charset->coll->strnxfrm(
56875687
charset, str, buf_length,
5688-
str_length, tmp_str, tmp_length, 0);
5688+
str_length, tmp_str, str_length, 0);
56895689
DBUG_ASSERT(tmp_length <= buf_length);
56905690
ret_length = tmp_length;
56915691
}
@@ -6228,6 +6228,7 @@ UNIV_INTERN
62286228
uint
62296229
wsrep_store_key_val_for_row(
62306230
/*===============================*/
6231+
THD* thd,
62316232
TABLE* table,
62326233
uint keynr, /*!< in: key number */
62336234
char* buff, /*!< in/out: buffer for the key value (in MySQL
@@ -6242,25 +6243,33 @@ wsrep_store_key_val_for_row(
62426243
char* buff_start = buff;
62436244
enum_field_types mysql_type;
62446245
Field* field;
6245-
6246+
uint buff_space = buff_len;
6247+
62466248
DBUG_ENTER("wsrep_store_key_val_for_row");
62476249

62486250
memset(buff, 0, buff_len);
62496251
*key_is_null = TRUE;
62506252

62516253
for (; key_part != end; key_part++) {
6254+
62526255
uchar sorted[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
62536256
ibool part_is_null = FALSE;
62546257

62556258
if (key_part->null_bit) {
6256-
if (record[key_part->null_offset] &
6257-
key_part->null_bit) {
6258-
*buff = 1;
6259-
part_is_null = TRUE;
6259+
if (buff_space > 0) {
6260+
if (record[key_part->null_offset]
6261+
& key_part->null_bit) {
6262+
*buff = 1;
6263+
part_is_null = TRUE;
6264+
} else {
6265+
*buff = 0;
6266+
}
6267+
buff++;
6268+
buff_space--;
62606269
} else {
6261-
*buff = 0;
6270+
fprintf (stderr, "WSREP: key truncated: %s\n",
6271+
wsrep_thd_query(thd));
62626272
}
6263-
buff++;
62646273
}
62656274
if (!part_is_null) *key_is_null = FALSE;
62666275

@@ -6280,8 +6289,15 @@ wsrep_store_key_val_for_row(
62806289
key_len = key_part->length;
62816290

62826291
if (part_is_null) {
6283-
buff += key_len + 2;
6284-
6292+
true_len = key_len + 2;
6293+
if (true_len > buff_space) {
6294+
fprintf (stderr,
6295+
"WSREP: key truncated: %s\n",
6296+
wsrep_thd_query(thd));
6297+
true_len = buff_space;
6298+
}
6299+
buff += true_len;
6300+
buff_space -= true_len;
62856301
continue;
62866302
}
62876303
cs = field->charset();
@@ -6321,13 +6337,20 @@ wsrep_store_key_val_for_row(
63216337
REC_VERSION_56_MAX_INDEX_COL_LEN);
63226338

63236339
if (wsrep_protocol_version > 1) {
6324-
memcpy(buff, sorted, true_len);
6325-
/* Note that we always reserve the maximum possible
6326-
length of the true VARCHAR in the key value, though
6327-
only len first bytes after the 2 length bytes contain
6328-
actual data. The rest of the space was reset to zero
6329-
in the bzero() call above. */
6330-
buff += true_len;
6340+
/* Note that we always reserve the maximum possible
6341+
length of the true VARCHAR in the key value, though
6342+
only len first bytes after the 2 length bytes contain
6343+
actual data. The rest of the space was reset to zero
6344+
in the bzero() call above. */
6345+
if (true_len > buff_space) {
6346+
fprintf (stderr,
6347+
"WSREP: key truncated: %s\n",
6348+
wsrep_thd_query(thd));
6349+
true_len = buff_space;
6350+
}
6351+
memcpy(buff, sorted, true_len);
6352+
buff += true_len;
6353+
buff_space -= true_len;
63316354
} else {
63326355
buff += key_len;
63336356
}
@@ -6351,7 +6374,15 @@ wsrep_store_key_val_for_row(
63516374
key_len = key_part->length;
63526375

63536376
if (part_is_null) {
6354-
buff += key_len + 2;
6377+
true_len = key_len + 2;
6378+
if (true_len > buff_space) {
6379+
fprintf (stderr,
6380+
"WSREP: key truncated: %s\n",
6381+
wsrep_thd_query(thd));
6382+
true_len = buff_space;
6383+
}
6384+
buff += true_len;
6385+
buff_space -= true_len;
63556386

63566387
continue;
63576388
}
@@ -6394,15 +6425,22 @@ wsrep_store_key_val_for_row(
63946425
mysql_type, cs->number, sorted, true_len,
63956426
REC_VERSION_56_MAX_INDEX_COL_LEN);
63966427

6397-
memcpy(buff, sorted, true_len);
63986428

63996429
/* Note that we always reserve the maximum possible
64006430
length of the BLOB prefix in the key value. */
64016431
if (wsrep_protocol_version > 1) {
6402-
buff += true_len;
6403-
} else {
6404-
buff += key_len;
6405-
}
6432+
if (true_len > buff_space) {
6433+
fprintf (stderr,
6434+
"WSREP: key truncated: %s\n",
6435+
wsrep_thd_query(thd));
6436+
true_len = buff_space;
6437+
}
6438+
buff += true_len;
6439+
buff_space -= true_len;
6440+
} else {
6441+
buff += key_len;
6442+
}
6443+
memcpy(buff, sorted, true_len);
64066444
} else {
64076445
/* Here we handle all other data types except the
64086446
true VARCHAR, BLOB and TEXT. Note that the column
@@ -6419,9 +6457,17 @@ wsrep_store_key_val_for_row(
64196457
key_len = key_part->length;
64206458

64216459
if (part_is_null) {
6422-
buff += key_len;
6460+
true_len = key_len;
6461+
if (true_len > buff_space) {
6462+
fprintf (stderr,
6463+
"WSREP: key truncated: %s\n",
6464+
wsrep_thd_query(thd));
6465+
true_len = buff_space;
6466+
}
6467+
buff += true_len;
6468+
buff_space -= true_len;
64236469

6424-
continue;
6470+
continue;
64256471
}
64266472

64276473
src_start = record + key_part->offset;
@@ -6459,12 +6505,18 @@ wsrep_store_key_val_for_row(
64596505
mysql_type, cs->number, sorted, true_len,
64606506
REC_VERSION_56_MAX_INDEX_COL_LEN);
64616507

6508+
if (true_len > buff_space) {
6509+
fprintf (stderr,
6510+
"WSREP: key truncated: %s\n",
6511+
wsrep_thd_query(thd));
6512+
true_len = buff_space;
6513+
}
64626514
memcpy(buff, sorted, true_len);
64636515
} else {
64646516
memcpy(buff, src_start, true_len);
64656517
}
6466-
buff += true_len;
6467-
6518+
buff += true_len;
6519+
buff_space -= true_len;
64686520
}
64696521
}
64706522

@@ -9690,7 +9742,8 @@ ha_innobase::wsrep_append_keys(
96909742
ibool is_null;
96919743

96929744
len = wsrep_store_key_val_for_row(
9693-
table, 0, key, key_info->key_length, record0, &is_null);
9745+
thd, table, 0, key, WSREP_MAX_SUPPORTED_KEY_LENGTH,
9746+
record0, &is_null);
96949747

96959748
if (!is_null) {
96969749
rcode = wsrep_append_key(
@@ -9712,9 +9765,6 @@ ha_innobase::wsrep_append_keys(
97129765
KEY* key_info = table->key_info + i;
97139766
if (key_info->flags & HA_NOSAME) {
97149767
hasPK = true;
9715-
if (i != table->s->primary_key) {
9716-
wsrep_thd_set_PA_safe(thd, FALSE);
9717-
}
97189768
}
97199769
}
97209770

@@ -9745,7 +9795,8 @@ ha_innobase::wsrep_append_keys(
97459795
(!tab && referenced_by_foreign_key()))) {
97469796

97479797
len = wsrep_store_key_val_for_row(
9748-
table, i, key0, key_info->key_length,
9798+
thd, table, i, key0,
9799+
WSREP_MAX_SUPPORTED_KEY_LENGTH,
97499800
record0, &is_null);
97509801
if (!is_null) {
97519802
rcode = wsrep_append_key(
@@ -9755,7 +9806,6 @@ ha_innobase::wsrep_append_keys(
97559806

97569807
if (key_info->flags & HA_NOSAME || shared)
97579808
key_appended = true;
9758-
97599809
}
97609810
else
97619811
{
@@ -9764,7 +9814,8 @@ ha_innobase::wsrep_append_keys(
97649814
}
97659815
if (record1) {
97669816
len = wsrep_store_key_val_for_row(
9767-
table, i, key1, key_info->key_length,
9817+
thd, table, i, key1,
9818+
WSREP_MAX_SUPPORTED_KEY_LENGTH,
97689819
record1, &is_null);
97699820
if (!is_null && memcmp(key0, key1, len)) {
97709821
rcode = wsrep_append_key(

storage/innobase/include/hash0hash.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,33 @@ do {\
144144
}\
145145
} while (0)
146146

147+
#ifdef WITH_WSREP
148+
/*******************************************************************//**
149+
Inserts a struct to the head of hash table. */
150+
151+
#define HASH_PREPEND(TYPE, NAME, TABLE, FOLD, DATA) \
152+
do { \
153+
hash_cell_t* cell3333; \
154+
TYPE* struct3333; \
155+
\
156+
HASH_ASSERT_OWN(TABLE, FOLD) \
157+
\
158+
(DATA)->NAME = NULL; \
159+
\
160+
cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
161+
\
162+
if (cell3333->node == NULL) { \
163+
cell3333->node = DATA; \
164+
DATA->NAME = NULL; \
165+
} else { \
166+
struct3333 = (TYPE*) cell3333->node; \
167+
\
168+
DATA->NAME = struct3333; \
169+
\
170+
cell3333->node = DATA; \
171+
} \
172+
} while (0)
173+
#endif /*WITH_WSREP */
147174
#ifdef UNIV_HASH_DEBUG
148175
# define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1)
149176
# define HASH_INVALIDATE(DATA, NAME) *(void**) (&DATA->NAME) = (void*) -1

0 commit comments

Comments
 (0)