1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-26 11:48:52 +03:00

229 Commits

Author SHA1 Message Date
Gagan Goel
7f456e58cc MCOL-4868 UPDATE on a ColumnStore table containing an IN-subquery
on a non-ColumnStore table does not work.

As part of MCOL-4617, we moved the in-to-exists predicate creation
and injection from the server into the engine. However, when query
with an IN Subquery contains a non-ColumnStore table, the server
still performs the in-to-exists predicate transformation for the
foreign engine table. This caused ColumnStore's execution plan to
contain incorrect WHERE predicates. As a fix, we call
mutate_optimizer_flags() for the WRITE lock, in addition to the READ
table lock. And in mutate_optimizer_flags(), we change the optimizer
flag from OPTIMIZER_SWITCH_IN_TO_EXISTS to OPTIMIZER_SWITCH_MATERIALIZATION.
2021-12-16 23:11:26 +00:00
Gagan Goel
340a90fc8d MCOL-4874 Crossengine JOIN involving a ColumnStore table and a
wide decimal column in a non-ColumnStore table throws an exception.

ROW::getSignedNullValue() method does not support wide decimal fields
yet. To fix this exception, we remove the call to this method from
CrossEngineStep::setField().
2021-12-08 22:26:52 +00:00
Alexander Barkov
fa9f18553a MCOL-4728 Query with unusual use of aggregate functions on ColumnStore table crashes MariaDB Server
After an AggreateColumn corresponding to SUM(1+1) is created,
it is pushed to the list:

    gwi.count_asterisk_list.push_back(ac)

Later, in getSelectPlan(), the expression SUM(1+1) was erroneously
treated as a constant:

  if (!hasNonSupportItem && !nonConstFunc(ifp) && !(parseInfo & AF_BIT) && tmpVec.size() == 0)
  {
     srcp.reset(buildReturnedColumn(item, gwi, gwi.fatalParseError));

This code freed the original AggregateColumn and replaced to a ConstantColumn.

But gwi.count_asterisk_list still pointer to the freed AggregateColumn().

The expression SUM(1+1) was treated as a constant because tmpVec
was empty due to a bug in this code:

                    // special handling for count(*). This should not be treated as constant.
                    if (isp->argument_count() == 1 &&
                            ( sfitempp[0]->type() == Item::CONST_ITEM &&
                                (sfitempp[0]->cmp_type() == INT_RESULT ||
                                 sfitempp[0]->cmp_type() == STRING_RESULT ||
                                 sfitempp[0]->cmp_type() == REAL_RESULT ||
                                 sfitempp[0]->cmp_type() == DECIMAL_RESULT)
                            )
                        )
                    {
                        field_vec.push_back((Item_field*)item); //dummy

Notice, it handles only aggregate functions with explicit literals
passed as an argument, while it does not handle constant expressions
such as 1+1.

Fix:

- Adding new classes ConstantColumnNull, ConstantColumnString,
  ConstantColumnNum, ConstantColumnUInt, ConstantColumnSInt,
  ConstantColumnReal, ValStrStdString, to reuse the code easier.

- Moving a part of the code from the case branch handling CONST_ITEM
  in buildReturnedColumn() into a new function
  newConstantColumnNotNullUsingValNativeNoTz(). This
  makes the code easier to read and to reuse in the future.

- Adding a new function newConstantColumnMaybeNullFromValStrNoTz().
  Removing dulplicate code from !!!four!!! places, using the new
  function instead.

- Adding a function isSupportedAggregateWithOneConstArg() to
  properly catch all constant expressions. Using the new function parse_item()
  in the code commented as "special handling for count(*)".
  Now it pushes all constant expressions to field_vec, not only
  explicit literals.

- Moving a part of the code from buildAggregateColumn()
  to a helper function processAggregateColumnConstArg().
  Using processAggregateColumnConstArg() in the CONST_ITEM
  and NULL_ITEM branches.

- Adding a new branch in buildReturnedColumn() handling FUNC_ITEM.
  If a function has constant arguments, a ConstantColumn() is
  immediately created, without going to
  buildArithmeticColumn()/buildFunctionColumn().

- Reusing isSupportedAggregateWithOneConstArg()
  and processAggregateColumnConstArg() in buildAggregateColumn().
  A new branch catches aggregate function has only one constant argument
  and immediately creates a single ConstantColumn without
  traversing to the argument sub-components.
2021-09-21 14:00:56 +04:00
Roman Nozdrin
83c0c84aea
This patch adds MTR's --sorted_result option to make the tests outputs deterministic (#2107) 2021-09-01 23:43:29 +03:00
David Hall
d1ef83c0f4 MCOL-3741 dev Change mtr IDB-xxx error codes to MCS-xxxx 2021-08-10 12:01:36 -05:00
Alexander Barkov
c16b0f6ad7
MCOL-4823 WHERE char_col<varchar_col returns a wrong result of a large table (#2060)
SCommand StrFilterCmd::duplicate() missed these two lines:

    filterCmd->leftColType = leftColType;
    filterCmd->rightColType = rightColType;

which exist in the parent's FilterCommand::duplicate().

Rewriting the code to avoid duplication by using more inherited
methods/constructors. This reduces the probability of similar bugs
in the future.
2021-08-03 11:53:05 +03:00
David Hall
a202bda485 MCOL-4719 iterate into subquery looking for windowfunctions
When an outer query filter accesses an subquery column that contains an aggregate or a window function, certain optimizations can't be performed. We had been looking at the surface of the returned column. We now iterate into any functions or operations looking for aggregates and window functions.
2021-07-22 13:56:21 -05:00
benthompson15
6e45c125c7
Merge pull request #2047 from dhall-MariaDB/develop
Disable the non-deterministic mcs211 test
2021-07-12 17:53:33 -05:00
David.Hall
10cc1159a2
Merge pull request #2040 from tntnatbry/MCOL-641-move-mtr-tests
MCOL-641 Move MTR tests from future/ to basic/
2021-07-12 15:47:45 -05:00
David.Hall
2b37c2c7bc
Merge pull request #2046 from denis0x0D/MCOL-4786_fix_regression
[MCOL-4786] Fix filter comparison.
2021-07-12 13:51:42 -05:00
David Hall
497d12e08f Remove the non-deterministic mcs211 test 2021-07-12 12:26:41 -05:00
Denis Khalikov
dc51dbf6cf [MCOL-4786] Fix filter comparison.
Compare ParseTree by dereferencing pointers.
2021-07-12 19:18:02 +03:00
Gagan Goel
78dbf3a7e1 MCOL-641 Move MTR tests from future/ to basic/ 2021-07-12 13:01:45 +00:00
Gagan Goel
3d557a2f1e
Merge pull request #2044 from dhall-MariaDB/MCOL-3738
MCOL-3738 COUNT(DISTINCT) with multiple parms
2021-07-12 07:34:56 -04:00
Sergey Zefirov
69eec2cc0f MCOL-2044 Test sources made more resilient 2021-07-09 18:21:08 +03:00
David Hall
76607be63a MCOL-3738 COUNT(DISTINCT) with multiple parms
Fixed regression
Added a few more mtr tests
2021-07-09 09:07:03 -05:00
Roman Nozdrin
4d265472ee
Merge pull request #2036 from mariadb-SergeyZefirov/MCOL-4766-UPDATE-INSERT-in-a-transaction-does-not-revert-back-extent-ranges-on-a-rollback
MCOL-4766 ROLLBACK kept ranges changed inside rolled back transaction
2021-07-09 16:33:06 +03:00
Denis Khalikov
adace6e0c7 MCOL-4786 Fix wrong comparison for the filters.
Fix wrong comparison for the filters while creating case function.
2021-07-09 12:18:26 +03:00
Sergey Zefirov
9e0851e4cf MCOL-4766 ROLLBACK kept ranges changed inside rolled back transaction
Now ROLLBACK drops ranges to INVALID state which makes engine to rescan
blocks and discover correct ranges.
2021-07-07 18:16:56 +03:00
Gagan Goel
74bdf522d1
Merge pull request #1999 from mariadb-SergeyZefirov/MCOL-4741-in-like-equal-returns-different-result
MCOL-4741 Fix extentmap handling of string prefixes encoded as 64-bit integers
2021-07-05 04:33:32 -04:00
David.Hall
237cad347f
MCOL-4758 Limit LONGTEXT and LONGBLOB to 16MB (#1995)
MCOL-4758 Limit LONGTEXT and LONGBLOB to 16MB

Also add the original test case from MCOL-3879.
2021-07-05 02:09:41 -04:00
Denis Khalikov
a576981db0 MCOL-1205 Remove old tests.
This patch removes some tests which check `circular join` error.
2021-07-03 15:29:35 +03:00
benthompson15
0553093986
Merge pull request #2023 from dhall-MariaDB/MCOL-4789
MCOL-4789 mcs51_cpimport_select_from is not deterministic
2021-07-02 13:31:54 -05:00
Sergey Zefirov
c58136a32d MCOL-4741 in/like/equal(=) operations differ in results
This is due to signedness in the string range comparison in extentmap
and unsignedness everywhere else.
2021-07-02 19:22:46 +03:00
Denis Khalikov
1d5f309b8f MCOL-1205 Support queries with circular joins
This patch adds support for queries with circular joins.
Currently support added for inner joins only.
2021-07-02 18:37:07 +03:00
David Hall
20d90c6293 MCOL-4789 mcs51_cpimport_select_from is not deterministic
Testing script was left in.
2021-07-02 09:21:31 -05:00
Roman Nozdrin
6dc356ed60
Merge pull request #1989 from denis0x0D/MCOL-4713
MCOL-4713 Analyze table implementation.
2021-07-02 16:17:07 +03:00
Denis Khalikov
c20015a7b2 MCOL-4713 Analyze table implementation. 2021-07-02 12:37:12 +03:00
David Hall
6ae64bc750 MCOL-4789 Make mcs51_cpimport_select_from deterministic 2021-07-01 16:29:37 -05:00
Roman Nozdrin
325bb6c9e0
Merge pull request #1986 from tntnatbry/MCOL-1482
MCOL-1482 An UPDATE operation on a non-ColumnStore table involving a cross-engine join
2021-07-01 14:25:32 +03:00
David.Hall
132146b9c8
Mcol 3738 Allow COUNT(DISTINCT to have multiple parms) (#2002)
* MCOL-3738 allow COUNT(DISTINCT) multiple parameters
Changes in the way tupleaggregatestep sets up the aggregate arrays.

* MCOL-3738 mtr test
2021-06-28 20:14:44 +03:00
Gagan Goel
49255f5cbd MCOL-1482 An UPDATE operation on a non-ColumnStore table involving a
cross-engine join with a ColumnStore table errors out.

ColumnStore cannot directly update a foreign table. We detect whether
a multi-table UPDATE operation is performed on a foreign table, if so,
do not create the select_handler and let the server execute the UPDATE
operation instead.
2021-06-25 15:27:54 +00:00
Roman Nozdrin
2de4888899
Merge pull request #1990 from drrtuy/MCOL-4173_9
MCOL-4173 This patch adds support for wide-DECIMAL INNER, OUTER, SEMI…
2021-06-24 16:15:07 +03:00
Roman Nozdrin
6620d873fd
Merge pull request #1927 from denis0x0D/MCOL-4407
MCOL-4407 and condtion does not work when HWM > columnstore_string_san_threshold - 1
2021-06-24 15:58:35 +03:00
Roman Nozdrin
bed0b7c6bc MCOL-4173 This patch adds support for wide-DECIMAL INNER, OUTER, SEMI, functional JOINs
based on top of TypelessData
2021-06-24 08:07:23 +00:00
Denis Khalikov
8dd2f2937c MCOL-4407 and condtion does not work when HWM > columnstore_string_scan_threshold - 1 2021-06-21 14:04:26 +03:00
Roman Nozdrin
96f2a55eea
Merge pull request #1970 from tntnatbry/MCOL-4525
MCOL-4525 Implement columnstore_select_handler=AUTO.
2021-06-14 10:43:34 +03:00
Gagan Goel
5155a08a67
Merge pull request #1987 from mariadb-corporation/bar-develop-MCOL-4700
MCOL-4700 Wrong result of a UNION for INT and INT UNSIGNED
2021-06-14 02:36:10 -04:00
Alexander Barkov
67449418ed MCOL-4700 Wrong result of a UNION for INT and INT UNSIGNED 2021-06-11 19:31:51 +04:00
Gagan Goel
e3d8100150 MCOL-4525 Implement columnstore_select_handler=AUTO.
This feature allows a query execution to fallback to the server,
in case query execution using the select_handler (SH) fails. In case
of fallback, a warning message containing the original reason for
query failure using SH is generated.

To accomplish this task, SH execution is moved to an earlier step when
we create the SH in create_columnstore_select_handler(), instead of the
previous call to SH execution in ha_columnstore_select_handler::init_scan().
This requires some pre-requisite steps that occur in the server in
JOIN::optimize() and JOIN::exec() to be performed before starting SH execution.

In addition, missing test cases from MCOL-424 are also added to the MTR suite,
and the corresponding fix using disable_indices_for_CEJ() is reverted back
since the original fix now appears to be redundant.
2021-06-11 11:35:34 +00:00
Alexander Barkov
d00ace2398 MCOL-4757 Empty set in SELECT * INFORMATION_SCHEMA.COLUMNSTORE_TABLES WHERE TABLE_NAME='t1' 2021-06-11 12:00:23 +04:00
Roman Nozdrin
47e9fc0312
Merge pull request #1922 from denis0x0D/MCOL-4685
MCOL-4685: Eliminate some irrelevant settings (uncompressed data and extents per file)
2021-06-06 16:00:29 +03:00
Gagan Goel
3537c0d635
Merge pull request #1962 from tntnatbry/MCOL-4642
MCOL-4642 NOT IN subquery containing an isnull in the OR predicate crashes server.
2021-06-04 07:18:46 -04:00
Alexander Barkov
a04ea450cd MCOL-4749 mcs247_from_unixtime_funtion fails if local time zone is not GMT 2021-06-04 11:53:46 +02:00
Alexander Barkov
107e417715
Merge pull request #1967 from mariadb-corporation/bar-develop-MCOL-4748
MCOL-4748 mtr mcs229_data_compression_type fails without --extern
2021-06-04 09:03:44 +04:00
Roman Nozdrin
911a41f5be
Merge pull request #1935 from tntnatbry/MCOL-4665
MCOL-4665 Move outer join to inner join conversion into the engine.
2021-06-03 16:05:58 +03:00
Denis Khalikov
606194e6e4 MCOL-4685: Eliminate some irrelevant settings (uncompressed data and extents per file).
This patch:
1. Removes the option to declare uncompressed columns (set columnstore_compression_type = 0).
2. Ignores [COMMENT '[compression=0] option at table or column level (no error messages, just disregard).
3. Removes the option to set more than 2 extents per file (ExtentsPreSegmentFile).
4. Updates rebuildEM tool to support up to 10 dictionary extent per dictionary segment file.
5. Adds check for `DBRootStorageType` for rebuildEM tool.
6. Renamed rebuildEM to mcsRebuildEM.
2021-06-03 14:44:33 +03:00
Gagan Goel
e0d2a21cb9 MCOL-4665 Move outer join to inner join conversion into the engine.
This is a subtask of MCOL-4525 Implement select_handler=AUTO.

Server performs outer join to inner join conversion using simplify_joins()
in sql/sql_select.cc, by updating the TABLE_LIST::outer_join variable.
In order to perform this conversion, permanent changes are made in some
cases to the SELECT_LEX::JOIN::conds and/or TABLE_LIST::on_expr.
This is undesirable for MCOL-4525 which will attemp to fallback and execute
the query inside the server, in case the query execution fails in ColumnStore
using the select_handler.

For a query such as:
  SELECT * FROM t1 LEFT JOIN t2 ON expr1 LEFT JOIN t3 ON expr2
In some cases, server can update the original SELECT_LEX::JOIN::conds
and/or TABLE_LIST::on_expr and create new Item_cond_and objects
(e.g. with 2 Item's expr1 and expr2 in Item_cond_and::list).
Instead of making changes to the original query structs, we use
gp_walk_info::tableOnExprList and gp_walk_info::condList. 2 Item's,
expr1 and expr2, in the condList, mean Item_cond_and(expr1, expr2), and
hence avoid permanent transformations to the SELECT_LEX.

We also define a new member variable
ha_columnstore_select_handler::tableOuterJoinMap
which saves the original TABLE_LIST::outer_join values before they are
updated. This member variable will be used later on to restore to the original
state of TABLE_LIST::outer_join in case of a query fallback to server execution.

The original simplify_joins() implementation in the server also performs a
flattening of the JOIN nest, however we don't perform this operation in
convertOuterJoinToInnerJoin() since it is not required for ColumnStore.
2021-06-03 11:13:19 +00:00
Alexander Barkov
d61690748e MCOL-4743 Regression: TIME_TO_SEC(const_expr) erroneosly returns 0 2021-06-03 11:16:53 +04:00
Alexander Barkov
20bb1b3031 MCOL-4748 mtr mcs229_data_compression_type fails without --extern 2021-06-03 11:12:05 +04:00