diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index e21e7903459..a95308b0e66 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -345,4 +345,19 @@ SELECT COALESCE(a) = COALESCE(b) FROM t1; COALESCE(a) = COALESCE(b) 1 DROP TABLE t1; -End of tests +# +# Bug #54461: crash with longblob and union or update with subquery +# +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +LEAST(a, (SELECT b FROM t1 LIMIT 1)) +1 +2 +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +GREATEST(a, (SELECT b FROM t1 LIMIT 1)) +2 +3 +1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index a60eb9cf845..5d93813a9ff 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -478,4 +478,17 @@ SELECT COALESCE(a) = COALESCE(b) FROM t1; DROP TABLE t1; ---echo End of tests + +--echo # +--echo # Bug #54461: crash with longblob and union or update with subquery +--echo # + +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); + +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 675910d2b20..ba62062ebc0 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -83,7 +83,9 @@ void my_print_stacktrace(uchar* stack_bottom __attribute__((unused)), #if BACKTRACE_DEMANGLE -char __attribute__ ((weak)) *my_demangle(const char *mangled_name, int *status) +char __attribute__ ((weak)) * +my_demangle(const char *mangled_name __attribute__((unused)), + int *status __attribute__((unused))) { return NULL; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 833eac6893b..7812460bd2b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2531,6 +2531,8 @@ void Item_func_min_max::fix_length_and_dec() decimals, unsigned_flag)); } + else if (cmp_type == REAL_RESULT) + max_length= float_length(decimals); cached_field_type= agg_field_type(args, arg_count); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 59a1085728a..79d91a461db 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1436,8 +1436,6 @@ int lex_one_token(void *arg, void *yythd) } else { - const char* version_mark= lip->get_ptr() - 1; - DBUG_ASSERT(*version_mark == '!'); /* Patch and skip the conditional comment to avoid it being propagated infinitely (eg. to a slave). @@ -1446,7 +1444,6 @@ int lex_one_token(void *arg, void *yythd) comment_closed= ! consume_comment(lip, 1); if (! comment_closed) { - DBUG_ASSERT(pcom == version_mark); *pcom= '!'; } /* version allowed to have one level of comment inside. */