Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä 2022-07-01 13:10:36 +03:00
commit 392ee571c1
32 changed files with 253 additions and 225 deletions

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2018, Oracle and/or its affiliates. Copyright (c) 2000, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2021, MariaDB Corporation. Copyright (c) 2009, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -3589,7 +3589,6 @@ print_table_data(MYSQL_RES *result)
{ {
String separator(256); String separator(256);
MYSQL_ROW cur; MYSQL_ROW cur;
MYSQL_FIELD *field;
bool *num_flag; bool *num_flag;
num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result)); num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
@ -3601,7 +3600,7 @@ print_table_data(MYSQL_RES *result)
mysql_field_seek(result,0); mysql_field_seek(result,0);
} }
separator.copy("+",1,charset_info); separator.copy("+",1,charset_info);
while ((field = mysql_fetch_field(result))) while (MYSQL_FIELD *field= mysql_fetch_field(result))
{ {
uint length= column_names ? field->name_length : 0; uint length= column_names ? field->name_length : 0;
if (quick) if (quick)
@ -3623,7 +3622,7 @@ print_table_data(MYSQL_RES *result)
{ {
mysql_field_seek(result,0); mysql_field_seek(result,0);
(void) tee_fputs("|", PAGER); (void) tee_fputs("|", PAGER);
for (uint off=0; (field = mysql_fetch_field(result)) ; off++) while (MYSQL_FIELD *field= mysql_fetch_field(result))
{ {
size_t name_length= (uint) strlen(field->name); size_t name_length= (uint) strlen(field->name);
size_t numcells= charset_info->cset->numcells(charset_info, size_t numcells= charset_info->cset->numcells(charset_info,
@ -3666,7 +3665,7 @@ print_table_data(MYSQL_RES *result)
data_length= (uint) lengths[off]; data_length= (uint) lengths[off];
} }
field= mysql_fetch_field(result); MYSQL_FIELD *field= mysql_fetch_field(result);
field_max_length= field->max_length; field_max_length= field->max_length;
/* /*

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2001, 2013, Oracle and/or its affiliates. Copyright (c) 2001, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB Copyright (c) 2010, 2012, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1001,7 +1001,6 @@ static void print_result()
char prev[(NAME_LEN+9)*3+2]; char prev[(NAME_LEN+9)*3+2];
char prev_alter[MAX_ALTER_STR_SIZE]; char prev_alter[MAX_ALTER_STR_SIZE];
size_t length_of_db= strlen(sock->db); size_t length_of_db= strlen(sock->db);
uint i;
my_bool found_error=0, table_rebuild=0; my_bool found_error=0, table_rebuild=0;
DYNAMIC_ARRAY *array4repair= &tables4repair; DYNAMIC_ARRAY *array4repair= &tables4repair;
DBUG_ENTER("print_result"); DBUG_ENTER("print_result");
@ -1010,7 +1009,7 @@ static void print_result()
prev[0] = '\0'; prev[0] = '\0';
prev_alter[0]= 0; prev_alter[0]= 0;
for (i = 0; (row = mysql_fetch_row(res)); i++) while ((row = mysql_fetch_row(res)))
{ {
int changed = strcmp(prev, row[0]); int changed = strcmp(prev, row[0]);
my_bool status = !strcmp(row[2], "status"); my_bool status = !strcmp(row[2], "status");

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2005, 2015, Oracle and/or its affiliates. Copyright (c) 2005, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB Copyright (c) 2010, 2022, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1830,12 +1830,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
pthread_handler_t run_task(void *p) pthread_handler_t run_task(void *p)
{ {
ulonglong counter= 0, queries; ulonglong queries;
ulonglong detach_counter; ulonglong detach_counter;
unsigned int commit_counter; unsigned int commit_counter;
MYSQL *mysql; MYSQL *mysql;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row;
statement *ptr; statement *ptr;
thread_context *con= (thread_context *)p; thread_context *con= (thread_context *)p;
@ -1956,8 +1955,7 @@ limit_not_met:
my_progname, mysql_errno(mysql), mysql_error(mysql)); my_progname, mysql_errno(mysql), mysql_error(mysql));
else else
{ {
while ((row= mysql_fetch_row(result))) while (mysql_fetch_row(result)) {}
counter++;
mysql_free_result(result); mysql_free_result(result);
} }
} }
@ -1967,7 +1965,7 @@ limit_not_met:
if (commit_rate && (++commit_counter == commit_rate)) if (commit_rate && (++commit_counter == commit_rate))
{ {
commit_counter= 0; commit_counter= 0;
run_query(mysql, "COMMIT", strlen("COMMIT")); run_query(mysql, C_STRING_WITH_LEN("COMMIT"));
} }
if (con->limit && queries == con->limit) if (con->limit && queries == con->limit)
@ -1979,7 +1977,7 @@ limit_not_met:
end: end:
if (commit_rate) if (commit_rate)
run_query(mysql, "COMMIT", strlen("COMMIT")); run_query(mysql, C_STRING_WITH_LEN("COMMIT"));
mysql_close(mysql); mysql_close(mysql);

View File

@ -7,9 +7,7 @@
#include <my_sys.h> #include <my_sys.h>
#include <my_pthread.h> #include <my_pthread.h>
int main (argc, argv) int main (int argc, char **argv)
int argc;
char *argv[];
{ {
register int result, ix; register int result, ix;
extern int factorial(int); extern int factorial(int);

View File

@ -148,9 +148,7 @@ int main(int argc, char *argv[])
/* reads options */ /* reads options */
/* Initiates DEBUG - but no debugging here ! */ /* Initiates DEBUG - but no debugging here ! */
static int static_get_options(argc,argv) static int static_get_options(int *argc, char***argv)
register int *argc;
register char **argv[];
{ {
int help,version; int help,version;
char *pos; char *pos;
@ -218,10 +216,9 @@ register char **argv[];
} /* static_get_options */ } /* static_get_options */
static int get_replace_strings(argc,argv,from_array,to_array) static int get_replace_strings(int *argc, char ***argv,
register int *argc; POINTER_ARRAY *from_array,
register char **argv[]; POINTER_ARRAY *to_array)
POINTER_ARRAY *from_array,*to_array;
{ {
char *pos; char *pos;
@ -965,9 +962,7 @@ static void free_buffer()
bytes read from disk. bytes read from disk.
*/ */
static int fill_buffer_retaining(fd,n) static int fill_buffer_retaining(File fd, int n)
File fd;
int n;
{ {
int i; int i;
@ -1010,9 +1005,7 @@ int n;
/* Return 0 if convert is ok */ /* Return 0 if convert is ok */
/* Global variable update is set if something was changed */ /* Global variable update is set if something was changed */
static int convert_pipe(rep,in,out) static int convert_pipe(REPLACE *rep, FILE *in, FILE *out)
REPLACE *rep;
FILE *in,*out;
{ {
int retain,error; int retain,error;
uint length; uint length;

@ -1 +1 @@
Subproject commit ab7a81e79e4be4324a2d09d19d4f5249801ef665 Subproject commit d12fd88b6c0fafbf25f59e7fecd639cb2b38f157

View File

@ -37,7 +37,9 @@ SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1;
--eval KILL $conid --eval KILL $conid
--disconnect con1 --disconnect con1
--connection default --connection default
--disable_warnings
DROP VIEW IF EXISTS vv; DROP VIEW IF EXISTS vv;
--enable_warnings
DROP VIEW v; DROP VIEW v;
DROP FUNCTION f; DROP FUNCTION f;
DROP TABLE t; DROP TABLE t;

View File

@ -137,3 +137,16 @@ id title body
1 MySQL Tutorial DBMS stands for Database... 1 MySQL Tutorial DBMS stands for Database...
2 MariaDB Tutorial DB means Database ... 2 MariaDB Tutorial DB means Database ...
DROP TABLE mdev19073, mdev19073_2; DROP TABLE mdev19073, mdev19073_2;
#
# MDEV-28706 Redundant InnoDB table fails during alter
#
SET @@global.innodb_file_per_table = 0;
CREATE TABLE t1 (
col_int INTEGER, col_text TEXT,
col_text_1 TEXT
) ENGINE = InnoDB ROW_FORMAT = Redundant ;
ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ;
INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB");
# restart
ALTER TABLE t1 ADD FULLTEXT(col_text_1);
DROP TABLE t1;

View File

@ -272,3 +272,10 @@ fts_doc_id first_name last_name score
6 Ned Flanders 0 6 Ned Flanders 0
7 Nelson Muntz 0 7 Nelson Muntz 0
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL;
ALTER TABLE t1 ADD d INT NULL;
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index
DROP TABLE t1;

View File

@ -193,3 +193,18 @@ AGAINST ('Database' IN NATURAL LANGUAGE MODE);
SELECT * FROM mdev19073_2 WHERE MATCH (title, body) SELECT * FROM mdev19073_2 WHERE MATCH (title, body)
AGAINST ('Database' IN NATURAL LANGUAGE MODE); AGAINST ('Database' IN NATURAL LANGUAGE MODE);
DROP TABLE mdev19073, mdev19073_2; DROP TABLE mdev19073, mdev19073_2;
--echo #
--echo # MDEV-28706 Redundant InnoDB table fails during alter
--echo #
SET @@global.innodb_file_per_table = 0;
CREATE TABLE t1 (
col_int INTEGER, col_text TEXT,
col_text_1 TEXT
) ENGINE = InnoDB ROW_FORMAT = Redundant ;
ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ;
INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB");
--source include/restart_mysqld.inc
ALTER TABLE t1 ADD FULLTEXT(col_text_1);
DROP TABLE t1;

View File

@ -257,3 +257,14 @@ INSERT INTO t1 (id, first_name, last_name) VALUES
analyze table t1; analyze table t1;
SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1; SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-28912 NON-UNIQUE FTS_DOC_ID mistaken as FTS_DOC_ID_INDEX
#
CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL;
ALTER TABLE t1 ADD d INT NULL;
--error ER_INNODB_FT_WRONG_DOCID_INDEX
ALTER TABLE t1 ADD FULLTEXT(b);
DROP TABLE t1;

View File

@ -860,6 +860,8 @@ SELECT LAST_INSERT_ID();
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
} }
--echo ##############################################################################
}
if (!$skip_update) if (!$skip_update)
{ {
@ -867,13 +869,13 @@ if (!$skip_update)
--echo # MDEV-19622 Assertion failures in --echo # MDEV-19622 Assertion failures in
--echo # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table --echo # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
--echo # --echo #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); eval CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=$engine PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
} }
if (!$skip_update) if (!$skip_delete)
{ {
--echo # --echo #
--echo # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' --echo # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
@ -884,5 +886,14 @@ REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
} }
--echo ############################################################################## if (!$skip_truncate)
{
--echo #
--echo # MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
--echo # Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
--echo #
eval CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE=$engine PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
} }

View File

@ -695,3 +695,26 @@ PARTITIONS 2
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Blackhole' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
#
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
# ha_partition::set_auto_increment_if_higher
#
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Blackhole' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Blackhole' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;

View File

@ -1101,11 +1101,12 @@ SELECT * FROM t1;
a a
0 0
DROP TABLE t1; DROP TABLE t1;
##############################################################################
# #
# MDEV-19622 Assertion failures in # MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
# #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='InnoDB' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
@ -1116,4 +1117,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB' PARTITION BY HASH (a) PARTITIONS 3; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3); REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
############################################################################## #
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='InnoDB' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;

View File

@ -1148,11 +1148,12 @@ SELECT * FROM t1;
a a
0 0
DROP TABLE t1; DROP TABLE t1;
##############################################################################
# #
# MDEV-19622 Assertion failures in # MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
# #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Aria' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
@ -1163,4 +1164,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria' PARTITION BY HASH (a) PARTITIONS 3; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3); REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
############################################################################## #
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Aria' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;

View File

@ -1129,11 +1129,12 @@ SELECT * FROM t1;
a a
0 0
DROP TABLE t1; DROP TABLE t1;
##############################################################################
# #
# MDEV-19622 Assertion failures in # MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
# #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Memory' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
@ -1144,4 +1145,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory' PARTITION BY HASH (a) PARTITIONS 3; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3); REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
############################################################################## #
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Memory' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;

View File

@ -1148,11 +1148,12 @@ SELECT * FROM t1;
a a
0 0
DROP TABLE t1; DROP TABLE t1;
##############################################################################
# #
# MDEV-19622 Assertion failures in # MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
# #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='MyISAM' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
@ -1163,4 +1164,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM' PARTITION BY HASH (a) PARTITIONS 3; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3); REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
############################################################################## #
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='MyISAM' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. /* Copyright (c) 2004, 2010, Oracle and/or its affiliates.
Copyright (c) 2012, 2014, Monty Program Ab Copyright (c) 2012, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -84,7 +84,7 @@ static void print_query(FILE *out, const char *query)
fprintf(out, "\""); fprintf(out, "\"");
while (*ptr) while (*ptr)
{ {
if(column >= MAX_COLUMN) if (column >= MAX_COLUMN)
{ {
/* Wrap to the next line, tabulated. */ /* Wrap to the next line, tabulated. */
fprintf(out, "\"\n \""); fprintf(out, "\"\n \"");

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2017, Oracle and/or its affiliates. Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2008, 2021, MariaDB Copyright (c) 2008, 2022, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -10127,7 +10127,7 @@ int Field_bit::cmp_prefix(const uchar *a, const uchar *b, size_t prefix_len)
} }
int Field_bit::key_cmp(const uchar *str, uint length) int Field_bit::key_cmp(const uchar *str, uint)
{ {
if (bit_len) if (bit_len)
{ {
@ -10136,7 +10136,6 @@ int Field_bit::key_cmp(const uchar *str, uint length)
if ((flag= (int) (bits - *str))) if ((flag= (int) (bits - *str)))
return flag; return flag;
str++; str++;
length--;
} }
return memcmp(ptr, str, bytes_in_rec); return memcmp(ptr, str, bytes_in_rec);
} }

View File

@ -2353,7 +2353,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
char *name_buffer_ptr; char *name_buffer_ptr;
const char *from_path; const char *from_path;
const char *to_path= NULL; const char *to_path= NULL;
uint i;
handler **file, **abort_file; handler **file, **abort_file;
DBUG_ENTER("ha_partition::del_ren_table"); DBUG_ENTER("ha_partition::del_ren_table");
@ -2382,7 +2381,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
from_path= get_canonical_filename(*file, from, from_lc_buff); from_path= get_canonical_filename(*file, from, from_lc_buff);
if (to != NULL) if (to != NULL)
to_path= get_canonical_filename(*file, to, to_lc_buff); to_path= get_canonical_filename(*file, to, to_lc_buff);
i= 0;
do do
{ {
if (unlikely((error= create_partition_name(from_buff, sizeof(from_buff), if (unlikely((error= create_partition_name(from_buff, sizeof(from_buff),
@ -2407,7 +2405,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
name_buffer_ptr= strend(name_buffer_ptr) + 1; name_buffer_ptr= strend(name_buffer_ptr) + 1;
if (unlikely(error)) if (unlikely(error))
save_error= error; save_error= error;
i++;
} while (*(++file)); } while (*(++file));
if (to != NULL) if (to != NULL)
{ {

View File

@ -1409,7 +1409,8 @@ private:
unless we already did it. unless we already did it.
*/ */
if (!part_share->auto_inc_initialized && if (!part_share->auto_inc_initialized &&
(ha_thd()->lex->sql_command == SQLCOM_INSERT || (ha_thd()->lex->sql_command == SQLCOM_INSERT ||
ha_thd()->lex->sql_command == SQLCOM_INSERT_SELECT ||
ha_thd()->lex->sql_command == SQLCOM_REPLACE) && ha_thd()->lex->sql_command == SQLCOM_REPLACE) &&
table->found_next_number_field) table->found_next_number_field)
bitmap_set_all(&m_part_info->read_partitions); bitmap_set_all(&m_part_info->read_partitions);

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. /* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB Corporation. Copyright (c) 2010, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1583,7 +1583,6 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
uchar **char_ptrs; uchar **char_ptrs;
unsigned i; unsigned i;
size_t size; size_t size;
uint tot_fields= 0;
uint tot_part_fields= 0; uint tot_part_fields= 0;
uint tot_subpart_fields= 0; uint tot_subpart_fields= 0;
DBUG_ENTER("set_up_charset_field_preps"); DBUG_ENTER("set_up_charset_field_preps");
@ -1595,13 +1594,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
ptr= part_field_array; ptr= part_field_array;
/* Set up arrays and buffers for those fields */ /* Set up arrays and buffers for those fields */
while ((field= *(ptr++))) while ((field= *(ptr++)))
{
if (field_is_partition_charset(field)) if (field_is_partition_charset(field))
{
tot_part_fields++; tot_part_fields++;
tot_fields++;
}
}
size= tot_part_fields * sizeof(char*); size= tot_part_fields * sizeof(char*);
if (!(char_ptrs= (uchar**)thd->calloc(size))) if (!(char_ptrs= (uchar**)thd->calloc(size)))
goto error; goto error;
@ -1635,13 +1629,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
/* Set up arrays and buffers for those fields */ /* Set up arrays and buffers for those fields */
ptr= subpart_field_array; ptr= subpart_field_array;
while ((field= *(ptr++))) while ((field= *(ptr++)))
{
if (field_is_partition_charset(field)) if (field_is_partition_charset(field))
{
tot_subpart_fields++; tot_subpart_fields++;
tot_fields++;
}
}
size= tot_subpart_fields * sizeof(char*); size= tot_subpart_fields * sizeof(char*);
if (!(char_ptrs= (uchar**) thd->calloc(size))) if (!(char_ptrs= (uchar**) thd->calloc(size)))
goto error; goto error;

View File

@ -2267,7 +2267,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
uchar quote_char) uchar quote_char)
{ {
CHARSET_INFO *const cs= thd->charset(); CHARSET_INFO *const cs= thd->charset();
uint double_quotes= 0;
uchar c; uchar c;
DBUG_ASSERT(m_ptr == m_tok_start + 1); DBUG_ASSERT(m_ptr == m_tok_start + 1);
@ -2292,7 +2291,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
if (yyPeek() != quote_char) if (yyPeek() != quote_char)
break; break;
c= yyGet(); c= yyGet();
double_quotes++;
continue; continue;
} }
} }

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2009 MySQL AB /* Copyright (C) 2009 MySQL AB
Copyright (c) 2019, 2020, MariaDB Corporation. Copyright (c) 2019, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2525,7 +2525,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
{ {
int rc= 0; int rc= 0;
KEY *key_info= &table->key_info[index]; KEY *key_info= &table->key_info[index];
ha_rows rows= 0;
DBUG_ENTER("collect_statistics_for_index"); DBUG_ENTER("collect_statistics_for_index");
@ -2560,7 +2559,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
if (rc) if (rc)
break; break;
rows++;
index_prefix_calc.add(); index_prefix_calc.add();
rc= table->file->ha_index_next(table->record[0]); rc= table->file->ha_index_next(table->record[0]);
} }

View File

@ -3635,7 +3635,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
List_iterator<Key> key_iterator(alter_info->key_list); List_iterator<Key> key_iterator(alter_info->key_list);
List_iterator<Key> key_iterator2(alter_info->key_list); List_iterator<Key> key_iterator2(alter_info->key_list);
uint key_parts=0, fk_key_count=0; uint key_parts=0;
bool primary_key=0,unique_key=0; bool primary_key=0,unique_key=0;
Key *key, *key2; Key *key, *key2;
uint tmp, key_number; uint tmp, key_number;
@ -3651,7 +3651,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
"(none)" , key->type)); "(none)" , key->type));
if (key->type == Key::FOREIGN_KEY) if (key->type == Key::FOREIGN_KEY)
{ {
fk_key_count++;
Foreign_key *fk_key= (Foreign_key*) key; Foreign_key *fk_key= (Foreign_key*) key;
if (fk_key->validate(alter_info->create_list)) if (fk_key->validate(alter_info->create_list))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@ -301,7 +301,6 @@ PageBulk::finish()
#endif #endif
ulint count = 0; ulint count = 0;
ulint n_recs = 0;
ulint slot_index = 0; ulint slot_index = 0;
rec_t* insert_rec = page_rec_get_next(page_get_infimum_rec(m_page)); rec_t* insert_rec = page_rec_get_next(page_get_infimum_rec(m_page));
page_dir_slot_t* slot = NULL; page_dir_slot_t* slot = NULL;
@ -309,7 +308,6 @@ PageBulk::finish()
/* Set owner & dir. */ /* Set owner & dir. */
while (!page_rec_is_supremum(insert_rec)) { while (!page_rec_is_supremum(insert_rec)) {
count++; count++;
n_recs++;
if (count == (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2) { if (count == (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2) {

View File

@ -1266,7 +1266,10 @@ void buf_page_print(const byte *read_buf, ulint zip_size)
byte row[64]; byte row[64];
for (byte *r= row; r != &row[64]; r+= 2, read_buf++) for (byte *r= row; r != &row[64]; r+= 2, read_buf++)
r[0]= hex_to_ascii(*read_buf >> 4), r[1]= hex_to_ascii(*read_buf & 15); {
r[0]= hex_to_ascii(byte(*read_buf >> 4));
r[1]= hex_to_ascii(*read_buf & 15);
}
sql_print_information("InnoDB: %.*s", 64, row); sql_print_information("InnoDB: %.*s", 64, row);
} }

View File

@ -1849,6 +1849,7 @@ dict_load_columns(
if (table->fts == NULL) { if (table->fts == NULL) {
table->fts = fts_create(table); table->fts = fts_create(table);
table->fts->cache = fts_cache_create(table); table->fts->cache = fts_cache_create(table);
DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME);
fts_optimize_add_table(table); fts_optimize_add_table(table);
} }
@ -2599,8 +2600,11 @@ next_rec:
ut_ad(table->fts_doc_id_index == NULL); ut_ad(table->fts_doc_id_index == NULL);
if (table->fts != NULL) { if (table->fts != NULL) {
table->fts_doc_id_index = dict_table_get_index_on_name( dict_index_t *idx = dict_table_get_index_on_name(
table, FTS_DOC_ID_INDEX_NAME); table, FTS_DOC_ID_INDEX_NAME);
if (idx && dict_index_is_unique(idx)) {
table->fts_doc_id_index = idx;
}
} }
/* If the table contains FTS indexes, populate table->fts->indexes */ /* If the table contains FTS indexes, populate table->fts->indexes */

View File

@ -9268,16 +9268,14 @@ innobase_rename_columns_try(
const char* table_name) const char* table_name)
{ {
uint i = 0; uint i = 0;
ulint num_v = 0;
DBUG_ASSERT(ctx->need_rebuild()); DBUG_ASSERT(ctx->need_rebuild());
DBUG_ASSERT(ha_alter_info->handler_flags DBUG_ASSERT(ha_alter_info->handler_flags
& ALTER_COLUMN_NAME); & ALTER_COLUMN_NAME);
for (Field** fp = table->field; *fp; fp++, i++) { for (Field** fp = table->field; *fp; fp++, i++) {
const bool is_virtual = !(*fp)->stored_in_db();
if (!((*fp)->flags & FIELD_IS_RENAMED)) { if (!((*fp)->flags & FIELD_IS_RENAMED)) {
goto processed_field; continue;
} }
for (const Create_field& cf : for (const Create_field& cf :
@ -9295,10 +9293,6 @@ innobase_rename_columns_try(
ut_error; ut_error;
processed_field: processed_field:
if (is_virtual) {
num_v++;
}
continue; continue;
} }

View File

@ -59,6 +59,7 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits)
#include "fil0crypt.h" #include "fil0crypt.h"
#include "dict0crea.h" #include "dict0crea.h"
#include "fts0vlc.h" #include "fts0vlc.h"
#include "log.h"
/** The latest successfully looked up innodb_fts_aux_table */ /** The latest successfully looked up innodb_fts_aux_table */
UNIV_INTERN table_id_t innodb_ft_aux_table_id; UNIV_INTERN table_id_t innodb_ft_aux_table_id;
@ -190,19 +191,37 @@ sync_arr_fill_sys_semphore_waits_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */ TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ); /*!< in: condition (not used) */ Item* ); /*!< in: condition (not used) */
/*******************************************************************//** /**
Common function to fill any of the dynamic tables: Common function to fill any of the dynamic tables:
INFORMATION_SCHEMA.innodb_trx INFORMATION_SCHEMA.innodb_trx
INFORMATION_SCHEMA.innodb_locks INFORMATION_SCHEMA.innodb_locks
INFORMATION_SCHEMA.innodb_lock_waits INFORMATION_SCHEMA.innodb_lock_waits
@return 0 on success */ @retval false if access to the table is blocked
static @retval true if something should be filled in */
int static bool trx_i_s_common_fill_table(THD *thd, TABLE_LIST *tables)
trx_i_s_common_fill_table( {
/*======================*/ DBUG_ENTER("trx_i_s_common_fill_table");
THD* thd, /*!< in: thread */
TABLE_LIST* tables, /*!< in/out: tables to fill */ /* deny access to non-superusers */
Item* ); /*!< in: condition (not used) */ if (check_global_access(thd, PROCESS_ACL))
DBUG_RETURN(false);
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* update the cache */
trx_i_s_cache_start_write(trx_i_s_cache);
trx_i_s_possibly_fetch_data_into_cache(trx_i_s_cache);
trx_i_s_cache_end_write(trx_i_s_cache);
if (trx_i_s_cache_is_truncated(trx_i_s_cache))
sql_print_warning("InnoDB: Data in %.*s truncated due to memory limit"
" of %u bytes",
int(tables->schema_table_name.length),
tables->schema_table_name.str,
TRX_I_S_MEM_LIMIT);
DBUG_RETURN(true);
}
/*******************************************************************//** /*******************************************************************//**
Unbind a dynamic INFORMATION_SCHEMA table. Unbind a dynamic INFORMATION_SCHEMA table.
@ -394,26 +413,29 @@ static ST_FIELD_INFO innodb_trx_fields_info[]=
/*******************************************************************//** /*******************************************************************//**
Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx
table with it. table with it.
@return 0 on success */ @retval 0 on success
static @retval 1 on failure */
int static int fill_innodb_trx_from_cache(THD *thd, TABLE_LIST *tables, Item*)
fill_innodb_trx_from_cache(
/*=======================*/
trx_i_s_cache_t* cache, /*!< in: cache to read from */
THD* thd, /*!< in: used to call
schema_table_store_record() */
TABLE* table) /*!< in/out: fill this table */
{ {
Field** fields;
ulint rows_num; ulint rows_num;
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
ulint i; ulint i;
DBUG_ENTER("fill_innodb_trx_from_cache"); DBUG_ENTER("fill_innodb_trx_from_cache");
fields = table->field; if (!trx_i_s_common_fill_table(thd, tables)) {
DBUG_RETURN(0);
}
rows_num = trx_i_s_cache_get_rows_used(cache, struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
} c;
Field** fields = tables->table->field;
rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_TRX); I_S_INNODB_TRX);
for (i = 0; i < rows_num; i++) { for (i = 0; i < rows_num; i++) {
@ -423,7 +445,7 @@ fill_innodb_trx_from_cache(
row = (i_s_trx_row_t*) row = (i_s_trx_row_t*)
trx_i_s_cache_get_nth_row( trx_i_s_cache_get_nth_row(
cache, I_S_INNODB_TRX, i); trx_i_s_cache, I_S_INNODB_TRX, i);
/* trx_id */ /* trx_id */
snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id); snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id);
@ -535,7 +557,7 @@ fill_innodb_trx_from_cache(
(longlong) row->trx_is_autocommit_non_locking, (longlong) row->trx_is_autocommit_non_locking,
true)); true));
OK(schema_table_store_record(thd, table)); OK(schema_table_store_record(thd, tables->table));
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -557,7 +579,7 @@ innodb_trx_init(
schema = (ST_SCHEMA_TABLE*) p; schema = (ST_SCHEMA_TABLE*) p;
schema->fields_info = innodb_trx_fields_info; schema->fields_info = innodb_trx_fields_info;
schema->fill_table = trx_i_s_common_fill_table; schema->fill_table = fill_innodb_trx_from_cache;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -672,20 +694,29 @@ static
int int
fill_innodb_locks_from_cache( fill_innodb_locks_from_cache(
/*=========================*/ /*=========================*/
trx_i_s_cache_t* cache, /*!< in: cache to read from */
THD* thd, /*!< in: MySQL client connection */ THD* thd, /*!< in: MySQL client connection */
TABLE* table) /*!< in/out: fill this table */ TABLE_LIST* tables, /*!< in/out: fill this table */
Item*)
{ {
Field** fields;
ulint rows_num; ulint rows_num;
char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
ulint i; ulint i;
DBUG_ENTER("fill_innodb_locks_from_cache"); DBUG_ENTER("fill_innodb_locks_from_cache");
fields = table->field; if (!trx_i_s_common_fill_table(thd, tables)) {
DBUG_RETURN(0);
}
rows_num = trx_i_s_cache_get_rows_used(cache, struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
} c;
Field** fields = tables->table->field;
rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_LOCKS); I_S_INNODB_LOCKS);
for (i = 0; i < rows_num; i++) { for (i = 0; i < rows_num; i++) {
@ -698,7 +729,7 @@ fill_innodb_locks_from_cache(
row = (i_s_locks_row_t*) row = (i_s_locks_row_t*)
trx_i_s_cache_get_nth_row( trx_i_s_cache_get_nth_row(
cache, I_S_INNODB_LOCKS, i); trx_i_s_cache, I_S_INNODB_LOCKS, i);
/* lock_id */ /* lock_id */
trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id)); trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id));
@ -746,7 +777,7 @@ fill_innodb_locks_from_cache(
OK(field_store_string(fields[IDX_LOCK_DATA], OK(field_store_string(fields[IDX_LOCK_DATA],
row->lock_data)); row->lock_data));
OK(schema_table_store_record(thd, table)); OK(schema_table_store_record(thd, tables->table));
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -768,7 +799,7 @@ innodb_locks_init(
schema = (ST_SCHEMA_TABLE*) p; schema = (ST_SCHEMA_TABLE*) p;
schema->fields_info = innodb_locks_fields_info; schema->fields_info = innodb_locks_fields_info;
schema->fill_table = trx_i_s_common_fill_table; schema->fill_table = fill_innodb_locks_from_cache;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -852,12 +883,11 @@ static
int int
fill_innodb_lock_waits_from_cache( fill_innodb_lock_waits_from_cache(
/*==============================*/ /*==============================*/
trx_i_s_cache_t* cache, /*!< in: cache to read from */
THD* thd, /*!< in: used to call THD* thd, /*!< in: used to call
schema_table_store_record() */ schema_table_store_record() */
TABLE* table) /*!< in/out: fill this table */ TABLE_LIST* tables, /*!< in/out: fill this table */
Item*)
{ {
Field** fields;
ulint rows_num; ulint rows_num;
char requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; char requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
char blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; char blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1];
@ -865,9 +895,19 @@ fill_innodb_lock_waits_from_cache(
DBUG_ENTER("fill_innodb_lock_waits_from_cache"); DBUG_ENTER("fill_innodb_lock_waits_from_cache");
fields = table->field; if (!trx_i_s_common_fill_table(thd, tables)) {
DBUG_RETURN(0);
}
rows_num = trx_i_s_cache_get_rows_used(cache, struct cache
{
cache() { trx_i_s_cache_start_read(trx_i_s_cache); }
~cache() { trx_i_s_cache_end_read(trx_i_s_cache); }
} c;
Field** fields = tables->table->field;
rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache,
I_S_INNODB_LOCK_WAITS); I_S_INNODB_LOCK_WAITS);
for (i = 0; i < rows_num; i++) { for (i = 0; i < rows_num; i++) {
@ -879,7 +919,7 @@ fill_innodb_lock_waits_from_cache(
row = (i_s_lock_waits_row_t*) row = (i_s_lock_waits_row_t*)
trx_i_s_cache_get_nth_row( trx_i_s_cache_get_nth_row(
cache, I_S_INNODB_LOCK_WAITS, i); trx_i_s_cache, I_S_INNODB_LOCK_WAITS, i);
/* requesting_trx_id */ /* requesting_trx_id */
snprintf(requesting_trx_id, sizeof(requesting_trx_id), snprintf(requesting_trx_id, sizeof(requesting_trx_id),
@ -909,7 +949,7 @@ fill_innodb_lock_waits_from_cache(
blocking_lock_id, blocking_lock_id,
sizeof(blocking_lock_id)))); sizeof(blocking_lock_id))));
OK(schema_table_store_record(thd, table)); OK(schema_table_store_record(thd, tables->table));
} }
DBUG_RETURN(0); DBUG_RETURN(0);
@ -931,7 +971,7 @@ innodb_lock_waits_init(
schema = (ST_SCHEMA_TABLE*) p; schema = (ST_SCHEMA_TABLE*) p;
schema->fields_info = innodb_lock_waits_fields_info; schema->fields_info = innodb_lock_waits_fields_info;
schema->fill_table = trx_i_s_common_fill_table; schema->fill_table = fill_innodb_lock_waits_from_cache;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -985,105 +1025,6 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_lock_waits =
MariaDB_PLUGIN_MATURITY_STABLE, MariaDB_PLUGIN_MATURITY_STABLE,
}; };
/*******************************************************************//**
Common function to fill any of the dynamic tables:
INFORMATION_SCHEMA.innodb_trx
INFORMATION_SCHEMA.innodb_locks
INFORMATION_SCHEMA.innodb_lock_waits
@return 0 on success */
static
int
trx_i_s_common_fill_table(
/*======================*/
THD* thd, /*!< in: thread */
TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ) /*!< in: condition (not used) */
{
LEX_CSTRING table_name;
int ret;
trx_i_s_cache_t* cache;
DBUG_ENTER("trx_i_s_common_fill_table");
/* deny access to non-superusers */
if (check_global_access(thd, PROCESS_ACL)) {
DBUG_RETURN(0);
}
/* minimize the number of places where global variables are
referenced */
cache = trx_i_s_cache;
/* which table we have to fill? */
table_name = tables->schema_table_name;
/* or table_name = tables->schema_table->table_name; */
RETURN_IF_INNODB_NOT_STARTED(table_name.str);
/* update the cache */
trx_i_s_cache_start_write(cache);
trx_i_s_possibly_fetch_data_into_cache(cache);
trx_i_s_cache_end_write(cache);
if (trx_i_s_cache_is_truncated(cache)) {
ib::warn() << "Data in " << table_name.str << " truncated due to"
" memory limit of " << TRX_I_S_MEM_LIMIT << " bytes";
}
ret = 0;
trx_i_s_cache_start_read(cache);
if (innobase_strcasecmp(table_name.str, "innodb_trx") == 0) {
if (fill_innodb_trx_from_cache(
cache, thd, tables->table) != 0) {
ret = 1;
}
} else if (innobase_strcasecmp(table_name.str, "innodb_locks") == 0) {
if (fill_innodb_locks_from_cache(
cache, thd, tables->table) != 0) {
ret = 1;
}
} else if (innobase_strcasecmp(table_name.str, "innodb_lock_waits") == 0) {
if (fill_innodb_lock_waits_from_cache(
cache, thd, tables->table) != 0) {
ret = 1;
}
} else {
ib::error() << "trx_i_s_common_fill_table() was"
" called to fill unknown table: " << table_name.str << "."
" This function only knows how to fill"
" innodb_trx, innodb_locks and"
" innodb_lock_waits tables.";
ret = 1;
}
trx_i_s_cache_end_read(cache);
#if 0
DBUG_RETURN(ret);
#else
/* if this function returns something else than 0 then a
deadlock occurs between the mysqld server and mysql client,
see http://bugs.mysql.com/29900 ; when that bug is resolved
we can enable the DBUG_RETURN(ret) above */
ret++; // silence a gcc46 warning
DBUG_RETURN(0);
#endif
}
/* Fields of the dynamic table information_schema.innodb_cmp. */ /* Fields of the dynamic table information_schema.innodb_cmp. */
static ST_FIELD_INFO i_s_cmp_fields_info[]= static ST_FIELD_INFO i_s_cmp_fields_info[]=
{ {

View File

@ -126,7 +126,6 @@ public:
rec_offs* ins_offsets = NULL; rec_offs* ins_offsets = NULL;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
dtuple_t* dtuple; dtuple_t* dtuple;
ulint count = 0;
const ulint flag = BTR_NO_UNDO_LOG_FLAG const ulint flag = BTR_NO_UNDO_LOG_FLAG
| BTR_NO_LOCKING_FLAG | BTR_NO_LOCKING_FLAG
| BTR_KEEP_SYS_FLAG | BTR_CREATE_FLAG; | BTR_KEEP_SYS_FLAG | BTR_CREATE_FLAG;
@ -234,7 +233,6 @@ public:
mtr_commit(&mtr); mtr_commit(&mtr);
rtr_clean_rtr_info(&rtr_info, true); rtr_clean_rtr_info(&rtr_info, true);
count++;
} }
m_dtuple_vec->clear(); m_dtuple_vec->clear();

View File

@ -1115,11 +1115,12 @@ SELECT * FROM t1;
a a
0 0
DROP TABLE t1; DROP TABLE t1;
##############################################################################
# #
# MDEV-19622 Assertion failures in # MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
# #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='TokuDB' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0; UPDATE t1 SET pk = 0;
DROP TABLE t1; DROP TABLE t1;
@ -1130,5 +1131,12 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='TokuDB' PARTITION BY HASH (a) PARTITIONS 3; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='TokuDB' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3); REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1; DROP TABLE t1;
############################################################################## #
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='TokuDB' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved; SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved;