[MDEV-21924] Clean up InnoDB GIS record comparison Created: 2020-03-12  Updated: 2020-03-12  Resolved: 2020-03-12

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.5.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: upstream

Issue Links:
Blocks
blocks MDEV-21907 Enable -Wconversion for InnoDB and Ma... Closed
Relates
relates to MDEV-14057 InnoDB GIS tests fail Closed

 Description   

When the InnoDB record comparison functions were extended for SPATIAL INDEX in MySQL 5.7, the work was suboptimal for multiple reasons:

  1. The int type was being used, which does not match ulint. This triggers additional -Wconversion in some GCC versions.
  2. Many functions unnecessarily take an offsets parameter, or a parameter for length, although the size of the minimum bounding rectangle (MBR) is fixed as SPDIMS * 2 * sizeof(double), or 32 bytes. In SPATIAL INDEX records, there always is a 32-byte key followed by either a 4-byte child page number or the PRIMARY KEY value.
  3. The length parameters were not properly validated. The function cmp_geometry_field() is making an incorrect attempt at checking that the lengths are at least sizeof(double) (8 bytes), even though the function is accessing up to 32 bytes in both MBR.
  4. Functions that are called from only one compilation unit are defined in another compilation unit, making the code harder to follow and potentially slower to execute.

Generated at Thu Feb 08 09:10:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.