diff options
51 files changed, 562 insertions, 423 deletions
diff --git a/.bzrignore b/.bzrignore index d51ffc7265b..7733bd2aa7c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3085,3 +3085,13 @@ client/dtoa.c libmysqld/sql_audit.cc configure.am libmysqld/des_key_file.cc +CPackConfig.cmake +CPackSourceConfig.cmake +make_dist.cmake +client/echo +libmysql/libmysql_exports_file.cc +libmysql/merge_archives_mysqlclient.cmake +libmysqld/merge_archives_mysqlserver.cmake +libmysqld/mysqlserver_depends.c +libmysqld/examples/mysql_embedded +sql/.empty diff --git a/cmd-line-utils/libedit/filecomplete.c b/cmd-line-utils/libedit/filecomplete.c index 4c63f57bc45..05bd10e9f9e 100644 --- a/cmd-line-utils/libedit/filecomplete.c +++ b/cmd-line-utils/libedit/filecomplete.c @@ -95,10 +95,9 @@ static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$', char * fn_tilde_expand(const char *txt) { - struct passwd pwres, *pass; + struct passwd *pass; char *temp; size_t len = 0; - char pwbuf[1024]; if (txt[0] != '~') return (strdup(txt)); diff --git a/configure.cmake b/configure.cmake index df71a96ee47..1727e2b2c10 100644 --- a/configure.cmake +++ b/configure.cmake @@ -54,6 +54,15 @@ IF(NOT SYSTEM_TYPE) ENDIF() +# Always enable -Wall for gnu C/C++ +IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter") +ENDIF() +IF(CMAKE_COMPILER_IS_GNUCC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCXX) # MySQL "canonical" GCC flags. At least -fno-rtti flag affects # ABI and cannot be simply removed. diff --git a/extra/comp_err.c b/extra/comp_err.c index e4a07caa2ef..362533d9781 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -686,7 +686,7 @@ static ha_checksum checksum_format_specifier(const char* msg) case 'u': case 'x': case 's': - chksum= my_checksum(chksum, start, (uint) (p + 1 - start)); + chksum= my_checksum(chksum, (uchar*) start, (uint) (p + 1 - start)); start= 0; /* Not in format specifier anymore */ break; diff --git a/extra/perror.c b/extra/perror.c index d9c636ceb8c..eda0253129d 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -269,7 +269,7 @@ int main(int argc,char *argv[]) HA_ERRORS *ha_err_ptr; for (code=1 ; code < sys_nerr ; code++) { - if (sys_errlist[code][0]) + if (sys_errlist[code] && sys_errlist[code][0]) { /* Skip if no error-text */ printf("%3d = %s\n",code,sys_errlist[code]); } diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 99bbe3ac8a3..b59f61a1cde 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -60,7 +60,7 @@ static int __cxa_pure_virtual() __attribute__((noinline, used)); static int __cxa_pure_virtual() { // oops, pure virtual called! - assert("Pure virtual method called." == "Aborted"); + assert(!"Pure virtual method called. Aborted"); return 0; } diff --git a/include/my_global.h b/include/my_global.h index 094853cb642..2a65c610604 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1070,6 +1070,17 @@ typedef long long my_ptrdiff_t; #define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B)) #define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))] +#ifdef __cplusplus +template <size_t sz> struct Aligned_char_array +{ + union { + void *v; // Ensures alignment. + char arr[sz]; // The actual buffer. + } u; + void* arr() { return &u.arr[0]; } +}; +#endif /* __cplusplus */ + /* Custom version of standard offsetof() macro which can be used to get offsets of members in class for non-POD types (according to the current diff --git a/mysql-test/r/information_schema_part.result b/mysql-test/r/information_schema_part.result index 11c57ceb2c2..b34183ebdee 100644 --- a/mysql-test/r/information_schema_part.result +++ b/mysql-test/r/information_schema_part.result @@ -37,9 +37,9 @@ partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t4"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -def test t4 p0 NULL 1 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL -def test t4 p1 NULL 2 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL -def test t4 p2 NULL 3 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +def test t4 p0 NULL 1 NULL KEY NULL `f1`,`f2` NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +def test t4 p1 NULL 2 NULL KEY NULL `f1`,`f2` NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL +def test t4 p2 NULL 3 NULL KEY NULL `f1`,`f2` NULL NULL 0 0 0 # 1024 0 # # NULL NULL default NULL drop table t1,t2,t3,t4; create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) @@ -67,10 +67,10 @@ def test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default def test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default t2 def test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default t1 def test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default t2 -def test t2 x1 x11 1 1 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default t1 -def test t2 x1 x12 1 2 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default t2 -def test t2 x2 x21 2 1 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default t1 -def test t2 x2 x22 2 2 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default t2 +def test t2 x1 x11 1 1 RANGE KEY a `a` 1 0 0 0 # 1024 0 # # NULL NULL default t1 +def test t2 x1 x12 1 2 RANGE KEY a `a` 1 0 0 0 # 1024 0 # # NULL NULL default t2 +def test t2 x2 x21 2 1 RANGE KEY a `a` 5 0 0 0 # 1024 0 # # NULL NULL default t1 +def test t2 x2 x22 2 2 RANGE KEY a `a` 5 0 0 0 # 1024 0 # # NULL NULL default t2 drop table t1,t2; create table t1 ( a int not null, diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 77c1778fc55..66f8ac68dfe 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,46 @@ drop table if exists t1, t2; +# Bug#39338: Fieldnames in +# INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION become unescaped +# NOTE: the partition expression is saved as a string, so changing from +# normal quotes to ansi quotes does not change the expression, only +# for partition by KEY. +CREATE TABLE t1 ( +ID int(11) NOT NULL, +`aaaa,aaaaa` tinyint(3) UNSIGNED NOT NULL DEFAULT '0', +ddddddddd int(11) NOT NULL DEFAULT '0', +new_field0 varchar(50), +PRIMARY KEY(ID, `aaaa,aaaaa`, ddddddddd)) +PARTITION BY RANGE(ID) +PARTITIONS 3 +SUBPARTITION BY LINEAR KEY(ID,`aaaa,aaaaa`) +SUBPARTITIONS 2 ( +PARTITION p01 VALUES LESS THAN(100), +PARTITION p11 VALUES LESS THAN(200), +PARTITION p21 VALUES LESS THAN MAXVALUE); +SELECT PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +PARTITION_EXPRESSION SUBPARTITION_EXPRESSION +ID `ID`,`aaaa,aaaaa` +ID `ID`,`aaaa,aaaaa` +ID `ID`,`aaaa,aaaaa` +ID `ID`,`aaaa,aaaaa` +ID `ID`,`aaaa,aaaaa` +ID `ID`,`aaaa,aaaaa` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ID` int(11) NOT NULL, + `aaaa,aaaaa` tinyint(3) unsigned NOT NULL DEFAULT '0', + `ddddddddd` int(11) NOT NULL DEFAULT '0', + `new_field0` varchar(50) DEFAULT NULL, + PRIMARY KEY (`ID`,`aaaa,aaaaa`,`ddddddddd`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (ID) +SUBPARTITION BY LINEAR KEY (ID,`aaaa,aaaaa`) +SUBPARTITIONS 2 +(PARTITION p01 VALUES LESS THAN (100) ENGINE = MyISAM, + PARTITION p11 VALUES LESS THAN (200) ENGINE = MyISAM, + PARTITION p21 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +drop table t1; CREATE TABLE t1 (a INT, b INT) PARTITION BY LIST (a) SUBPARTITION BY HASH (b) diff --git a/mysql-test/r/partition_binlog_stmt.result b/mysql-test/r/partition_binlog_stmt.result new file mode 100644 index 00000000000..9be23636ca6 --- /dev/null +++ b/mysql-test/r/partition_binlog_stmt.result @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS t1; +# +# Bug#51851: Server with SBR locks mutex twice on LOAD DATA into +# partitioned MyISAM table +CREATE TABLE t1 +(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +name TINYBLOB NOT NULL, +modified TIMESTAMP DEFAULT '0000-00-00 00:00:00', +INDEX namelocs (name(255))) ENGINE = MyISAM +PARTITION BY HASH(id) PARTITIONS 2; +LOAD DATA LOCAL INFILE 'init_file.txt' +INTO TABLE t1 (name); +DROP TABLE t1; diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result index 458343a6b92..7b45ffcb0de 100644 --- a/mysql-test/r/partition_column.result +++ b/mysql-test/r/partition_column.result @@ -1,4 +1,44 @@ drop table if exists t1; +# +# Bug#52815: LIST COLUMNS doesn't insert rows in correct partition +# if muliple columns used +CREATE TABLE t1 ( +id INT NOT NULL, +name VARCHAR(255), +department VARCHAR(10), +country VARCHAR(255) +) PARTITION BY LIST COLUMNS (department, country) ( +PARTITION first_office VALUES IN (('dep1', 'Russia'), ('dep1', 'Croatia')), +PARTITION second_office VALUES IN (('dep2', 'Russia')) +); +INSERT INTO t1 VALUES(1, 'Ann', 'dep1', 'Russia'); +INSERT INTO t1 VALUES(2, 'Bob', 'dep1', 'Croatia'); +INSERT INTO t1 VALUES(3, 'Cecil', 'dep2', 'Russia'); +INSERT INTO t1 VALUES(3, 'Dan', 'dep2', 'Croatia'); +ERROR HY000: Table has no partition for value from column_list +SELECT PARTITION_NAME,TABLE_ROWS +FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't1'; +PARTITION_NAME TABLE_ROWS +first_office 2 +second_office 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `department` varchar(10) DEFAULT NULL, + `country` varchar(255) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50500 PARTITION BY LIST COLUMNS(department,country) +(PARTITION first_office VALUES IN (('dep1','Russia'),('dep1','Croatia')) ENGINE = MyISAM, + PARTITION second_office VALUES IN (('dep2','Russia')) ENGINE = MyISAM) */ +SELECT * FROM t1 WHERE department = 'dep2' and country = 'Croatia'; +id name department country +SELECT * FROM t1 WHERE department = 'dep1' and country = 'Croatia'; +id name department country +2 Bob dep1 Croatia +DROP TABLE t1; CREATE TABLE t1 (a DECIMAL) PARTITION BY RANGE COLUMNS (a) (PARTITION p0 VALUES LESS THAN (0)); @@ -168,22 +208,22 @@ partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE)); select partition_method, partition_expression, partition_description from information_schema.partitions where table_name = "t1"; partition_method partition_expression partition_description -RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01' -RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01' -RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01' -RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01' -RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01' -RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01' -RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01' -RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01' -RANGE COLUMNS a,b,c,d 1,'b',MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,'b',MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,'b',MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,'b',MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE -RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'0',MAXVALUE,'1900-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'0',MAXVALUE,'1900-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'0',MAXVALUE,'1900-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'0',MAXVALUE,'1900-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'a',MAXVALUE,'1999-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'a',MAXVALUE,'1999-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'a',MAXVALUE,'1999-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'a',MAXVALUE,'1999-01-01' +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'b',MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'b',MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'b',MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,'b',MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,MAXVALUE,MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,MAXVALUE,MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,MAXVALUE,MAXVALUE,MAXVALUE +RANGE COLUMNS `a`,`b`,`c`,`d` 1,MAXVALUE,MAXVALUE,MAXVALUE show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -266,9 +306,9 @@ partition p2 values in ((3, NULL), (NULL, 1))); select partition_method, partition_expression, partition_description from information_schema.partitions where table_name = "t1"; partition_method partition_expression partition_description -LIST COLUMNS a,b (1,NULL),(2,NULL),(NULL,NULL) -LIST COLUMNS a,b (1,1),(2,2) -LIST COLUMNS a,b (3,NULL),(NULL,1) +LIST COLUMNS `a`,`b` (1,NULL),(2,NULL),(NULL,NULL) +LIST COLUMNS `a`,`b` (1,1),(2,2) +LIST COLUMNS `a`,`b` (3,NULL),(NULL,1) show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -298,11 +338,11 @@ select * from t1 where a > 8; a b select * from t1 where a not between 8 and 8; a b +1 NULL 2 NULL +1 1 2 2 3 NULL -1 NULL -1 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -356,8 +396,8 @@ partition p1 values in (4, NULL, 3)); select partition_method, partition_expression, partition_description from information_schema.partitions where table_name = "t1"; partition_method partition_expression partition_description -LIST COLUMNS a 2,1 -LIST COLUMNS a 4,NULL,3 +LIST COLUMNS `a` 2,1 +LIST COLUMNS `a` 4,NULL,3 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -393,18 +433,18 @@ partition p3 values less than (4,'abc','abc')); select partition_method, partition_expression, partition_description from information_schema.partitions where table_name = "t1"; partition_method partition_expression partition_description -RANGE COLUMNS a,b,c 1,'abc','abc' -RANGE COLUMNS a,b,c 1,'abc','abc' -RANGE COLUMNS a,b,c 1,'abc','abc' -RANGE COLUMNS a,b,c 2,'abc','abc' -RANGE COLUMNS a,b,c 2,'abc','abc' -RANGE COLUMNS a,b,c 2,'abc','abc' -RANGE COLUMNS a,b,c 3,'abc','abc' -RANGE COLUMNS a,b,c 3,'abc','abc' -RANGE COLUMNS a,b,c 3,'abc','abc' -RANGE COLUMNS a,b,c 4,'abc','abc' -RANGE COLUMNS a,b,c 4,'abc','abc' -RANGE COLUMNS a,b,c 4,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 1,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 1,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 1,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 2,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 2,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 2,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 3,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 3,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 3,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 4,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 4,'abc','abc' +RANGE COLUMNS `a`,`b`,`c` 4,'abc','abc' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -437,8 +477,8 @@ partition p1 values less than (1, 'B', 1)); select partition_method, partition_expression, partition_description from information_schema.partitions where table_name = "t1"; partition_method partition_expression partition_description -RANGE COLUMNS a,b,c 1,'A',1 -RANGE COLUMNS a,b,c 1,'B',1 +RANGE COLUMNS `a`,`b`,`c` 1,'A',1 +RANGE COLUMNS `a`,`b`,`c` 1,'B',1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index ce304b136d0..6c7b7127975 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,5 +1,75 @@ drop table if exists t1; # +# Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with +# subpartitions +SET @org_mode=@@sql_mode; +SET @@sql_mode='NO_DIR_IN_CREATE'; +SELECT @@sql_mode; +@@sql_mode +NO_DIR_IN_CREATE +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE +DATA DIRECTORY = '/tmp/not-existing' +INDEX DIRECTORY = '/tmp/not-existing'); +Warnings: +Warning 1618 <DATA DIRECTORY> option ignored +Warning 1618 <INDEX DIRECTORY> option ignored +Warning 1618 <DATA DIRECTORY> option ignored +Warning 1618 <INDEX DIRECTORY> option ignored +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `purchased` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (YEAR(purchased)) +SUBPARTITION BY HASH (TO_DAYS(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +DROP TABLE t1; +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2 +(PARTITION p0 VALUES LESS THAN MAXVALUE +(SUBPARTITION sp0 +DATA DIRECTORY = '/tmp/not-existing' +INDEX DIRECTORY = '/tmp/not-existing', +SUBPARTITION sp1)); +Warnings: +Warning 1618 <DATA DIRECTORY> option ignored +Warning 1618 <INDEX DIRECTORY> option ignored +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `purchased` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (YEAR(purchased)) +SUBPARTITION BY HASH (TO_DAYS(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE + (SUBPARTITION sp0 ENGINE = MyISAM, + SUBPARTITION sp1 ENGINE = MyISAM)) */ +DROP TABLE t1; +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE +DATA DIRECTORY = '/tmp/not-existing' +INDEX DIRECTORY = '/tmp/not-existing'); +Warnings: +Warning 1618 <DATA DIRECTORY> option ignored +Warning 1618 <INDEX DIRECTORY> option ignored +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `purchased` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (YEAR(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# # Bug#50392: insert_id is not reset for partitioned tables # auto_increment on duplicate entry CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result b/mysql-test/suite/perfschema/r/dml_setup_instruments.result index 448aaa7400f..73dc1178a54 100644 --- a/mysql-test/suite/perfschema/r/dml_setup_instruments.result +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result @@ -8,12 +8,12 @@ wait/synch/mutex/sql/Cversion_lock YES YES wait/synch/mutex/sql/Delayed_insert::mutex YES YES wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state YES YES wait/synch/mutex/sql/hash_filo::lock YES YES +wait/synch/mutex/sql/HA_DATA_PARTITION::LOCK_auto_inc YES YES wait/synch/mutex/sql/LOCK_active_mi YES YES wait/synch/mutex/sql/LOCK_audit_mask YES YES wait/synch/mutex/sql/LOCK_connection_count YES YES wait/synch/mutex/sql/LOCK_crypt YES YES wait/synch/mutex/sql/LOCK_delayed_create YES YES -wait/synch/mutex/sql/LOCK_delayed_insert YES YES select * from performance_schema.SETUP_INSTRUMENTS where name like 'Wait/Synch/Rwlock/sql/%' and name not in ('wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock') diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 4b7be00148f..bcb5d4b5d92 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -14,6 +14,28 @@ drop table if exists t1, t2; --enable_warnings +--echo # Bug#39338: Fieldnames in +--echo # INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION become unescaped +--echo # NOTE: the partition expression is saved as a string, so changing from +--echo # normal quotes to ansi quotes does not change the expression, only +--echo # for partition by KEY. +CREATE TABLE t1 ( + ID int(11) NOT NULL, + `aaaa,aaaaa` tinyint(3) UNSIGNED NOT NULL DEFAULT '0', + ddddddddd int(11) NOT NULL DEFAULT '0', + new_field0 varchar(50), + PRIMARY KEY(ID, `aaaa,aaaaa`, ddddddddd)) +PARTITION BY RANGE(ID) +PARTITIONS 3 +SUBPARTITION BY LINEAR KEY(ID,`aaaa,aaaaa`) +SUBPARTITIONS 2 ( + PARTITION p01 VALUES LESS THAN(100), + PARTITION p11 VALUES LESS THAN(200), + PARTITION p21 VALUES LESS THAN MAXVALUE); +SELECT PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1'; +show create table t1; +drop table t1; + # # Bug#48276: can't add column if subpartition exists CREATE TABLE t1 (a INT, b INT) diff --git a/mysql-test/t/partition_binlog_stmt.test b/mysql-test/t/partition_binlog_stmt.test new file mode 100644 index 00000000000..bb52c2210f3 --- /dev/null +++ b/mysql-test/t/partition_binlog_stmt.test @@ -0,0 +1,28 @@ +--source include/have_partition.inc +--source include/have_binlog_format_statement.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Bug#51851: Server with SBR locks mutex twice on LOAD DATA into +--echo # partitioned MyISAM table +perl; +open( INIT, ">init_file.txt"); +print INIT "abcd\n"; +close( INIT ); +EOF + +CREATE TABLE t1 +(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + name TINYBLOB NOT NULL, + modified TIMESTAMP DEFAULT '0000-00-00 00:00:00', + INDEX namelocs (name(255))) ENGINE = MyISAM +PARTITION BY HASH(id) PARTITIONS 2; + +LOAD DATA LOCAL INFILE 'init_file.txt' +INTO TABLE t1 (name); + +--remove_file init_file.txt +DROP TABLE t1; diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test index d1d2d666a39..95a2be36395 100644 --- a/mysql-test/t/partition_column.test +++ b/mysql-test/t/partition_column.test @@ -8,6 +8,32 @@ drop table if exists t1; --enable_warnings +--echo # +--echo # Bug#52815: LIST COLUMNS doesn't insert rows in correct partition +--echo # if muliple columns used +CREATE TABLE t1 ( +id INT NOT NULL, +name VARCHAR(255), +department VARCHAR(10), +country VARCHAR(255) +) PARTITION BY LIST COLUMNS (department, country) ( +PARTITION first_office VALUES IN (('dep1', 'Russia'), ('dep1', 'Croatia')), +PARTITION second_office VALUES IN (('dep2', 'Russia')) +); + +INSERT INTO t1 VALUES(1, 'Ann', 'dep1', 'Russia'); +INSERT INTO t1 VALUES(2, 'Bob', 'dep1', 'Croatia'); +INSERT INTO t1 VALUES(3, 'Cecil', 'dep2', 'Russia'); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO t1 VALUES(3, 'Dan', 'dep2', 'Croatia'); +SELECT PARTITION_NAME,TABLE_ROWS +FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't1'; +SHOW CREATE TABLE t1; +SELECT * FROM t1 WHERE department = 'dep2' and country = 'Croatia'; +SELECT * FROM t1 WHERE department = 'dep1' and country = 'Croatia'; +DROP TABLE t1; + # # Bug#51347: assertion with show create table + partition by columns # on decimal column diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index bfa1206fe2d..d1b152c8799 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -7,7 +7,40 @@ --disable_warnings drop table if exists t1; --enable_warnings - + +--echo # +--echo # Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with +--echo # subpartitions +SET @org_mode=@@sql_mode; +SET @@sql_mode='NO_DIR_IN_CREATE'; +SELECT @@sql_mode; +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE + DATA DIRECTORY = '/tmp/not-existing' + INDEX DIRECTORY = '/tmp/not-existing'); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2 +(PARTITION p0 VALUES LESS THAN MAXVALUE + (SUBPARTITION sp0 + DATA DIRECTORY = '/tmp/not-existing' + INDEX DIRECTORY = '/tmp/not-existing', + SUBPARTITION sp1)); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +(PARTITION p0 VALUES LESS THAN MAXVALUE + DATA DIRECTORY = '/tmp/not-existing' + INDEX DIRECTORY = '/tmp/not-existing'); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET @@sql_mode= @org_mode; + --echo # --echo # Bug#50392: insert_id is not reset for partitioned tables --echo # auto_increment on duplicate entry diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index fda9b97791d..7fd10703871 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -329,10 +329,9 @@ static void _lf_pinbox_real_free(LF_PINS *pins) { int npins, alloca_size; void *list, **addr; - void *first, *last= NULL; + void *first= NULL, *last= NULL; LF_PINBOX *pinbox= pins->pinbox; - LINT_INIT(first); npins= pinbox->pins_in_array+1; #ifdef HAVE_ALLOCA diff --git a/mysys/make-ccc b/mysys/make-ccc deleted file mode 100755 index b34bd80e1d1..00000000000 --- a/mysys/make-ccc +++ /dev/null @@ -1,4 +0,0 @@ -rm -f .deps/* raid.o mf_iocache.o libmysys.a -ccc -DDEFAULT_BASEDIR="\"/usr/local/mysql\"" -DDATADIR="\"/usr/local/mysql/var\"" -DHAVE_CONFIG_H -I./../include -I../include -I.. -DDBUG_OFF -fast -O3 -fomit-frame-pointer -c array.c checksum.c default.c errors.c getopt.c getopt1.c getvar.c hash.c list.c mf_brkhant.c mf_cache.c mf_casecnv.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_keycache.c mf_loadpath.c mf_pack.c mf_pack2.c mf_path.c mf_qsort.c mf_qsort2.c mf_radix.c mf_reccache.c mf_same.c mf_sort.c mf_soundex.c mf_stripp.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_alarm.c my_alloc.c my_append.c my_chsize.c my_clock.c my_compress.c my_copy.c my_create.c my_delete.c my_div.c my_error.c my_fopen.c my_fstream.c my_getwd.c my_init.c my_lib.c my_lockmem.c my_malloc.c my_messnc.c my_mkdir.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_static.c my_tempnam.c my_thr_init.c my_write.c ptr_cmp.c queues.c safemalloc.c string.c thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c tree.c typelib.c -make raid.o mf_iocache.o my_lock.o -ar -cr libmysys.a array.o raid.o mf_iocache.o my_lock.o diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc index 2a41179974d..8f037e8babb 100644 --- a/plugin/daemon_example/daemon_example.cc +++ b/plugin/daemon_example/daemon_example.cc @@ -16,6 +16,7 @@ #include <sql_priv.h> #include <stdlib.h> #include <ctype.h> +#include <time.h> // localtime_r #include <mysql_version.h> #include <mysql/plugin.h> #include <my_global.h> diff --git a/regex/make-ccc b/regex/make-ccc deleted file mode 100755 index 561c5a9bddc..00000000000 --- a/regex/make-ccc +++ /dev/null @@ -1,3 +0,0 @@ -ccc -DHAVE_CONFIG_H -I. -I. -I.. -I./../include -I../include -O -DDBUG_OFF -fast -O3 -c regerror.c regcomp.c regexec.c regfree.c reginit.c -rm libregex.a -ar -cr libregex.a regerror.o diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 2d082cc71f6..9f003174d2e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4249,7 +4249,7 @@ int ha_ndbcluster::info(uint flag) } -void ha_ndbcluster::get_dynamic_partition_info(PARTITION_INFO *stat_info, +void ha_ndbcluster::get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id) { /* @@ -4257,7 +4257,7 @@ void ha_ndbcluster::get_dynamic_partition_info(PARTITION_INFO *stat_info, implement ndb function which retrives the statistics about ndb partitions. */ - bzero((char*) stat_info, sizeof(PARTITION_INFO)); + bzero((char*) stat_info, sizeof(PARTITION_STATS)); return; } diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 17ba7451538..de1e36b61d2 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -275,7 +275,7 @@ class ha_ndbcluster: public handler ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; } int info(uint); - void get_dynamic_partition_info(PARTITION_INFO *stat_info, uint part_id); + void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id); int extra(enum ha_extra_function operation); int extra_opt(enum ha_extra_function operation, ulong cache_size); int reset(); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index b8831127e3f..86332f8c79c 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -59,6 +59,7 @@ #include "sql_table.h" // tablename_to_filename #include "key.h" #include "sql_plugin.h" +#include "table.h" /* HA_DATA_PARTITION */ static const char *ha_par_ext= ".par"; #ifdef NOT_USED @@ -2498,12 +2499,11 @@ err1: A destructor for partition-specific TABLE_SHARE data. */ -void ha_data_partition_destroy(void *ha_data) +void ha_data_partition_destroy(HA_DATA_PARTITION* ha_part_data) { - if (ha_data) + if (ha_part_data) { - HA_DATA_PARTITION *ha_data_partition= (HA_DATA_PARTITION*) ha_data; - pthread_mutex_destroy(&ha_data_partition->mutex); + mysql_mutex_destroy(&ha_part_data->LOCK_auto_inc); } } @@ -2643,28 +2643,30 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) goto err_handler; /* - Use table_share->ha_data to share auto_increment_value among all handlers - for the same table. + Use table_share->ha_part_data to share auto_increment_value among + all handlers for the same table. */ if (is_not_tmp_table) mysql_mutex_lock(&table_share->LOCK_ha_data); - if (!table_share->ha_data) + if (!table_share->ha_part_data) { - HA_DATA_PARTITION *ha_data; /* currently only needed for auto_increment */ - table_share->ha_data= ha_data= (HA_DATA_PARTITION*) + table_share->ha_part_data= (HA_DATA_PARTITION*) alloc_root(&table_share->mem_root, sizeof(HA_DATA_PARTITION)); - if (!ha_data) + if (!table_share->ha_part_data) { if (is_not_tmp_table) mysql_mutex_unlock(&table_share->LOCK_ha_data); goto err_handler; } - DBUG_PRINT("info", ("table_share->ha_data 0x%p", ha_data)); - bzero(ha_data, sizeof(HA_DATA_PARTITION)); - table_share->ha_data_destroy= ha_data_partition_destroy; - pthread_mutex_init(&ha_data->mutex, MY_MUTEX_INIT_FAST); + DBUG_PRINT("info", ("table_share->ha_part_data 0x%p", + table_share->ha_part_data)); + bzero(table_share->ha_part_data, sizeof(HA_DATA_PARTITION)); + table_share->ha_part_data_destroy= ha_data_partition_destroy; + mysql_mutex_init(key_PARTITION_LOCK_auto_inc, + &table_share->ha_part_data->LOCK_auto_inc, + MY_MUTEX_INIT_FAST); } if (is_not_tmp_table) mysql_mutex_unlock(&table_share->LOCK_ha_data); @@ -3088,7 +3090,6 @@ int ha_partition::write_row(uchar * buf) longlong func_value; bool have_auto_increment= table->next_number_field && buf == table->record[0]; my_bitmap_map *old_map; - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; THD *thd= ha_thd(); timestamp_auto_set_type orig_timestamp_type= table->timestamp_field_type; #ifdef NOT_NEEDED @@ -3108,8 +3109,8 @@ int ha_partition::write_row(uchar * buf) */ if (have_auto_increment) { - if (!ha_data->auto_inc_initialized && - !table->s->next_number_keypart) + if (!table_share->ha_part_data->auto_inc_initialized && + !table_share->next_number_keypart) { /* If auto_increment in table_share is not initialized, start by @@ -3249,7 +3250,7 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) exit: /* if updating an auto_increment column, update - table_share->ha_data->next_auto_inc_val if needed. + table_share->ha_part_data->next_auto_inc_val if needed. (not to be used if auto_increment on secondary field in a multi-column index) mysql_update does not set table->next_number_field, so we use @@ -3258,8 +3259,7 @@ exit: if (table->found_next_number_field && new_data == table->record[0] && !table->s->next_number_keypart) { - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; - if (!ha_data->auto_inc_initialized) + if (!table_share->ha_part_data->auto_inc_initialized) info(HA_STATUS_AUTO); set_auto_increment_if_higher(table->found_next_number_field); } @@ -3351,11 +3351,10 @@ int ha_partition::delete_all_rows() if (thd->lex->sql_command == SQLCOM_TRUNCATE) { Alter_info *alter_info= &thd->lex->alter_info; - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; /* TRUNCATE also means resetting auto_increment */ lock_auto_increment(); - ha_data->next_auto_inc_val= 0; - ha_data->auto_inc_initialized= FALSE; + table_share->ha_part_data->next_auto_inc_val= 0; + table_share->ha_part_data->auto_inc_initialized= FALSE; unlock_auto_increment(); if (alter_info->flags & ALTER_ADMIN_PARTITION) { @@ -4182,10 +4181,9 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key, int ha_partition::common_index_read(uchar *buf, bool have_start_key) { int error; - uint key_len; + uint UNINIT_VAR(key_len); /* used if have_start_key==TRUE */ bool reverse_order= FALSE; DBUG_ENTER("ha_partition::common_index_read"); - LINT_INIT(key_len); /* used if have_start_key==TRUE */ DBUG_PRINT("info", ("m_ordered %u m_ordered_scan_ong %u have_start_key %u", m_ordered, m_ordered_scan_ongoing, have_start_key)); @@ -5071,22 +5069,22 @@ int ha_partition::info(uint flag) if (flag & HA_STATUS_AUTO) { bool auto_inc_is_first_in_idx= (table_share->next_number_keypart == 0); - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; DBUG_PRINT("info", ("HA_STATUS_AUTO")); if (!table->found_next_number_field) stats.auto_increment_value= 0; - else if (ha_data->auto_inc_initialized) + else if (table_share->ha_part_data->auto_inc_initialized) { lock_auto_increment(); - stats.auto_increment_value= ha_data->next_auto_inc_val; + stats.auto_increment_value= table_share->ha_part_data->next_auto_inc_val; unlock_auto_increment(); } else { lock_auto_increment(); /* to avoid two concurrent initializations, check again when locked */ - if (ha_data->auto_inc_initialized) - stats.auto_increment_value= ha_data->next_auto_inc_val; + if (table_share->ha_part_data->auto_inc_initialized) + stats.auto_increment_value= + table_share->ha_part_data->next_auto_inc_val; else { handler *file, **file_array; @@ -5106,10 +5104,11 @@ int ha_partition::info(uint flag) stats.auto_increment_value= auto_increment_value; if (auto_inc_is_first_in_idx) { - set_if_bigger(ha_data->next_auto_inc_val, auto_increment_value); - ha_data->auto_inc_initialized= TRUE; + set_if_bigger(table_share->ha_part_data->next_auto_inc_val, + auto_increment_value); + table_share->ha_part_data->auto_inc_initialized= TRUE; DBUG_PRINT("info", ("initializing next_auto_inc_val to %lu", - (ulong) ha_data->next_auto_inc_val)); + (ulong) table_share->ha_part_data->next_auto_inc_val)); } } unlock_auto_increment(); @@ -5284,7 +5283,7 @@ int ha_partition::info(uint flag) } -void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, +void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id) { handler *file= m_file[part_id]; @@ -6499,11 +6498,10 @@ int ha_partition::reset_auto_increment(ulonglong value) { handler **file= m_file; int res; - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; DBUG_ENTER("ha_partition::reset_auto_increment"); lock_auto_increment(); - ha_data->auto_inc_initialized= FALSE; - ha_data->next_auto_inc_val= 0; + table_share->ha_part_data->auto_inc_initialized= FALSE; + table_share->ha_part_data->next_auto_inc_val= 0; do { if ((res= (*file)->ha_reset_auto_increment(value)) != 0) @@ -6517,7 +6515,7 @@ int ha_partition::reset_auto_increment(ulonglong value) /** This method is called by update_auto_increment which in turn is called by the individual handlers as part of write_row. We use the - table_share->ha_data->next_auto_inc_val, or search all + table_share->ha_part_data->next_auto_inc_val, or search all partitions for the highest auto_increment_value if not initialized or if auto_increment field is a secondary part of a key, we must search every partition when holding a mutex to be sure of correctness. @@ -6570,13 +6568,12 @@ void ha_partition::get_auto_increment(ulonglong offset, ulonglong increment, else { THD *thd= ha_thd(); - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; /* This is initialized in the beginning of the first write_row call. */ - DBUG_ASSERT(ha_data->auto_inc_initialized); + DBUG_ASSERT(table_share->ha_part_data->auto_inc_initialized); /* - Get a lock for handling the auto_increment in table_share->ha_data + Get a lock for handling the auto_increment in table_share->ha_part_data for avoiding two concurrent statements getting the same number. */ @@ -6603,8 +6600,9 @@ void ha_partition::get_auto_increment(ulonglong offset, ulonglong increment, } /* this gets corrected (for offset/increment) in update_auto_increment */ - *first_value= ha_data->next_auto_inc_val; - ha_data->next_auto_inc_val+= nb_desired_values * increment; + *first_value= table_share->ha_part_data->next_auto_inc_val; + table_share->ha_part_data->next_auto_inc_val+= + nb_desired_values * increment; unlock_auto_increment(); DBUG_PRINT("info", ("*first_value: %lu", (ulong) *first_value)); @@ -6624,10 +6622,9 @@ void ha_partition::release_auto_increment() } else if (next_insert_id) { - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; ulonglong next_auto_inc_val; lock_auto_increment(); - next_auto_inc_val= ha_data->next_auto_inc_val; + next_auto_inc_val= table_share->ha_part_data->next_auto_inc_val; /* If the current auto_increment values is lower than the reserved value, and the reserved value was reserved by this thread, @@ -6642,10 +6639,10 @@ void ha_partition::release_auto_increment() with SET INSERT_ID, i.e. forced/non generated values. */ if (thd->auto_inc_intervals_forced.maximum() < next_insert_id) - ha_data->next_auto_inc_val= next_insert_id; + table_share->ha_part_data->next_auto_inc_val= next_insert_id; } - DBUG_PRINT("info", ("ha_data->next_auto_inc_val: %lu", - (ulong) ha_data->next_auto_inc_val)); + DBUG_PRINT("info", ("table_share->ha_part_data->next_auto_inc_val: %lu", + (ulong) table_share->ha_part_data->next_auto_inc_val)); /* Unlock the multi row statement lock taken in get_auto_increment */ if (auto_increment_safe_stmt_log_lock) @@ -6745,127 +6742,6 @@ int ha_partition::indexes_are_disabled(void) } -/**************************************************************************** - MODULE Partition Share -****************************************************************************/ -/* - Service routines for ... methods. -------------------------------------------------------------------------- - Variables for partition share methods. A hash used to track open tables. - A mutex for the hash table and an init variable to check if hash table - is initialized. - There is also a constant ending of the partition handler file name. -*/ - -#ifdef NOT_USED -static HASH partition_open_tables; -static mysql_mutex_t partition_mutex; -static int partition_init= 0; - - -/* - Function we use in the creation of our hash to get key. -*/ - -static uchar *partition_get_key(PARTITION_SHARE *share, size_t *length, - my_bool not_used __attribute__ ((unused))) -{ - *length= share->table_name_length; - return (uchar *) share->table_name; -} - -/* - Example of simple lock controls. The "share" it creates is structure we - will pass to each partition handler. Do you have to have one of these? - Well, you have pieces that are used for locking, and they are needed to - function. -*/ - -static PARTITION_SHARE *get_share(const char *table_name, TABLE *table) -{ - PARTITION_SHARE *share; - uint length; - char *tmp_name; - - /* - So why does this exist? There is no way currently to init a storage - engine. - Innodb and BDB both have modifications to the server to allow them to - do this. Since you will not want to do this, this is probably the next - best method. - */ - if (!partition_init) - { - /* Hijack a mutex for init'ing the storage engine */ - mysql_mutex_lock(&LOCK_mysql_create_db); - if (!partition_init) - { - partition_init++; - mysql_mutex_init(INSTRUMENT_ME, &partition_mutex, MY_MUTEX_INIT_FAST); - (void) hash_init(&partition_open_tables, system_charset_info, 32, 0, 0, - (hash_get_key) partition_get_key, 0, 0); - } - mysql_mutex_unlock(&LOCK_mysql_create_db); - } - mysql_mutex_lock(&partition_mutex); - length= (uint) strlen(table_name); - - if (!(share= (PARTITION_SHARE *) hash_search(&partition_open_tables, - (uchar *) table_name, length))) - { - if (!(share= (PARTITION_SHARE *) - my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, (uint) sizeof(*share), - &tmp_name, (uint) length + 1, NullS))) - { - mysql_mutex_unlock(&partition_mutex); - return NULL; - } - - share->use_count= 0; - share->table_name_length= length; - share->table_name= tmp_name; - strmov(share->table_name, table_name); - if (my_hash_insert(&partition_open_tables, (uchar *) share)) - goto error; - thr_lock_init(&share->lock); - mysql_mutex_init(INSTRUMENT_ME, &share->mutex, MY_MUTEX_INIT_FAST); - } - share->use_count++; - mysql_mutex_unlock(&partition_mutex); - - return share; - -error: - mysql_mutex_unlock(&partition_mutex); - my_free((uchar*) share, MYF(0)); - - return NULL; -} - - -/* - Free lock controls. We call this whenever we close a table. If the table - had the last reference to the share then we free memory associated with - it. -*/ - -static int free_share(PARTITION_SHARE *share) -{ - mysql_mutex_lock(&partition_mutex); - if (!--share->use_count) - { - hash_delete(&partition_open_tables, (uchar *) share); - thr_lock_delete(&share->lock); - mysql_mutex_destroy(&share->mutex); - my_free((uchar*) share, MYF(0)); - } - mysql_mutex_unlock(&partition_mutex); - - return 0; -} -#endif /* NOT_USED */ - struct st_mysql_storage_engine partition_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 9f499e7b4a9..eec3cb71537 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -29,31 +29,6 @@ enum partition_keywords PKW_COLUMNS }; -/* - PARTITION_SHARE is a structure that will be shared amoung all open handlers - The partition implements the minimum of what you will probably need. -*/ - -#ifdef NOT_USED -typedef struct st_partition_share -{ - char *table_name; - uint table_name_length, use_count; - mysql_mutex_t mutex; - THR_LOCK lock; -} PARTITION_SHARE; -#endif - -/** - Partition specific ha_data struct. - @todo: move all partition specific data from TABLE_SHARE here. -*/ -typedef struct st_ha_data_partition -{ - ulonglong next_auto_inc_val; /**< first non reserved value */ - bool auto_inc_initialized; - pthread_mutex_t mutex; -} HA_DATA_PARTITION; #define PARTITION_BYTES_IN_POS 2 #define PARTITION_ENABLED_TABLE_FLAGS (HA_FILE_BASED | HA_REC_NOT_IN_SEQ) @@ -522,7 +497,7 @@ public: ------------------------------------------------------------------------- */ virtual int info(uint); - void get_dynamic_partition_info(PARTITION_INFO *stat_info, + void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id); virtual int extra(enum ha_extra_function operation); virtual int extra_opt(enum ha_extra_function operation, ulong cachesize); @@ -944,16 +919,16 @@ private: /* lock already taken */ if (auto_increment_safe_stmt_log_lock) return; - DBUG_ASSERT(table_share->ha_data && !auto_increment_lock); + DBUG_ASSERT(table_share->ha_part_data && !auto_increment_lock); if(table_share->tmp_table == NO_TMP_TABLE) { auto_increment_lock= TRUE; - mysql_mutex_lock(&table_share->LOCK_ha_data); + mysql_mutex_lock(&table_share->ha_part_data->LOCK_auto_inc); } } virtual void unlock_auto_increment() { - DBUG_ASSERT(table_share->ha_data); + DBUG_ASSERT(table_share->ha_part_data); /* If auto_increment_safe_stmt_log_lock is true, we have to keep the lock. It will be set to false and thus unlocked at the end of the statement by @@ -961,20 +936,19 @@ private: */ if(auto_increment_lock && !auto_increment_safe_stmt_log_lock) { - mysql_mutex_unlock(&table_share->LOCK_ha_data); + mysql_mutex_unlock(&table_share->ha_part_data->LOCK_auto_inc); auto_increment_lock= FALSE; } } virtual void set_auto_increment_if_higher(Field *field) { - HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; ulonglong nr= (((Field_num*) field)->unsigned_flag || field->val_int() > 0) ? field->val_int() : 0; lock_auto_increment(); - DBUG_ASSERT(ha_data->auto_inc_initialized == TRUE); + DBUG_ASSERT(table_share->ha_part_data->auto_inc_initialized == TRUE); /* must check when the mutex is taken */ - if (nr >= ha_data->next_auto_inc_val) - ha_data->next_auto_inc_val= nr + 1; + if (nr >= table_share->ha_part_data->next_auto_inc_val) + table_share->ha_part_data->next_auto_inc_val= nr + 1; unlock_auto_increment(); } diff --git a/sql/handler.cc b/sql/handler.cc index c0a5e2ff55c..8b56921a3a1 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3548,7 +3548,7 @@ int handler::index_next_same(uchar *buf, const uchar *key, uint keylen) } -void handler::get_dynamic_partition_info(PARTITION_INFO *stat_info, +void handler::get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id) { info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE | diff --git a/sql/handler.h b/sql/handler.h index 9f21cb0f25d..1b5d5f8cb1f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -961,7 +961,7 @@ typedef struct { ulong check_time; ulong update_time; ulonglong check_sum; -} PARTITION_INFO; +} PARTITION_STATS; #define UNDEF_NODEGROUP 65535 class Item; @@ -1560,7 +1560,7 @@ public: { return (ha_rows) 10; } virtual void position(const uchar *record)=0; virtual int info(uint)=0; // see my_base.h for full description - virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info, + virtual void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id); virtual int extra(enum ha_extra_function operation) { return 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b35e2545a18..89b601d07f9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5343,11 +5343,11 @@ inline void kill_broken_server() void handle_connections_sockets() { - my_socket sock,new_sock; + my_socket UNINIT_VAR(sock), UNINIT_VAR(new_sock); uint error_count=0; THD *thd; struct sockaddr_storage cAddr; - int ip_flags=0,socket_flags=0,flags,retval; + int ip_flags=0,socket_flags=0,flags=0,retval; st_vio *vio_tmp; #ifdef HAVE_POLL int socket_count= 0; @@ -5359,8 +5359,6 @@ void handle_connections_sockets() DBUG_ENTER("handle_connections_sockets"); - LINT_INIT(new_sock); - #ifndef HAVE_POLL FD_ZERO(&clientFDs); #endif @@ -7918,8 +7916,9 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_master_info_data_lock, key_master_info_run_lock, key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock, key_relay_log_info_log_space_lock, key_relay_log_info_run_lock, - key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, key_LOCK_error_messages, - key_LOG_INFO_lock, key_LOCK_thread_count; + key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, + key_LOCK_error_messages, key_LOG_INFO_lock, key_LOCK_thread_count, + key_PARTITION_LOCK_auto_inc; static PSI_mutex_info all_server_mutexes[]= { @@ -7973,7 +7972,8 @@ static PSI_mutex_info all_server_mutexes[]= { &key_TABLE_SHARE_LOCK_ha_data, "TABLE_SHARE::LOCK_ha_data", 0}, { &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL}, { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}, - { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL} + { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL}, + { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0} }; PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, diff --git a/sql/mysqld.h b/sql/mysqld.h index 2547100d8ff..842d74d063a 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -240,8 +240,8 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_master_info_data_lock, key_master_info_run_lock, key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock, key_relay_log_info_log_space_lock, key_relay_log_info_run_lock, - key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, key_LOCK_error_messages, - key_LOCK_thread_count; + key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, + key_LOCK_error_messages, key_LOCK_thread_count, key_PARTITION_LOCK_auto_inc; extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave, diff --git a/sql/partition_info.cc b/sql/partition_info.cc index f42a8ee2312..e505630d08f 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -701,12 +701,11 @@ bool partition_info::check_range_constants(THD *thd) if (column_list) { part_column_list_val *loc_range_col_array; - part_column_list_val *current_largest_col_val; + part_column_list_val *UNINIT_VAR(current_largest_col_val); uint num_column_values= part_field_list.elements; uint size_entries= sizeof(part_column_list_val) * num_column_values; range_col_array= (part_column_list_val*)sql_calloc(num_parts * size_entries); - LINT_INIT(current_largest_col_val); if (unlikely(range_col_array == NULL)) { mem_alloc_error(num_parts * size_entries); @@ -739,12 +738,10 @@ bool partition_info::check_range_constants(THD *thd) } else { - longlong current_largest; + longlong UNINIT_VAR(current_largest); longlong part_range_value; bool signed_flag= !part_expr->unsigned_flag; - LINT_INIT(current_largest); - part_result_type= INT_RESULT; range_int_array= (longlong*)sql_alloc(num_parts * sizeof(longlong)); if (unlikely(range_int_array == NULL)) @@ -894,7 +891,8 @@ bool partition_info::check_list_constants(THD *thd) part_elem_value *list_value; bool result= TRUE; longlong type_add, calc_value; - void *curr_value, *prev_value; + void *curr_value; + void *UNINIT_VAR(prev_value); partition_element* part_def; bool found_null= FALSE; int (*compare_func)(const void *, const void*); @@ -1009,7 +1007,6 @@ bool partition_info::check_list_constants(THD *thd) compare_func); i= 0; - LINT_INIT(prev_value); do { DBUG_ASSERT(i < num_list_values); @@ -1032,6 +1029,30 @@ end: DBUG_RETURN(result); } +/** + Check if we allow DATA/INDEX DIRECTORY, if not warn and set them to NULL. + + @param thd THD also containing sql_mode (looks from MODE_NO_DIR_IN_CREATE). + @param part_elem partition_element to check. +*/ +static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem) +{ +#ifdef HAVE_READLINK + if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) +#endif + { + if (part_elem->data_file_name) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); + if (part_elem->index_file_name) + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); + part_elem->data_file_name= part_elem->index_file_name= NULL; + } +} + /* This code is used early in the CREATE TABLE and ALTER TABLE process. @@ -1169,20 +1190,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, do { partition_element *part_elem= part_it++; -#ifdef HAVE_READLINK - if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) -#endif - { - if (part_elem->data_file_name) - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), - "DATA DIRECTORY"); - if (part_elem->index_file_name) - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), - "INDEX DIRECTORY"); - part_elem->data_file_name= part_elem->index_file_name= NULL; - } + warn_if_dir_in_part_elem(thd, part_elem); if (!is_sub_partitioned()) { if (part_elem->engine_type == NULL) @@ -1208,6 +1216,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, do { sub_elem= sub_it++; + warn_if_dir_in_part_elem(thd, sub_elem); if (check_table_name(sub_elem->partition_name, strlen(sub_elem->partition_name))) { diff --git a/sql/partition_info.h b/sql/partition_info.h index 479714a3928..b196d0b59a2 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -151,8 +151,6 @@ public: char *part_func_string; char *subpart_func_string; - const char *part_state; - partition_element *curr_part_elem; partition_element *current_partition; part_elem_value *curr_list_val; @@ -173,7 +171,6 @@ public: partition_type subpart_type; uint part_info_len; - uint part_state_len; uint part_func_len; uint subpart_func_len; @@ -226,13 +223,12 @@ public: list_array(NULL), err_value(0), part_info_string(NULL), part_func_string(NULL), subpart_func_string(NULL), - part_state(NULL), curr_part_elem(NULL), current_partition(NULL), curr_list_object(0), num_columns(0), default_engine_type(NULL), part_result_type(INT_RESULT), part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION), - part_info_len(0), part_state_len(0), + part_info_len(0), part_func_len(0), subpart_func_len(0), num_parts(0), num_subparts(0), count_curr_subparts(0), part_error_code(0), diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc index 9cb5391075d..be0a61bcae2 100644 --- a/sql/rpl_handler.cc +++ b/sql/rpl_handler.cc @@ -89,21 +89,24 @@ int get_user_var_str(const char *name, char *value, int delegates_init() { - static unsigned long trans_mem[sizeof(Trans_delegate) / sizeof(unsigned long) + 1]; - static unsigned long storage_mem[sizeof(Binlog_storage_delegate) / sizeof(unsigned long) + 1]; + static Aligned_char_array<sizeof(Trans_delegate)> trans_mem; + static Aligned_char_array<sizeof(Binlog_storage_delegate)> storage_mem; #ifdef HAVE_REPLICATION - static unsigned long transmit_mem[sizeof(Binlog_transmit_delegate) / sizeof(unsigned long) + 1]; - static unsigned long relay_io_mem[sizeof(Binlog_relay_IO_delegate)/ sizeof(unsigned long) + 1]; + static Aligned_char_array<sizeof(Binlog_transmit_delegate)> transmit_mem; + static Aligned_char_array<sizeof(Binlog_relay_IO_delegate)> relay_io_mem; #endif - - if (!(transaction_delegate= new (trans_mem) Trans_delegate) + + if (!(transaction_delegate= new (trans_mem.arr()) Trans_delegate) || (!transaction_delegate->is_inited()) - || !(binlog_storage_delegate= new (storage_mem) Binlog_storage_delegate) + || !(binlog_storage_delegate= + new (storage_mem.arr()) Binlog_storage_delegate) || (!binlog_storage_delegate->is_inited()) #ifdef HAVE_REPLICATION - || !(binlog_transmit_delegate= new (transmit_mem) Binlog_transmit_delegate) + || !(binlog_transmit_delegate= + new (transmit_mem.arr()) Binlog_transmit_delegate) || (!binlog_transmit_delegate->is_inited()) - || !(binlog_relay_io_delegate= new (relay_io_mem) Binlog_relay_IO_delegate) + || !(binlog_relay_io_delegate= + new (relay_io_mem.arr()) Binlog_relay_IO_delegate) || (!binlog_relay_io_delegate->is_inited()) #endif /* HAVE_REPLICATION */ ) diff --git a/sql/spatial.cc b/sql/spatial.cc index 34b1f3d1f0c..fcf06119db9 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -128,6 +128,16 @@ Geometry::Class_info *Geometry::find_class(const char *name, uint32 len) } +Geometry *Geometry::create_by_typeid(Geometry_buffer *buffer, int type_id) +{ + Class_info *ci; + if (!(ci= find_class((int) type_id))) + return NULL; + (*ci->m_create_func)(buffer->buf.arr()); + return my_reinterpret_cast(Geometry *)(buffer->buf.arr()); +} + + Geometry *Geometry::construct(Geometry_buffer *buffer, const char *data, uint32 data_len) { diff --git a/sql/spatial.h b/sql/spatial.h index a4bce47d0e5..aabbb7a1b97 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -267,14 +267,7 @@ public: virtual int geometry_n(uint32 num, String *result) const { return -1; } public: - static Geometry *create_by_typeid(Geometry_buffer *buffer, int type_id) - { - Class_info *ci; - if (!(ci= find_class((int) type_id))) - return NULL; - (*ci->m_create_func)((void *)buffer); - return my_reinterpret_cast(Geometry *)(buffer); - } + static Geometry *create_by_typeid(Geometry_buffer *buffer, int type_id); static Geometry *construct(Geometry_buffer *buffer, const char *data, uint32 data_len); @@ -532,10 +525,9 @@ public: const Class_info *get_class_info() const; }; -const int geometry_buffer_size= sizeof(Gis_point); struct Geometry_buffer { - void *arr[(geometry_buffer_size - 1)/sizeof(void *) + 1]; + Aligned_char_array<sizeof(Gis_point)> buf; }; #endif /*HAVE_SPATAIAL*/ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 60b2ffa4179..2e47ce1e02a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2943,7 +2943,7 @@ end_with_restore_list: access is granted. We need to check if first_table->grant.privilege contains any table-specific privilege. */ - DBUG_PRINT("debug", ("first_table->grant.privilege: %x", + DBUG_PRINT("debug", ("first_table->grant.privilege: %lx", first_table->grant.privilege)); if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, first_table) || (first_table->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 0eb92dc23a9..e6f9a10801b 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3096,7 +3096,7 @@ int get_partition_id_list_col(partition_info *part_info, } else { - *part_id= (uint32)list_col_array[list_index].partition_id; + *part_id= (uint32)list_col_array[list_index*num_columns].partition_id; DBUG_RETURN(0); } } @@ -4186,7 +4186,6 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, bool mysql_unpack_partition(THD *thd, const char *part_buf, uint part_info_len, - const char *part_state, uint part_state_len, TABLE* table, bool is_create_table_ind, handlerton *default_db_type, bool *work_part_info_used) @@ -4222,8 +4221,6 @@ bool mysql_unpack_partition(THD *thd, goto end; } part_info= lex.part_info; - part_info->part_state= part_state; - part_info->part_state_len= part_state_len; DBUG_PRINT("info", ("Parse: %s", part_buf)); if (parse_sql(thd, & parser_state, NULL) || part_info->fix_parser_data(thd)) @@ -4587,7 +4584,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, partition_info *tab_part_info= table->part_info; partition_info *alt_part_info= thd->work_part_info; uint flags= 0; - bool is_last_partition_reorged; + bool is_last_partition_reorged= FALSE; part_elem_value *tab_max_elem_val= NULL; part_elem_value *alt_max_elem_val= NULL; longlong tab_max_range= 0, alt_max_range= 0; @@ -7701,7 +7698,7 @@ uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter) DESCRIPTION This implementation of PARTITION_ITERATOR::get_next() is special for LIST partitioning: it enumerates partition ids in - part_info->list_array[i] (list_col_array[i] for COLUMNS LIST + part_info->list_array[i] (list_col_array[i*cols] for COLUMNS LIST partitioning) where i runs over [min_idx, max_idx] interval. The function conforms to partition_iter_func type. @@ -7727,9 +7724,12 @@ uint32 get_next_partition_id_list(PARTITION_ITERATOR *part_iter) { partition_info *part_info= part_iter->part_info; uint32 num_part= part_iter->part_nums.cur++; - return part_info->column_list ? - part_info->list_col_array[num_part].partition_id : - part_info->list_array[num_part].partition_id; + if (part_info->column_list) + { + uint num_columns= part_info->part_field_list.elements; + return part_info->list_col_array[num_part*num_columns].partition_id; + } + return part_info->list_array[num_part].partition_id; } } diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 8542074e718..2e0ea740555 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -64,20 +64,6 @@ typedef struct st_lock_param_type partition_info *part_info; } ALTER_PARTITION_PARAM_TYPE; - -/*typedef struct { - ulonglong data_file_length; - ulonglong max_data_file_length; - ulonglong index_file_length; - ulonglong delete_length; - ha_rows records; - ulong mean_rec_length; - time_t create_time; - time_t check_time; - time_t update_time; - ulonglong check_sum; -} PARTITION_INFO; -*/ typedef struct { longlong list_value; uint32 partition_id; @@ -126,7 +112,6 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf, part_id_range *part_spec); bool mysql_unpack_partition(THD *thd, const char *part_buf, uint part_info_len, - const char *part_state, uint part_state_len, TABLE *table, bool is_create_table_ind, handlerton *default_db_type, bool *work_part_info_used); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f1db513d0e2..00a507f0e47 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3750,7 +3750,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, } #ifdef WITH_PARTITION_STORAGE_ENGINE if (share->db_type() == partition_hton && - share->partition_info_len) + share->partition_info_str_len) { tmp_db_type= share->default_part_db_type; is_partitioned= TRUE; @@ -5238,7 +5238,8 @@ static int get_schema_key_column_usage_record(THD *thd, #ifdef WITH_PARTITION_STORAGE_ENGINE -static void collect_partition_expr(List<char> &field_list, String *str) +static void collect_partition_expr(THD *thd, List<char> &field_list, + String *str) { List_iterator<char> part_it(field_list); ulong no_fields= field_list.elements; @@ -5246,7 +5247,7 @@ static void collect_partition_expr(List<char> &field_list, String *str) str->length(0); while ((field_str= part_it++)) { - str->append(field_str); + append_identifier(thd, str, field_str, strlen(field_str)); if (--no_fields != 0) str->append(","); } @@ -5313,7 +5314,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, { TABLE* table= schema_table; CHARSET_INFO *cs= system_charset_info; - PARTITION_INFO stat_info; + PARTITION_STATS stat_info; MYSQL_TIME time; file->get_dynamic_partition_info(&stat_info, part_id); table->field[0]->store(STRING_WITH_LEN("def"), cs); @@ -5513,7 +5514,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, } else if (part_info->list_of_part_fields) { - collect_partition_expr(part_info->part_field_list, &tmp_str); + collect_partition_expr(thd, part_info->part_field_list, &tmp_str); table->field[9]->store(tmp_str.ptr(), tmp_str.length(), cs); } table->field[9]->set_notnull(); @@ -5542,7 +5543,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, } else if (part_info->list_of_subpart_fields) { - collect_partition_expr(part_info->subpart_field_list, &tmp_str); + collect_partition_expr(thd, part_info->subpart_field_list, &tmp_str); table->field[10]->store(tmp_str.ptr(), tmp_str.length(), cs); } table->field[10]->set_notnull(); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2b8e7de3a60..f8d99d87228 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1751,11 +1751,12 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) error= 1; goto err; } - share->partition_info= tmp_part_syntax_str; + share->partition_info_str= tmp_part_syntax_str; } else - memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1); - share->partition_info_len= part_info->part_info_len= syntax_len; + memcpy((char*) share->partition_info_str, part_syntax_buf, + syntax_len + 1); + share->partition_info_str_len= part_info->part_info_len= syntax_len; part_info->part_info_string= part_syntax_buf; } #endif @@ -1898,8 +1899,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool dont_log_query) { TABLE_LIST *table; - char path[FN_REFLEN + 1], *alias; - uint path_length; + char path[FN_REFLEN + 1], *alias= NULL; + uint path_length= 0; String wrong_tables; int error= 0; int non_temp_tables_count= 0; @@ -1908,9 +1909,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, String built_tmp_query; DBUG_ENTER("mysql_rm_table_part2"); - LINT_INIT(alias); - LINT_INIT(path_length); - if (thd->is_current_stmt_binlog_format_row() && !dont_log_query) { built_query.set_charset(system_charset_info); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index b8312fc3255..aeb9dda3a8b 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2723,8 +2723,8 @@ static Sys_var_mybool Sys_log_slow( static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) { bool res; - my_bool *newvalptr, newval, oldval; - uint log_type; + my_bool *UNINIT_VAR(newvalptr), newval, UNINIT_VAR(oldval); + uint UNINIT_VAR(log_type); if (self == &Sys_general_log || self == &Sys_log) { diff --git a/sql/table.cc b/sql/table.cc index 65918dd58f9..5ffe1cf17ae 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -967,28 +967,28 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } if (next_chunk + 5 < buff_end) { - uint32 partition_info_len = uint4korr(next_chunk); + uint32 partition_info_str_len = uint4korr(next_chunk); #ifdef WITH_PARTITION_STORAGE_ENGINE if ((share->partition_info_buffer_size= - share->partition_info_len= partition_info_len)) + share->partition_info_str_len= partition_info_str_len)) { - if (!(share->partition_info= (char*) + if (!(share->partition_info_str= (char*) memdup_root(&share->mem_root, next_chunk + 4, - partition_info_len + 1))) + partition_info_str_len + 1))) { my_free(buff, MYF(0)); goto err; } } #else - if (partition_info_len) + if (partition_info_str_len) { DBUG_PRINT("info", ("WITH_PARTITION_STORAGE_ENGINE is not defined")); my_free(buff, MYF(0)); goto err; } #endif - next_chunk+= 5 + partition_info_len; + next_chunk+= 5 + partition_info_str_len; } #if MYSQL_VERSION_ID < 50200 if (share->mysql_version >= 50106 && share->mysql_version <= 50109) @@ -1651,6 +1651,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, my_hash_free(&share->name_hash); if (share->ha_data_destroy) share->ha_data_destroy(share->ha_data); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (share->ha_part_data_destroy) + share->ha_part_data_destroy(share->ha_part_data); +#endif open_table_error(share, error, share->open_errno, errarg); DBUG_RETURN(error); @@ -1842,7 +1846,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, } #ifdef WITH_PARTITION_STORAGE_ENGINE - if (share->partition_info_len && outparam->file) + if (share->partition_info_str_len && outparam->file) { /* In this execution we must avoid calling thd->change_item_tree since @@ -1863,10 +1867,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, bool tmp; bool work_part_info_used; - tmp= mysql_unpack_partition(thd, share->partition_info, - share->partition_info_len, - share->part_state, - share->part_state_len, + tmp= mysql_unpack_partition(thd, share->partition_info_str, + share->partition_info_str_len, outparam, is_create_table, share->default_part_db_type, &work_part_info_used); diff --git a/sql/table.h b/sql/table.h index fcff0cfb0d5..af357807add 100644 --- a/sql/table.h +++ b/sql/table.h @@ -488,6 +488,19 @@ typedef struct st_table_field_def } TABLE_FIELD_DEF; +#ifdef WITH_PARTITION_STORAGE_ENGINE +/** + Partition specific ha_data struct. +*/ +typedef struct st_ha_data_partition +{ + bool auto_inc_initialized; + mysql_mutex_t LOCK_auto_inc; /**< protecting auto_inc val */ + ulonglong next_auto_inc_val; /**< first non reserved value */ +} HA_DATA_PARTITION; +#endif + + class Table_check_intact { protected: @@ -628,13 +641,11 @@ struct TABLE_SHARE int cached_row_logging_check; #ifdef WITH_PARTITION_STORAGE_ENGINE - /** @todo: Move into *ha_data for partitioning */ + /* filled in when reading from frm */ bool auto_partitioned; - const char *partition_info; - uint partition_info_len; + const char *partition_info_str; + uint partition_info_str_len; uint partition_info_buffer_size; - const char *part_state; - uint part_state_len; handlerton *default_part_db_type; #endif @@ -654,6 +665,14 @@ struct TABLE_SHARE void *ha_data; void (*ha_data_destroy)(void *); /* An optional destructor for ha_data */ +#ifdef WITH_PARTITION_STORAGE_ENGINE + /** place to store partition specific data, LOCK_ha_data hold while init. */ + HA_DATA_PARTITION *ha_part_data; + /* Destructor for ha_part_data */ + void (*ha_part_data_destroy)(HA_DATA_PARTITION *); +#endif + + /** Instrumentation for this table share. */ PSI_table_share *m_psi; diff --git a/storage/heap/make-ccc b/storage/heap/make-ccc deleted file mode 100755 index 192647298ad..00000000000 --- a/storage/heap/make-ccc +++ /dev/null @@ -1,4 +0,0 @@ -ccc -I./../include -I../include -DDBUG_OFF -fast -O3 -c _check.c _rectest.c hp_block.c hp_clear.c hp_close.c hp_create.c hp_delete.c hp_extra.c hp_hash.c hp_info.c hp_open.c hp_panic.c hp_rename.c hp_rfirst.c hp_rkey.c hp_rlast.c hp_rnext.c hp_rprev.c hp_rrnd.c hp_rsame.c hp_scan.c hp_static.c hp_update.c hp_write.c -rm libheap.a -ar -cr libheap.a _check.o - diff --git a/storage/myisam/make-ccc b/storage/myisam/make-ccc deleted file mode 100755 index 6d1303729db..00000000000 --- a/storage/myisam/make-ccc +++ /dev/null @@ -1,5 +0,0 @@ -rm -f .deps/*.P -ccc -DMAP_TO_USE_RAID -I./../include -I../include -DDBUG_OFF -fast -O3 -c mi_cache.c mi_changed.c mi_checksum.c mi_close.c mi_create.c mi_dbug.c mi_delete.c mi_delete_all.c mi_delete_table.c mi_dynrec.c mi_extra.c mi_info.c mi_key.c mi_locking.c mi_log.c mi_open.c mi_packrec.c mi_page.c mi_panic.c mi_range.c mi_rename.c mi_rfirst.c mi_rkey.c mi_rlast.c mi_rnext.c mi_rnext_same.c mi_rprev.c mi_rrnd.c mi_rsame.c mi_rsamepos.c mi_scan.c mi_search.c mi_static.c mi_statrec.c mi_unique.c mi_update.c mi_write.c ft_update.c ft_search.o ft_stem.o ft_stopwords.c ft_parser.c -make sort.o mi_check.o -rm libmyisam.a -ar -cr libmyisam.a mi_cache.o sort.o mi_check.o diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 66d5d4fa3cd..3db03e23637 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -38,7 +38,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, MI_CREATE_INFO *ci,uint flags) { register uint i,j; - File UNINIT_VAR(dfile),file; + File UNINIT_VAR(dfile), UNINIT_VAR(file); int errpos,save_errno, create_mode= O_RDWR | O_TRUNC; myf create_flag; uint fields,length,max_key_length,packed,pointer,real_length_diff, @@ -73,8 +73,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, { DBUG_RETURN(my_errno=HA_WRONG_CREATE_OPTION); } - LINT_INIT(dfile); - LINT_INIT(file); + errpos=0; options=0; bzero((uchar*) &share,sizeof(share)); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index f7137ac554d..ef5b442cd3a 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -143,7 +143,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (uchar*) myisam_file_magic, 4)) { DBUG_PRINT("error",("Wrong header in %s",name_buff)); - DBUG_DUMP("error_dump",(char*) share->state.header.file_version, + DBUG_DUMP("error_dump", share->state.header.file_version, head_length); my_errno=HA_ERR_NOT_A_TABLE; goto err; diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index 23a2526f756..2cf3891807f 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -49,7 +49,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); + DBUG_DUMP("page", tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; mi_print_error(info->s, HA_ERR_CRASHED); my_errno = HA_ERR_CRASHED; diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 95f817e47aa..c7ebf9ae220 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -819,7 +819,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long null packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",(uchar*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; @@ -876,7 +876,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",(uchar*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ @@ -948,7 +948,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long binary packed key: %u of %u at 0x%lx", length, keyinfo->maxlength, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key",(uchar*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); /* Wrong key */ diff --git a/storage/myisammrg/make-ccc b/storage/myisammrg/make-ccc deleted file mode 100755 index a7e3dfc3cdb..00000000000 --- a/storage/myisammrg/make-ccc +++ /dev/null @@ -1,3 +0,0 @@ -ccc -I./../include -I../include -DDBUG_OFF -fast -O3 -c myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c myrg_locking.c myrg_open.c myrg_panic.c myrg_rrnd.c myrg_rsame.c myrg_static.c myrg_update.c -rm libmyisammrg.a -ar -cr libmyisammrg.a myrg_close.o diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index e3e13af85ef..3946f6a83b4 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1961,12 +1961,10 @@ my_strnncoll_utf32(CHARSET_INFO *cs, const uchar *t, size_t tlen, my_bool t_is_prefix) { - my_wc_t s_wc,t_wc; + my_wc_t UNINIT_VAR(s_wc),UNINIT_VAR(t_wc); const uchar *se= s + slen; const uchar *te= t + tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; - LINT_INIT(s_wc); - LINT_INIT(t_wc); while (s < se && t < te) { @@ -2028,11 +2026,9 @@ my_strnncollsp_utf32(CHARSET_INFO *cs, my_bool diff_if_only_endspace_difference) { int res; - my_wc_t s_wc, t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se= s + slen, *te= t + tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; - LINT_INIT(s_wc); - LINT_INIT(t_wc); DBUG_ASSERT((slen % 4) == 0); DBUG_ASSERT((tlen % 4) == 0); @@ -2498,11 +2494,9 @@ my_strnncoll_utf32_bin(CHARSET_INFO *cs, const uchar *t, size_t tlen, my_bool t_is_prefix) { - my_wc_t s_wc, t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se= s + slen; const uchar *te= t + tlen; - LINT_INIT(s_wc); - LINT_INIT(t_wc); while (s < se && t < te) { @@ -2624,7 +2618,7 @@ my_like_range_utf32(CHARSET_INFO *cs, { my_wc_t wc; int res; - if ((res= my_utf32_uni(cs, &wc, ptr, end)) < 0) + if ((res= my_utf32_uni(cs, &wc, (uchar*) ptr, (uchar*) end)) < 0) { my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char); my_fill_utf32(cs, max_str, min_end - min_str, cs->max_sort_char); @@ -2635,15 +2629,15 @@ my_like_range_utf32(CHARSET_INFO *cs, if (wc == (my_wc_t) escape) { ptr+= 4; /* Skip escape */ - if ((res= my_utf32_uni(cs, &wc, ptr, end)) < 0) + if ((res= my_utf32_uni(cs, &wc, (uchar*) ptr, (uchar*) end)) < 0) { my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char); my_fill_utf32(cs, max_str, max_end - min_str, cs->max_sort_char); /* min_length and max_length are not important */ return TRUE; } - if (my_uni_utf32(cs, wc, min_str, min_end) != 4 || - my_uni_utf32(cs, wc, max_str, max_end) != 4) + if (my_uni_utf32(cs, wc, (uchar*) min_str, (uchar*) min_end) != 4 || + my_uni_utf32(cs, wc, (uchar*) max_str, (uchar*) max_end) != 4) goto pad_set_lengths; *min_str++= 4; *max_str++= 4; @@ -2652,8 +2646,8 @@ my_like_range_utf32(CHARSET_INFO *cs, if (wc == (my_wc_t) w_one) { - if (my_uni_utf32(cs, cs->min_sort_char, min_str, min_end) != 4 || - my_uni_utf32(cs, cs->max_sort_char, max_str, max_end) != 4) + if (my_uni_utf32(cs, cs->min_sort_char, (uchar*) min_str, (uchar*) min_end) != 4 || + my_uni_utf32(cs, cs->max_sort_char, (uchar*) max_str, (uchar*) max_end) != 4) goto pad_set_lengths; min_str+= 4; max_str+= 4; @@ -2675,8 +2669,8 @@ my_like_range_utf32(CHARSET_INFO *cs, } /* Normal character */ - if (my_uni_utf32(cs, wc, min_str, min_end) != 4 || - my_uni_utf32(cs, wc, max_str, max_end) != 4) + if (my_uni_utf32(cs, wc, (uchar*) min_str, (uchar*) min_end) != 4 || + my_uni_utf32(cs, wc, (uchar*) max_str, (uchar*) max_end) != 4) goto pad_set_lengths; min_str+= 4; max_str+= 4; @@ -2704,7 +2698,7 @@ my_scan_utf32(CHARSET_INFO *cs, for ( ; str < end; ) { my_wc_t wc; - int res= my_utf32_uni(cs, &wc, str, end); + int res= my_utf32_uni(cs, &wc, (uchar*) str, (uchar*) end); if (res < 0 || wc != ' ') break; str+= res; @@ -3008,7 +3002,7 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc),UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; @@ -3195,7 +3189,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc),UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; diff --git a/strings/make-ccc b/strings/make-ccc deleted file mode 100755 index 78d5ad1ce42..00000000000 --- a/strings/make-ccc +++ /dev/null @@ -1,3 +0,0 @@ -ccc -DHAVE_CONFIG_H -I. -I. -I.. -I./../include -I../include -O -DDBUG_OFF -fast -O3 -fomit-frame-pointer -c atof.c bchange.c bcmp.c bfill.c bmove.c bmove512.c bmove_upp.c ct_init.c ctype-latin1.c int2str.c is_prefix.c llstr.c longlong2str.c r_strinstr.c str2int.c strappend.c strcend.c strcont.c strend.c strfill.c strinstr.c strmake.c strmov.c strnmov.c strstr.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c -rm libmystrings.a -ar -cr libmystrings.a atof.o |