1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-28 13:01:41 +03:00
Gleb Shchepa 33cd911a16 Bug #44139: Table scan when NULL appears in IN clause
SELECT ... WHERE ... IN (NULL, ...) does full table scan,
even if the same query without the NULL uses efficient range scan.

The bugfix for the bug 18360 introduced an optimization:
if
  1) all right-hand arguments of the IN function are constants
  2) result types of all right argument items are compatible
     enough to use the same single comparison function to
     compare all of them to the left argument,

then

  we can convert the right-hand list of constant items to an array
  of equally-typed constant values for the further
  QUICK index access etc. (see Item_func_in::fix_length_and_dec()).

The Item_null constant item objects have STRING_RESULT
result types, so, as far as Item_func_in::fix_length_and_dec()
is aware of NULLs in the right list, this improvement efficiently
optimizes IN function calls with a mixed right list of NULLs and
string constants. However, the optimization doesn't affect mixed
lists of NULLs and integers, floats etc., because there is no
unique common comparator.


New optimization has been added to ignore the result type
of NULL constants in the static analysis of mixed right-hand lists.
This is safe, because at the execution phase we care about
presence of NULLs anyway.

1. The collect_cmp_types() function has been modified to optionally
   ignore NULL constants in the item list.
2. NULL-skipping code of the Item_func_in::fix_length_and_dec()
   function has been modified to work not only with in_string
   vectors but with in_vectors of other types.


mysql-test/r/func_in.result:
  Added test case for the bug #44139.
mysql-test/t/func_in.test:
  Added test case for the bug #44139.
sql/item_cmpfunc.cc:
  Bug #44139: Table scan when NULL appears in IN clause
  
  1. The collect_cmp_types() function has been modified to optionally
     ignore NULL constants in the item list.
  2. NULL-skipping code of the Item_func_in::fix_length_and_dec()
     function has been modified to work not only with in_string
     vectors but with in_vectors of other types.
2009-10-05 10:27:36 +05:00
..
2009-09-10 11:58:13 +05:00
2009-08-20 14:30:59 +02:00
2009-02-09 22:00:15 +01:00
2009-09-03 08:38:06 +02:00
2009-02-09 22:00:15 +01:00
2009-06-25 13:44:50 +05:00
2008-12-23 18:21:01 +04:00
2008-11-21 17:32:45 +04:00
2009-09-29 17:38:40 +02:00
2009-09-29 10:12:04 +02:00
2009-09-04 12:39:56 +05:00
2009-07-15 15:43:45 +05:30
2009-03-27 10:18:06 +08:00
2008-09-05 13:36:02 +05:00
2009-02-06 18:25:08 +01:00
2009-09-10 15:30:03 +05:00
2009-01-23 13:22:05 +01:00
2009-04-29 07:59:10 +05:00
2009-02-26 18:17:06 +01:00
2009-01-16 17:38:38 +02:00
2009-05-06 15:00:14 +05:30
2009-09-02 18:58:17 +02:00
2009-04-09 14:38:50 +05:00
2008-10-23 21:27:09 +02:00
2009-01-23 13:22:05 +01:00
2009-02-09 22:00:15 +01:00
2009-07-30 17:51:25 -07:00
2009-02-03 14:45:17 +01:00
2009-08-12 12:03:05 +02:00
2009-09-10 11:54:26 +05:00
2008-07-03 23:41:22 +04:00
2009-03-10 16:54:24 +01:00
2009-07-03 10:19:32 +02:00
2009-06-10 11:58:36 +03:00
2008-07-07 11:43:56 +03:00
2009-08-31 16:40:35 +03:00
2008-12-13 19:42:12 +00:00
2009-02-19 18:24:25 -05:00
2008-12-09 17:31:22 +04:00
2009-01-13 15:04:28 +01:00
2009-01-31 02:08:41 +01:00
2009-05-15 12:11:07 +05:00
2009-05-10 21:20:35 +05:00
2009-08-31 17:09:09 +03:00