1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00
Commit Graph

1028 Commits

Author SHA1 Message Date
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
6f69194462 MCOL-4642 NOT IN subquery containing an isnull in the OR predicate crashes server.
InSub::handleFunc() was incorrectly exiting early for an IN subquery
containing an isnull predicate in the OR operation in the WHERE clause.
This patch properly handles the OR predicate containing an isnull/isnotnull
predicate in the WHERE clause. We don't remove the isnull operand from the
filter ParseTree in 6.x as the server no longer injects the isnull predicate
in the IN subquery due to MCOL-4617, where we moved the creation and injection
of in-to-exists predicate into the engine.
2021-06-03 01:34:14 -04:00
9608533d92 MCOL-4734 Compilation failure: MariaDB-10.6 + ColumnStore-develop
mcsconfig.h and my_config.h have the following
pre-processor definitions:

1. Conflicting definitions coming from the standard cmake definitions:
- PACKAGE
- PACKAGE_BUGREPORT
- PACKAGE_NAME
- PACKAGE_STRING
- PACKAGE_TARNAME
- PACKAGE_VERSION
- VERSION

2. Conflicting definitions of other kinds:
- HAVE_STRTOLL - this is a dirt in MariaDB headers.
  Should be fixed in the server code. my_config.h erroneously
  performs "#define HAVE_STRTOLL" instead of "#define HAVE_STRTOLL 1".
  in some cases. The former is not CMake compatible style. The latter is.

3. Non-conflicting definitions:
  Otherwise, mcsconfig.h and my_config.h should be mutually compatible,
  because both are generated by cmake on the same host machine. So
  they should have exactly equal definitions like "HAVE_XXX", "SIZEOF_XXX", etc.

Observations:
- It's OK to include both mcsconfig.h and my_config.h providing that we
  suppress duplicate definition of the above conflicting types #1 and #2.
- There is no a need to suppress duplicate definitions mentioned in #3,
  as they are compatible!
- my_sys.h and m_ctype.h must always follow a CMake configuation header,
  either my_config.h or mcsconfig.h (or both).
  They must never be included without any preceeding configuration header.

This change make sure that we resolve conflicts by:
- either disallowing inclusion of mcsconfig.h and my_config.h
  at the same time
- or by hiding conflicting definitions #1 and #2
  (with their later restoring).
- also, by making sure that my_sys.h and m_ctype.h always follow
  a CMake configuration file.

Details:
- idb_mysql.h can now only be included only after my_config.h
  An attempt to use idb_mysql.h with mcsconfig.h instead of
  my_config.h is caught by the "#error" preprocessor directive.

- mariadb_my_sys.h can now be only included after mcsconfig.h.
  An attempt to use mariadb_my_sys.h without mcscofig.h
  (e.g. with my_config.h) is also caught by "#error".

- collation.h now can now be included in two ways.
  It now has the following effective structure:

    #if defined(PREFER_MY_CONFIG_H) && defined(MY_CONFIG_H)
    //  Remember current conflicting definitions on the preprocessor stack
    //  Undefine current conflicting definitions
    #endif
    #include "mcsconfig.h"
    #include "m_ctype.h"
    #if defined(PREFER_MY_CONFIG_H) && defined(MY_CONFIG_H)
    #    Restore conflicting definitions from the preprocessor stack
    #endif

  and can be included as follows:

  a. using only mcsconfig.h as a configuration header:

    // my_config.h must not be included so far
    #include "collation.h"

  b. using my_config.h as the first included configuration file:

    #define PREFER_MY_CONFIG_H // Force conflict resolution
    #include "my_config.h"     // can be included directly or indirectly
    ...
    #include "collation.h"

Other changes:

- Adding helper header files
     utils/common/mcsconfig_conflicting_defs_remember.h
     utils/common/mcsconfig_conflicting_defs_restore.h
     utils/common/mcsconfig_conflicting_defs_undef.h
  to perform conflict resolution easier.

- Removing `#include "collation.h"` from a number of files,
  as it's automatically included from rowgroup.h.

- Removing redundant `#include "utils_utf8.h"`.
  This change is not directly related to the problem being fixed,
  but it's nice to remove redundant directives for both collation.h
  and utils_utf8.h from all the files that do not really need them.
  (this change could probably have gone as a separate commit)

- Changing my_init() to MY_INIT(argv[0]) in the MCS services sources.
  After the fix of the complitation failure it appeared that ColumnStore
  services compiled with the debug build crash due to recent changes in
  safemalloc. The crash happened in strcmp() with `my_progname` as an argument
  (where my_progname is a mysys global variable). This problem should
  probably be fixed on the server side as well to avoid passing NULL.
  But, the majority of MariaDB executable programs also use MY_INIT(argv[0])
  rather than my_init(). So let's make MCS do like the other programs do.
2021-05-25 12:34:36 +04:00
c6db1f9191 Merge pull request #1825 from tntnatbry/MCOL-4617
MCOL-4617 Move in-to-exists predicate creation and injection into the engine.
2021-05-07 13:33:02 +03:00
b9094c1b69 Merge pull request #1912 from tntnatbry/MCOL-4680-dev
MCOL-4680 FROM subquery containing nested joins returns an error.
2021-05-06 13:52:36 +03:00
3ed9993fe7 MCOL-4410 SELECT bypasses select handler if @variables are involved
in the query projection list.

With this patch, we enable SELECT/DERIVED handler execution for
queries involving 'get_user_var' function. Whereas for 'set_user_var'
function, the handlers are still disabled and the query execution
fallsback to the server, except for some edges case described in
the test file mcol-4410.test, in which case, an appropriate error
message is returned to the client.
2021-05-05 07:14:16 +00:00
22c7fb7c01 MCOL-4680 FROM subquery containing nested joins returns an error.
Main theme of the patch is to fix joins processing in the plugin
code. We now use SELECT_LEX::top_join_list and process the nested
joins recursively, instead of SELECT_LEX::table_list struct which
we earlier used to build the join filters. The earlier approach
did not process certain nested join ON expressions, causing certain
queries to incorrectly error out such as that described in MCOL-4680.

In addition, some legacy code is also removed.
2021-05-03 06:28:27 +00:00
2697c9bce7 MCOL-4687 Insert from view regression 2021-04-30 14:20:26 +04:00
f167a6e505 MCOL-4617 Move in-to-exists predicate creation and injection into the engine.
We earlier leveraged the server functionality provided by

Item_in_subselect::create_in_to_exists_cond and
Item_in_subselect::inject_in_to_exists_cond

to create and inject the in-to-exists predicate into an IN
subquery's JOIN struct. With this patch, we leave the IN subquery's
JOIN unaltered and instead directly perform this predicate creation
and injection into ColumnStore's select execution plan.
2021-04-30 07:57:00 +00:00
c67f70f385 MCOL-4689 [135B blob data] in PrimPrim jounralctl records 2021-04-22 10:46:26 +04:00
1f46baa980 Merge pull request #1827 from cvicentiu/fetch-first-refactor
MCOL-4645 Update columnstore usage of select_lex
2021-04-21 14:24:43 +03:00
9c2f2f5084 MCOL-4681 Fix install_mcs_mysql.sh.in to do CREATE FUNCTION instead of INSERT INTO mysql.func 2021-04-16 17:26:04 +04:00
f4b02a7aca Merge pull request #1828 from tntnatbry/MCOL-4543-4589
MCOL -4543/MCOL-4589 Subquery optimization
2021-04-14 13:50:46 +03:00
5546f6a3d5 Merge pull request #1861 from mariadb-corporation/bar-develop-MCOL-4674
MCOL-4674 Fix ColumnStore to run MTR tests in a build directory
2021-04-13 12:34:56 -05:00
75e3bbc31e MCOL-4674 Fix ColumnStore to run MTR tests in a build directory 2021-04-13 11:25:25 +04:00
362bfcd15e MCOL-4361 Replace pow(10.0, (double)scale) expressions with a static dictionary lookup. 2021-04-09 12:41:04 +04:00
dfa9657f2e MCOL-4589 Follow up on MCOL-4543 to optimize out non-referenced
columns from a subquery involving UNIONs.
2021-03-29 12:07:36 +00:00
8a03e6c7d1 MCOL-4543 Subquery optimization.
For a query of the form:

SELECT COUNT(c2) FROM (SELECT * FROM t1) q;

where t1 contains 10 columns c1, c2, ... , c10.

We currently create an intermediate RowGroup in ExeMgr with
a row of the form (1, c2_value1, 1, 1, 1, 1, 1, 1, 1, 1), i.e.
for all the columns of the subquery which are not referenced in
the outer query, we substitute a constant value, which is wasteful.

With this optimization, we are trimming the RowGroup to a row
of the form (1, c2_value1). This can have non-trivial query
execution time improvements if the subquery contains large number
of columns (such as a "select *" on a very wide table) and the outer
query is only referencing a subset of these columns with lower
index values from the subquery (as an example, c1 or c2 above).
That is, the current limitation of this optimization is we are not
removing those non-referenced subquery columns (c1 in the query above)
which are to the left of a referenced column.
2021-03-29 11:56:04 +00:00
0643125426 Update columnstore usage of select_lex
After the cleanup work done for FETCH FIRST ... WITH TIES
SELECT_LEX members select_limit, explicit_limit and offset_limit are now moved
to SELECT_LEX::limit_params.
2021-03-28 16:07:32 +03:00
907e99cf20 changes to match upmerge from 10.4 2021-02-17 17:11:47 +00:00
229fd5d1bd Merge pull request #1756 from benthompson15/MCOL-4193-dev
MCOL-4193-dev
2021-02-12 22:41:29 +03:00
846f7fb29b MCOL-4193: Delete unused OAM and applications, ProcMon, ProcMgr, and no longer build all tools for packages 2021-02-08 17:51:09 -06:00
222b214287 Merge pull request #1750 from tntnatbry/MCOL-4515-develop
MCOL-4515 Binlog replication to CS slave hangs for INSERT .. SELECT query on master.
2021-02-08 16:27:37 +03:00
049d60f1cf Merge pull request #1749 from tntnatbry/MCOL-4493-develop
MCOL 4493
2021-02-05 12:19:32 +03:00
abf45bf46c MCOL-4493 Add ON expressions for WHERE processing when the JOIN
type is not LEFT/RIGHT.

In buildOuterJoin(), do not add ON expressions for WHERE
processing when the JOIN type is not LEFT/RIGHT.

Test cases to check correct processing of INNER JOIN ON expressions
with possible/impossible WHERE conditions are added for
  1. One side of the LEFT JOIN being INNER JOIN.
  2. One side of the LEFT JOIN being an INNER JOIN inside an INNER JOIN.
  3. Both sides of the LEFT JOIN being an INNER JOIN.
2021-02-05 09:10:38 +00:00
3096edc1d3 MCOL-3785 wrap names of db, table & columns in "`" 2021-02-04 11:40:14 +03:00
bdd0963ea3 MCOL-4515 Binlog replication to CS slave hangs for INSERT .. SELECT query on master.
An INSERT .. SELECT performed on a master node caused an infinite
loop on the slave node with columnstore_replication_slave=OFF.

The issue was ha_mcs_impl_select_next() was returning 0 if
the executing thread is a slave and returning early to avoid DML
execution on the slave. The calling code in select_handler::execute()
ran into an infinite loop due to this as it checked the return code
of the function as 0, and incorrectly thought there are more rows
to process.

The fix is to return HA_ERR_END_OF_FILE as the return value,
instead of 0. This is for the case of the query running on the
slave node with columnstore_replication_slave=OFF.
2021-02-04 06:35:00 +00:00
abbe2ebbf6 Dynamic version numbering 2021-01-21 10:30:46 +00:00
0b6dbcd4a8 MCOL-4456 Fix for bulk insertion of BLOBs 2021-01-20 11:27:56 +00:00
8206fafb7c MCOL-4496 Upmerged the commit 7fa5ca3a6 to generalise CHAR|VARCHAR|TEXT|BLOB
bulk insertion processing and fix the original issue introduced by MCOL-2000
2021-01-19 13:25:06 +00:00
b0f97611fc Merge pull request #1691 from drrtuy/MCOL-4465_MCOL-4466_MCOL-4452
Mcol 4465 mcol 4466 mcol 4452
2020-12-23 16:28:40 +03:00
994d9a5125 MCOL-4465 Use a proper ColType for UDAF in a projection RowGroup 2020-12-23 10:32:11 +00:00
bfe90be3db Merge pull request #1677 from tntnatbry/MCOL-4177-2
MCOL-4177 Add support for bulk insertion for wide decimals.
2020-12-18 12:37:23 +03:00
d35002fb65 MCOL-4263 return int for func_floor on datetime
For TIMESTAMP, it should do similar. However, it didn't work. For some reason, MDB has the function set as DATETIME, which for cs, isn't the same thing. Added a kludge to ha_mcs_execplan.cpp to handle it.
2020-12-16 16:23:21 -06:00
f6b55c1e18 MCOL-4177 Add support for bulk insertion for wide decimals.
1. This patch adds support for wide decimals with/without scale
     to cpimport. In addition, INSERT ... SELECT and LDI are also
     now supported.
  2. Logic to compute the number of bytes to convert a binary
     representation in the buffer to a narrow decimal is also
     simplified.
2020-12-15 22:14:54 +00:00
b1d1ad1486 MCOL-2000 Fix CREATE TABLE syntax
for a generated replacement statements of original statements:
* `CREATE TABLE .. LIKE ..`
* `ALTER TABLE .. ENGINE=Columnstore`
* `CREATE TABLE .. AS ..`
2020-12-07 18:12:25 +03:00
d2e7c9d98d MCOL-2000 Process charset definitions in the DDL
MCOL-2000 Process charset definitions in the ALTER TABLE .. ADD COLUMN

MCOL-2000 Yet another fixes for column charsets

* make respect for column (including table/db/server default) charsets
  for the TEXT(n) fields
* round TEXT(n) column length up to the next default length of TEXT-like
  subtypes, 255 (TINYTEXT), 65535 (TEXT) and so on up to 2100000000
  (LONGTEXT)
2020-12-04 15:01:01 +03:00
4319dcf89f Merge pull request #1628 from dhall-MariaDB/MCOL-4105-dev
MCOL-4105 dev skip calpontsys tables
2020-12-01 13:10:13 -06:00
611ad780ef MCOL-4105 dev skip calpontsys tables
Procedure columnstore_upgrade trips table comments. This is not allowed for calpontsys tables.
2020-12-01 09:57:01 -06:00
a159f8a0b6 MCOL-4188 Regression fixes for MCOL-641.
1. Add wide decimal support to AggregateColumn::evaluate
and TreeNode::getDecimalVal().
2. Use the pm aggregate attributes to determine um aggregate
attributes in TupleAggregateStep::prep2PhasesAggregate.
2020-11-30 13:49:05 -05:00
494bde61e1 MCOL-4409 Moved static Decimal conversion methods into VDecimal class
MCOL-4409 This patch combines VDecimal and Decimal and makes
IDB_Decimal an alias for the result class

MCOL-4409 More boilerplate reduction in Func_mod

Removed couple TSInt128::toType() methods
2020-11-30 12:08:52 +00:00
2ea73846b9 MCOL-4422 Remove mariadb.h and my_sys.h dependency from collation.h 2020-11-30 14:26:35 +04:00
61b55127ac A fix for MCOL-4174 Review/refactor frontend/connector code
- The code in ha_mcs_partition.cpp erroneously printed data
  to a temporary ostringstream "oss" instead of "output".

- The left-side adjustfield (applied when printing the range values)
  unintentionally disappeared during MCOL-4174 refactoring.
  Restoring left adjustfield in TypeHandler::PrintPartitionValue*().
2020-11-20 10:23:13 +04:00
8603c8f780 Merge pull request #1606 from dhall-MariaDB/MCOL-4397-dev
MCOL-4397 dev call refreshShm() for calshowpartitions
2020-11-19 17:02:25 -05:00
f742a55cd6 MCOL-4397 dev call refreshShm() for calshowpartitions 2020-11-19 13:49:10 -06:00
31e0909552 Merge for 13264feb7 that is the fix for multiple LDI issues described in MCOL-4320/4364/4370 2020-11-18 13:53:16 +00:00
58495d0d2f MCOL-4387 Convert dataconvert::decimalToString() into VDecimal and TSInt128 methods 2020-11-18 13:53:16 +00:00
d5c6645ba1 Adding mcs_basic_types.h
For now it consists of only:

using int128_t = __int128;
using uint128_t = unsigned __int128;

All new privitive data types should go into this file in the future.
2020-11-18 13:53:15 +00:00
129d5b5a0f MCOL-4174 Review/refactor frontend/connector code 2020-11-18 13:53:15 +00:00
1f4a781704 MCOL-641 Fixes for arithmetic operations.
1. Perform type promotion to wide decimal if the result
   of an arithmetic operation has a precision > 18.
2. Only set the decimal width of an arithmetic operation to wide
   if both the LHS and RHS of the operation are decimal types.
2020-11-18 13:52:20 +00:00