Commit 00e67a0c authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

merge

parents d25f8cdc 17d716c9
...@@ -1270,12 +1270,17 @@ static void cleanup_and_exit(int exit_code) ...@@ -1270,12 +1270,17 @@ static void cleanup_and_exit(int exit_code)
void print_file_stack() void print_file_stack()
{ {
for (struct st_test_file* err_file= cur_file; struct st_test_file* err_file= cur_file;
err_file != file_stack; if (err_file == file_stack)
err_file--) return;
for (;;)
{ {
err_file--;
fprintf(stderr, "included from %s at line %d:\n", fprintf(stderr, "included from %s at line %d:\n",
err_file->file_name, err_file->lineno); err_file->file_name, err_file->lineno);
if (err_file == file_stack)
break;
} }
} }
......
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop view if exists v1,v2;
CREATE TABLE t1 (S1 INT); CREATE TABLE t1 (S1 INT);
CREATE TABLE t2 (S1 INT); CREATE TABLE t2 (S1 INT);
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
...@@ -1220,4 +1221,22 @@ f1 ...@@ -1220,4 +1221,22 @@ f1
2 2
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
#
# Bug LP:798597: Incorrect "Duplicate entry" error with views and
# GROUP BY
#
CREATE TABLE t1 ( f1 int NOT NULL , f2 int NOT NULL ) ;
INSERT INTO t1 VALUES (214,0),(6,6);
CREATE TABLE t2 ( f2 int) ;
INSERT INTO t2 VALUES (88),(88);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0) ;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0 or t1.f2 is null) ;
SELECT f1 , MIN(f2) FROM v1 GROUP BY f1;
f1 MIN(f2)
214 88
SELECT f1 , MIN(f2) FROM v2 GROUP BY f1;
f1 MIN(f2)
214 88
drop table t1,t2;
drop view v1,v2;
End of 5.1 tests End of 5.1 tests
...@@ -334,10 +334,10 @@ included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1: ...@@ -334,10 +334,10 @@ included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1: included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1: included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1: included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1: included from <stdin> at line 1:
At line 1: Source directives are nesting too deep At line 1: Source directives are nesting too deep
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql":
included from MYSQLTEST_VARDIR/tmp/error.sql at line 1: included from <stdin> at line 1:
At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
2 = outer loop variable after while 2 = outer loop variable after while
...@@ -433,7 +433,7 @@ while with string, only once ...@@ -433,7 +433,7 @@ while with string, only once
1 1
Testing while with not Testing while with not
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc": mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc":
included from MYSQLTEST_VARDIR/tmp/mysqltest_while.inc at line 65: included from <stdin> at line 1:
At line 64: Nesting too deeply At line 64: Nesting too deeply
mysqltest: At line 1: missing '(' in while mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while mysqltest: At line 1: missing ')' in while
...@@ -484,10 +484,10 @@ mysqltest: At line 1: Illegal argument for port: 'illegal_port' ...@@ -484,10 +484,10 @@ mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP mysqltest: At line 1: Illegal option to connect: SMTP
200 connects succeeded 200 connects succeeded
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
included from MYSQLTEST_VARDIR/tmp/mysqltest.sql at line 3: included from <stdin> at line 1:
At line 3: connection 'test_con1' not found in connection pool At line 3: connection 'test_con1' not found in connection pool
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
included from MYSQLTEST_VARDIR/tmp/mysqltest.sql at line 2: included from <stdin> at line 1:
At line 2: Connection test_con1 already exists At line 2: Connection test_con1 already exists
show tables; show tables;
ERROR 3D000: No database selected ERROR 3D000: No database selected
......
install plugin example soname 'ha_example.so';
create table t1(a int) engine=example;
drop table t1;
alter table mysql.plugin engine=innodb;
restart
create table t1(a int) engine=example;
select * from t1;
a
drop table t1;
alter table mysql.plugin engine=myisam;
uninstall plugin example;
This source diff could not be displayed because it is too large. You can view the blob instead.
set @@global.innodb_fast_shutdown=0;
CREATE TABLE t(a INT)ENGINE=InnoDB; CREATE TABLE t(a INT)ENGINE=InnoDB;
RENAME TABLE t TO u; RENAME TABLE t TO u;
DROP TABLE u; DROP TABLE u;
......
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
-- source include/not_embedded.inc -- source include/not_embedded.inc
-- source include/have_innodb.inc -- source include/have_innodb.inc
if (`SELECT @@innodb_fast_shutdown != 0`) #
# This test will not work if we don't do full shutdown of innodb
{ #
skip Need innodb_fast_shutdown=0; set @@global.innodb_fast_shutdown=0;
}
CREATE TABLE t(a INT)ENGINE=InnoDB; CREATE TABLE t(a INT)ENGINE=InnoDB;
RENAME TABLE t TO u; RENAME TABLE t TO u;
......
set @@global.innodb_fast_shutdown=0;
CREATE TABLE t(a INT)ENGINE=InnoDB; CREATE TABLE t(a INT)ENGINE=InnoDB;
RENAME TABLE t TO u; RENAME TABLE t TO u;
DROP TABLE u; DROP TABLE u;
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
-- source include/not_embedded.inc -- source include/not_embedded.inc
-- source include/have_innodb_plugin.inc -- source include/have_innodb_plugin.inc
# This test will not work if we don't do full shutdown of innodb
#
set @@global.innodb_fast_shutdown=0;
CREATE TABLE t(a INT)ENGINE=InnoDB; CREATE TABLE t(a INT)ENGINE=InnoDB;
RENAME TABLE t TO u; RENAME TABLE t TO u;
DROP TABLE u; DROP TABLE u;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Initialization # Initialization
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
drop view if exists v1,v2;
--enable_warnings --enable_warnings
# #
...@@ -921,4 +922,21 @@ EXECUTE stmt; ...@@ -921,4 +922,21 @@ EXECUTE stmt;
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug LP:798597: Incorrect "Duplicate entry" error with views and
--echo # GROUP BY
--echo #
CREATE TABLE t1 ( f1 int NOT NULL , f2 int NOT NULL ) ;
INSERT INTO t1 VALUES (214,0),(6,6);
CREATE TABLE t2 ( f2 int) ;
INSERT INTO t2 VALUES (88),(88);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0) ;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0 or t1.f2 is null) ;
SELECT f1 , MIN(f2) FROM v1 GROUP BY f1;
SELECT f1 , MIN(f2) FROM v2 GROUP BY f1;
drop table t1,t2;
drop view v1,v2;
--echo End of 5.1 tests --echo End of 5.1 tests
--source include/not_embedded.inc
--source include/have_example_plugin.inc
--source include/have_innodb.inc
if (!`select count(*) from information_schema.plugins
where plugin_name = 'innodb' and plugin_status = 'active' and
plugin_library is null`) {
skip Need compiled-in InnoDB;
}
--replace_regex /\.dll/.so/
eval install plugin example soname '$HA_EXAMPLE_SO';
create table t1(a int) engine=example;
drop table t1;
alter table mysql.plugin engine=innodb;
--echo restart
--source include/restart_mysqld.inc
create table t1(a int) engine=example;
select * from t1;
drop table t1;
alter table mysql.plugin engine=myisam;
uninstall plugin example;
...@@ -893,16 +893,17 @@ static int check_connection(THD *thd) ...@@ -893,16 +893,17 @@ static int check_connection(THD *thd)
(uchar)(*passwd++) : strlen(passwd); (uchar)(*passwd++) : strlen(passwd);
db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
db + passwd_len + 1 : 0; db + passwd_len + 1 : 0;
/* strlen() can't be easily deleted without changing protocol */
uint db_len= db ? strlen(db) : 0;
if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len) if (passwd + passwd_len + test(db) > (char *)net->read_pos + pkt_len)
{ {
inc_host_errors(&thd->remote.sin_addr); inc_host_errors(&thd->remote.sin_addr);
my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip); my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
return 1; return 1;
} }
/* strlen() can't be easily deleted without changing protocol */
uint db_len= db ? strlen(db) : 0;
/* Since 4.1 all database names are stored in utf8 */ /* Since 4.1 all database names are stored in utf8 */
if (db) if (db)
{ {
......
...@@ -1232,15 +1232,23 @@ int plugin_init(int *argc, char **argv, int flags) ...@@ -1232,15 +1232,23 @@ int plugin_init(int *argc, char **argv, int flags)
if (register_builtin(plugin, &tmp, &plugin_ptr)) if (register_builtin(plugin, &tmp, &plugin_ptr))
goto err_unlock; goto err_unlock;
/* only initialize MyISAM and CSV at this stage */ is_myisam= !my_strcasecmp(&my_charset_latin1, plugin->name, "MyISAM");
if (!(is_myisam=
!my_strcasecmp(&my_charset_latin1, plugin->name, "MyISAM")) &&
my_strcasecmp(&my_charset_latin1, plugin->name, "CSV"))
continue;
if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED && /*
plugin_initialize(plugin_ptr)) strictly speaking, we should to initialize all plugins,
goto err_unlock; even for mysqld --help, because important subsystems
may be disabled otherwise, and the help will be incomplete.
For example, if the mysql.plugin table is not MyISAM.
But for now it's an unlikely corner case, and to optimize
mysqld --help for all other users, we will only initialize
MyISAM here.
*/
if (!(flags & PLUGIN_INIT_SKIP_INITIALIZATION) || is_myisam)
{
if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED &&
plugin_initialize(plugin_ptr))
goto err_unlock;
}
/* /*
initialize the global default storage engine so that it may initialize the global default storage engine so that it may
...@@ -1445,13 +1453,6 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) ...@@ -1445,13 +1453,6 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
table= tables.table; table= tables.table;
init_read_record(&read_record_info, new_thd, table, NULL, 1, 0, FALSE); init_read_record(&read_record_info, new_thd, table, NULL, 1, 0, FALSE);
table->use_all_columns(); table->use_all_columns();
/*
there're no other threads running yet, so we don't need a mutex.
but plugin_add() before is designed to work in multi-threaded
environment, and it uses safe_mutex_assert_owner(), so we lock
the mutex here to satisfy the assert
*/
pthread_mutex_lock(&LOCK_plugin);
while (!(error= read_record_info.read_record(&read_record_info))) while (!(error= read_record_info.read_record(&read_record_info)))
{ {
DBUG_PRINT("info", ("init plugin record")); DBUG_PRINT("info", ("init plugin record"));
...@@ -1462,12 +1463,19 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) ...@@ -1462,12 +1463,19 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
LEX_STRING name= {(char *)str_name.ptr(), str_name.length()}; LEX_STRING name= {(char *)str_name.ptr(), str_name.length()};
LEX_STRING dl= {(char *)str_dl.ptr(), str_dl.length()}; LEX_STRING dl= {(char *)str_dl.ptr(), str_dl.length()};
/*
there're no other threads running yet, so we don't need a mutex.
but plugin_add() before is designed to work in multi-threaded
environment, and it uses safe_mutex_assert_owner(), so we lock
the mutex here to satisfy the assert
*/
pthread_mutex_lock(&LOCK_plugin);
if (plugin_add(tmp_root, &name, &dl, argc, argv, REPORT_TO_LOG)) if (plugin_add(tmp_root, &name, &dl, argc, argv, REPORT_TO_LOG))
sql_print_warning("Couldn't load plugin named '%s' with soname '%s'.", sql_print_warning("Couldn't load plugin named '%s' with soname '%s'.",
str_name.c_ptr(), str_dl.c_ptr()); str_name.c_ptr(), str_dl.c_ptr());
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
pthread_mutex_unlock(&LOCK_plugin);
} }
pthread_mutex_unlock(&LOCK_plugin);
if (error > 0) if (error > 0)
sql_print_error(ER(ER_GET_ERRNO), my_errno); sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info); end_read_record(&read_record_info);
......
...@@ -10637,15 +10637,30 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -10637,15 +10637,30 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
(ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT1 || (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT1 ||
(ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT2) ? (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT2) ?
0 : FIELDFLAG_BINARY; 0 : FIELDFLAG_BINARY;
if (!using_unique_constraint) if (!using_unique_constraint)
{ {
cur_group->buff=(char*) group_buff; cur_group->buff=(char*) group_buff;
if (maybe_null && !field->null_bit)
{
/*
This can only happen in the unusual case where an outer join
table was found to be not-nullable by the optimizer and we
the item can't really be null.
We solve this by marking the item as !maybe_null to ensure
that the key,field and item definition match.
*/
(*cur_group->item)->maybe_null= maybe_null= 0;
}
if (!(cur_group->field= field->new_key_field(thd->mem_root,table, if (!(cur_group->field= field->new_key_field(thd->mem_root,table,
group_buff + group_buff +
test(maybe_null), test(maybe_null),
field->null_ptr, field->null_ptr,
field->null_bit))) field->null_bit)))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
if (maybe_null) if (maybe_null)
{ {
/* /*
...@@ -10667,6 +10682,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -10667,6 +10682,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
} }
keyinfo->key_length+= key_part_info->length; keyinfo->key_length+= key_part_info->length;
} }
/*
Ensure we didn't overrun the group buffer. The < is only true when
some maybe_null fields was changed to be not null fields.
*/
DBUG_ASSERT(using_unique_constraint ||
group_buff <= param->group_buff + param->group_length);
} }
if (distinct && field_count != param->hidden_field_count) if (distinct && field_count != param->hidden_field_count)
......
...@@ -3415,9 +3415,15 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -3415,9 +3415,15 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
it.rewind(); /* To get access to new elements in basis list */ it.rewind(); /* To get access to new elements in basis list */
while ((db_name= it++)) while ((db_name= it++))
{ {
/* db_name can be changed in make_table_list() func */ LEX_STRING orig_db_name;
LEX_STRING orig_db_name= *db_name;
/*
db_name can be changed in make_table_list() func.
We need copy of db_name because it can change case.
*/
if (!thd->make_lex_string(&orig_db_name, db_name->str,
db_name->length, FALSE))
goto err;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(check_access(thd,SELECT_ACL, db_name->str, if (!(check_access(thd,SELECT_ACL, db_name->str,
&thd->col_access, 0, 1, with_i_schema) || &thd->col_access, 0, 1, with_i_schema) ||
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#undef DBUG_OFF #undef DBUG_OFF
#endif #endif
#ifndef SAFEMALLOC #ifndef SAFEMALLOC
#define SAFEMALLOC #define SAFEMALLOC 1
#endif #endif
#include "heapdef.h" /* Because of hp_find_block */ #include "heapdef.h" /* Because of hp_find_block */
......
...@@ -1447,10 +1447,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, ...@@ -1447,10 +1447,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap,
best_prefix_bits|= tmp; best_prefix_bits|= tmp;
int6store(best_data, best_prefix_bits); int6store(best_data, best_prefix_bits);
if (!(best_area_size-= best_prefix_area_size)) if (!(best_area_size-= best_prefix_area_size))
{ goto end;
DBUG_EXECUTE("bitmap", _ma_print_bitmap_changes(bitmap););
DBUG_RETURN(block->page_count);
}
best_data+= 6; best_data+= 6;
} }
best_area_size*= 3; /* Bits to set */ best_area_size*= 3; /* Bits to set */
...@@ -1468,6 +1465,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, ...@@ -1468,6 +1465,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap,
bitmap->used_size= (uint) (best_data - bitmap->map); bitmap->used_size= (uint) (best_data - bitmap->map);
DBUG_ASSERT(bitmap->used_size <= bitmap->total_size); DBUG_ASSERT(bitmap->used_size <= bitmap->total_size);
} }
end:
bitmap->changed= 1; bitmap->changed= 1;
DBUG_EXECUTE("bitmap", _ma_print_bitmap_changes(bitmap);); DBUG_EXECUTE("bitmap", _ma_print_bitmap_changes(bitmap););
DBUG_RETURN(block->page_count); DBUG_RETURN(block->page_count);
...@@ -2290,7 +2288,7 @@ my_bool _ma_bitmap_set_full_page_bits(MARIA_HA *info, ...@@ -2290,7 +2288,7 @@ my_bool _ma_bitmap_set_full_page_bits(MARIA_HA *info,
bitmap_page= page - page % bitmap->pages_covered; bitmap_page= page - page % bitmap->pages_covered;
if (page == bitmap_page || if (page == bitmap_page ||
page + page_count >= bitmap_page + bitmap->pages_covered) page + page_count > bitmap_page + bitmap->pages_covered)
{ {
DBUG_ASSERT(0); /* Wrong in data */ DBUG_ASSERT(0); /* Wrong in data */
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -558,8 +558,10 @@ xtPublic int xt_p_set_low_priority(pthread_t thr) ...@@ -558,8 +558,10 @@ xtPublic int xt_p_set_low_priority(pthread_t thr)
*/ */
/* -20 = highest, 20 = lowest */ /* -20 = highest, 20 = lowest */
#ifdef SET_GLOBAL_PRIORITY
if (setpriority(PRIO_PROCESS, getpid(), 20) == -1) if (setpriority(PRIO_PROCESS, getpid(), 20) == -1)
return errno; return errno;
#endif
return 0; return 0;
} }
return pth_set_priority(thr, pth_min_priority); return pth_set_priority(thr, pth_min_priority);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment