diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh
index a631219322150d3978c70ca88e16915179418947..f76fe02e2bd8c0433b49cf6edef512727a4ee832 100755
--- a/scripts/make_win_src_distribution.sh
+++ b/scripts/make_win_src_distribution.sh
@@ -12,6 +12,7 @@ CP="cp -p"
 DEBUG=0
 SILENT=0
 SUFFIX=""
+DIRNAME=""
 OUTTAR=0
 
 #
@@ -75,6 +76,7 @@ parse_arguments() {
       --debug)    DEBUG=1;;
       --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
       --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
+      --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;;
       --silent)   SILENT=1 ;;
       --tar)      OUTTAR=1 ;;
       --help)     show_usage ;;
@@ -155,11 +157,15 @@ mkdir $BASE/Docs $BASE/extra $BASE/include
 # Copy directory files
 #
 
-copy_dir_files() {
-  
+copy_dir_files()
+{
   for arg do
     print_debug "Copying files from directory '$arg'"
-    cd $SOURCE/$arg/
+    cd $SOURCE/$arg
+    if [ ! -d $BASE/$arg ]; then
+       print_debug "Creating directory '$arg'"
+       mkdir $BASE/$arg
+     fi
     for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def \
              README INSTALL* LICENSE 
     do 
@@ -199,9 +205,6 @@ copy_dir_dirs() {
     for i in *
     do
       if [ -d $SOURCE/$basedir/$i ] && [ "$i" != "SCCS" ]; then
-        if [ ! -d $BASE/$basedir/$i ]; then
-          mkdir $BASE/$basedir/$i
-        fi
         copy_dir_files $basedir/$i
       fi
     done
@@ -214,7 +217,7 @@ copy_dir_dirs() {
 
 for i in client dbug extra heap include isam \
          libmysql libmysqld merge myisam \
-         myisammrg mysys regex sql strings \
+         myisammrg mysys regex sql strings sql-common \
          vio zlib
 do
   copy_dir_files $i
@@ -270,15 +273,19 @@ done
 
 if [ -f scripts/mysql_install_db ]; then 
   print_debug "Initializing the 'data' directory"
-  scripts/mysql_install_db --windows --datadir=$BASE/data
+  scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data
 fi
 
-
 #
 # Specify the distribution package name and copy it
 #
 
-NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX
+if test -z $DIRNAME
+then
+  NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX
+else
+  NEW_DIR_NAME=$DIRNAME
+fi
 NEW_NAME=$NEW_DIR_NAME-win-src
 
 BASE2=$TMP/$NEW_DIR_NAME
@@ -345,7 +352,7 @@ set_tarzip_options()
       EXT=".zip"
       NEED_COMPRESS=0
       if [ "$SILENT" = "1" ] ; then
-        OPT="-r"
+        OPT="$OPT -q"
       fi
     fi
   done
@@ -386,9 +393,7 @@ fi
 print_debug "Removing temporary directory"
 rm -r -f $BASE
 
-echo "$NEW_NAME$EXT created successfully !!"
-
+if [ "$SILENT" = "0" ] ; then
+  echo "$NEW_NAME$EXT created successfully !!"
+fi
 # End of script
-
-
-
diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh
index c54394305cd7cf7b2b5cfdb1dcb92962922bd86f..51fbb8a80974a42619452c3040a0bceaf1d5166d 100644
--- a/scripts/mysql_create_system_tables.sh
+++ b/scripts/mysql_create_system_tables.sh
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (C) 1997-2002 MySQL AB
+# Copyright (C) 1997-2003 MySQL AB
 # For a more info consult the file COPYRIGHT distributed with this file
 
 # This script writes on stdout SQL commands to generate all not
@@ -12,7 +11,7 @@
 # $3 - hostname  
 # $4 - windows option
 
-if test x$1 = x"" ;
+if test "$1" = ""
 then
   echo "
 This script writes on stdout SQL commands to generate all not
@@ -20,9 +19,9 @@ existing MySQL system tables. It also replaces the help tables with
 new context from the manual (from fill_help_tables.sql).
 
 Usage:
-  mysql_create_system_tables {help|real|verbose} <path to mysql-database directory> <hostname> <windows option>
-";
-  exit;
+  mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
+"
+  exit
 fi
 
 mdata=$2
@@ -44,7 +43,7 @@ i_ht=""
 # Check for old tables
 if test ! -f $mdata/db.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing db table" 1>&2; 
   fi
 
@@ -76,7 +75,7 @@ fi
 
 if test ! -f $mdata/host.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing host table" 1>&2;
   fi
 
@@ -102,7 +101,7 @@ fi
 
 if test ! -f $mdata/user.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing user table" 1>&2;
   fi
 
@@ -142,7 +141,7 @@ then
   c_u="$c_u )"
   c_u="$c_u comment='Users and global privileges';"
 
-  if test x$1 = x"test" 
+  if test "$1" = "test" 
   then
     i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
     INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
@@ -165,7 +164,7 @@ fi
 
 if test ! -f $mdata/func.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing func table" 1>&2;
   fi
 
@@ -181,7 +180,7 @@ fi
 
 if test ! -f $mdata/tables_priv.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing tables_priv table" 1>&2;
   fi
 
@@ -202,7 +201,7 @@ fi
 
 if test ! -f $mdata/columns_priv.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing columns_priv table" 1>&2;
   fi
 
@@ -221,7 +220,7 @@ fi
 
 if test ! -f $mdata/help_topic.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing help_topic table" 1>&2;
   fi
 
@@ -242,7 +241,7 @@ old_categories="yes"
 		    
 if test ! -f $mdata/help_category.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing help_category table" 1>&2;
   fi
   
@@ -259,7 +258,7 @@ fi
 
 if test ! -f $mdata/help_keyword.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
     echo "Preparing help_keyword table" 1>&2;
   fi
 
@@ -274,7 +273,7 @@ fi
 				    
 if test ! -f $mdata/help_relation.frm
 then
-  if test x$1 = x"verbose" ; then
+  if test "$1" = "verbose" ; then
    echo "Preparing help_relation table" 1>&2;
   fi
 
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 96e33d3e7c50c130a3e3fb3166b8a174b09c7e0a..9e4f35dd5e192ef9fd835d87caba95b1f1b4e4f5 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -8,18 +8,8 @@
 # All unrecognized arguments to this script are passed to mysqld.
 
 in_rpm=0
-case "$1" in
-    --rpm)
-      in_rpm="1"; shift
-      ;;
-esac
 windows=0
-case "$1" in
-    --windows)
-      windows="1"; shift
-      ;;
-esac
-defaults=
+defaults=""
 case "$1" in
     --no-defaults|--defaults-file=*|--defaults-extra-file=*)
       defaults="$1"; shift
@@ -44,6 +34,8 @@ parse_arguments() {
       --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
       --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
       --verbose) verbose=1 ;;
+      --rpm) in_rpm=1 ;;
+      --windows) windows=1 ;;
       *)
         if test -n "$pick_args"
         then
@@ -61,6 +53,9 @@ parse_arguments() {
 if test -x ./bin/my_print_defaults
 then
   print_defaults="./bin/my_print_defaults"
+elif test -x ./extra/my_print_defaults
+then
+  print_defaults="./extra/my_print_defaults"
 elif test -x @bindir@/my_print_defaults
 then
   print_defaults="@bindir@/my_print_defaults"
@@ -79,6 +74,7 @@ basedir=
 force=0
 verbose=0
 fill_help_tables=""
+
 parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
 parse_arguments PICK-ARGS-FROM-ARGV "$@"
 
@@ -103,7 +99,7 @@ else
 fi
 
 # find fill_help_tables.sh
-for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` @pkgdatadir@
+for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
 do
   if test -f $i/fill_help_tables.sql
   then
@@ -115,22 +111,28 @@ if test -f $pkgdatadir/fill_help_tables.sql
 then
   fill_help_tables=$pkgdatadir/fill_help_tables.sql
 else
-  if test $verbose -eq 1
-  then
-    echo "Could not find help file 'fill_help_tables.sql' ;$pkgdatadir; ;$basedir;".
-  fi
+  echo "Could not find help file 'fill_help_tables.sql' in @pkgdatadir@ or inside $basedir".
+  exit 1;
 fi
 
 mdata=$ldata/mysql
+mysqld=$execdir/mysqld
+mysqld_opt=""
 
-if test "$windows" -eq 0 -a ! -x $execdir/mysqld
+if test "$windows" = 1
+then
+  mysqld="./sql/mysqld"
+  mysqld_opt="--language=./sql/share/english"
+fi
+
+if test ! -x $mysqld
 then
   if test "$in_rpm" -eq 1
   then
-    echo "FATAL ERROR $execdir/mysqld not found!"
+    echo "FATAL ERROR $mysqld not found!"
     exit 1
   else
-    echo "Didn't find $execdir/mysqld"
+    echo "Didn't find $mysqld"
     echo "You should do a 'make install' before executing this script"
     exit 1
   fi
@@ -184,23 +186,28 @@ else
   create_option="real"
 fi
 
-echo "Installing all prepared tables"
+if test "$in_rpm" -eq 0 -a "$windows" -eq 0
+then
+  echo "Installing all prepared tables"
+fi
 if (
-   mysql_create_system_tables $create_option $mdata $hostname $windows 
+   $pkgdatadir/mysql_create_system_tables $create_option $mdata $hostname $windows 
    if test -n "$fill_help_tables"
    then
      cat $fill_help_tables
    fi
-) | eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \
+) | eval "$mysqld $defaults $mysqld_opt --bootstrap --skip-grant-tables \
          --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $args" 
 then
-  echo ""
-  if test "$in_rpm" -eq 0 || "$windows" -eq 0
+  if test "$in_rpm" -eq 0 -a "$windows" -eq 0
   then
+    echo ""
     echo "To start mysqld at boot time you have to copy support-files/mysql.server"
     echo "to the right place for your system"
     echo
   fi
+  if test "$windows" -eq 0
+  then
   echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
   echo "This is done with:"
   echo "$bindir/mysqladmin -u root password 'new-password'"
@@ -216,7 +223,7 @@ then
     echo "able to use the new GRANT command!"
   fi
   echo
-  if test "$in_rpm" -eq 0 -a "$windows" -eq 0
+  if test "$in_rpm" -eq 0
   then
     echo "You can start the MySQL daemon with:"
     echo "cd @prefix@ ; $bindir/mysqld_safe &"
@@ -230,13 +237,14 @@ then
   echo "The latest information about MySQL is available on the web at"
   echo "http://www.mysql.com"
   echo "Support MySQL by buying support/licenses at https://order.mysql.com"
+  fi
   exit 0
 else
   echo "Installation of grant tables failed!"
   echo
   echo "Examine the logs in $ldata for more information."
   echo "You can also try to start the mysqld daemon with:"
-  echo "$execdir/mysqld --skip-grant &"
+  echo "$mysqld --skip-grant &"
   echo "You can use the command line tool"
   echo "$bindir/mysql to connect to the mysql"
   echo "database and look at the grant tables:"
diff --git a/sql-common/client.c b/sql-common/client.c
index 1f0f67e4ff17e36e4345d0542ec4c9a8fe9ed04b..66a073ed53f640f0f6d83ccdfd926e39df0123ac 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -107,7 +107,7 @@ const char	*unknown_sqlstate= "HY000";
 const char	*not_error_sqlstate= "00000";
 #ifdef HAVE_SMEM
 char		 *shared_memory_base_name= 0;
-const char 	def_shared_memory_base_name= default_shared_memory_base_name;
+const char 	*def_shared_memory_base_name= default_shared_memory_base_name;
 #endif
 
 static void mysql_close_free_options(MYSQL *mysql);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 74036edf605c4647b7f67353633c7bbe0ac1d514..d4997f78a9e224f74ddd81ae6b340436dad20492 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1652,7 +1652,9 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
 {
   List_iterator<Item> li(list);
   Item *item;
+#ifndef EMBEDDED_LIBRARY
   char buff[sizeof(char*)];			// Max local vars in function
+#endif
   used_tables_cache=0;
   const_item_cache=0;
 
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 49aad321702a0f4a5ff58421dd1731d1aef0a220..1bdca7167e80ee236e42a8ee375ed13f5bd869ad 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3337,15 +3337,19 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
     }
 
     tables[0].table->field[0]->store(user_name->host.str,(uint) 
-				     user_name->host.length, system_charset_info);
+				     user_name->host.length,
+				     system_charset_info);
     tables[0].table->field[1]->store(user_name->user.str,(uint) 
-				     user_name->user.length, system_charset_info);
+				     user_name->user.length,
+				     system_charset_info);
     if (!tables[0].table->file->index_read_idx(tables[0].table->record[0],0,
-					       (byte*) tables[0].table->field[0]->ptr,0,
+					       (byte*) tables[0].table->
+					       field[0]->ptr,0,
 					       HA_READ_KEY_EXACT))
     {
       int error;
-      if ((error = tables[0].table->file->delete_row(tables[0].table->record[0])))
+      if ((error = tables[0].table->file->delete_row(tables[0].table->
+						     record[0])))
       {
 	tables[0].table->file->print_error(error, MYF(0));
 	tables[0].table->file->index_end();
@@ -3355,7 +3359,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
     }
     tables[0].table->file->index_end();
   }
-err:
+
   VOID(pthread_mutex_unlock(&acl_cache->lock));
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a9a29904b601356ce5f05f491fc1440fdef4a23b..47c7026c184d81f6ea4813e0ea16b4b52425114e 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2308,7 +2308,6 @@ mysql_execute_command(THD *thd)
     break;
   }
   case SQLCOM_UPDATE:
-    TABLE_LIST *table;
     if (check_db_used(thd,tables))
       goto error;
 
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a5fd69c8fbb5a5841d40960ba21713b940fcc5f1..248496d6b4304de61ea276d0a4f0e805883f5a60 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8061,7 +8061,6 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select)
 bool JOIN::rollup_init()
 {
   uint i,j;
-  ORDER *group;
   Item **ref_array;
 
   tmp_table_param.quick_group= 0;	// Can't create groups in tmp table
@@ -8145,7 +8144,7 @@ bool JOIN::rollup_make_fields(List<Item> &all_fields, List<Item> &fields,
     ...
   */
 
-  for (level=0 ; level < send_group_parts > 0 ; level++)
+  for (level=0 ; level < send_group_parts ; level++)
   {
     uint i;
     uint pos= send_group_parts - level -1;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 91bd5a77d27900e89306f2186180a293aa51fb70..c385d6d5308c0c7bb31b32ea639851a143d0dc04 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3850,7 +3850,7 @@ purge_option:
 	  }
 	  Item *tmp= new Item_func_unix_timestamp($2);
 	  Lex->sql_command = SQLCOM_PURGE_BEFORE;
-	  Lex->purge_time= tmp->val_int();
+	  Lex->purge_time= (ulong) tmp->val_int();
 	}
 	;
 
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 4d9c735de216934e8a511ebc1867ae453993901c..f5da95571c449693872eb027ae5f7b223c314048 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -1723,13 +1723,13 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
   switch (count) { 
     /* Fall through all cases!!! */
 #ifdef UNICODE_32BIT
-    case 6: r[5] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x4000000;
-    case 5: r[4] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x200000;
-    case 4: r[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000;
+    case 6: r[5] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x4000000;
+    case 5: r[4] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x200000;
+    case 4: r[3] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000;
 #endif
-    case 3: r[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800;
-    case 2: r[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0;
-    case 1: r[0] = wc;
+    case 3: r[2] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800;
+    case 2: r[1] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0xc0;
+    case 1: r[0] = (uchar) wc;
   }
   return count;
 }