summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt4
-rw-r--r--client/mysqltest.c34
-rw-r--r--include/config-win.h4
-rw-r--r--include/my_global.h2
-rw-r--r--mysql-test/r/flush.result1
-rw-r--r--mysql-test/r/func_group.result6
-rw-r--r--mysql-test/r/information_schema.result13
-rw-r--r--mysql-test/r/sp-code.result28
-rw-r--r--mysql-test/r/subselect3.result13
-rw-r--r--mysql-test/r/view.result18
-rw-r--r--mysql-test/t/flush.test9
-rw-r--r--mysql-test/t/func_group.test10
-rw-r--r--mysql-test/t/information_schema.test27
-rw-r--r--mysql-test/t/sp-code.test32
-rw-r--r--mysql-test/t/subselect3.test19
-rw-r--r--mysql-test/t/view.test23
-rw-r--r--sql/handler.h2
-rw-r--r--sql/item.cc15
-rw-r--r--sql/item_subselect.cc12
-rw-r--r--sql/item_sum.cc10
-rw-r--r--sql/mysql_priv.h14
-rw-r--r--sql/procedure.h2
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_acl.h6
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_analyse.h2
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_delete.cc4
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_prepare.cc6
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_update.cc2
35 files changed, 291 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27b2bf9b70e..77c95e16a76 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,6 +78,10 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
+#TODO: update the code and remove the disabled warnings
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805")
+
IF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996")
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 05c9ced3848..1d85e777e48 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -550,6 +550,17 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
return 0;
}
+static void wait_query_thread_end(struct st_connection *con)
+{
+ if (!con->query_done)
+ {
+ pthread_mutex_lock(&con->mutex);
+ while (!con->query_done)
+ pthread_cond_wait(&con->cond, &con->mutex);
+ pthread_mutex_unlock(&con->mutex);
+ }
+}
+
#else /*EMBEDDED_LIBRARY*/
#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
@@ -4071,7 +4082,14 @@ void do_close_connection(struct st_command *command)
con->mysql.net.vio = 0;
}
}
-#endif
+#else
+ /*
+ As query could be still executed in a separate theread
+ we need to check if the query's thread was finished and probably wait
+ (embedded-server specific)
+ */
+ wait_query_thread_end(con);
+#endif /*EMBEDDED_LIBRARY*/
if (con->stmt)
mysql_stmt_close(con->stmt);
con->stmt= 0;
@@ -4361,6 +4379,9 @@ void do_connect(struct st_command *command)
(int) (sizeof(connections)/sizeof(struct st_connection)));
}
+#ifdef EMBEDDED_LIBRARY
+ con_slot->query_done= 1;
+#endif
if (!mysql_init(&con_slot->mysql))
die("Failed on mysql_init()");
if (opt_compress || con_compress)
@@ -5848,16 +5869,11 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
}
#ifdef EMBEDDED_LIBRARY
/*
- Here we handle 'reap' command, so we need to check if the
- query's thread was finished and probably wait
+ Here we handle 'reap' command, so we need to check if the
+ query's thread was finished and probably wait
*/
else if (flags & QUERY_REAP_FLAG)
- {
- pthread_mutex_lock(&cn->mutex);
- while (!cn->query_done)
- pthread_cond_wait(&cn->cond, &cn->mutex);
- pthread_mutex_unlock(&cn->mutex);
- }
+ wait_query_thread_end(cn);
#endif /*EMBEDDED_LIBRARY*/
if (!(flags & QUERY_REAP_FLAG))
DBUG_VOID_RETURN;
diff --git a/include/config-win.h b/include/config-win.h
index 45bfeb5ba26..c9c25d44691 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -157,14 +157,12 @@ typedef uint rf_SetTimer;
#define Socket_defined
#define my_socket SOCKET
-#define bool BOOL
#define SIGPIPE SIGINT
#define RETQSORTTYPE void
#define QSORT_TYPE_IS_VOID
#define RETSIGTYPE void
#define SOCKET_SIZE_TYPE int
#define my_socket_defined
-#define bool_defined
#define byte_defined
#define HUGE_PTR
#define STDCALL __stdcall /* Used by libmysql.dll */
@@ -457,4 +455,4 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_CHARSET_ujis 1
#define HAVE_CHARSET_utf8 1
#define HAVE_UCA_COLLATIONS 1
-
+#define HAVE_BOOL 1
diff --git a/include/my_global.h b/include/my_global.h
index 08877300d8a..f0f33a7de8b 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -980,7 +980,7 @@ typedef int myf; /* Type of MyFlags in my_funcs */
typedef char byte; /* Smallest addressable unit */
#endif
typedef char my_bool; /* Small bool */
-#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
+#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
typedef char bool; /* Ordinary boolean values 0 1 */
#endif
/* Macros for converting *constants* to the right type */
diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result
index ce64e09c1d3..778f138f29d 100644
--- a/mysql-test/r/flush.result
+++ b/mysql-test/r/flush.result
@@ -72,3 +72,4 @@ flush tables with read lock;
unlock tables;
drop table t1, t2;
set session low_priority_updates=default;
+select benchmark(200, (select sin(1))) > 1000;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 4785ca9919d..772e432355b 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -1419,4 +1419,10 @@ Note 1003 select (`test`.`t1`.`a` + 1) AS `y` from `test`.`t1` group by (`test`.
DROP VIEW v1;
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
+CREATE TABLE t1(a DOUBLE);
+INSERT INTO t1 VALUES (10), (20);
+SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1;
+AVG(a) CAST(AVG(a) AS DECIMAL)
+15 15
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 80f85aee429..d7ff87bd1eb 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -1417,8 +1417,19 @@ select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
-End of 5.0 tests.
show fields from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
show keys from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
+USE information_schema;
+SET max_heap_table_size = 16384;
+CREATE TABLE test.t1( a INT );
+SELECT *
+FROM tables ta
+JOIN collations co ON ( co.collation_name = ta.table_catalog )
+JOIN character_sets cs ON ( cs.character_set_name = ta.table_catalog );
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
+DROP TABLE test.t1;
+SET max_heap_table_size = DEFAULT;
+USE test;
+End of 5.0 tests.
diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result
index 855cabc25d8..2848306b442 100644
--- a/mysql-test/r/sp-code.result
+++ b/mysql-test/r/sp-code.result
@@ -842,4 +842,32 @@ Pos Instruction
21 jump 3
drop procedure proc_33618_h;
drop procedure proc_33618_c;
+drop procedure if exists p_20906_a;
+drop procedure if exists p_20906_b;
+create procedure p_20906_a() SET @a=@a+1, @b=@b+1;
+show procedure code p_20906_a;
+Pos Instruction
+0 stmt 32 "SET @a=@a+1"
+1 stmt 32 "SET @b=@b+1"
+set @a=1;
+set @b=1;
+call p_20906_a();
+select @a, @b;
+@a @b
+2 2
+create procedure p_20906_b() SET @a=@a+1, @b=@b+1, @c=@c+1;
+show procedure code p_20906_b;
+Pos Instruction
+0 stmt 32 "SET @a=@a+1"
+1 stmt 32 "SET @b=@b+1"
+2 stmt 32 "SET @c=@c+1"
+set @a=1;
+set @b=1;
+set @c=1;
+call p_20906_b();
+select @a, @b, @c;
+@a @b @c
+2 2 2
+drop procedure p_20906_a;
+drop procedure p_20906_b;
End of 5.0 tests.
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index bdf00e4c307..c194ba33756 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -758,5 +758,16 @@ EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using index; Using where
-DROP TABLE t1;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2 (placeholder CHAR(11));
+INSERT INTO t2 VALUES("placeholder");
+SELECT ROW(1, 2) IN (SELECT t1.a, 2) FROM t1 GROUP BY t1.a;
+ROW(1, 2) IN (SELECT t1.a, 2)
+1
+SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a;
+ROW(1, 2) IN (SELECT t1.a, 2 FROM t2)
+1
+DROP TABLE t1, t2;
End of 5.0 tests
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 520bf9426b8..eb7a89c3d12 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3660,5 +3660,23 @@ DROP TABLE t1;
# -- End of test case for Bug#34337.
# -----------------------------------------------------------------
+# -- Bug#35193: VIEW query is rewritten without "FROM DUAL",
+# -- causing syntax error
+# -----------------------------------------------------------------
+
+CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE 1;
+
+SELECT * FROM v1;
+1
+1
+SHOW CREATE TABLE v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` from DUAL where 1
+
+DROP VIEW v1;
+
+# -- End of test case for Bug#35193.
+
+# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index 72efa8a2ee6..4c6d4265600 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -164,4 +164,13 @@ drop table t1, t2;
set session low_priority_updates=default;
+#
+# Bug #33334 mysqltest_embedded crashes when disconnecting before reap
+#
+
+connect (con1,localhost,root,,);
+send select benchmark(200, (select sin(1))) > 1000;
+disconnect con1;
+connection default;
+
# End of 5.0 tests
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 75a380c733f..dbe6d3113d5 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -916,5 +916,15 @@ DROP VIEW v1;
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
+#
+# Bug #34512: CAST( AVG( double ) AS DECIMAL ) returns wrong results
+#
+
+CREATE TABLE t1(a DOUBLE);
+INSERT INTO t1 VALUES (10), (20);
+SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1;
+
+DROP TABLE t1;
+
###
--echo End of 5.0 tests
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 3d3310e389e..caf38945cbc 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -1108,8 +1108,6 @@ select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL;
select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL;
---echo End of 5.0 tests.
-
#
# Bug#30079 A check for "hidden" I_S tables is flawed
#
@@ -1118,3 +1116,28 @@ show fields from information_schema.table_names;
--error 1109
show keys from information_schema.table_names;
+#
+# Bug#34529: Crash on complex Falcon I_S select after ALTER .. PARTITION BY
+#
+USE information_schema;
+SET max_heap_table_size = 16384;
+
+CREATE TABLE test.t1( a INT );
+
+# What we need to create here is a bit of a corner case:
+# We need a star query with information_schema tables, where the first
+# branch of the star join produces zero rows, so that reading of the
+# second branch never happens. At the same time we have to make sure
+# that data for at least the last table is swapped from MEMORY/HEAP to
+# MyISAM. This and only this triggers the bug.
+SELECT *
+FROM tables ta
+JOIN collations co ON ( co.collation_name = ta.table_catalog )
+JOIN character_sets cs ON ( cs.character_set_name = ta.table_catalog );
+
+DROP TABLE test.t1;
+SET max_heap_table_size = DEFAULT;
+USE test;
+
+--echo End of 5.0 tests.
+
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 751282c895a..a76863dd5fa 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -598,4 +598,36 @@ show procedure code proc_33618_c;
drop procedure proc_33618_h;
drop procedure proc_33618_c;
+#
+# Bug#20906 (Multiple assignments in SET in stored routine produce incorrect
+# instructions)
+#
+
+--disable_warnings
+drop procedure if exists p_20906_a;
+drop procedure if exists p_20906_b;
+--enable_warnings
+
+create procedure p_20906_a() SET @a=@a+1, @b=@b+1;
+show procedure code p_20906_a;
+
+set @a=1;
+set @b=1;
+
+call p_20906_a();
+select @a, @b;
+
+create procedure p_20906_b() SET @a=@a+1, @b=@b+1, @c=@c+1;
+show procedure code p_20906_b;
+
+set @a=1;
+set @b=1;
+set @c=1;
+
+call p_20906_b();
+select @a, @b, @c;
+
+drop procedure p_20906_a;
+drop procedure p_20906_b;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index 2f844c9cc21..cfbde8c29cd 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -586,6 +586,23 @@ SELECT a FROM t1 WHERE a NOT IN (65,66);
SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
-DROP TABLE t1;
+DROP TABLE t1, t2;
+
+#
+# Bug #34763: item_subselect.cc:1235:Item_in_subselect::row_value_transformer:
+# Assertion failed, unexpected error message:
+# ERROR 1247 (42S22): Reference '<list ref>' not supported (forward
+# reference in item list)
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES(1);
+
+CREATE TABLE t2 (placeholder CHAR(11));
+INSERT INTO t2 VALUES("placeholder");
+
+SELECT ROW(1, 2) IN (SELECT t1.a, 2) FROM t1 GROUP BY t1.a;
+SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a;
+
+DROP TABLE t1, t2;
--echo End of 5.0 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 23e64b0546f..9fa981ccb9a 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3538,5 +3538,28 @@ DROP TABLE t1;
###########################################################################
--echo # -----------------------------------------------------------------
+--echo # -- Bug#35193: VIEW query is rewritten without "FROM DUAL",
+--echo # -- causing syntax error
+--echo # -----------------------------------------------------------------
+--echo
+
+CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE 1;
+
+--echo
+
+SELECT * FROM v1;
+SHOW CREATE TABLE v1;
+
+--echo
+
+DROP VIEW v1;
+
+--echo
+--echo # -- End of test case for Bug#35193.
+--echo
+
+###########################################################################
+
+--echo # -----------------------------------------------------------------
--echo # -- End of 5.0 tests.
--echo # -----------------------------------------------------------------
diff --git a/sql/handler.h b/sql/handler.h
index 74c09d2d9ee..aa3377c3868 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -815,7 +815,7 @@ public:
{ return HA_ADMIN_NOT_IMPLEMENTED; }
/* end of the list of admin commands */
- virtual bool check_and_repair(THD *thd) { return HA_ERR_WRONG_COMMAND; }
+ virtual bool check_and_repair(THD *thd) { return TRUE; }
virtual int dump(THD* thd, int fd = -1) { return HA_ERR_WRONG_COMMAND; }
virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
diff --git a/sql/item.cc b/sql/item.cc
index 11e9acb1e55..d2047826f18 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5481,13 +5481,16 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
DBUG_ASSERT(*ref);
/*
Check if this is an incorrect reference in a group function or forward
- reference. Do not issue an error if this is an unnamed reference inside an
- aggregate function.
+ reference. Do not issue an error if this is:
+ 1. outer reference (will be fixed later by the fix_inner_refs function);
+ 2. an unnamed reference inside an aggregate function.
*/
- if (((*ref)->with_sum_func && name &&
- !(current_sel->linkage != GLOBAL_OPTIONS_TYPE &&
- current_sel->having_fix_field)) ||
- !(*ref)->fixed)
+ if (!((*ref)->type() == REF_ITEM &&
+ ((Item_ref *)(*ref))->ref_type() == OUTER_REF) &&
+ (((*ref)->with_sum_func && name &&
+ !(current_sel->linkage != GLOBAL_OPTIONS_TYPE &&
+ current_sel->having_fix_field)) ||
+ !(*ref)->fixed))
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
name, ((*ref)->with_sum_func?
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index b3710841dfb..a03a7d739b2 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1232,7 +1232,11 @@ Item_in_subselect::row_value_transformer(JOIN *join)
Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++)
{
- DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
+ DBUG_ASSERT(left_expr->fixed &&
+ select_lex->ref_pointer_array[i]->fixed ||
+ (select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
+ ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
+ Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(RES_ERROR);
@@ -1306,7 +1310,11 @@ Item_in_subselect::row_value_transformer(JOIN *join)
for (uint i= 0; i < cols_num; i++)
{
Item *item, *item_isnull;
- DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
+ DBUG_ASSERT(left_expr->fixed &&
+ select_lex->ref_pointer_array[i]->fixed ||
+ (select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
+ ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
+ Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(RES_ERROR);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 3d6d46ab3f4..f583fc7f988 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1206,7 +1206,15 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val)
null_value=1;
return NULL;
}
- sum_dec= Item_sum_sum::val_decimal(&sum_buff);
+
+ /*
+ For non-DECIMAL hybrid_type the division will be done in
+ Item_sum_avg::val_real().
+ */
+ if (hybrid_type != DECIMAL_RESULT)
+ return val_decimal_from_real(val);
+
+ sum_dec= dec_buffs + curr_dec_buff;
int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &cnt);
my_decimal_div(E_DEC_FATAL_ERROR, val, sum_dec, &cnt, prec_increment);
return val;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 59ec18e1a3d..0b488900ac5 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -597,8 +597,8 @@ bool check_merge_table_access(THD *thd, char *db,
bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
-bool mysql_multi_update_prepare(THD *thd);
-bool mysql_multi_delete_prepare(THD *thd);
+int mysql_multi_update_prepare(THD *thd);
+int mysql_multi_delete_prepare(THD *thd);
bool mysql_insert_select_prepare(THD *thd);
bool update_precheck(THD *thd, TABLE_LIST *tables);
bool delete_precheck(THD *thd, TABLE_LIST *tables);
@@ -691,7 +691,7 @@ struct Query_cache_query_flags
uint build_table_path(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext);
-bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
+int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
@@ -731,7 +731,7 @@ pthread_handler_t handle_one_connection(void *arg);
pthread_handler_t handle_bootstrap(void *arg);
void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache();
-bool mysql_execute_command(THD *thd);
+int mysql_execute_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length);
void log_slow_statement(THD *thd);
@@ -862,7 +862,7 @@ void prepare_triggers_for_insert_stmt(THD *thd, TABLE *table,
enum_duplicates duplic);
void mark_fields_used_by_triggers_for_insert_stmt(THD *thd, TABLE *table,
enum_duplicates duplic);
-bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
+int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
SQL_LIST *order, ha_rows rows, ulonglong options,
bool reset_auto_increment);
@@ -1106,7 +1106,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
void wait_for_refresh(THD *thd);
int open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags);
int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables);
-bool open_and_lock_tables(THD *thd,TABLE_LIST *tables);
+int open_and_lock_tables(THD *thd,TABLE_LIST *tables);
bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen);
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
@@ -1177,7 +1177,7 @@ inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table,
bool eval_const_cond(COND *cond);
/* sql_load.cc */
-bool mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
+int mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values_list,
enum enum_duplicates handle_duplicates, bool ignore,
diff --git a/sql/procedure.h b/sql/procedure.h
index 850d5c74db4..f1fb433a6ee 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -144,7 +144,7 @@ public:
virtual int send_row(List<Item> &fields)=0;
virtual bool change_columns(List<Item> &fields)=0;
virtual void update_refs(void) {}
- virtual bool end_of_records() { return 0; }
+ virtual int end_of_records() { return 0; }
};
Procedure *setup_procedure(THD *thd,ORDER *proc_param,select_result *result,
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index e9504f423ad..e773f754e18 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1382,7 +1382,7 @@ bool acl_check_host(const char *host, const char *ip)
1 ERROR ; In this case the error is sent to the client.
*/
-bool check_change_password(THD *thd, const char *host, const char *user,
+int check_change_password(THD *thd, const char *host, const char *user,
char *new_password, uint new_password_len)
{
if (!initialized)
@@ -2763,7 +2763,7 @@ table_error:
TRUE error
*/
-bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
+int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
List <LEX_USER> &user_list,
List <LEX_COLUMN> &columns, ulong rights,
bool revoke_grant)
@@ -5805,7 +5805,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
< 0 Error. Error message not yet sent.
*/
-bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
+int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
bool is_proc)
{
Security_context *sctx= thd->security_ctx;
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index b2007ccdf47..1efcd2e3b6b 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -183,13 +183,13 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, const char *passwd,
bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
char *ip, char *db);
bool acl_check_host(const char *host, const char *ip);
-bool check_change_password(THD *thd, const char *host, const char *user,
+int check_change_password(THD *thd, const char *host, const char *user,
char *password, uint password_len);
bool change_password(THD *thd, const char *host, const char *user,
char *password);
bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,
ulong rights, bool revoke);
-bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
+int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
List <LEX_COLUMN> &column_list, ulong rights,
bool revoke);
bool mysql_routine_grant(THD *thd, TABLE_LIST *table, bool is_proc,
@@ -225,7 +225,7 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
const char *db, const char *table);
bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
bool is_proc);
-bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
+int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
bool is_proc);
bool check_routine_level_acl(THD *thd, const char *db, const char *name,
bool is_proc);
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 95a7fb3d34d..2e90d00f8aa 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -683,7 +683,7 @@ int analyse::send_row(List<Item> &field_list __attribute__((unused)))
} // analyse::send_row
-bool analyse::end_of_records()
+int analyse::end_of_records()
{
field_info **f = f_info;
char buff[MAX_FIELD_WIDTH];
diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h
index 21a37209e89..2a4226b2d95 100644
--- a/sql/sql_analyse.h
+++ b/sql/sql_analyse.h
@@ -350,7 +350,7 @@ public:
virtual bool change_columns(List<Item> &fields);
virtual int send_row(List<Item> &fields);
virtual void end_group(void) {}
- virtual bool end_of_records(void);
+ virtual int end_of_records(void);
friend Procedure *proc_analyse_init(THD *thd, ORDER *param,
select_result *result,
List<Item> &field_list);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index c9f20b3d71b..533b0070fee 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -3046,7 +3046,7 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables)
The lock will automaticaly be freed by close_thread_tables()
*/
-bool open_and_lock_tables(THD *thd, TABLE_LIST *tables)
+int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
{
uint counter;
bool need_reopen;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 91b0c02d23b..e25ede1be03 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -449,7 +449,7 @@ bool load_db_opt_by_name(THD *thd, const char *db_name,
*/
-bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
+int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
bool silent)
{
char path[FN_REFLEN+16];
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 94733c2ea42..213da1d49e8 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -375,7 +375,7 @@ cleanup:
FALSE OK
TRUE error
*/
-bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
+int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
{
Item *fake_conds= 0;
SELECT_LEX *select_lex= &thd->lex->select_lex;
@@ -438,7 +438,7 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b)
TRUE Error
*/
-bool mysql_multi_delete_prepare(THD *thd)
+int mysql_multi_delete_prepare(THD *thd)
{
LEX *lex= thd->lex;
TABLE_LIST *aux_tables= (TABLE_LIST *)lex->auxiliary_table_list.first;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index d687ceff393..4da3c19bb3c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -110,7 +110,7 @@ static bool write_execute_load_query_log_event(THD *thd,
TRUE - error / FALSE - success
*/
-bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
+int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values,
enum enum_duplicates handle_duplicates, bool ignore,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 8bdbd812529..98e04e45bdd 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2500,10 +2500,10 @@ static void reset_one_shot_variables(THD *thd)
TRUE Error
*/
-bool
+int
mysql_execute_command(THD *thd)
{
- bool res= FALSE;
+ int res= FALSE;
bool need_start_waiting= FALSE; // have protection against global read lock
int up_result= 0;
LEX *lex= thd->lex;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index b00606aba4a..e7855946179 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1403,7 +1403,7 @@ error:
*/
static bool select_like_stmt_test(Prepared_statement *stmt,
- bool (*specific_prepare)(THD *thd),
+ int (*specific_prepare)(THD *thd),
ulong setup_tables_done_option)
{
DBUG_ENTER("select_like_stmt_test");
@@ -1441,7 +1441,7 @@ static bool select_like_stmt_test(Prepared_statement *stmt,
static bool
select_like_stmt_test_with_open_n_lock(Prepared_statement *stmt,
TABLE_LIST *tables,
- bool (*specific_prepare)(THD *thd),
+ int (*specific_prepare)(THD *thd),
ulong setup_tables_done_option)
{
DBUG_ENTER("select_like_stmt_test_with_open_n_lock");
@@ -1630,7 +1630,7 @@ error:
because mysql_handle_derived uses local tables lists.
*/
-static bool mysql_insert_select_prepare_tester(THD *thd)
+static int mysql_insert_select_prepare_tester(THD *thd)
{
SELECT_LEX *first_select= &thd->lex->select_lex;
TABLE_LIST *second_table= ((TABLE_LIST*)first_select->table_list.first)->
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6392f7c4299..bb3030a721c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -15806,6 +15806,14 @@ void st_select_lex::print(THD *thd, String *str)
/* go through join tree */
print_join(thd, str, &top_join_list);
}
+ else if (where)
+ {
+ /*
+ "SELECT 1 FROM DUAL WHERE 2" should not be printed as
+ "SELECT 1 WHERE 2": the 1st syntax is valid, but the 2nd is not.
+ */
+ str->append(STRING_WITH_LEN(" from DUAL "));
+ }
// Where
Item *cur_where= where;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 36d154181f8..a80319785bd 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4073,9 +4073,11 @@ bool get_schema_tables_result(JOIN *join,
{
result= 1;
join->error= 1;
+ tab->read_record.file= table_list->table->file;
table_list->schema_table_state= executed_place;
break;
}
+ tab->read_record.file= table_list->table->file;
table_list->schema_table_state= executed_place;
}
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 9c82bde9497..a8238141f25 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -716,7 +716,7 @@ static table_map get_table_map(List<Item> *items)
TRUE Error
*/
-bool mysql_multi_update_prepare(THD *thd)
+int mysql_multi_update_prepare(THD *thd)
{
LEX *lex= thd->lex;
TABLE_LIST *table_list= lex->query_tables;