Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-13 18:46:19+05:00, holyfoot@stripped +4 -0
NOT TO BE PUSHED AS IT IS
some GIS fixes
sql/gcalc_slicescan.cc@stripped, 2007-06-13 18:46:17+05:00, holyfoot@stripped +9 -8
find_first_different fixed
sql/item_create.cc@stripped, 2007-06-13 18:46:17+05:00, holyfoot@stripped +153 -25
MBR functions creators added
sql/item_geofunc.cc@stripped, 2007-06-13 18:46:17+05:00, holyfoot@stripped +71 -0
MBR functions implementations added
sql/item_geofunc.h@stripped, 2007-06-13 18:46:17+05:00, holyfoot@stripped +26 -0
MBR functions interface added
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: holyfoot
# Host: hfmain.(none)
# Root: /home/hf/work/mysql-5.1.spa
--- 1.80/sql/item_create.cc 2007-06-13 18:46:25 +05:00
+++ 1.81/sql/item_create.cc 2007-06-13 18:46:25 +05:00
@@ -504,16 +504,16 @@ protected:
#ifdef HAVE_SPATIAL
-class Create_func_contains : public Create_func_arg2
+class Create_func_mbrcontains : public Create_func_arg2
{
public:
virtual Item* create(THD *thd, Item *arg1, Item *arg2);
- static Create_func_contains s_singleton;
+ static Create_func_mbrcontains s_singleton;
protected:
- Create_func_contains() {}
- virtual ~Create_func_contains() {}
+ Create_func_mbrcontains() {}
+ virtual ~Create_func_mbrcontains() {}
};
#endif
@@ -744,6 +744,19 @@ protected:
#ifdef HAVE_SPATIAL
+class Create_func_mbr_disjoint : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_disjoint s_singleton;
+
+protected:
+ Create_func_mbr_disjoint() {}
+ virtual ~Create_func_mbr_disjoint() {}
+};
+
+
class Create_func_disjoint : public Create_func_arg2
{
public:
@@ -822,10 +835,8 @@ protected:
Create_func_endpoint() {}
virtual ~Create_func_endpoint() {}
};
-#endif
-#ifdef HAVE_SPATIAL
class Create_func_envelope : public Create_func_arg1
{
public:
@@ -837,10 +848,21 @@ protected:
Create_func_envelope() {}
virtual ~Create_func_envelope() {}
};
-#endif
-#ifdef HAVE_SPATIAL
+class Create_func_mbr_equals : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_equals s_singleton;
+
+protected:
+ Create_func_mbr_equals() {}
+ virtual ~Create_func_mbr_equals() {}
+};
+
+
class Create_func_equals : public Create_func_arg2
{
public:
@@ -1167,6 +1189,19 @@ protected:
};
+class Create_func_mbr_intersects : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_intersects s_singleton;
+
+protected:
+ Create_func_mbr_intersects() {}
+ virtual ~Create_func_mbr_intersects() {}
+};
+
+
class Create_func_intersects : public Create_func_arg2
{
public:
@@ -1675,6 +1710,19 @@ protected:
#ifdef HAVE_SPATIAL
+class Create_func_mbr_overlaps : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_overlaps s_singleton;
+
+protected:
+ Create_func_mbr_overlaps() {}
+ virtual ~Create_func_mbr_overlaps() {}
+};
+
+
class Create_func_overlaps : public Create_func_arg2
{
public:
@@ -2125,6 +2173,19 @@ protected:
#ifdef HAVE_SPATIAL
+class Create_func_mbr_touches : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_touches s_singleton;
+
+protected:
+ Create_func_mbr_touches() {}
+ virtual ~Create_func_mbr_touches() {}
+};
+
+
class Create_func_touches : public Create_func_arg2
{
public:
@@ -2257,6 +2318,19 @@ protected:
#ifdef HAVE_SPATIAL
+class Create_func_mbr_within : public Create_func_arg2
+{
+public:
+ virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+
+ static Create_func_mbr_within s_singleton;
+
+protected:
+ Create_func_mbr_within() {}
+ virtual ~Create_func_mbr_within() {}
+};
+
+
class Create_func_within : public Create_func_arg2
{
public:
@@ -2928,13 +3002,13 @@ Create_func_connection_id::create(THD *t
#ifdef HAVE_SPATIAL
-Create_func_contains Create_func_contains::s_singleton;
+Create_func_mbrcontains Create_func_mbrcontains::s_singleton;
Item*
-Create_func_contains::create(THD *thd, Item *arg1, Item *arg2)
+Create_func_mbrcontains::create(THD *thd, Item *arg1, Item *arg2)
{
- return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
- Item_func::SP_CONTAINS_FUNC);
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_CONTAINS_FUNC);
}
#endif
@@ -3160,6 +3234,16 @@ Create_func_dimension::create(THD *thd,
#ifdef HAVE_SPATIAL
+Create_func_mbr_disjoint Create_func_mbr_disjoint::s_singleton;
+
+Item*
+Create_func_mbr_disjoint::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_DISJOINT_FUNC);
+}
+
+
Create_func_disjoint Create_func_disjoint::s_singleton;
Item*
@@ -3257,10 +3341,8 @@ Create_func_endpoint::create(THD *thd, I
return new (thd->mem_root) Item_func_spatial_decomp(arg1,
Item_func::SP_ENDPOINT);
}
-#endif
-#ifdef HAVE_SPATIAL
Create_func_envelope Create_func_envelope::s_singleton;
Item*
@@ -3268,10 +3350,18 @@ Create_func_envelope::create(THD *thd, I
{
return new (thd->mem_root) Item_func_envelope(arg1);
}
-#endif
-#ifdef HAVE_SPATIAL
+Create_func_mbr_equals Create_func_mbr_equals::s_singleton;
+
+Item*
+Create_func_mbr_equals::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_EQUALS_FUNC);
+}
+
+
Create_func_equals Create_func_equals::s_singleton;
Item*
@@ -3663,6 +3753,16 @@ Create_func_interiorringn::create(THD *t
}
+Create_func_mbr_intersects Create_func_mbr_intersects::s_singleton;
+
+Item*
+Create_func_mbr_intersects::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_INTERSECTS_FUNC);
+}
+
+
Create_func_intersects Create_func_intersects::s_singleton;
Item*
@@ -4175,6 +4275,16 @@ Create_func_ord::create(THD *thd, Item *
#ifdef HAVE_SPATIAL
+Create_func_mbr_overlaps Create_func_mbr_overlaps::s_singleton;
+
+Item*
+Create_func_mbr_overlaps::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_OVERLAPS_FUNC);
+}
+
+
Create_func_overlaps Create_func_overlaps::s_singleton;
Item*
@@ -4572,6 +4682,16 @@ Create_func_to_days::create(THD *thd, It
#ifdef HAVE_SPATIAL
+Create_func_mbr_touches Create_func_mbr_touches::s_singleton;
+
+Item*
+Create_func_mbr_touches::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_TOUCHES_FUNC);
+}
+
+
Create_func_touches Create_func_touches::s_singleton;
Item*
@@ -4698,6 +4818,16 @@ Create_func_weekofyear::create(THD *thd,
#ifdef HAVE_SPATIAL
+Create_func_mbr_within Create_func_mbr_within::s_singleton;
+
+Item*
+Create_func_mbr_within::create(THD *thd, Item *arg1, Item *arg2)
+{
+ return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
+ Item_func::SP_WITHIN_FUNC);
+}
+
+
Create_func_within Create_func_within::s_singleton;
Item*
@@ -4706,10 +4836,8 @@ Create_func_within::create(THD *thd, Ite
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_WITHIN_FUNC);
}
-#endif
-#ifdef HAVE_SPATIAL
Create_func_x Create_func_x::s_singleton;
Item*
@@ -4928,13 +5056,13 @@ static Native_func_registry func_array[]
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
{ { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
{ { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
- { { C_STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_contains)},
- { { C_STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_disjoint)},
- { { C_STRING_WITH_LEN("MBREQUAL") }, GEOM_BUILDER(Create_func_equals)},
- { { C_STRING_WITH_LEN("MBRINTERSECTS") }, GEOM_BUILDER(Create_func_intersects)},
- { { C_STRING_WITH_LEN("MBROVERLAPS") }, GEOM_BUILDER(Create_func_overlaps)},
- { { C_STRING_WITH_LEN("MBRTOUCHES") }, GEOM_BUILDER(Create_func_touches)},
- { { C_STRING_WITH_LEN("MBRWITHIN") }, GEOM_BUILDER(Create_func_within)},
+ { { C_STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbrcontains)},
+ { { C_STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
+ { { C_STRING_WITH_LEN("MBREQUAL") }, GEOM_BUILDER(Create_func_mbr_equals)},
+ { { C_STRING_WITH_LEN("MBRINTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
+ { { C_STRING_WITH_LEN("MBROVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
+ { { C_STRING_WITH_LEN("MBRTOUCHES") }, GEOM_BUILDER(Create_func_mbr_touches)},
+ { { C_STRING_WITH_LEN("MBRWITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
{ { C_STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)},
{ { C_STRING_WITH_LEN("MLINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
{ { C_STRING_WITH_LEN("MLINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
--- 1.1/sql/gcalc_slicescan.cc 2007-06-13 18:46:25 +05:00
+++ 1.2/sql/gcalc_slicescan.cc 2007-06-13 18:46:25 +05:00
@@ -99,14 +99,15 @@ static inline void trim_node(gcalc_heap:
static double find_first_different(const gcalc_heap::info *p)
{
- const gcalc_heap::info *dif;
- for (dif= p->left;
- dif && dif->left && (dif->left->left != dif); dif= dif->left)
- if (dif->y != p->y)
- return dif->y;
- for (dif= p->right; dif; dif= dif->right)
- if (dif->y != p->y)
- return dif->y;
+ if (p->left && (p->left->y != p->y))
+ return p->left->y;
+ if (p->right && (p->right->y != p->y))
+ return p->right->y;
+ if (p->left && p->left->left && (p->left->left->y != p->y))
+ return p->left->left->y;
+ if (p->right && p->right->right && (p->right->right->y != p->y))
+ return p->right->right->y;
+
return p->y;
}
--- 1.36/sql/item_geofunc.cc 2007-06-13 18:46:25 +05:00
+++ 1.37/sql/item_geofunc.cc 2007-06-13 18:46:25 +05:00
@@ -498,6 +498,77 @@ err:
Functions for spatial relations
*/
+const char *Item_func_spatial_mbr_rel::func_name() const
+{
+ switch (spatial_rel) {
+ case SP_CONTAINS_FUNC:
+ return "mbrcontains";
+ case SP_WITHIN_FUNC:
+ return "mbrwithin";
+ case SP_EQUALS_FUNC:
+ return "mbrequals";
+ case SP_DISJOINT_FUNC:
+ return "mbrdisjoint";
+ case SP_INTERSECTS_FUNC:
+ return "mbrintersects";
+ case SP_TOUCHES_FUNC:
+ return "mbrtouches";
+ case SP_CROSSES_FUNC:
+ return "mbrcrosses";
+ case SP_OVERLAPS_FUNC:
+ return "mbroverlaps";
+ default:
+ DBUG_ASSERT(0); // Should never happened
+ return "mbrsp_unknown";
+ }
+}
+
+
+longlong Item_func_spatial_mbr_rel::val_int()
+{
+ DBUG_ASSERT(fixed == 1);
+ String *res1= args[0]->val_str(&tmp_value1);
+ String *res2= args[1]->val_str(&tmp_value2);
+ Geometry_buffer buffer1, buffer2;
+ Geometry *g1, *g2;
+ MBR mbr1, mbr2;
+ const char *dummy;
+
+ if ((null_value=
+ (args[0]->null_value ||
+ args[1]->null_value ||
+ !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
+ !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
+ g1->get_mbr(&mbr1, &dummy) ||
+ g2->get_mbr(&mbr2, &dummy))))
+ return 0;
+
+ switch (spatial_rel) {
+ case SP_CONTAINS_FUNC:
+ return mbr1.contains(&mbr2);
+ case SP_WITHIN_FUNC:
+ return mbr1.within(&mbr2);
+ case SP_EQUALS_FUNC:
+ return mbr1.equals(&mbr2);
+ case SP_DISJOINT_FUNC:
+ return mbr1.disjoint(&mbr2);
+ case SP_INTERSECTS_FUNC:
+ return mbr1.intersects(&mbr2);
+ case SP_TOUCHES_FUNC:
+ return mbr1.touches(&mbr2);
+ case SP_OVERLAPS_FUNC:
+ return mbr1.overlaps(&mbr2);
+ case SP_CROSSES_FUNC:
+ return 0;
+ default:
+ break;
+ }
+
+ null_value=1;
+ return 0;
+}
+
+
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b,
enum Functype sp_rel) :
Item_bool_func2(a,b), collector()
--- 1.18/sql/item_geofunc.h 2007-06-13 18:46:25 +05:00
+++ 1.19/sql/item_geofunc.h 2007-06-13 18:46:25 +05:00
@@ -187,6 +187,32 @@ public:
Spatial relations
*/
+class Item_func_spatial_mbr_rel: public Item_bool_func2
+{
+ enum Functype spatial_rel;
+public:
+ Item_func_spatial_mbr_rel(Item *a,Item *b, enum Functype sp_rel) :
+ Item_bool_func2(a,b) { spatial_rel = sp_rel; }
+ longlong val_int();
+ enum Functype functype() const
+ {
+ switch (spatial_rel) {
+ case SP_CONTAINS_FUNC:
+ return SP_WITHIN_FUNC;
+ case SP_WITHIN_FUNC:
+ return SP_CONTAINS_FUNC;
+ default:
+ return spatial_rel;
+ }
+ }
+ enum Functype rev_functype() const { return spatial_rel; }
+ const char *func_name() const;
+ void print(String *str) { Item_func::print(str); }
+ void fix_length_and_dec() { maybe_null= 1; }
+ bool is_null() { (void) val_int(); return null_value; }
+};
+
+
class Item_func_spatial_rel: public Item_bool_func2
{
enum Functype spatial_rel;
| Thread |
|---|
| • bk commit into 5.1 tree (holyfoot:1.2515) | holyfoot | 13 Jun |