From 376c509e76a9bb6be1b1d77d08ca07fc223009ec Mon Sep 17 00:00:00 2001
From: unknown <hf@deer.(none)>
Date: Wed, 11 Jun 2003 20:09:37 +0500
Subject: [PATCH] Bugfix for #614

Item_extract needs special implementation for eq().
Item_func::eq doesn't work correctly because we have to compare
Item_extract::int_type parameters also

We need to propagate this to 4.1


sql/item_timefunc.cc:
  Item_extract::eq implementation added
sql/item_timefunc.h:
  Item_extract::eq definition added
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
---
 BitKeeper/etc/logging_ok |  1 +
 sql/item_timefunc.cc     | 16 ++++++++++++++++
 sql/item_timefunc.h      |  1 +
 3 files changed, 18 insertions(+)

diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 4617e9d697b..092b6f3f2a5 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -24,6 +24,7 @@ heikki@donna.mysql.fi
 heikki@hundin.mysql.fi
 heikki@rescue.
 heikki@work.mysql.com
+hf@deer.(none)
 hf@deer.mysql.r18.ru
 hf@genie.(none)
 igor@hundin.mysql.fi
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 6a95c15a226..84e7a44ac61 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1137,6 +1137,22 @@ longlong Item_extract::val_int()
   return 0;					// Impossible
 }
 
+bool Item_extract::eq(const Item *item, bool binary_cmp) const
+{
+  if (this == item)
+    return 1;
+  if (item->type() != FUNC_ITEM ||
+      func_name() != ((Item_func*)item)->func_name())
+    return 0;
+
+  Item_extract* ie= (Item_extract*)item;
+  if (ie->int_type != int_type)
+    return 0;
+
+  if (!args[0]->eq(ie->args[0], binary_cmp))
+      return 0;
+  return 1;
+}
 
 void Item_typecast::print(String *str)
 {
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 0ca2a36609d..e04e24627d9 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -422,6 +422,7 @@ class Item_extract :public Item_int_func
   longlong val_int();
   const char *func_name() const { return "extract"; }
   void fix_length_and_dec();
+  bool eq(const Item *item, bool binary_cmp) const;
   unsigned int size_of() { return sizeof(*this);}  
 };
 
-- 
2.30.9