diff --git a/Docs/INSTALL-BINARY b/Docs/INSTALL-BINARY
index c33d23674d69911324f8ec6b6d1718259094d910..499a8adf411fb7213e5ef3f30abdb5f26d0c920d 100644
--- a/Docs/INSTALL-BINARY
+++ b/Docs/INSTALL-BINARY
@@ -1,25 +1,20 @@
+MariaDB and MySQL have identical install methods. In this document we
+describe how to install MariaDB; However all documentation at www.mysql.com
+also applies.
 
-2.9. Installing MySQL from tar.gz Packages on Other Unix-Like Systems
 
-   This section covers the installation of MySQL binary distributions
-   that are provided for various platforms in the form of compressed
-   tar files (files with a .tar.gz extension). See Section 2.1.2.4,
-   "MySQL Binaries Compiled by Sun Microsystems, Inc.," for a
-   detailed list.
+2.9. Installing MariaDB from tar.gz Packages on Other Unix-Like Systems
 
-   To obtain MySQL, see Section 2.1.3, "How to Get MySQL."
+   This section covers the installation of MariaDB binary distributions
+   that are provided for various platforms in the form of compressed
+   tar files (files with a .tar.gz extension).
 
-   MySQL tar file binary distributions have names of the form
-   mysql-VERSION-OS.tar.gz, where VERSION is a number (for example,
+   MariaDB tar file binary distributions have names of the form
+   mariadb-VERSION-OS.tar.gz, where VERSION is a number (for example,
    5.1.39), and OS indicates the type of operating system for which
    the distribution is intended (for example, pc-linux-i686).
 
-   In addition to these generic packages, we also offer binaries in
-   platform-specific package formats for selected platforms. See
-   Section 2.2, "Standard MySQL Installation Using a Binary
-   Distribution," for more information on how to install these.
-
-   You need the following tools to install a MySQL tar file binary
+   You need the following tools to install a MariaDB tar file binary
    distribution:
 
      * GNU gunzip to uncompress the distribution.
@@ -33,11 +28,14 @@
        program. On other systems with a deficient tar, you should
        install GNU tar first.
 
-   If you run into problems and need to file a bug report, please use
-   the instructions in Section 1.6, "How to Report Bugs or Problems."
+   If you run into problems and need to file a bug report,
+   please report them to: http://bugs.launchpad.net/maria
+
+   See the instructions in Section 1.6, "How to Report Bugs or Problems."
 
    The basic commands that you must execute to install and use a
-   MySQL binary distribution are:
+   MariaDB binary distribution are:
+
 shell> groupadd mysql
 shell> useradd -g mysql mysql
 shell> cd /usr/local
@@ -53,7 +51,7 @@ shell> bin/mysqld_safe --user=mysql &
 
 Note
 
-   This procedure does not set up any passwords for MySQL accounts.
+   This procedure does not set up any passwords for MariaDB accounts.
    After following the procedure, proceed to Section 2.11,
    "Post-Installation Setup and Testing."
 
@@ -80,8 +78,8 @@ shell> useradd -g mysql mysql
 shell> cd /usr/local
 
     3. Obtain a distribution file using the instructions in Section
-       2.1.3, "How to Get MySQL." For a given release, binary
-       distributions for all platforms are built from the same MySQL
+       2.1.3, "How to Get MariaDB." For a given release, binary
+       distributions for all platforms are built from the same MariaDB
        source distribution.
 
     4. Unpack the distribution, which creates the installation
@@ -106,7 +104,7 @@ shell> cd mysql
           + The bin directory contains client programs and the
             server. You should add the full path name of this
             directory to your PATH environment variable so that your
-            shell finds the MySQL programs properly. See Section
+            shell finds the MariaDB programs properly. See Section
             2.14, "Environment Variables."
 
           + The scripts directory contains the mysql_install_db
@@ -126,8 +124,8 @@ shell> chgrp -R mysql .
        the mysql user. The second changes the group attribute to the
        mysql group.
 
-    7. If you have not installed MySQL before, you must create the
-       MySQL data directory and initialize the grant tables:
+    7. If you have not installed MariaDB before, you must create the
+       MariaDB data directory and initialize the grant tables:
 shell> scripts/mysql_install_db --user=mysql
        If you run the command as root, include the --user option as
        shown. If you run the command while logged in as that user,
@@ -137,25 +135,26 @@ shell> scripts/mysql_install_db --user=mysql
        After creating or updating the grant tables, you need to
        restart the server manually.
 
-    8. Most of the MySQL installation can be owned by root if you
+    8. Most of the MariaDB installation can be owned by root if you
        like. The exception is that the data directory must be owned
        by mysql. To accomplish this, run the following commands as
        root in the installation directory:
+
 shell> chown -R root .
 shell> chown -R mysql data
 
-    9. If you want MySQL to start automatically when you boot your
+    9. If you want MariaDB to start automatically when you boot your
        machine, you can copy support-files/mysql.server to the
        location where your system has its startup files. More
        information can be found in the support-files/mysql.server
        script itself and in Section 2.11.2.2, "Starting and Stopping
-       MySQL Automatically."
+       MariaDB Automatically."
    10. You can set up new accounts using the bin/mysql_setpermission
        script if you install the DBI and DBD::mysql Perl modules. See
        Section 4.6.14, "mysql_setpermission --- Interactively Set
        Permissions in Grant Tables." For Perl module installation
        instructions, see Section 2.15, "Perl Installation Notes."
-   11. If you would like to use mysqlaccess and have the MySQL
+   11. If you would like to use mysqlaccess and have the MariaDB
        distribution in some nonstandard location, you must change the
        location where mysqlaccess expects to find the mysql client.
        Edit the bin/mysqlaccess script at approximately line 18.
@@ -166,7 +165,7 @@ $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
        error will occur when you run mysqlaccess.
 
    After everything has been unpacked and installed, you should test
-   your distribution. To start the MySQL server, use the following
+   your distribution. To start the MariaDB server, use the following
    command:
 shell> bin/mysqld_safe --user=mysql &
 
@@ -185,7 +184,7 @@ shell> bin/mysqld_safe --user=mysql &
 
 Note
 
-   The accounts that are listed in the MySQL grant tables initially
+   The accounts that are listed in the MariaDB grant tables initially
    have no passwords. After starting the server, you should set up
    passwords for them using the instructions in Section 2.11,
    "Post-Installation Setup and Testing."
diff --git a/Docs/myisam.txt b/Docs/myisam.txt
index e0b56e795488ddc6665ead4a752a1a8e34081a18..ceb4ae7dc0bbc040b2759e0ecbe4450cca606780 100644
--- a/Docs/myisam.txt
+++ b/Docs/myisam.txt
@@ -868,7 +868,7 @@ Space compression makes the index file smaller if the string column has a lot of
 Prefix compression helps if there are many strings with an identical prefix.
 
 In memory table characteristics 
-HEAP tables only exists in memory so they are lost if `mysqld' is taken down or crashes. But since they are *very* fast they are usefull as anyway. 
+HEAP tables only exists in memory so they are lost if `mysqld' is taken down or crashes. But since they are *very* fast they are useful as anyway. 
 
 The *MySQL* internal HEAP tables uses 100% dynamic hashing without overflow areas and don't have problems with delete. 
 
diff --git a/Docs/mysql.info b/Docs/mysql.info
index b2c411e51ab1b254c0e69533aba7376c03d0dc0a..3b9d298a6843c31d89416da308bbaebaf16fea7a 100644
--- a/Docs/mysql.info
+++ b/Docs/mysql.info
@@ -1,3 +1,10 @@
+MariaDB is in most aspects identical to MySQL.
+
+Differences between MySQL and MariaDB can be found at:
+http://askmonty.org/wiki/index.php/MariaDB_versus_MySQL
+
+The MariaDB references manual can be found at:
+http://askmonty.org/wiki/index.php/Manual
 
 The MySQL Reference Manual is available in various formats on
 http://dev.mysql.com/doc; if you're interested in the DocBook XML
diff --git a/README b/README
index fb6d8a8abcfe279b50d03032ad05888f6fafa9ef..7ad036784dda13c4373aa1789502e545a41d1c91 100644
--- a/README
+++ b/README
@@ -1,5 +1,4 @@
 This is a release of MariaDB, a branch of MySQL.
-MySQL is brought to you by the MySQL team at Sun Microsystems, Inc.
 
 MariaDB is a drop-in replacement of MySQL, with more features, less
 bugs and better performance.
diff --git a/configure.in b/configure.in
index 8ee4a3a47fca75f72a32084b764de61fcfcafa5e..0bbb91894c82c749c78b9f565a69dd7ceeb4ffae 100644
--- a/configure.in
+++ b/configure.in
@@ -2847,7 +2847,7 @@ do
 done
 AC_SUBST(sql_union_dirs)
 
-# Some usefull subst
+# Some useful subst
 AC_SUBST(CC)
 AC_SUBST(GXX)
 
@@ -2897,13 +2897,11 @@ AC_CONFIG_COMMANDS_POST(ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' C
 AC_OUTPUT
 
 echo
-echo "MySQL has a Web site at http://www.mysql.com/ which carries details on the"
-echo "latest release, upcoming features, and other information to make your"
-echo "work or play with MySQL more productive. There you can also find"
-echo "information about mailing lists for MySQL discussion."
+echo "You can find information about MariaDB at"
+echo http://askmonty.org/wiki/index.php/MariaDB
 echo
 echo "Remember to check the platform specific part of the reference manual for"
-echo "hints about installing MySQL on your platform. Also have a look at the"
+echo "hints about installing MariaDB on your platform. Also have a look at the"
 echo "files in the Docs directory."
 echo
 
@@ -2922,5 +2920,5 @@ echo "---"
 
 # The following text is checked in ./Do-compile to verify that configure
 # ended sucessfully - don't remove it.
-echo "Thank you for choosing MySQL!"
+echo "Thank you for choosing MariaDB!"
 echo
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 526dcf51e70889b7576d6cd227c24df508de9332..b2d222a6d669c4f4a82d10403c05c63921d121e6 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1432,7 +1432,8 @@ mysql_get_server_info(MYSQL *mysql)
 
 my_bool STDCALL mariadb_connection(MYSQL *mysql)
 {
-  return strinstr(mysql->server_version, "MariaDB") != 0;
+  return (strinstr(mysql->server_version, "MariaDB") != 0 ||
+          strinstr(mysql->server_version, "-maria-") != 0);
 }
 
 const char * STDCALL
diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl
index 3061506da51125532d9ff03f7d1d00f3f7c3fc33..ff2566b1476476a973e32195c31c0a92ac07b7e9 100755
--- a/mysql-test/mysql-stress-test.pl
+++ b/mysql-test/mysql-stress-test.pl
@@ -1100,7 +1100,7 @@ mysql-stress-test.pl --stress-basedir=<dir> --stress-suite-basedir=<dir> --serve
       they specified in the list file. 
       
 --sleep-time=<time in seconds>
-  Delay between test execution. Could be usefull in continued testsing 
+  Delay between test execution. Could be useful in continued testsing 
   when one of instance of stress script perform periodical cleanup or
   recreating of some database objects
 
@@ -1109,7 +1109,7 @@ mysql-stress-test.pl --stress-basedir=<dir> --stress-suite-basedir=<dir> --serve
 
 --check-tests-file
   Check file with list of tests. If file was modified it will force to
-  reread list of tests. Could be usefull in continued testing for
+  reread list of tests. Could be useful in continued testing for
   adding/removing tests without script interruption 
 
 --mysqltest=/path/to/mysqltest binary
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 0e1a8c9a4aafd058d0ccb947ce40526d4adb4de7..e7ab9ba7a1f1468fb521a2debd6993d8933f3aa4 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -42,7 +42,8 @@ static void netware_init();
 
 my_bool my_init_done= 0;
 uint	mysys_usage_id= 0;              /* Incremented for each my_init() */
-ulong   my_thread_stack_size= 65536;
+
+ulong   my_thread_stack_size= (sizeof(void*) <= 4)? 65536: ((256-16)*1024);
 
 static ulong atoi_octal(const char *str)
 {
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index 79ae643a301c098467b049c826a5e8e48239e73a..c666b517608884919b80899a3c992b0459d3bdb6 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -436,7 +436,7 @@ void TERMINATE(FILE *file, uint flag)
 /*
   Report where a piece of memory was allocated
 
-  This is usefull to call from withing a debugger
+  This is useful to call from withing a debugger
 */
 
 void sf_malloc_report_allocated(void *memory)
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index bc54dc7062f65465552c54b43c64101ace50c569..9595a56ef62c3ff2efb373dd0ab4c9a0c3c9a72e 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -171,9 +171,9 @@ case $VERSION_NAME in
   *-ndb-* )  VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;;
 esac
 if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then
-  NEW_NAME=mysql-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX
+  NEW_NAME=mariadb-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX
 else
-  NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX
+  NEW_NAME=mariadb@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX
 fi
 
 # ----------------------------------------------------------------------
@@ -239,8 +239,8 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
   # ----------------------------------------------------------------------
 
   cd scripts
-  rm -f mysql_install_db
-  @MAKE@ mysql_install_db \
+  rm -f mysql_install_db mysqld_safe mysql_fix_privilege_tables
+  @MAKE@ mysql_install_db mysqld_safe mysql_fix_privilege_tables \
     prefix=. \
     bindir=./bin \
     sbindir=./bin \
@@ -257,7 +257,7 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
     sbindir=./bin \
     scriptdir=./bin \
     libexecdir=./bin \
-    pkgdatadir=@pkgdatadir@
+    pkgdatadir=./share 
   cd ..
 
   # ----------------------------------------------------------------------
@@ -320,6 +320,33 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
   mkdir       $DEST/data $DEST/data/mysql $DEST/data/test
   chmod o-rwx $DEST/data $DEST/data/mysql $DEST/data/test
 
+  # Remove not needed files
+  rm $DEST/share/mysql/errmsg.txt
+
+  # Remove NDB files
+  rm -f $DEST/share/mysql/ndb-config-2-node.ini \
+      $DEST/share/mysql/config*
+
+  #
+  # Move things to make them easier to find in tar installation
+  #
+  mv $DEST/libexec/* $DEST/bin
+  mv $DEST/share/man $DEST
+  mv $DEST/share/mysql/binary-configure $DEST/configure
+  mv $DEST/share/mysql/*.sql $DEST/share
+  mv $DEST/share/mysql/*.cnf $DEST/share/mysql/*.server $DEST/share/mysql/mysql-log-rotate $DEST/support-files
+  rmdir $DEST/libexec
+
+  #
+  # Move some scripts that are only run once to 'scripts' directory
+  # but add symbolic links instead to old place for compatibility
+  #
+  for i in mysql_secure_installation mysql_fix_extensions mysql_fix_privilege_tables
+  do
+    mv $DEST/bin/$i $DEST/scripts
+    ln -s "../scripts/$i" $DEST/bin/$i
+  done
+
   # ----------------------------------------------------------------------
   # Create the result tar file
   # ----------------------------------------------------------------------
@@ -389,6 +416,9 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
   extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
   storage/myisam/myisamchk$BS storage/myisam/myisampack$BS \
   storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \
+  storage/maria/maria_chk$BS storage/maria/maria_pack$BS \
+  storage/maria/maria_ftdump$BS storage/maria/maria_read_log$BS \
+  storage/maria/maria_dump_log$BS \
   sql/mysqld$BS sql/mysqld-debug$BS \
   sql/mysql_tzinfo_to_sql$BS \
   server-tools/instance-manager/mysqlmanager$BS \
@@ -493,12 +523,21 @@ rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh \
     $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution \
     $BASE/bin/make_win_* \
     $BASE/bin/setsomevars $BASE/support-files/Makefile* \
-    $BASE/support-files/*.sh
+    $BASE/support-files/*.sh \
+    $BASE/share/mysql/errmsg.txt
+
+# Remove NDB files
+rm -f $BASE/share/ndb-config-2-node.ini \
+      $BASE/share/mysql/config*
 
 #
-# Copy system dependent files
+# Move things to make things easier to find in tar installation
 #
-./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
+
+mv $BASE/share/man $BASE
+mv $BASE/share/mysql/binary-configure $BASE/configure
+mv $BASE/share/mysql/*.sql $BASE/share
+mv $BASE/share/mysql/*.cnf $BASE/share/mysql/*.server $BASE/share/mysql/mysql-log-rotate $BASE/support-files
 
 #
 # Remove system dependent files
@@ -512,12 +551,6 @@ rm -f   $BASE/support-files/magic \
         $BASE/support-files/MySQL-shared-compat.spec \
         $BASE/INSTALL-BINARY
 
-# Clean up if we did this from a bk tree
-if [ -d $BASE/sql-bench/SCCS ] ; then
-  find $BASE/share -name SCCS -print | xargs rm -rf
-  find $BASE/sql-bench -name SCCS -print | xargs rm -rf
-fi
-
 BASE2=$TMP/$NEW_NAME
 rm -rf $BASE2
 mv $BASE $BASE2
diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh
index 6c2d88d6d29eab93f2fa9eb033a3c0ef731fe361..6985a58ce767782e18be4bd33ef34742924100cf 100644
--- a/scripts/mysql_secure_installation.sh
+++ b/scripts/mysql_secure_installation.sh
@@ -23,6 +23,157 @@ trap "interrupt" 2
 rootpass=""
 echo_n=
 echo_c=
+basedir=
+bindir=
+
+parse_arg()
+{
+  echo "$1" | sed -e 's/^[^=]*=//'
+}
+
+parse_arguments()
+{
+  # We only need to pass arguments through to the server if we don't
+  # handle them here.  So, we collect unrecognized options (passed on
+  # the command line) into the args variable.
+  pick_args=
+  if test "$1" = PICK-ARGS-FROM-ARGV
+  then
+    pick_args=1
+    shift
+  fi
+
+  for arg
+  do
+    case "$arg" in
+      --basedir=*) basedir=`parse_arg "$arg"` ;;
+      --no-defaults|--defaults-file=*|--defaults-extra-file=*)
+        defaults="$arg" ;;
+      *)
+        if test -n "$pick_args"
+        then
+          # This sed command makes sure that any special chars are quoted,
+          # so the arg gets passed exactly to the server.
+          # XXX: This is broken; true fix requires using eval and proper
+          # quoting of every single arg ($basedir, $ldata, etc.)
+          #args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
+          args="$args $arg"
+        fi
+        ;;
+    esac
+  done
+}
+
+# Try to find a specific file within --basedir which can either be a binary
+# release or installed source directory and return the path.
+find_in_basedir()
+{
+  return_dir=
+  case "$1" in
+    --dir)
+      return_dir=1; shift
+      ;;
+  esac
+
+  file=$1; shift
+
+  for dir in "$@"
+  do
+    if test -f "$basedir/$dir/$file"
+    then
+      if test -n "$return_dir"
+      then
+        echo "$basedir/$dir"
+      else
+        echo "$basedir/$dir/$file"
+      fi
+      break
+    fi
+  done
+}
+
+cannot_find_file()
+{
+  echo
+  echo "FATAL ERROR: Could not find $1"
+
+  shift
+  if test $# -ne 0
+  then
+    echo
+    echo "The following directories were searched:"
+    echo
+    for dir in "$@"
+    do
+      echo "    $dir"
+    done
+  fi
+
+  echo
+  echo "If you compiled from source, you need to run 'make install' to"
+  echo "copy the software into the correct location ready for operation."
+  echo
+  echo "If you are using a binary release, you must either be at the top"
+  echo "level of the extracted archive, or pass the --basedir option"
+  echo "pointing to that location."
+  echo
+}
+
+# Ok, let's go.  We first need to parse arguments which are required by
+# my_print_defaults so that we can execute it first, then later re-parse
+# the command line to add any extra bits that we need.
+parse_arguments PICK-ARGS-FROM-ARGV "$@"
+
+#
+# We can now find my_print_defaults.  This script supports:
+#
+#   --srcdir=path pointing to compiled source tree
+#   --basedir=path pointing to installed binary location
+#
+# or default to compiled-in locations.
+#
+
+if test -n "$basedir"
+then
+  print_defaults=`find_in_basedir my_print_defaults bin extra`
+  echo "print: $print_defaults"
+  if test -z "$print_defaults"
+  then
+    cannot_find_file my_print_defaults $basedir/bin $basedir/extra
+    exit 1
+  fi
+else
+  print_defaults="@bindir@/my_print_defaults"
+fi
+
+if test ! -x "$print_defaults"
+then
+  cannot_find_file "$print_defaults"
+  exit 1
+fi
+
+# Now we can get arguments from the group [client]
+# in the my.cfg file, then re-run to merge with command line arguments.
+parse_arguments `$print_defaults $defaults client`
+parse_arguments PICK-ARGS-FROM-ARGV "$@"
+
+# Configure paths to support files
+if test -n "$basedir"
+then
+  bindir="$basedir/bin"
+elif test -f "./bin/mysql"
+  then
+  bindir="./bin"
+else
+  bindir="@bindir@"
+fi
+
+mysql_command=`find_in_basedir mysql $bindir`
+if test -z "$print_defaults"
+then
+  cannot_find_file mysql $bindir
+  exit 1
+fi
 
 set_echo_compat() {
     case `echo "testing\c"`,`echo -n testing` in
@@ -39,7 +190,7 @@ prepare() {
 
 do_query() {
     echo $1 >$command
-    mysql --defaults-file=$config <$command
+    $bindir/mysql --defaults-file=$config <$command
     return $?
 }
 
@@ -184,15 +335,10 @@ cleanup() {
 prepare
 set_echo_compat
 
-echo
-echo
-echo
 echo
 echo "NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL"
 echo "      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!"
 echo
-echo
-
 echo "In order to log into MySQL to secure it, we'll need the current"
 echo "password for the root user.  If you've just installed MySQL, and"
 echo "you haven't set the root password yet, the password will be blank,"
@@ -309,14 +455,9 @@ echo
 
 cleanup
 
-echo
-echo
 echo
 echo "All done!  If you've completed all of the above steps, your MySQL"
 echo "installation should now be secure."
 echo
 echo "Thanks for using MySQL!"
-echo
-echo
-
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 02f427301a41c27dfc6e865f4b52495f4206bd0e..6a7209cd6116eb42885aa497a47e378c9e7b87bf 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4564,7 +4564,13 @@ we force server id to 2, but this MySQL server will not act as a slave.");
   {
     select_thread_in_use= 0;                    // Allow 'kill' to work
     bootstrap(stdin);
-    unireg_abort(bootstrap_error ? 1 : 0);
+    if (!kill_in_progress)
+      unireg_abort(bootstrap_error ? 1 : 0);
+    else
+    {
+      sleep(2);                                 // Wait for kill
+      exit(0);
+    }
   }
   if (opt_init_file)
   {
@@ -4716,7 +4722,7 @@ default_service_handling(char **argv,
     if (opt_delim= strchr(extra_opt, '='))
     {
       size_t length= ++opt_delim - extra_opt;
-      strnmov(pos, extra_opt, length);
+      pos= strnmov(pos, extra_opt, length);
     }
     else
       opt_delim= extra_opt;
@@ -6636,7 +6642,7 @@ log and this option does nothing anymore.",
    0, 0, 0, 0, 0},
 
   {"test-ignore-wrong-options", OPT_TEST_IGNORE_WRONG_OPTIONS,
-   "Ignore wrong enums values in command line arguments. Usefull only for test scripts",
+   "Ignore wrong enums values in command line arguments. Useful only for test scripts",
    (uchar**) &opt_ignore_wrong_options, (uchar**) &opt_ignore_wrong_options,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"timed_mutexes", OPT_TIMED_MUTEXES,
@@ -7176,7 +7182,7 @@ The minimum value for this variable is 4096.",
   {"thread_stack", OPT_THREAD_STACK,
    "The stack size for each thread.", (uchar**) &my_thread_stack_size,
    (uchar**) &my_thread_stack_size, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
-   1024L*128L, (longlong) ULONG_MAX, 0, 1024, 0},
+   (sizeof(void*)<=4)?1024L*128L: ((256-16)*1024L), (longlong) ULONG_MAX, 0, 1024, 0},
   { "time_format", OPT_TIME_FORMAT,
     "The TIME format (for future).",
     (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 05ea8f8ad6566ae0ff5691a8b4cf5cf5ca297ce0..df707075f5fe5c0741e3cac3176fd28463f07712 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -11813,7 +11813,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
   {
 #if !defined(DBUG_OFF) && defined(NOT_USING_ITEM_EQUAL)
     /*
-      This test could be very usefull to find bugs in the optimizer
+      This test could be very useful to find bugs in the optimizer
       where we would call this function with an expression that can't be
       evaluated yet. We can't have this enabled by default as long as
       have items like Item_equal, that doesn't report they are const but
diff --git a/sql/udf_example.c b/sql/udf_example.c
index 96b7da525dc2e1b5f2531bd4a0476e9c5ad1b06e..9b8f65a4a7463e657e7a43f41b1d75135b461873 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -207,7 +207,7 @@ char *is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long
 **		try to keep the error message less than 80 bytes long!
 **
 ** This function should return 1 if something goes wrong. In this case
-** message should contain something usefull!
+** message should contain something useful!
 **************************************************************************/
 
 #define MAXMETAPH 8
diff --git a/storage/maria/Makefile.am b/storage/maria/Makefile.am
index 0f1e482c3a16d9b3b48147a4e52a2047aadbfb41..d38abe01bdcce0fc978f2331f1c128955aaa0cf3 100644
--- a/storage/maria/Makefile.am
+++ b/storage/maria/Makefile.am
@@ -32,7 +32,7 @@ SUBDIRS =		. unittest
 
 EXTRA_DIST =		ma_test_all.sh ma_test_all.res ma_test_big.sh \
 			ma_ft_stem.c CMakeLists.txt plug.in ma_test_recovery
-pkgdata_DATA =		ma_test_all ma_test_all.res ma_test_recovery
+pkgdata_DATA =		
 pkglib_LIBRARIES =	libmaria.a
 bin_PROGRAMS =		maria_chk maria_pack maria_ftdump maria_read_log \
 			maria_dump_log
diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am
index 4bd0b177daa09e889751f563cfdac7cc71f43456..ea9426728560d3147b652d03087dd5ff8ecf51e5 100644
--- a/storage/myisam/Makefile.am
+++ b/storage/myisam/Makefile.am
@@ -28,7 +28,7 @@ LDADD =
 DEFS =                  @DEFS@
 
 EXTRA_DIST =		mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
-pkgdata_DATA =		mi_test_all mi_test_all.res
+pkgdata_DATA =		
 
 pkglib_LIBRARIES =	libmyisam.a
 bin_PROGRAMS =		myisamchk myisamlog myisampack myisam_ftdump
diff --git a/support-files/Makefile.am b/support-files/Makefile.am
index 77eddea3227ae590b53cb7329eb2bc324bab32f3..52e3ed5d8540faebf6456b1f2e8fb68fdbd9a814 100644
--- a/support-files/Makefile.am
+++ b/support-files/Makefile.am
@@ -53,7 +53,9 @@ pkgsupp_DATA =		my-small.cnf \
 			ndb-config-2-node.ini
 
 pkgsupp_SCRIPTS =	mysql.server \
-			mysqld_multi.server
+			mysqld_multi.server \
+	                binary-configure \
+			mysql-log-rotate
 
 aclocaldir =		$(datadir)/aclocal
 aclocal_DATA =		mysql.m4
diff --git a/support-files/config.huge.ini.sh b/support-files/config.huge.ini.sh
old mode 100755
new mode 100644
diff --git a/support-files/config.medium.ini.sh b/support-files/config.medium.ini.sh
old mode 100755
new mode 100644
diff --git a/support-files/config.small.ini.sh b/support-files/config.small.ini.sh
old mode 100755
new mode 100644
diff --git a/support-files/my-innodb-heavy-4G.cnf.sh b/support-files/my-innodb-heavy-4G.cnf.sh
index e9390a5b9e8424a1df268301ac38a3c56e5167c4..305a6ee30063b79fd866cd6f4f749b744c231dad 100644
--- a/support-files/my-innodb-heavy-4G.cnf.sh
+++ b/support-files/my-innodb-heavy-4G.cnf.sh
@@ -174,7 +174,7 @@ default-storage-engine = MYISAM
 # memory, while if you use your own stack hungry UDF functions or your
 # OS requires more stack for some operations, you might need to set this
 # to a higher value.
-thread_stack = 192K
+thread_stack = 240K
 
 # Set the default transaction isolation level. Levels available are:
 # READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE
diff --git a/support-files/my-small.cnf.sh b/support-files/my-small.cnf.sh
index 3bfa08d0bd199d3de03e7e81cbce3e7ca31a6791..7dce9e60ed9855b99a35898ae185ba46312d2d3f 100644
--- a/support-files/my-small.cnf.sh
+++ b/support-files/my-small.cnf.sh
@@ -34,7 +34,7 @@ sort_buffer_size = 64K
 read_buffer_size = 256K
 read_rnd_buffer_size = 256K
 net_buffer_length = 2K
-thread_stack = 128K
+thread_stack = 240K
 
 # Don't listen on a TCP/IP port at all. This can be a security enhancement,
 # if all processes that need to connect to mysqld run on the same host.
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 87198fc9cf5ab010e757d3698b0922548928849d..d8725b98ca55d0b37aaace506fed1ccb0a0fc680 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -77,7 +77,12 @@ else
     datadir="$basedir/data"
   fi
   sbindir="$basedir/sbin"
-  libexecdir="$basedir/libexec"
+  if test -f "$basedir/bin/mysqld"
+  then
+    libexecdir="$basedir/bin"
+  else
+    libexecdir="$basedir/libexec"
+  fi
 fi
 
 # datadir_set is used to determine if datadir was set (and so should be
@@ -126,6 +131,12 @@ parse_server_arguments() {
 		      datadir="$basedir/data"
 		    fi
 		    sbindir="$basedir/sbin"
+                    if test -f "$basedir/bin/mysqld"
+                    then
+                      libexecdir="$basedir/bin"
+                    else
+                      libexecdir="$basedir/libexec"
+                    fi
 		    libexecdir="$basedir/libexec"
         ;;
       --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
@@ -434,9 +445,36 @@ case "$mode" in
       fi
     fi
     ;;
-    *)
+  'configtest')
+    # Safeguard (relative paths, core dumps..)
+    cd $basedir
+    echo $echo_n "Testing MySQL configuration syntax"
+    daemon=$bindir/mysqld
+    if test -x $libexecdir/mysqld
+    then
+      daemon=$libexecdir/mysqld
+    elif test -x $sbindir/mysqld
+    then
+      daemon=$sbindir/mysqld
+    elif test -x `which mysqld`
+    then
+      daemon=`which mysqld`
+    else
+      log_failure_msg "Unable to locate the mysqld binary!"
+      exit 1
+    fi
+    help_out=`$daemon --help 2>&1`; r=$?
+    if test "$r" != 0 ; then
+      log_failure_msg "$help_out"
+      log_failure_msg "There are syntax errors in the server configuration. Please fix them!"
+    else
+      log_success_msg "Syntax OK"
+    fi
+    exit $r
+    ;;
+  *)
       # usage
-      echo "Usage: $0  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]"
+      echo "Usage: $0  {start|stop|restart|reload|force-reload|status|configtest}  [ MySQL server options ]"
       exit 1
     ;;
 esac