Commit 4f29d776 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.3 into 10.4

parents a4996f95 3eadb135
......@@ -91,6 +91,9 @@ extern "C" {
#include <conio.h>
#else
#include <readline.h>
#if !defined(USE_LIBEDIT_INTERFACE)
#include <history.h>
#endif
#define HAVE_READLINE
#define USE_POPEN
#endif
......@@ -1042,22 +1045,6 @@ static const char *embedded_server_groups[]=
{ "server", "embedded", "mysql_SERVER", "mariadb_SERVER", 0 };
#ifdef HAVE_READLINE
/*
HIST_ENTRY is defined for libedit, but not for the real readline
Need to redefine it for real readline to find it
*/
#if !defined(HAVE_HIST_ENTRY)
typedef struct _hist_entry {
const char *line;
const char *data;
} HIST_ENTRY;
#endif
extern "C" int add_history(const char *command); /* From readline directory */
extern "C" int read_history(const char *command);
extern "C" int write_history(const char *command);
extern "C" HIST_ENTRY *history_get(int num);
extern "C" int history_length;
static int not_in_history(const char *line);
static void initialize_readline ();
static void fix_history(String *final_command);
......
......@@ -1154,6 +1154,40 @@ NULL 8
drop function agg_sum;
drop table t1;
#
# User defined aggregate functions not working correctly when the schema is changed
#
CREATE SCHEMA IF NOT EXISTS common_schema;
CREATE SCHEMA IF NOT EXISTS another_schema;
DROP FUNCTION IF EXISTS common_schema.add_ints |
Warnings:
Note 1305 FUNCTION common_schema.add_ints does not exist
CREATE FUNCTION common_schema.add_ints(int_1 INT, int_2 INT) RETURNS INT NO SQL
BEGIN
RETURN int_1 + int_2;
END |
DROP FUNCTION IF EXISTS common_schema.sum_ints |
Warnings:
Note 1305 FUNCTION common_schema.sum_ints does not exist
CREATE AGGREGATE FUNCTION common_schema.sum_ints(int_val INT) RETURNS INT
BEGIN
DECLARE result INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN result;
LOOP FETCH GROUP NEXT ROW;
SET result = common_schema.add_ints(result, int_val);
END LOOP;
END |
use common_schema;
SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
common_schema.sum_ints(seq)
3
USE another_schema;
SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
common_schema.sum_ints(seq)
3
drop database common_schema;
drop database another_schema;
USE test;
#
# MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW
#
CREATE PROCEDURE p1()
......@@ -1186,3 +1220,4 @@ STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
DO FETCH GROUP NEXT ROW;
ERROR HY000: Aggregate specific instruction (FETCH GROUP NEXT ROW) used in a wrong context
# End of 10.4 tests
......@@ -966,6 +966,40 @@ select i, sum(i) from t1 group by i with rollup;
drop function agg_sum;
drop table t1;
--echo #
--echo # User defined aggregate functions not working correctly when the schema is changed
--echo #
CREATE SCHEMA IF NOT EXISTS common_schema;
CREATE SCHEMA IF NOT EXISTS another_schema;
DELIMITER |;
DROP FUNCTION IF EXISTS common_schema.add_ints |
CREATE FUNCTION common_schema.add_ints(int_1 INT, int_2 INT) RETURNS INT NO SQL
BEGIN
RETURN int_1 + int_2;
END |
DROP FUNCTION IF EXISTS common_schema.sum_ints |
CREATE AGGREGATE FUNCTION common_schema.sum_ints(int_val INT) RETURNS INT
BEGIN
DECLARE result INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN result;
LOOP FETCH GROUP NEXT ROW;
SET result = common_schema.add_ints(result, int_val);
END LOOP;
END |
DELIMITER ;|
use common_schema;
SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
USE another_schema;
SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
drop database common_schema;
drop database another_schema;
USE test;
--echo #
--echo # MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW
......@@ -1016,3 +1050,5 @@ CREATE EVENT ev1
STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
DO FETCH GROUP NEXT ROW;
--echo # End of 10.4 tests
This diff is collapsed.
......@@ -715,6 +715,65 @@ SELECT 9223372036854775808 MOD -9223372036854775808;
SELECT -9223372036854775808 MOD 9223372036854775808;
SELECT -9223372036854775808 MOD -9223372036854775808;
--echo #
--echo # MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
--echo #
CREATE TABLE t1 (d decimal(5,5));
INSERT INTO t1 VALUES (0.55555);
SELECT TRUNCATE(d,0) FROM t1;
CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
SELECT * FROM t2;
SHOW CREATE TABLE t2;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
--echo #
CREATE TABLE t44 (d1 decimal(38,0) DEFAULT NULL);
INSERT INTO t44 VALUES (12345678901234567890123456789012345678);
SELECT FLOOR(d1) FROM t44;
CREATE TABLE t45 AS SELECT FLOOR(d1) FROM t44;
SELECT * FROM t45;
SHOW CREATE TABLE t45;
DROP TABLE t44, t45;
DELIMITER $$;
CREATE PROCEDURE p1(prec INT, scale INT)
BEGIN
DECLARE maxval VARCHAR(128) DEFAULT '';
SET @type= CONCAT('DECIMAL(', prec, ',', scale,')');
SET @stmt= CONCAT('CREATE TABLE t1 (a ', @type, ',b ', @type, 'unsigned)');
PREPARE stmt FROM @stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET maxval= CONCAT(REPEAT('9', prec-scale), '.', REPEAT('9',scale));
INSERT INTO t1 VALUES (maxval, maxval);
CREATE TABLE t2 AS SELECT a, b, FLOOR(a) AS fa, FLOOR(b) AS fb FROM t1;
SHOW CREATE TABLE t2;
SELECT * FROM t2;
DROP TABLE t1, t2;
END;
$$
CREATE PROCEDURE p2(prec INT)
BEGIN
DECLARE scale INT DEFAULT 0;
WHILE scale < prec AND scale <= 30 DO
CALL p1(prec, scale);
SET scale= scale + 1;
END WHILE;
END;
$$
DELIMITER ;$$
--vertical_results
CALL p2(38);
CALL p2(30);
--horizontal_results
DROP PROCEDURE p2;
DROP PROCEDURE p1;
--echo #
......@@ -1013,7 +1072,7 @@ DROP FUNCTION crc32_func;
PREPARE stmt1 FROM 'SELECT CRC32(?)';
SET @val = 'a';
EXECUTE stmt1 USING @val;
DEALLOCATE PREPARE stmt;
DEALLOCATE PREPARE stmt1;
# Test case for checksum on contents of a file
SET NAMES utf8;
......
......@@ -2599,3 +2599,14 @@ a
2
1
drop view v1;
#
# MDEV-22560 Crash on a table value constructor with an SP variable
#
BEGIN NOT ATOMIC
DECLARE a INT DEFAULT 0;
VALUES (a) UNION SELECT 1;
END;
$$
a
0
1
......@@ -1326,3 +1326,16 @@ create view v1 as with t(a) as (values (2), (1)) select a from t;
show create view v1;
select * from v1;
drop view v1;
--echo #
--echo # MDEV-22560 Crash on a table value constructor with an SP variable
--echo #
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE a INT DEFAULT 0;
VALUES (a) UNION SELECT 1;
END;
$$
DELIMITER ;$$
......@@ -861,6 +861,17 @@ SELECT * FROM t1;
DROP TABLE t1;
}
if (!$skip_update)
{
--echo #
--echo # MDEV-19622 Assertion failures in
--echo # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
--echo #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
}
--echo ##############################################################################
}
......@@ -1101,4 +1101,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
##############################################################################
......@@ -1148,4 +1148,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
##############################################################################
......@@ -1129,4 +1129,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
##############################################################################
......@@ -1148,4 +1148,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
##############################################################################
......@@ -2173,6 +2173,12 @@ longlong Item_func_bit_neg::val_int()
void Item_func_int_val::fix_length_and_dec_int_or_decimal()
{
/*
The INT branch of this code should be revised.
It creates too large data types, e.g.
CREATE OR REPLACE TABLE t2 AS SELECT FLOOR(9999999.999) AS fa;
results in a BININT(10) column, while INT(7) should probably be enough.
*/
ulonglong tmp_max_length= (ulonglong ) args[0]->max_length -
(args[0]->decimals ? args[0]->decimals + 1 : 0) + 2;
max_length= tmp_max_length > (ulonglong) UINT_MAX32 ?
......@@ -2187,6 +2193,9 @@ void Item_func_int_val::fix_length_and_dec_int_or_decimal()
*/
if (args[0]->max_length - args[0]->decimals >= DECIMAL_LONGLONG_DIGITS - 2)
{
fix_char_length(
my_decimal_precision_to_length_no_truncation(
args[0]->decimal_int_part(), 0, false));
set_handler(&type_handler_newdecimal);
}
else
......@@ -2303,6 +2312,8 @@ void Item_func_round::fix_length_and_dec_decimal(uint decimals_to_set)
set_handler(&type_handler_newdecimal);
unsigned_flag= args[0]->unsigned_flag;
decimals= decimals_to_set;
if (!precision)
precision= 1; // DECIMAL(0,0) -> DECIMAL(1,0)
max_length= my_decimal_precision_to_length_no_truncation(precision,
decimals,
unsigned_flag);
......
......@@ -1385,10 +1385,12 @@ Item_sum_sp::execute()
bool res;
uint old_server_status= thd->server_status;
/* We set server status so we can send a signal to exit from the
function with the return value. */
/*
We set server status so we can send a signal to exit from the
function with the return value.
*/
thd->server_status= SERVER_STATUS_LAST_ROW_SENT;
thd->server_status|= SERVER_STATUS_LAST_ROW_SENT;
res= Item_sp::execute(thd, &null_value, args, arg_count);
thd->server_status= old_server_status;
return res;
......
......@@ -4505,7 +4505,7 @@ sp_instr_agg_cfetch::execute(THD *thd, uint *nextp)
else
{
thd->spcont->pause_state= FALSE;
if (thd->server_status == SERVER_STATUS_LAST_ROW_SENT)
if (thd->server_status & SERVER_STATUS_LAST_ROW_SENT)
{
my_message(ER_SP_FETCH_NO_DATA,
ER_THD(thd, ER_SP_FETCH_NO_DATA), MYF(0));
......
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates.
Copyright (c) 2008, 2019, MariaDB Corporation
Copyright (c) 2008, 2020, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -2005,7 +2005,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
pos= my_b_tell(log);
if (repl_semisync_master.update_sync_header(info->thd,
(uchar*) packet->ptr(),
(uchar*) packet->c_ptr_safe(),
info->log_file_name + info->dirlen,
pos, &need_sync))
{
......@@ -2029,7 +2029,8 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
}
}
if (need_sync && repl_semisync_master.flush_net(info->thd, packet->c_ptr()))
if (need_sync && repl_semisync_master.flush_net(info->thd,
packet->c_ptr_safe()))
{
info->error= ER_UNKNOWN_ERROR;
return "Failed to run hook 'after_send_event'";
......
......@@ -52,7 +52,14 @@ bool fix_fields_for_tvc(THD *thd, List_iterator_fast<List_item> &li)
while ((item= it++))
{
if (item->fix_fields(thd, 0))
/*
Some items have already been fixed.
For example Item_splocal items get fixed in
Item_splocal::append_for_log(), which is called from subst_spvars()
while replacing their values to NAME_CONST()s.
So fix only those that have not been.
*/
if (item->fix_fields_if_needed(thd, 0))
DBUG_RETURN(true);
}
}
......
......@@ -7007,6 +7007,12 @@ void TABLE::mark_columns_needed_for_update()
}
need_signal= true;
}
else
{
if (found_next_number_field)
mark_auto_increment_column();
}
if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE)
{
/*
......
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