summaryrefslogtreecommitdiff
path: root/sql/spatial.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-07-16 19:09:54 +0200
committerSergei Golubchik <sergii@pisem.net>2013-07-16 19:09:54 +0200
commit005c7e54214546584c8dc67a746e215f8dbe4b58 (patch)
treedea50cd7b32808413e058d43d20cf230d1cc7477 /sql/spatial.h
parentb9f220b45afaae9b61af29129a8c8ec5f9a7759b (diff)
parent4f5c10e6b565bc2761b9d083e25c6a36141552a0 (diff)
downloadmariadb-git-005c7e54214546584c8dc67a746e215f8dbe4b58.tar.gz
mysql-5.5.32 merge
Diffstat (limited to 'sql/spatial.h')
-rw-r--r--sql/spatial.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/sql/spatial.h b/sql/spatial.h
index 9aaedfe8a20..6df6e37e9b8 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -1,5 +1,6 @@
/*
- Copyright (c) 2002, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2002, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,7 +29,7 @@ class Gis_read_stream;
const uint SRID_SIZE= 4;
const uint SIZEOF_STORED_DOUBLE= 8;
-const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2;
+const uint POINT_DATA_SIZE= (SIZEOF_STORED_DOUBLE * 2);
const uint WKB_HEADER_SIZE= 1+4;
const uint32 GET_SIZE_ERROR= ((uint32) -1);
@@ -334,10 +335,36 @@ protected:
const char *get_mbr_for_points(MBR *mbr, const char *data, uint offset)
const;
- inline bool no_data(const char *cur_data, uint32 data_amount) const
+ /**
+ Check if there're enough data remaining as requested
+
+ @arg cur_data pointer to the position in the binary form
+ @arg data_amount number of points expected
+ @return true if not enough data
+ */
+ inline bool no_data(const char *cur_data, size_t data_amount) const
{
return (cur_data + data_amount > m_data_end);
}
+
+ /**
+ Check if there're enough points remaining as requested
+
+ Need to perform the calculation in logical units, since multiplication
+ can overflow the size data type.
+
+ @arg data pointer to the begining of the points array
+ @arg expected_points number of points expected
+ @arg extra_point_space extra space for each point element in the array
+ @return true if there are not enough points
+ */
+ inline bool not_enough_points(const char *data, uint32 expected_points,
+ uint32 extra_point_space = 0) const
+ {
+ return (m_data_end < data ||
+ (expected_points > ((m_data_end - data) /
+ (POINT_DATA_SIZE + extra_point_space))));
+ }
const char *m_data;
const char *m_data_end;
};