Commit b3c320bb authored by Varun Gupta's avatar Varun Gupta

MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with

            optimizer_use_condition_selectivity>=3

Selectivity analysis should be disabled for Geometrical columns
for the case like geometric_field= string_constant.
parent a9c09c95
......@@ -1659,5 +1659,21 @@ c2
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
# optimizer_use_condition_selectivity>=3
#
CREATE TABLE t1 (a POINT);
INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
set @save_use_stat_tables= @@use_stat_tables;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set @@use_stat_tables= PREFERABLY;
set @@optimizer_use_condition_selectivity=3;
SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
COUNT(*)
0
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1;
#
# End 10.0 tests
#
......@@ -3733,7 +3733,7 @@ id MIN(a) MAX(a)
4 2001-01-04 2001-01-04
DROP TABLE t1;
#
# Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
# MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
# and use_stat_tables= PREFERABLY
#
CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
......
......@@ -1516,6 +1516,21 @@ SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FR
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
--echo #
--echo # MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
--echo # optimizer_use_condition_selectivity>=3
--echo #
CREATE TABLE t1 (a POINT);
INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
set @save_use_stat_tables= @@use_stat_tables;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set @@use_stat_tables= PREFERABLY;
set @@optimizer_use_condition_selectivity=3;
SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1;
--echo #
--echo # End 10.0 tests
......
......@@ -1520,7 +1520,7 @@ SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=DATE'2001-01-04' GROUP BY id;
DROP TABLE t1;
--echo #
--echo # Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
--echo # MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
--echo # and use_stat_tables= PREFERABLY
--echo #
......
......@@ -3328,7 +3328,8 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
{
Column_statistics* col_stats= (*field_ptr)->read_stats;
if (bitmap_is_set(used_fields, (*field_ptr)->field_index)
&& col_stats && !col_stats->no_stat_values_provided())
&& col_stats && !col_stats->no_stat_values_provided()
&& !((*field_ptr)->type() == MYSQL_TYPE_GEOMETRY))
parts++;
}
......@@ -3349,6 +3350,9 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
if (bitmap_is_set(used_fields, (*field_ptr)->field_index))
{
Field *field= *field_ptr;
if (field->type() == MYSQL_TYPE_GEOMETRY)
continue;
uint16 store_length;
uint16 max_key_part_length= (uint16) table->file->max_key_part_length();
key_part->key= keys;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment