Handle string length as size_t, consistently (almost always:))
Change function prototypes to accept size_t, where in the past
ulong or uint were used. change local/member variables to size_t
when appropriate.
This fix excludes rocksdb, spider,spider, sphinx and connect for now.
adding a separte class Item_func_spatial_relate for ST_RELATE().
This is a preparatory patch for:
MDEV-8239 Reverse spatial operations OP(const, field) do not get optimized
includes:
* remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING"
* introduce LOCK_share, now LOCK_ha_data is strictly for engines
* rea_create_table() always creates .par file (even in "frm-only" mode)
* fix a 5.6 bug, temp file leak on dummy ALTER TABLE
Fixed the get_data_size() methods for multi-point features to check properly for end
of their respective data arrays.
Extended the point checking function to take a 3d optional argument so cases where
there's additional data in each array element (besides the point data itself) can be
covered by the helper function.
Fixed the 3 cases where such offset was present to use the proper checking helper
function.
Test cases added.
Fixed review comments.
The GIS WKB reader was checking for the presence of
enough data by first multiplying the number read (where
it could overflow) and only then comparing it to the
number of bytes available.
This can overflow and effectively turn off the check.
Fixed by:
1. Introducing a new function that does division only so
no overflow is possible.
2. Using the proper macros and parenthesizing them.
3. Doing an in-line division check in the only place where
the boundary check is done over a data structure other
than a dense points array.
Additional fixes for possible overflows in length-related
calculations in 'spatial' implementations.
Checks added to the ::get_data_size() methods.
max_n_points decreased to occupy less 2G size. An
object of that size is practically inoperable anyway.
The bug was found by Alyssa Milburn.
If the number of points of a geometry feature read from
binary representation is greater than 0x10000000, then
the (uint32) (num_points * 16) will cut the higher byte,
which leads to various errors.
Fixed by additional check if (num_points > max_n_points).
The bug was found by Alyssa Milburn.
If the number of points of a geometry feature read from
binary representation is greater than 0x10000000, then
the (uint32) (num_points * 16) will cut the higher byte,
which leads to various errors.
Fixed by additional check if (num_points > max_n_points).
Coinciding nodes can appear as a result of DOUBLE inaccuracy.
We should test that before we start the loop.
Also the spatial relations can be calculated faster if we check
MBR relations first. And we do have the shape's MBR-s now.
per-file comments:
sql/gcalc_slicescan.cc
set_extent() method added.
bug #901655 ST_BUFFER asserts with a coplicated shape.
sql/gcalc_slicescan.h
set_extent() method declared.
bug #901655 ST_BUFFER asserts with a coplicated shape.
sql/gcalc_tools.cc
bug #901655 ST_BUFFER asserts with a coplicated shape.
checks for equal nodes added.
sql/item_geofunc.cc
bug #901655 ST_BUFFER asserts with a coplicated shape.
MBR for the shapes calculated, and MBR checks added before we
start the heavy calculations.
sql/spatial.h
bug #901655 ST_BUFFER asserts with a coplicated shape.
MBR::buffer() method implemented.
per-file comments:
mysql-test/r/gis.result
bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
test result updated.
mysql-test/t/gis.test
bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
test case added.
sql/item_geofunc.cc
bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
geom_length() call fixed.
sql/spatial.cc
bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
Geometry_collection::geom_length implemented.
sql/spatial.h
bug 855336 ST_LENGTH does not work on GEOMETRYCOLLECTIONs fixed.
Geometry_collection::geom_length declaration added.
855253 Compiler error: gcalc_slicescan.cc:2036: error: suggest parentheses around comparison in operand of .|. in maria-5.3-gis
850775 ST_AREA does not work on GEOMETRYCOLLECTIONs in maria-5.3-gis
per-file comments:
mysql-test/r/gis.result
test result updated.
mysql-test/t/gis.test
test case added for 850775.
sql/gcalc_slicescan.cc
compiler error fixed.
sql/spatial.cc
ST_AREA implementation for GEOMETRY_COLLECTION, POINT and LINESTRING.
sql/spatial.h
area() declarations added.
If the result contains a polygon with a hole, consequitive shapes weren't calculated
properly, as the hole appeared as shape in the result, but actually it's a single shape
with the surrounding polygon. It's more natural to use the size of the result as
a border instead of the number of resulting shapes.
per-file comments:
mysql-test/r/gis-precise.result
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
test result updated.
mysql-test/t/gis-precise.test
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
test case added.
sql/spatial.cc
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
check the data lenght instead of number of shapes.
sql/spatial.h
fix for bug #801243 Assertion `(0)' failed in Gis_geometry_collection::init_from_opresult on ST_UNION
check the data lenght instead of number of shapes.
strict aliasing violations.
Another rather noisy violation of strict aliasing rules
is the spatial code which makes use of stack-based memory
(of type Geometry_buffer) to provide placement for Geometry
objects. Although a placement new is allowed to dynamically
change the type of a object, the object returned by the
new placement was being ignored and the original stack-based
object was being casted to the new type, thus violating strict
aliasing rules.
The solution is to reorganize the code so that the object
returned by the new placement is used instead of casting the
original object. Also, to ensure that the stack-based object
is properly aligned with respect to the objects it provides
placement for, a set of compiler-dependent macros and types
are introduced so that the alignment of objects can be inquired
and specified.
include/Makefile.am:
Add new header.
include/my_compiler.h:
Add new header.
include/my_global.h:
Remove now-unnecessary macros.
sql/spatial.cc:
Make object creation functions return the object whose type
was dynamically changed by the new placement.
Move static method from the header in order to avoid having
to access a forward declaration.
sql/spatial.h:
Object creation callbacks now take a array of chars as the
storage area.
Move create_by_typeid to a source file as to not access the
forward declaration of Geometry_buffer.
Ensure that Geometry_buffer is properly aligned.
sql/sql_show.cc:
Use newly added aligned storage helper.
strict aliasing violations.
Post-merge fix: include my_compiler.h before my_attribute.h
as the latter will undef __attribute__ if the compiler is not
GCC. Based on the compiler version, in my_compiler.h we know
for sure whether the aligned attribute is supported. Furthermore,
undefining attribute might cause bugs if some system header
uses it.
include/my_compiler.h:
Drop aligned attribute support from Sun Studio C++ compiler
as its not clear exactly which version of it supports the
attribute.