The InnoDB SPATIAL INDEX implementation that was copied from MySQL 5.7.9 to MariaDB Server 10.2.2 is somewhat problematic, because the implementation employs a mix of duplicating B-tree specific code and ‘pushing down’ R-tree specific conditions to B-tree specific code. I think that it would be clearest to let row_sel_sec_rec_is_for_clust_rec() only cover B-tree indexes and to create a separate variant for SPATIAL INDEX.
Note: There are problems with the InnoDB implementation of SPATIAL INDEX, especially in the area of MVCC. I do not completely understand the design decisions that were made in MySQL 5.7: making copies of buffer pool pages (MDEV-14059) and some tweaks to the purge of history, which does not seem to work for ROLLBACK (MDEV-15284). When I worked on MDEV-20612, I got suspicion of inconsistency in the predicate locking for R-tree indexes. Due to these reasons, I would not recommend using InnoDB SPATIAL INDEX on data that is changing frequently. For read-mostly data (or when updates and reads are not nearly concurrent) it could be safe.
I realize that the ROW_FORMAT=COMPRESSED format (which I would seek to eventually phase out; see MDEV-23497) provides efficient storage format for geometry data, because it is essentially doing the same as MDEV-11371, storing the BLOB as a singly linked list of zlib compressed stream. It is a pity that the MDEV-11371 column compression cannot be combined with any indexes, in ‘normal’ tables.
Thank you for the report.
Do you have a test case where len would exceed 3072 bytes? That should be the maximum column prefix length in a secondary index, ever since a larger limit was introduced to replace the original one of 768 bytes.