Browse Source

MDEV-7682 Incorrect use of SPATIAL KEY for query plan

If the spatial key is used within an equality comparison, the comparison
does not produce relevant results generally as identical geometry can be
stored differently. Still, we want to support the operation. In order
to allow a hash join plan, we must define a key_length for Field_geom.
pull/39/head
Vicențiu Ciorbaru 11 years ago
parent
commit
9253064c05
  1. 4
      mysql-test/r/select_jcl6.result
  2. 8
      sql/field.h

4
mysql-test/r/select_jcl6.result

@ -4417,7 +4417,7 @@ INSERT INTO t1 VALUES
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 hash_ALL a #hash#$hj 2 test.t1.a 2 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL a #hash#$hj 6 test.t1.a 2 Using where; Using join buffer (flat, BNLH join)
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
1
1
@ -4427,7 +4427,7 @@ SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 hash_ALL a #hash#$hj 2 test.t1.a 2 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_ALL a #hash#$hj 6 test.t1.a 2 Using where; Using join buffer (flat, BNLH join)
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
1
1

8
sql/field.h

@ -1982,6 +1982,14 @@ public:
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
uint size_of() const { return sizeof(*this); }
/**
Key length is provided only to support hash joins. (compared byte for byte)
Ex: SELECT .. FROM t1,t2 WHERE t1.field_geom1=t2.field_geom2.
The comparison is not very relevant, as identical geometry might be
represented differently, but we need to support it either way.
*/
uint32 key_length() const { return packlength; }
/**
Non-nullable GEOMETRY types cannot have defaults,

Loading…
Cancel
Save