1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-12325 Unexpected data type and truncation when using CTE

When creating a recursive CTE, the column types are taken from the
non recursive part of the CTE (this is according to the SQL standard).

This patch adds code to abort the CTE if the calculated values in the
recursive part does not fit in the fields in the created temporary table.

The new code only affects recursive CTE, so it should not cause any notable
problems for old applications.

Other things:
- Fixed that we get correct row numbers for warnings generated with
  WITH RECURSIVE

Reviewer: Alexander Barkov <bar@mariadb.com>
This commit is contained in:
Monty
2022-08-05 17:57:27 +03:00
parent 43c7f6a0f3
commit a5a9fcdfe4
6 changed files with 223 additions and 3 deletions

View File

@ -5691,10 +5691,12 @@ class select_union_recursive :public select_unit
or for the unit specifying a CTE that mutually recursive with this CTE.
*/
uint cleanup_count;
long row_counter;
select_union_recursive(THD *thd_arg):
select_unit(thd_arg),
incr_table(0), first_rec_table_to_update(0), cleanup_count(0)
incr_table(0), first_rec_table_to_update(0), cleanup_count(0),
row_counter(0)
{ incr_table_param.init(); };
int send_data(List<Item> &items);