mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
Merge remote-tracking branch 'origin/10.3' into bb-10.3-cc
This commit is contained in:
commit
3a50a13071
14 changed files with 138 additions and 15 deletions
|
@ -1123,3 +1123,33 @@ t1 CREATE TABLE `t1` (
|
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
DROP FUNCTION f1;
|
||||
#
|
||||
# MDEV-14520: Custom aggregate functions work incorrectly with WITH ROLLUP clause
|
||||
#
|
||||
create aggregate function agg_sum(x INT) returns INT
|
||||
begin
|
||||
declare z int default 0;
|
||||
declare continue handler for not found return z;
|
||||
loop
|
||||
fetch group next row;
|
||||
set z= z+x;
|
||||
end loop;
|
||||
end|
|
||||
create table t1 (i int);
|
||||
insert into t1 values (1),(2),(2),(3);
|
||||
select i, agg_sum(i) from t1 group by i with rollup;
|
||||
i agg_sum(i)
|
||||
1 1
|
||||
2 4
|
||||
3 3
|
||||
NULL 8
|
||||
#
|
||||
# Compare with
|
||||
select i, sum(i) from t1 group by i with rollup;
|
||||
i sum(i)
|
||||
1 1
|
||||
2 4
|
||||
3 3
|
||||
NULL 8
|
||||
drop function agg_sum;
|
||||
drop table t1;
|
||||
|
|
|
@ -939,3 +939,29 @@ SHOW CREATE TABLE t1;
|
|||
DROP TABLE t1;
|
||||
DROP FUNCTION f1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-14520: Custom aggregate functions work incorrectly with WITH ROLLUP clause
|
||||
--echo #
|
||||
|
||||
--delimiter |
|
||||
create aggregate function agg_sum(x INT) returns INT
|
||||
begin
|
||||
declare z int default 0;
|
||||
declare continue handler for not found return z;
|
||||
loop
|
||||
fetch group next row;
|
||||
set z= z+x;
|
||||
end loop;
|
||||
end|
|
||||
--delimiter ;
|
||||
|
||||
create table t1 (i int);
|
||||
insert into t1 values (1),(2),(2),(3);
|
||||
select i, agg_sum(i) from t1 group by i with rollup;
|
||||
--echo #
|
||||
--echo # Compare with
|
||||
select i, sum(i) from t1 group by i with rollup;
|
||||
|
||||
# Cleanup
|
||||
drop function agg_sum;
|
||||
drop table t1;
|
||||
|
|
|
@ -1301,3 +1301,24 @@ Pos Instruction
|
|||
28 jump 4
|
||||
29 cpop 1
|
||||
DROP PROCEDURE p1;
|
||||
#
|
||||
# MDEV-14623: Output of show function code does not show FETCH GROUP NEXT ROW
|
||||
# for custom aggregates
|
||||
#
|
||||
create aggregate function f1(x INT) returns int
|
||||
begin
|
||||
declare continue handler for not found return 0;
|
||||
loop
|
||||
fetch group next row;
|
||||
insert into t2 (sal) values (x);
|
||||
end loop;
|
||||
end|
|
||||
show function code f1;
|
||||
Pos Instruction
|
||||
0 hpush_jump 2 1 CONTINUE
|
||||
1 freturn int 0
|
||||
2 agg_cfetch
|
||||
3 stmt 5 "insert into t2 (sal) values (x)"
|
||||
4 jump 2
|
||||
5 hpop 1
|
||||
drop function f1;
|
||||
|
|
|
@ -927,3 +927,22 @@ $$
|
|||
DELIMITER ;$$
|
||||
SHOW PROCEDURE CODE p1;
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-14623: Output of show function code does not show FETCH GROUP NEXT ROW
|
||||
--echo # for custom aggregates
|
||||
--echo #
|
||||
|
||||
delimiter |;
|
||||
create aggregate function f1(x INT) returns int
|
||||
begin
|
||||
declare continue handler for not found return 0;
|
||||
loop
|
||||
fetch group next row;
|
||||
insert into t2 (sal) values (x);
|
||||
end loop;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
show function code f1;
|
||||
drop function f1;
|
||||
|
|
|
@ -126,7 +126,6 @@ a b
|
|||
15 o
|
||||
Warnings:
|
||||
Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
|
||||
Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 3 to 2
|
||||
# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -152,7 +151,6 @@ a b
|
|||
15 o
|
||||
Warnings:
|
||||
Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
|
||||
Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 2 to 3
|
||||
# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -177,7 +175,6 @@ a b
|
|||
15 o
|
||||
Warnings:
|
||||
Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
|
||||
Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 4 to 3
|
||||
# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -206,7 +203,6 @@ a b
|
|||
15 o
|
||||
Warnings:
|
||||
Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
|
||||
Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 3 to 4
|
||||
# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
# If you got a difference in error message, just add it to rdiff file
|
||||
|
|
11
sql/item.cc
11
sql/item.cc
|
@ -2802,6 +2802,17 @@ Item_sp::Item_sp(THD *thd, Name_resolution_context *context_arg,
|
|||
memset(&sp_mem_root, 0, sizeof(sp_mem_root));
|
||||
}
|
||||
|
||||
Item_sp::Item_sp(THD *thd, Item_sp *item):
|
||||
context(item->context), m_name(item->m_name),
|
||||
m_sp(item->m_sp), func_ctx(NULL), sp_result_field(NULL)
|
||||
{
|
||||
dummy_table= (TABLE*) thd->calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE) +
|
||||
sizeof(Query_arena));
|
||||
dummy_table->s= (TABLE_SHARE*) (dummy_table+1);
|
||||
sp_query_arena= (Query_arena *) (dummy_table->s + 1);
|
||||
memset(&sp_mem_root, 0, sizeof(sp_mem_root));
|
||||
}
|
||||
|
||||
const char *
|
||||
Item_sp::func_name(THD *thd) const
|
||||
{
|
||||
|
|
|
@ -4658,6 +4658,7 @@ public:
|
|||
*/
|
||||
Field *sp_result_field;
|
||||
Item_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name_arg);
|
||||
Item_sp(THD *thd, Item_sp *item);
|
||||
const char *func_name(THD *thd) const;
|
||||
void cleanup();
|
||||
bool sp_check_access(THD *thd);
|
||||
|
|
|
@ -1269,6 +1269,12 @@ Item_sum_sp::Item_sum_sp(THD *thd, Name_resolution_context *context_arg,
|
|||
m_sp= sp;
|
||||
}
|
||||
|
||||
Item_sum_sp::Item_sum_sp(THD *thd, Item_sum_sp *item):
|
||||
Item_sum(thd, item), Item_sp(thd, item)
|
||||
{
|
||||
maybe_null= item->maybe_null;
|
||||
quick_group= item->quick_group;
|
||||
}
|
||||
|
||||
bool
|
||||
Item_sum_sp::fix_fields(THD *thd, Item **ref)
|
||||
|
@ -1400,6 +1406,14 @@ Item_sum_sp::func_name() const
|
|||
return Item_sp::func_name(thd);
|
||||
}
|
||||
|
||||
Item* Item_sum_sp::copy_or_same(THD *thd)
|
||||
{
|
||||
Item_sum_sp *copy_item= new (thd->mem_root) Item_sum_sp(thd, this);
|
||||
copy_item->init_result_field(thd, max_length, maybe_null,
|
||||
©_item->null_value, ©_item->name);
|
||||
return copy_item;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
** reset and add of sum_func
|
||||
***********************************************************************/
|
||||
|
|
|
@ -1292,6 +1292,7 @@ public:
|
|||
|
||||
Item_sum_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name,
|
||||
sp_head *sp, List<Item> &list);
|
||||
Item_sum_sp(THD *thd, Item_sum_sp *item);
|
||||
|
||||
enum Sumfunctype sum_func () const
|
||||
{
|
||||
|
@ -1361,6 +1362,7 @@ public:
|
|||
}
|
||||
Item *get_copy(THD *thd)
|
||||
{ return get_item_copy<Item_sum_sp>(thd, this); }
|
||||
Item *copy_or_same(THD *thd);
|
||||
};
|
||||
|
||||
/* Items to get the value of a stored sum function */
|
||||
|
|
|
@ -4409,7 +4409,7 @@ sp_instr_cfetch::print(String *str)
|
|||
int
|
||||
sp_instr_agg_cfetch::execute(THD *thd, uint *nextp)
|
||||
{
|
||||
DBUG_ENTER("sp_instr_cfetch::execute");
|
||||
DBUG_ENTER("sp_instr_agg_cfetch::execute");
|
||||
int res= 0;
|
||||
if (!thd->spcont->instr_ptr)
|
||||
{
|
||||
|
@ -4434,7 +4434,16 @@ sp_instr_agg_cfetch::execute(THD *thd, uint *nextp)
|
|||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
void
|
||||
sp_instr_agg_cfetch::print(String *str)
|
||||
{
|
||||
|
||||
uint rsrv= SP_INSTR_UINT_MAXLEN+11;
|
||||
|
||||
if (str->reserve(rsrv))
|
||||
return;
|
||||
str->qs_append(STRING_WITH_LEN("agg_cfetch"));
|
||||
}
|
||||
|
||||
/*
|
||||
sp_instr_cursor_copy_struct class functions
|
||||
|
|
|
@ -1957,7 +1957,7 @@ public:
|
|||
|
||||
virtual int execute(THD *thd, uint *nextp);
|
||||
|
||||
virtual void print(String *str){};
|
||||
virtual void print(String *str);
|
||||
}; // class sp_instr_agg_cfetch : public sp_instr
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
call mtr.add_suppression("Found 2 prepared XA transactions");
|
||||
FLUSH TABLES;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
@@ -18,12 +24,18 @@
|
||||
@@ -18,12 +24,17 @@
|
||||
connection default;
|
||||
XA RECOVER;
|
||||
formatID gtrid_length bqual_length data
|
||||
|
@ -28,6 +28,5 @@
|
|||
4
|
||||
+Warnings:
|
||||
+Error 145 Table './test/t1' is marked as crashed and should be repaired
|
||||
+Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
+Error 1034 1 client is using or hasn't closed the table properly
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- suite/storage_engine/parts/repair_table.result 2017-08-28 19:29:20.491633306 +0300
|
||||
+++ suite/storage_engine/parts/repair_table.reject 2017-08-28 19:34:41.723633059 +0300
|
||||
@@ -1,236 +1,116 @@
|
||||
@@ -1,232 +1,116 @@
|
||||
call mtr.add_suppression("Table '.*t1.*' is marked as crashed and should be repaired");
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
|
||||
|
@ -192,7 +192,6 @@
|
|||
-15 o
|
||||
-Warnings:
|
||||
-Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
|
||||
-Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
-Error 1034 Number of rows changed from 3 to 2
|
||||
-# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
-# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -218,7 +217,6 @@
|
|||
-15 o
|
||||
-Warnings:
|
||||
-Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
|
||||
-Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
-Error 1034 Number of rows changed from 2 to 3
|
||||
-# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
-# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -243,7 +241,6 @@
|
|||
-15 o
|
||||
-Warnings:
|
||||
-Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
|
||||
-Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
-Error 1034 Number of rows changed from 4 to 3
|
||||
-# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
-# If you got a difference in error message, just add it to rdiff file
|
||||
|
@ -272,7 +269,6 @@
|
|||
-15 o
|
||||
-Warnings:
|
||||
-Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
|
||||
-Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
-Error 1034 Number of rows changed from 3 to 4
|
||||
-# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
|
||||
-# If you got a difference in error message, just add it to rdiff file
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
call mtr.add_suppression("Found 2 prepared XA transactions");
|
||||
FLUSH TABLES;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
@@ -18,12 +24,18 @@
|
||||
@@ -18,12 +24,17 @@
|
||||
connection default;
|
||||
XA RECOVER;
|
||||
formatID gtrid_length bqual_length data
|
||||
|
@ -28,6 +28,5 @@
|
|||
4
|
||||
+Warnings:
|
||||
+Error 145 Table './mrg/t1' is marked as crashed and should be repaired
|
||||
+Error 1194 Table 't1' is marked as crashed and should be repaired
|
||||
+Error 1034 1 client is using or hasn't closed the table properly
|
||||
DROP TABLE t1;
|
||||
|
|
Loading…
Add table
Reference in a new issue