[MCOL-3769] Impossible WHERE and HAVING conditions are skiped by SH. Replaced by MCOL-3787. Created: 2020-02-10  Updated: 2020-04-01  Resolved: 2020-03-25

Status: Closed
Project: MariaDB ColumnStore
Component/s: MDB Plugin
Affects Version/s: 1.4.2
Fix Version/s: 1.4.4

Type: Bug Priority: Minor
Reporter: Roman Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-3787 CS doesn't apply having with impossib... Closed
Sprint: 2020-2, 2020-5

 Description   

Below is the reproduction, now in 3787. The commit made for this ticket does not fix the issue, only cleans up some code.

********************************************************************
Consider the example:

CREATE TABLE cs1 (a BIGINT)engine=columnstore;
INSERT INTO cs1 VALUES (42);
MariaDB [test]> select sum(a) from cs1 having -1 != -1;
+--------+
| sum(a) |
+--------+
|   NULL |
+--------+
1 row in set, 1 warning (0.012 sec)
 
CREATE TABLE t1 (a BIGINT);
INSERT INTO t1 VALUES (42);
MariaDB [test]> select sum(a) from t1 having 1 != 1;
Empty set (0.001 sec)

create_SH checks whether HAVING or WHERE has impossible conditions returning if there are such. After JOIN::optimize() had been removed from create_SH thus both select_lex->having_value, select_lex->cond_value always are in COND_UNDEF. This disables the check.
There are two ways:

  • reuse the code and port Item_cond::remove_eq_conds and all prerequisites to reenable check in create_SH
  • implement custom Item traverser that searches for a conditions that is constant column with a value of 0.


 Comments   
Comment by Roman [ 2020-02-12 ]

The problems aren't so severe b/c CS processes impossible conditions. I've refactored create_SH() for this issue though removing needless impossible conditions check and adding meaningful error message in case if SH fails to process the query that has unsupported features.

Comment by Roman [ 2020-02-12 ]

Plz review.

Comment by Patrick LeBlanc (Inactive) [ 2020-02-18 ]

Found a problem with the latest fix, the default sql_mode, and insert-select among other things.

Comment by Patrick LeBlanc (Inactive) [ 2020-02-18 ]

Warnings were being promoted to errors by the STRICT_TRANS_TABLES option in sql_mode. Apparently the warnings are all effectively 'expect low performance', which shouldn't be a warning anyway. I commented the warnings out.

Comment by Daniel Lee (Inactive) [ 2020-02-19 ]

The original change is for code refactoring only.

Reproduced the issue in a BB night build 2020/20/18
engine commit:
1a65d34

MariaDB [mytest]> insert into orders1 select * from orders;
Query OK, 1500000 rows affected, 1 warning (20.335 sec)
Records: 1500000 Duplicates: 0 Warnings: 1

MariaDB [mytest]> show warnings;
-------------------------------------------------------------------

Level Code Message

-------------------------------------------------------------------

Warning 9999 Query inserts its result. Select Handler doesn't work.

-------------------------------------------------------------------
1 row in set (0.000 sec)

MariaDB [mytest]> set sql_mode=STRICT_TRANS_TABLES;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mytest]> insert into orders1 select * from orders;
ERROR 9999 (HY000): Query inserts its result. Select Handler doesn't work.

verified fix in source
server
commit cbfa2cfc48da12a13957d06c59e6a7651b77aa6a
engine
commit ebd8448fdb76f5c55c139d7bd02c839c957fb11d
Merge: 1a65d34 d5ec634
Author: Patrick LeBlanc <43503225+pleblanc1976@users.noreply.github.com>
Date: Tue Feb 18 11:08:30 2020 -0600

Merge pull request #1055 from pleblanc1976/develop-1.4

Fixed a problem with the fix for MCOL-3769 & the default sql_mode.

MariaDB [mytest]> insert into orders1 select * from orders;
Query OK, 1500000 rows affected (1 min 16.117 sec)
Records: 1500000 Duplicates: 0 Warnings: 0

MariaDB [mytest]> set sql_mode=STRICT_TRANS_TABLES;
Query OK, 0 rows affected (0.000 sec)

MariaDB [mytest]> insert into orders1 select * from orders;
Query OK, 1500000 rows affected (1 min 14.254 sec)
Records: 1500000 Duplicates: 0 Warnings: 0

Comment by Roman [ 2020-03-07 ]

Reopen this as the fix breaks the logic behind the original commit for the issue. Also pleblanc asked me to port this feature into develop.

Comment by Roman [ 2020-03-07 ]

I'll first repeat the orignal comment here:

The original problem with impossible WHERE and HAVING aren't so severe b/c CS processes impossible conditions.

CS still returns record for queries that both contains aggregation functions and impossible conditions and this will be addressed by MCOL-3787.

Comment by Roman [ 2020-03-07 ]

4 QA:

There are not dedicated tests to check this issue so I would suggest to check whether it affects regr/test001 or not.

Comment by Roman [ 2020-03-16 ]

Please review.

Comment by Patrick LeBlanc (Inactive) [ 2020-03-17 ]

It looks good to me, but I don't know this code very well. Gagan can take the lead on this one.

BTW, buildbot is broken again, so we'll have to be extra careful to not break anything. Roman, if you haven't already done so, be sure to run at least test001 or 101 before and after this change to verify it doesn't break something.

Comment by Roman [ 2020-03-18 ]

Very unfortunatelly nobody does.

I tested it against HEAD of develop/-1.4 last week and there was no failures introduced.

Comment by Gagan Goel (Inactive) [ 2020-03-18 ]

For QA, this is a code refactor, so no dedicated tests for this ticket. Please ensure it doesn't introduce new regressions in test001.

Comment by Daniel Lee (Inactive) [ 2020-03-25 ]

Build verified: 1.4.4-1 source

/root/ColumnStore/buildColumnstoreFromGithubSource/server
commit aaf2a53452447b0223866db16e88d52448986ea3
Author: Monty <monty@mariadb.org>
Date: Thu Aug 8 23:04:05 2019 +0300

MENT-401: Include Aria and S3 index length limit increase in ES 10.4

Cherry-picked from:

98ea611940fd492fc5f883625f2afcbbab312795

MDEV-20279 Increase Aria index length limit

/root/ColumnStore/buildColumnstoreFromGithubSource/server/engine
commit 0574127148e4c0a1cd9a341c7b9e8ffc982d0d24
Merge: ca3e2d7 cd7372f
Author: David.Hall <david.hall@mariadb.com>
Date: Mon Mar 23 13:43:27 2020 -0500

Merge pull request #1099 from pleblanc1976/mcol-2022-1.4

Mcol 2022 1.4

Verified that the report issue still exist and it is being tracked by MCOL-3787. This fix is for code refactoring only.

Ran regression test001 autopilot.

Generated at Thu Feb 08 02:45:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.