From bffebc8e0be4772e7988b6b23570bd1197c7214a Mon Sep 17 00:00:00 2001
From: unknown <monty@bitch.mysql.fi>
Date: Fri, 10 Aug 2001 17:05:54 +0300
Subject: [PATCH] Fixed bug in ALTER TABLE for MERGE tables Portability fixes
 Fixed problem when giving wrong arguments to myisam_recover Fix to remove
 warnings when using purify

BUILD/compile-solaris-sparc-purify:
  Added innodb and berkeleydb to test
mysql-test/install_test_db.sh:
  Portability fix.
sql/ha_myisam.cc:
  Fixed problem when giving wrong arguments to myisam_recover
sql/ha_myisammrg.cc:
  Fixed bug in ALTER TABLE for MERGE tables
sql/sql_list.h:
  Fix to remove warnings when using purify
sql/sql_select.cc:
  Fix to remove warnings from purify
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
---
 BUILD/compile-solaris-sparc-purify |  4 ++-
 BitKeeper/etc/logging_ok           |  1 +
 mysql-test/install_test_db.sh      |  2 +-
 sql/ha_myisam.cc                   |  2 +-
 sql/ha_myisammrg.cc                |  2 ++
 sql/sql_list.h                     | 11 ++++++--
 sql/sql_select.cc                  | 44 +++++++++++++++++-------------
 7 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify
index 7b655520da..b5c898bff3 100755
--- a/BUILD/compile-solaris-sparc-purify
+++ b/BUILD/compile-solaris-sparc-purify
@@ -6,6 +6,8 @@ aclocal && autoheader && aclocal && automake && autoconf
 (cd bdb/dist && sh s_all)
 (cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
 
-CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -O2" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_PURIFY -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug=full
+CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug=full --with-berkeley-db --with-innodb
 
 gmake -j 4
+
+cd sql ; rm mysqld ; make CXXLD="purify -best-effort g++"  mysqld
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index ce08f235c9..d39597b171 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -15,3 +15,4 @@ jcole@tetra.spaceapes.com
 davida@isil.mysql.com
 tonu@x153.internalnet
 tim@bitch.mysql.fi
+monty@bitch.mysql.fi
diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh
index 049ac6b1cd..6fe736644d 100644
--- a/mysql-test/install_test_db.sh
+++ b/mysql-test/install_test_db.sh
@@ -59,7 +59,7 @@ else
 basedir=.
 rm -rf share
 mkdir  share
-ln -sf ../../sql/share share/mysql 
+ln -f -s ../../sql/share share/mysql 
 fi
 
 # Initialize variables
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 6409ec5d01..8be6292030 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -35,7 +35,7 @@ ulong myisam_recover_options= HA_RECOVER_NONE;
 
 /* bits in myisam_recover_options */
 const char *myisam_recover_names[] =
-{ "DEFAULT", "BACKUP", "FORCE", "QUICK"};
+{ "DEFAULT", "BACKUP", "FORCE", "QUICK", NullS};
 TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names),"",
 				 myisam_recover_names};
 
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index b842c15cce..866fd1e69f 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -229,6 +229,7 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
     MYRG_TABLE *table;
     THD *thd=current_thd;
     create_info->merge_list.next= &create_info->merge_list.first;
+    create_info->merge_list.elements=0;
 
     for (table=file->open_tables ; table != file->end_table ; table++)
     {
@@ -240,6 +241,7 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
       fn_format(buff,name,"","",3);
       if (!(ptr->real_name=thd->strdup(buff)))
 	goto err;
+      create_info->merge_list.elements++;
       (*create_info->merge_list.next) = (byte*) ptr;
       create_info->merge_list.next= (byte**) &ptr->next;
     }
diff --git a/sql/sql_list.h b/sql/sql_list.h
index b86250f70b..d21f2e658d 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -27,8 +27,15 @@ class Sql_alloc
 public:
   static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr, size_t size) {} /*lint -e715 */
-  inline Sql_alloc() {};
-  inline ~Sql_alloc() {};
+#ifdef HAVE_purify
+  bool dummy;
+  inline Sql_alloc() :dummy(0) {}
+  inline ~Sql_alloc() {}
+#else
+  inline Sql_alloc() {}
+  inline ~Sql_alloc() {}
+#endif
+
 };
 
 /*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d23a7edd37..14640e8387 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1368,24 +1368,27 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
 
   if (cond->type() == Item::FUNC_ITEM)
   {
-    Item_func *func=(Item_func *)cond,
-              *arg0=(Item_func *)(func->arguments()[0]),
-              *arg1=(Item_func *)(func->arguments()[1]);
-
-    if (func->functype() == Item_func::FT_FUNC)
+    Item_func *func=(Item_func *)cond;
+    Item_func::Functype functype=  func->functype();
+    if (functype == Item_func::FT_FUNC)
       cond_func=(Item_func_match *)cond;
-    else if ((func->functype() == Item_func::GE_FUNC ||
-              func->functype() == Item_func::GT_FUNC)  &&
-              arg0->type() == Item::FUNC_ITEM          &&
-              arg0->functype() == Item_func::FT_FUNC   &&
-              arg1->const_item() && arg1->val()>=0)
-      cond_func=(Item_func_match *)arg0;
-    else if ((func->functype() == Item_func::LE_FUNC ||
-              func->functype() == Item_func::LT_FUNC)  &&
-              arg1->type() == Item::FUNC_ITEM          &&
-              arg1->functype() == Item_func::FT_FUNC   &&
-              arg0->const_item() && arg0->val()>=0)
-      cond_func=(Item_func_match *)arg1;
+    else if (func->arg_count == 2)
+    {
+      Item_func *arg0=(Item_func *)(func->arguments()[0]),
+                *arg1=(Item_func *)(func->arguments()[1]);
+      if ((functype == Item_func::GE_FUNC ||
+           functype == Item_func::GT_FUNC)  &&
+     	   arg0->type() == Item::FUNC_ITEM          &&
+           arg0->functype() == Item_func::FT_FUNC   &&
+           arg1->const_item() && arg1->val()>=0)
+        cond_func=(Item_func_match *) arg0;
+      else if ((functype == Item_func::LE_FUNC ||
+                functype == Item_func::LT_FUNC)  &&
+                arg1->type() == Item::FUNC_ITEM          &&
+                arg1->functype() == Item_func::FT_FUNC   &&
+                arg0->const_item() && arg0->val()>=0)
+        cond_func=(Item_func_match *) arg1;
+    }
   }
   else if (cond->type() == Item::COND_ITEM)
   {
@@ -1394,18 +1397,21 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
     if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
     {
       Item *item;
-      /* I'm too lazy to implement proper recursive descent here,
+      /*
+         I', (Sergei) too lazy to implement proper recursive descent here,
          and anyway, nobody will use such a stupid queries
          that will require it :-)
          May be later...
-       */
+      */
       while ((item=li++))
+      {
         if (item->type() == Item::FUNC_ITEM &&
             ((Item_func *)item)->functype() == Item_func::FT_FUNC)
         {
           cond_func=(Item_func_match *)item;
           break;
         }
+      }
     }
   }
 
-- 
2.30.9