1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-24 19:42:23 +03:00
Commit Graph

50 Commits

Author SHA1 Message Date
36eba98817 MDEV-19123 Change default charset from latin1 to utf8mb4
Changing the default server character set from latin1 to utf8mb4.
2024-07-11 10:21:07 +04:00
51f9d62005 Merge branch '10.11' into 11.0 2023-08-09 07:53:48 +02:00
6bf8483cac Merge branch '10.5' into 10.6 2023-08-01 15:08:52 +02:00
7564be1352 Merge branch '10.4' into 10.5 2023-07-26 16:02:57 +02:00
7a5c984fa3 MDEV-20010 Equal on two RANK window functions create wrong result
The problematic query outlined a bug in window functions sorting
optimization. When multiple window functions are present in a query,
we sort the sorting key (as defined by PARTITION BY and ORDER BY) from
generic to specific.

SELECT RANK() OVER (ORDER BY const_col) as r1,
       RANK() OVER (ORDER BY const_col, a) as r2,
       RANK() OVER (PARTITION BY c) as r3,
       RANK() OVER (PARTITION BY c ORDER BY b) as r4
FROM table;

For these functions, the sorting we need to do for window function
computations are: [(const_col), (const_col, a)] and [(c), (c, b)].

Instead of doing 4 different sort order, the sorts grouped within [] are
compatible and we can use the most *specific* sort to cover both window
functions.

The bug was caused by an incorrect flagging of which sort is most
specific for a compatible group of functions. In our specific test case,
instead of picking (const_col, a) as the most specific sort, it would
only sort by (const_col), which lead to wrong results for rank function.
By ensuring that we pick the last sort key before an "incompatible sort"
flag is met in our "ordered array of sorting specifications", we
guarantee correct results.
2023-07-10 18:43:56 +03:00
2e431ff7e6 Merge 10.11 into 11.0 2023-02-16 13:34:45 +02:00
ffe0beca25 MDEV-30032: EXPLAIN FORMAT=JSON output: print costs
Basic printout for join and table execution costs.
2023-02-03 11:01:24 +03:00
a977054ee0 Merge branch '10.3' into 10.4 2023-01-28 18:22:55 +01:00
7fa02f5c0b Merge branch '10.4' into 10.5 2023-01-27 13:54:14 +01:00
dd24fa3063 Merge branch '10.3' into 10.4 2023-01-26 10:34:26 +01:00
074bef4dca MDEV-30248 Infinite sequence of recursive calls when processing embedded CTE
This patch fixes the patch for bug MDEV-30248 that unsatisfactorily
resolved the problem of resolution of references to CTE. In some cases
when such a reference has the same table name as the name of one of
CTEs containing this reference the reference could be resolved incorrectly
that led to an invalid select tree where units could be mutually dependent.
This in its turn could lead to an infinite sequence of recursive calls or
to falls into infinite loops.

The patch also removes LEX::resolve_references_to_cte_in_hanging_cte() as
with the new code for resolution of CTE references the call of this
function is not needed anymore.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2023-01-23 11:51:48 -08:00
8b9b4ab3f5 Merge 10.4 into 10.5 2023-01-03 17:08:42 +02:00
fb0808c450 Merge 10.3 into 10.4 2023-01-03 16:10:02 +02:00
c562ccf796 MDEV-30233 DROP DATABASE test fails: Directory not empty
Some tests drop the default mtr database "test". This may fail due
to the directory not being empty. InnoDB may not delete all tables
immediately, due to the "background drop table queue" or its
replacement in commit 1bd681c8b3
(the purge of history would clean up after a DDL operation during
which the server was killed).

Let us try to avoid "drop database test" whenever it is easily possible.
Where it is not, SET GLOBAL innodb_max_purge_lag_wait=0 will ensure
that the replacement of the "background drop table queue" will have
completed its job.
2022-12-15 11:14:23 +02:00
3a2116241b Merge branch '10.4' into 10.5 2022-10-02 14:38:13 +02:00
d4f6d2f08f Merge branch '10.3' into 10.4 2022-10-01 23:07:26 +02:00
28ae361857 MDEV-29361 Infinite recursive calls when detecting CTE dependencies
This patch resolves the problem of improper name resolution of table
references to embedded CTEs for some queries. This improper binding could
lead to
  - infinite sequence of calls of recursive functions
  - crashes due to resolution of null pointers
  - wrong result sets returned by queries
  - bogus error messages

If the definition of a CTE contains with clauses then such CTE is called
embedding CTE while CTEs from the with clauses are called embedded CTEs.
If a table reference used in the definition of an embedded CTE cannot be
resolved within the unit that contains this reference it still may be
resolved against a CTE definition from the with clause with one of the
embedding CTEs.
A table reference can be resolved against a CTE definition if it used in
the the scope of this definition and it refers to the name of the CTE.
Table reference t is in the scope of the CTE definition of CTE cte if
- the definition of cte is an element of a with clause declared as
  RECURSIVE and the reference t belongs either to the unit to which
  this with clause is attached or to one of the elements of this clause
- the definition of cte is an element of a with clause without RECURSIVE
  specifier and the reference t belongs either to the unit to which this
  with clause is attached or to one of the elements from this clause that
  are placed before the definition of cte.
If a table reference can be resolved against several CTE definitions then
it is bound to the most embedded.

The code before this patch not always resolved table references used in
embedded CTE according to the above rules.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2022-09-28 22:33:05 -07:00
1ac0bce36e Merge branch '10.4' into 10.5 2022-08-10 12:24:31 +02:00
65e8506ca9 Merge branch '10.3' into bb-10.4-release 2022-08-10 12:21:08 +02:00
a5a9fcdfe4 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>
2022-08-08 11:19:55 +03:00
13076bd314 Avoid some failures WITH_MSAN 2022-02-28 14:05:50 +02:00
ae6bdc6769 Merge branch '10.4' into 10.5 2021-07-31 23:19:51 +02:00
7841a7eb09 Merge branch '10.3' into 10.4 2021-07-31 22:59:58 +02:00
f50eb0d398 Merge 10.2 into 10.3 2021-07-27 10:47:17 +03:00
b50ea90063 Merge 10.2 into 10.3 2021-07-22 18:57:54 +03:00
6190a02f35 Merge branch '10.2' into 10.3 2021-07-21 20:11:07 +02:00
b4ec3313f6 Merge 10.4 into 10.5 2021-07-20 09:32:11 +03:00
78735dcaf7 MDEV-26108 Crash with query referencing twice CTE that uses embedded recursive CTE
This bug could affect queries that had at least two references to a CTE that
used an embedded recursive CTE.
Starting from version 10.4 some code in With_element::clone_parsed_spec()
that assumed a certain order of selects after parsing the specification of
a CTE became not valid anymore. It could lead to global select lists where
some selects were missing. If a missing CTE happened to belong to the
recursive part of a recursive CTE some recursive table references were not
set as references to materialized derived tables and this caused a crash of
the server.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2021-07-08 17:47:17 -07:00
02e7bff882 Merge commit '10.4' into 10.5 2021-01-06 10:53:00 +01:00
25561435e0 Merge branch '10.2' into 10.3 2020-12-23 19:28:02 +01:00
ca331bdcda MDEV-23619: Merge 10.4 into 10.5 2020-11-13 22:06:05 +02:00
6fed6de93f MDEV-23619: Merge 10.2 into 10.3 2020-11-13 20:41:07 +02:00
d3681335b1 Merge 10.4 into 10.5 2020-06-08 12:58:11 +03:00
befb0bed68 Merge 10.2 into 10.3 2020-06-08 11:09:49 +03:00
0e69f601aa Merge 10.4 into 10.5 2020-06-07 12:22:06 +03:00
b3e395a13e Merge 10.2 into 10.3 2020-06-06 18:50:25 +03:00
cd41ffe1f1 MDEV-19713 Remove big_tables system variable
mark big_tables deprecated, the server can put temp tables on disk
as needed avoiding "table full" errors.

in case someone would really need to force a tmp table to be created
on disk from the start and for testing allow tmp_memory_table_size
to be set to 0.

fix tests to use that instead (and add a test that it actually
works).

make sure in-memory TREE size limit is never 0 (it's [ab]using
tmp_memory_table_size at the moment)

remove few sys_vars.*_basic tests
2019-09-28 19:21:14 +02:00
a071e0e029 Merge branch '10.2' into 10.3 2019-09-03 13:17:32 +03:00
56d3a0e73b MDEV-17967 Add a solution of the 8 queens problem to the regression test for CTE 2018-12-12 10:39:17 +01:00
b6f203984b Merge 10.2 into 10.3 2018-12-04 13:18:14 +02:00
2767cb76d4 Merge 10.2 into 10.3 2018-11-08 09:39:37 +02:00
57e0da50bb Merge branch '10.2' into 10.3 2018-09-28 16:37:06 +02:00
934d5f95d3 Merge 10.2 into 10.3 2018-07-06 22:18:35 +03:00
b4c377f215 Merge 10.2 into 10.3 2018-07-05 17:08:44 +03:00
4ec8598c1d Merge branch 'github/10.2' into 10.3 2018-05-22 11:47:09 +02:00
e74181e3c2 MDEV-15159 NULL is treated as 0 in CTE
Forced columns of recursive CTEs to be nullable. SQL standard
requires this only from recursive columns, but in our code
so far we do not differentiate between recursive and non-recursive
columns when aggregating types of the union that specifies a
recursive CTE.
2018-05-14 14:38:17 -07:00
1b8749f73b Merge 10.2 into 10.3 2018-05-08 17:18:55 +03:00
9477a2a9ba Merge 10.2 into 10.3 2018-04-25 07:59:25 +03:00
d71a8855ee Merge 10.2 to 10.3
Temporarily disable main.cte_recursive due to hang in
an added test related to MDEV-15575.
2018-04-19 15:23:21 +03:00
a7abddeffa Create 'main' test directory and move 't' and 'r' there 2018-03-29 13:59:44 +03:00