Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Feb 4, 2018
2 parents d6ed077 + 28d4cf0 commit 217fc12
Show file tree
Hide file tree
Showing 69 changed files with 483 additions and 205 deletions.
2 changes: 1 addition & 1 deletion client/completion_hash.cc
Expand Up @@ -49,7 +49,7 @@ int completion_hash_init(HashTable *ht, uint nSize)
ht->initialized = 0;
return FAILURE;
}
init_alloc_root(&ht->mem_root, 8192, 0, MYF(0));
init_alloc_root(&ht->mem_root, "completion_hash", 8192, 0, MYF(0));
ht->pHashFunction = hashpjw;
ht->nTableSize = nSize;
ht->initialized = 1;
Expand Down
2 changes: 1 addition & 1 deletion client/mysql.cc
Expand Up @@ -1205,7 +1205,7 @@ int main(int argc,char *argv[])
}
glob_buffer.realloc(512);
completion_hash_init(&ht, 128);
init_alloc_root(&hash_mem_root, 16384, 0, MYF(0));
init_alloc_root(&hash_mem_root, "hash", 16384, 0, MYF(0));
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
Expand Down
2 changes: 1 addition & 1 deletion client/mysqldump.c
Expand Up @@ -4980,7 +4980,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
if (init_dumping(db, init_dumping_tables))
DBUG_RETURN(1);

init_alloc_root(&glob_root, 8192, 0, MYF(0));
init_alloc_root(&glob_root, "glob_root", 8192, 0, MYF(0));
if (!(dump_tables= pos= (char**) alloc_root(&glob_root,
tables * sizeof(char *))))
die(EX_EOM, "alloc_root failure.");
Expand Down
2 changes: 1 addition & 1 deletion client/mysqltest.cc
Expand Up @@ -9146,7 +9146,7 @@ int main(int argc, char **argv)
#endif

init_dynamic_string(&ds_res, "", 2048, 2048);
init_alloc_root(&require_file_root, 1024, 1024, MYF(0));
init_alloc_root(&require_file_root, "require_file", 1024, 1024, MYF(0));

parse_args(argc, argv);

Expand Down
1 change: 1 addition & 0 deletions include/my_alloc.h
Expand Up @@ -52,6 +52,7 @@ typedef struct st_mem_root
unsigned int first_block_usage;

void (*error_handler)(void);
const char *name;
} MEM_ROOT;

#ifdef __cplusplus
Expand Down
5 changes: 3 additions & 2 deletions include/my_sys.h
Expand Up @@ -893,8 +893,9 @@ extern void my_free_lock(void *ptr);
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
size_t pre_alloc_size, myf my_flags);
extern void init_alloc_root(MEM_ROOT *mem_root, const char *name,
size_t block_size, size_t pre_alloc_size,
myf my_flags);
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
Expand Down
1 change: 1 addition & 0 deletions include/mysql.h.pp
Expand Up @@ -242,6 +242,7 @@
unsigned int block_num;
unsigned int first_block_usage;
void (*error_handler)(void);
const char *name;
} MEM_ROOT;
typedef struct st_typelib {
unsigned int count;
Expand Down
2 changes: 1 addition & 1 deletion libmysqld/emb_qcache.cc
Expand Up @@ -418,7 +418,7 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)

if (!data)
goto err;
init_alloc_root(&data->alloc, 8192,0,MYF(0));
init_alloc_root(&data->alloc, "embedded_query_cache", 8192,0,MYF(0));
f_alloc= &data->alloc;

data->fields= src->load_int();
Expand Down
4 changes: 2 additions & 2 deletions libmysqld/lib_sql.cc
Expand Up @@ -655,7 +655,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag)
thd->mysql= mysql;
mysql->server_version= server_version;
mysql->client_flag= client_flag;
init_alloc_root(&mysql->field_alloc, 8192, 0, MYF(0));
init_alloc_root(&mysql->field_alloc, "fields", 8192, 0, MYF(0));
}

/**
Expand Down Expand Up @@ -971,7 +971,7 @@ int Protocol::begin_dataset()
return 1;
alloc= &data->alloc;
/* Assume rowlength < 8192 */
init_alloc_root(alloc, 8192, 0, MYF(0));
init_alloc_root(alloc, "protocol", 8192, 0, MYF(0));
alloc->min_malloc= sizeof(MYSQL_ROWS);
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions libmysqld/libmysql.c
Expand Up @@ -1533,8 +1533,9 @@ mysql_stmt_init(MYSQL *mysql)
DBUG_RETURN(NULL);
}

init_alloc_root(&stmt->mem_root, 2048,2048, MYF(MY_THREAD_SPECIFIC));
init_alloc_root(&stmt->result.alloc, 4096, 4096, MYF(MY_THREAD_SPECIFIC));
init_alloc_root(&stmt->mem_root, "stmt", 2048,2048, MYF(MY_THREAD_SPECIFIC));
init_alloc_root(&stmt->result.alloc, "result", 4096, 4096,
MYF(MY_THREAD_SPECIFIC));
stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS);
mysql->stmts= list_add(mysql->stmts, &stmt->list);
stmt->list.data= stmt;
Expand All @@ -1545,7 +1546,7 @@ mysql_stmt_init(MYSQL *mysql)
strmov(stmt->sqlstate, not_error_sqlstate);
/* The rest of statement members was bzeroed inside malloc */

init_alloc_root(&stmt->extension->fields_mem_root, 2048, 0,
init_alloc_root(&stmt->extension->fields_mem_root, "extension", 2048, 0,
MYF(MY_THREAD_SPECIFIC));

DBUG_RETURN(stmt);
Expand Down
32 changes: 16 additions & 16 deletions mysql-test/r/ps.result
Expand Up @@ -1741,7 +1741,7 @@ execute stmt using @a;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`?` decimal(2,1) DEFAULT NULL
`?` decimal(2,1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
drop table if exists t1;
Expand Down Expand Up @@ -4435,7 +4435,7 @@ EXECUTE stmt USING 10.123;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` decimal(5,3) DEFAULT NULL
`c1` decimal(5,3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING 10.123e0;
Expand All @@ -4449,49 +4449,49 @@ EXECUTE stmt USING CURRENT_DATE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` date DEFAULT NULL
`c1` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` datetime DEFAULT NULL
`c1` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP(3);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` datetime(3) DEFAULT NULL
`c1` datetime(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP(6);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` datetime(6) DEFAULT NULL
`c1` datetime(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` time DEFAULT NULL
`c1` time NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME(3);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` time(3) DEFAULT NULL
`c1` time(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME(6);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` time(6) DEFAULT NULL
`c1` time(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DEALLOCATE PREPARE stmt;
Expand Down Expand Up @@ -4636,7 +4636,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) NOT NULL,
`b` decimal(3,1) DEFAULT NULL,
`b` decimal(3,1) NOT NULL,
`c` double NOT NULL,
`d` tinytext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Expand All @@ -4648,7 +4648,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(2) NOT NULL,
`b` decimal(3,1) DEFAULT NULL,
`b` decimal(3,1) NOT NULL,
`c` double NOT NULL,
`d` varchar(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Expand All @@ -4663,11 +4663,11 @@ TIMESTAMP'2001-01-01 10:20:30.123';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` time DEFAULT NULL,
`t2` time(3) DEFAULT NULL,
`d1` date DEFAULT NULL,
`dt1` datetime DEFAULT NULL,
`dt2` datetime(3) DEFAULT NULL
`t1` time NOT NULL,
`t2` time(3) NOT NULL,
`d1` date NOT NULL,
`dt1` datetime NOT NULL,
`dt2` datetime(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
Expand Down
129 changes: 129 additions & 0 deletions mysql-test/r/type_time.result
Expand Up @@ -1283,3 +1283,132 @@ a
10:20:32
DROP TABLE t1;
SET timestamp=DEFAULT;
#
# MDEV-15176 Storing DATETIME-alike VARCHAR data into TIME produces wrong results
#
SET sql_mode='';
CREATE OR REPLACE TABLE t0 (d VARCHAR(64));
INSERT INTO t0 VALUES ('0000-00-00 10:20:30');
INSERT INTO t0 VALUES ('0000-00-01 10:20:30');
INSERT INTO t0 VALUES ('0000-01-00 10:20:30');
INSERT INTO t0 VALUES ('0000-01-01 10:20:30');
INSERT INTO t0 VALUES ('0001-00-00 10:20:30');
INSERT INTO t0 VALUES ('0001-00-01 10:20:30');
INSERT INTO t0 VALUES ('0001-01-00 10:20:30');
INSERT INTO t0 VALUES ('0001-01-01 10:20:30');
SET @@global.mysql56_temporal_format=false;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT d,d,d FROM t0;
Warnings:
Note 1265 Data truncated for column 't0' at row 3
Note 1265 Data truncated for column 't1' at row 3
Note 1265 Data truncated for column 't0' at row 4
Note 1265 Data truncated for column 't1' at row 4
Note 1265 Data truncated for column 't0' at row 5
Note 1265 Data truncated for column 't1' at row 5
Note 1265 Data truncated for column 't0' at row 6
Note 1265 Data truncated for column 't1' at row 6
Note 1265 Data truncated for column 't0' at row 7
Note 1265 Data truncated for column 't1' at row 7
Note 1265 Data truncated for column 't0' at row 8
Note 1265 Data truncated for column 't1' at row 8
SELECT * FROM t1 ORDER BY d;
d t0 t1
0000-00-00 10:20:30 10:20:30 10:20:30.0
0000-00-01 10:20:30 34:20:30 34:20:30.0
0000-01-00 10:20:30 10:20:30 10:20:30.0
0000-01-01 10:20:30 10:20:30 10:20:30.0
0001-00-00 10:20:30 10:20:30 10:20:30.0
0001-00-01 10:20:30 10:20:30 10:20:30.0
0001-01-00 10:20:30 10:20:30 10:20:30.0
0001-01-01 10:20:30 10:20:30 10:20:30.0
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT CONCAT(d,'x'),CONCAT(d,'x'),CONCAT(d,'x') FROM t0;
Warnings:
Warning 1265 Data truncated for column 't0' at row 1
Warning 1265 Data truncated for column 't1' at row 1
Warning 1265 Data truncated for column 't0' at row 2
Warning 1265 Data truncated for column 't1' at row 2
Warning 1265 Data truncated for column 't0' at row 3
Warning 1265 Data truncated for column 't1' at row 3
Warning 1265 Data truncated for column 't0' at row 4
Warning 1265 Data truncated for column 't1' at row 4
Warning 1265 Data truncated for column 't0' at row 5
Warning 1265 Data truncated for column 't1' at row 5
Warning 1265 Data truncated for column 't0' at row 6
Warning 1265 Data truncated for column 't1' at row 6
Warning 1265 Data truncated for column 't0' at row 7
Warning 1265 Data truncated for column 't1' at row 7
Warning 1265 Data truncated for column 't0' at row 8
Warning 1265 Data truncated for column 't1' at row 8
SELECT * FROM t1;
d t0 t1
0000-00-00 10:20:30x 10:20:30 10:20:30.0
0000-00-01 10:20:30x 34:20:30 34:20:30.0
0000-01-00 10:20:30x 10:20:30 10:20:30.0
0000-01-01 10:20:30x 10:20:30 10:20:30.0
0001-00-00 10:20:30x 10:20:30 10:20:30.0
0001-00-01 10:20:30x 10:20:30 10:20:30.0
0001-01-00 10:20:30x 10:20:30 10:20:30.0
0001-01-01 10:20:30x 10:20:30 10:20:30.0
DROP TABLE t1;
SET @@global.mysql56_temporal_format=true;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT d,d,d FROM t0;
Warnings:
Note 1265 Data truncated for column 't0' at row 3
Note 1265 Data truncated for column 't1' at row 3
Note 1265 Data truncated for column 't0' at row 4
Note 1265 Data truncated for column 't1' at row 4
Note 1265 Data truncated for column 't0' at row 5
Note 1265 Data truncated for column 't1' at row 5
Note 1265 Data truncated for column 't0' at row 6
Note 1265 Data truncated for column 't1' at row 6
Note 1265 Data truncated for column 't0' at row 7
Note 1265 Data truncated for column 't1' at row 7
Note 1265 Data truncated for column 't0' at row 8
Note 1265 Data truncated for column 't1' at row 8
SELECT * FROM t1;
d t0 t1
0000-00-00 10:20:30 10:20:30 10:20:30.0
0000-00-01 10:20:30 34:20:30 34:20:30.0
0000-01-00 10:20:30 10:20:30 10:20:30.0
0000-01-01 10:20:30 10:20:30 10:20:30.0
0001-00-00 10:20:30 10:20:30 10:20:30.0
0001-00-01 10:20:30 10:20:30 10:20:30.0
0001-01-00 10:20:30 10:20:30 10:20:30.0
0001-01-01 10:20:30 10:20:30 10:20:30.0
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT CONCAT(d,'x'),CONCAT(d,'x'),CONCAT(d,'x') FROM t0;
Warnings:
Warning 1265 Data truncated for column 't0' at row 1
Warning 1265 Data truncated for column 't1' at row 1
Warning 1265 Data truncated for column 't0' at row 2
Warning 1265 Data truncated for column 't1' at row 2
Warning 1265 Data truncated for column 't0' at row 3
Warning 1265 Data truncated for column 't1' at row 3
Warning 1265 Data truncated for column 't0' at row 4
Warning 1265 Data truncated for column 't1' at row 4
Warning 1265 Data truncated for column 't0' at row 5
Warning 1265 Data truncated for column 't1' at row 5
Warning 1265 Data truncated for column 't0' at row 6
Warning 1265 Data truncated for column 't1' at row 6
Warning 1265 Data truncated for column 't0' at row 7
Warning 1265 Data truncated for column 't1' at row 7
Warning 1265 Data truncated for column 't0' at row 8
Warning 1265 Data truncated for column 't1' at row 8
SELECT * FROM t1 ORDER BY d;
d t0 t1
0000-00-00 10:20:30x 10:20:30 10:20:30.0
0000-00-01 10:20:30x 34:20:30 34:20:30.0
0000-01-00 10:20:30x 10:20:30 10:20:30.0
0000-01-01 10:20:30x 10:20:30 10:20:30.0
0001-00-00 10:20:30x 10:20:30 10:20:30.0
0001-00-01 10:20:30x 10:20:30 10:20:30.0
0001-01-00 10:20:30x 10:20:30 10:20:30.0
0001-01-01 10:20:30x 10:20:30 10:20:30.0
DROP TABLE t1;
DROP TABLE t0;
SET sql_mode=DEFAULT;
38 changes: 38 additions & 0 deletions mysql-test/t/type_time.test
Expand Up @@ -776,3 +776,41 @@ INSERT INTO t1 VALUES ('10:20:30'),('10:20:31'),('10:20:32');
SELECT a FROM t1 WHERE a IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') ORDER BY a;
DROP TABLE t1;
SET timestamp=DEFAULT;

--echo #
--echo # MDEV-15176 Storing DATETIME-alike VARCHAR data into TIME produces wrong results
--echo #

SET sql_mode='';
CREATE OR REPLACE TABLE t0 (d VARCHAR(64));
INSERT INTO t0 VALUES ('0000-00-00 10:20:30');
INSERT INTO t0 VALUES ('0000-00-01 10:20:30');
INSERT INTO t0 VALUES ('0000-01-00 10:20:30');
INSERT INTO t0 VALUES ('0000-01-01 10:20:30');
INSERT INTO t0 VALUES ('0001-00-00 10:20:30');
INSERT INTO t0 VALUES ('0001-00-01 10:20:30');
INSERT INTO t0 VALUES ('0001-01-00 10:20:30');
INSERT INTO t0 VALUES ('0001-01-01 10:20:30');

SET @@global.mysql56_temporal_format=false;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT d,d,d FROM t0;
SELECT * FROM t1 ORDER BY d;
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT CONCAT(d,'x'),CONCAT(d,'x'),CONCAT(d,'x') FROM t0;
SELECT * FROM t1;
DROP TABLE t1;

SET @@global.mysql56_temporal_format=true;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT d,d,d FROM t0;
SELECT * FROM t1;
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (d VARCHAR(64), t0 TIME(0), t1 TIME(1));
INSERT INTO t1 SELECT CONCAT(d,'x'),CONCAT(d,'x'),CONCAT(d,'x') FROM t0;
SELECT * FROM t1 ORDER BY d;
DROP TABLE t1;

DROP TABLE t0;
SET sql_mode=DEFAULT;

0 comments on commit 217fc12

Please sign in to comment.