diff --git a/BitKeeper/etc/config b/BitKeeper/etc/config
index 85b5a871301f105da570fe86ce779955b002942e..9df006ac7d5c703d56b171c3a19d8bbb3e7e9de9 100644
--- a/BitKeeper/etc/config
+++ b/BitKeeper/etc/config
@@ -42,7 +42,7 @@ single_host:
 # discovers a problem which requires local intervention.  Please make the
 # contact information accurate so we can support you.
 # 
-contact: Sasha Pachev <sasha@mysql.com> 
+contact: sys@mysql.com
 # 
 # It is very important that this email address is filled out and accurate.
 # If someone converts your repository to open logging (which you may not
@@ -51,7 +51,7 @@ contact: Sasha Pachev <sasha@mysql.com>
 # response from anyone else at your location after 90 days, then open logging
 # will be implicitly approved.
 # 
-email: sasha@mysql.com 
+email: sys@mysql.com 
 # 
 # Add your street address if you like, it is optional.
 # 
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 14778876868d64537e577aa5bba0068bd32f6866..4cf86eb31c7654407e0fabf3c1f121eca6e5e6fd 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -210,7 +210,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     print_version();
     exit(0);
   case '?':
-  default:
     usage();
     exit(0);
   }
diff --git a/include/my_base.h b/include/my_base.h
index 7d7e296ead3f4ea3a662c282acc005957a0c86bc..2450ab334250ea27b9de15e0703d791011916803 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -300,8 +300,10 @@ enum data_file_type {
 
 /* For number of records */
 #ifdef BIG_TABLES
+#define rows2double(A)	ulonglong2double(A)
 typedef my_off_t	ha_rows;
 #else
+#define rows2double(A)	(double) (A)
 typedef ulong		ha_rows;	
 #endif
 
diff --git a/sql/filesort.cc b/sql/filesort.cc
index e42baf333a5fad883c27d4e9c8424d3b5419a112..ad16c16db3e3b96908488c5abac8eb060a572ff4 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -230,7 +230,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
   if (error)
     my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG));
   else
-    statistic_add(filesort_rows, records, &LOCK_status);
+    statistic_add(filesort_rows, (ulong) records, &LOCK_status);
   *examined_rows= param.examined_rows;
 #ifdef SKIP_DBUG_IN_FILESORT
   DBUG_POP();			/* Ok to DBUG */
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index e34bfdea2dd8eefc7b0156ed9b358bd7372362d6..06acf4fa2e38b0302655ac4840a9c272ad49c0a9 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -1929,7 +1929,7 @@ int ha_berkeley::delete_table(const char *name)
 
 double ha_berkeley::scan_time()
 {
-  return records/3;
+  return rows2double(records/3);
 }
 
 ha_rows ha_berkeley::records_in_range(int keynr,
@@ -2204,7 +2204,7 @@ static BDB_SHARE *get_share(const char *table_name, TABLE *table)
   if (!(share=(BDB_SHARE*) hash_search(&bdb_open_tables, (byte*) table_name,
 				       length)))
   {
-    ha_rows *rec_per_key;
+    ulong *rec_per_key;
     char *tmp_name;
     DB **key_file;
     u_int32_t *key_type;
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 198664d0c066b6b3f45e6b5e2769e033d9b9f87a..f2a81d123f1eb06744703c608154b4446799ada3 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -27,7 +27,8 @@
 
 typedef struct st_berkeley_share {
   ulonglong auto_ident;
-  ha_rows rows, org_rows, *rec_per_key;
+  ha_rows rows, org_rows;
+  ulong *rec_per_key;
   THR_LOCK lock;
   pthread_mutex_t mutex;
   char *table_name;
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index e6d7871b016b8c5a9bb62f0f9c14833ff8914760..2edc3b1478e6be4f8e6bc2bccaa2e58d8e6ec932 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -88,9 +88,9 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
   file=heap_open(name,mode,
 		 table->keys,keydef,
 		 table->reclength,
-		 ((table->max_rows < max_rows && table->max_rows) ? 
-		  table->max_rows : max_rows),
-		 table->min_rows);
+		 (ulong) ((table->max_rows < max_rows && table->max_rows) ? 
+			  table->max_rows : max_rows),
+		 (ulong) table->min_rows);
   my_free((gptr) keydef,MYF(0));
   if (file)
     info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 62ba435b1d285f02c18e26cc7b887c1334d1c60b..d4e5d0e43cfe8ce857b05f10f08c6723518a320e 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -3421,7 +3421,7 @@ ha_innobase::info(
 	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
 	dict_table_t*	ib_table;
 	dict_index_t*	index;
-	ulong		rec_per_key;
+	ha_rows		rec_per_key;
 	ulong		j;
 	ulong		i;
 
@@ -3482,7 +3482,7 @@ ha_innobase::info(
 
 					rec_per_key = records;
 				} else {
-					rec_per_key = (ulong)(records /
+					rec_per_key = (ha_rows)(records /
    				         index->stat_n_diff_key_vals[j + 1]);
 				}
 
@@ -3497,8 +3497,9 @@ ha_innobase::info(
 					rec_per_key = 1;
 				}
 
- 				table->key_info[i].rec_per_key[j]
-								= rec_per_key;
+ 				table->key_info[i].rec_per_key[j]=
+				  rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
+				  rec_per_key;
 			}
 
 			index = dict_table_get_next_index_noninline(index);
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc
index 052e6a4b9ecd7f686003bc89c9ce3b1cee5ba121..6fa54d18aac9988a66c892bc10f7de0cc28b35e3 100644
--- a/sql/ha_isam.cc
+++ b/sql/ha_isam.cc
@@ -380,7 +380,8 @@ int ha_isam::create(const char *name, register TABLE *form,
   }
   recinfo_pos->base.type= (int) FIELD_LAST;	/* End of fieldinfo */
   error=nisam_create(fn_format(buff,name,"","",2+4+16),form->keys,keydef,
-		  recinfo,form->max_rows,form->min_rows,0,0,0L);
+		     recinfo,(ulong) form->max_rows, (ulong) form->min_rows,
+		     0, 0, 0L);
   my_free((gptr) recinfo,MYF(0));
   DBUG_RETURN(error);
 
diff --git a/sql/handler.h b/sql/handler.h
index 6b0f6d35136c8c0e793e82f77b2edb678fcf5c5d..a018af298063d8c18b373fccc1a933f70ee97b69 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -228,7 +228,7 @@ public:
   void change_table_ptr(TABLE *table_arg) { table=table_arg; }
   virtual double scan_time()
     { return ulonglong2double(data_file_length) / IO_SIZE + 1; }
-  virtual double read_time(ha_rows rows) { return rows; }
+  virtual double read_time(ha_rows rows) { return rows2double(rows); }
   virtual bool fast_key_read() { return 0;}
   virtual key_map keys_to_use_for_scanning() { return 0; }
   virtual bool has_transactions(){ return 0;}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 558dd807d80cae1179a8ef6a1c6108aa76be278e..ccbba3777c4173cc1d3cf972772d3a285f35e32d 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -192,7 +192,7 @@ longlong Item_func_week::val_int()
   TIME ltime;
   if (get_arg0_date(&ltime,0))
     return 0;
-  week_format= args[1]->val_int();
+  week_format= (uint) args[1]->val_int();
   return (longlong) calc_week(&ltime, 
 			      (week_format & 2) != 0,
 			      (week_format & 1) == 0,
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 16020b680e08370c9f243bc084e0957b0659ed78..373e50b84f7a9dda4e94c09ada95c3c48d8b5ebd 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1969,8 +1969,8 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
 
 int Rand_log_event::exec_event(struct st_relay_log_info* rli)
 {
-  thd->rand.seed1 = seed1;
-  thd->rand.seed2 = seed2;
+  thd->rand.seed1 = (ulong) seed1;
+  thd->rand.seed2 = (ulong) seed2;
   rli->inc_pending(get_event_len());
   return 0;
 }
diff --git a/sql/set_var.cc b/sql/set_var.cc
index ce85a81594c3965832414afb898cf2b55dfeb168..8e12f98b09b89d07cedcabed06fcb25685b717c8 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1049,13 +1049,13 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
 
 bool sys_var_rand_seed1::update(THD *thd, set_var *var)
 {
-  thd->rand.seed1=var->value->val_int();
+  thd->rand.seed1= (ulong) var->value->val_int();
   return 0;
 }
 
 bool sys_var_rand_seed2::update(THD *thd, set_var *var)
 {
-  thd->rand.seed2=var->value->val_int();
+  thd->rand.seed2= (ulong) var->value->val_int();
   return 0;
 }
 
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 003bb290b41e66ec6346bea2fb0fdb33d3c85da5..ee16b84f87ead3b7c600f1c54239650642d4d280 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -940,7 +940,7 @@ int show_binlog_events(THD* thd)
   if (mysql_bin_log.is_open())
   {
     LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
-    uint event_count, limit_start, limit_end;
+    ha_rows event_count, limit_start, limit_end;
     my_off_t pos = lex_mi->pos;
     char search_file_name[FN_REFLEN], *name;
     const char *log_file_name = lex_mi->log_file_name;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4969097b2c353e1162063c6cf5e2d233b87f05c4..4f3ebd61774385f904f6cc9cff8cae98839c76b2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1751,7 +1751,7 @@ static void
 find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
 	  double read_time)
 {
-  ulong rec;
+  ha_rows rec;
   double tmp;
   THD *thd= current_thd;
 
@@ -2013,7 +2013,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
       {						// Check full join
 	if (s->on_expr)
 	{
-	  tmp=s->found_records;			// Can't use read cache
+	  tmp=rows2double(s->found_records);	// Can't use read cache
 	}
 	else
 	{
@@ -2032,11 +2032,11 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
 	    will ensure that this will be used
 	  */
 	  best=tmp;
-	  records=s->found_records;
+	  records= rows2double(s->found_records);
 	  best_key=0;
 	}
       }
-      join->positions[idx].records_read=(double) records;
+      join->positions[idx].records_read= records;
       join->positions[idx].key=best_key;
       join->positions[idx].table= s;
       if (!best_key && idx == join->const_tables &&
@@ -2373,7 +2373,7 @@ bool
 store_val_in_field(Field *field,Item *item)
 {
   THD *thd=current_thd;
-  ulong cuted_fields=thd->cuted_fields;
+  ha_rows cuted_fields=thd->cuted_fields;
   thd->count_cuted_fields=1;
   item->save_in_field(field);
   thd->count_cuted_fields=0;
@@ -2461,7 +2461,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
 	use_quick_range=1;
 	tab->use_quick=1;
 	tab->ref.key_parts=0;		// Don't use ref key.
-	join->best_positions[i].records_read=tab->quick->records;
+	join->best_positions[i].records_read= rows2double(tab->quick->records);
       }
 
       COND *tmp=make_cond_for_table(cond,used_tables,current_map);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ef8fce455b1b15613c3150738584302162437ffc..8dfe5e9e948a7ce18d725f347985f6fcc0198032 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -659,7 +659,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
   field_list.push_back(new Item_empty_string("Column_name",NAME_LEN));
   field_list.push_back(item=new Item_empty_string("Collation",1));
   item->maybe_null=1;
-  field_list.push_back(item=new Item_int("Cardinality",0,11));
+  field_list.push_back(item=new Item_int("Cardinality",0,21));
   item->maybe_null=1;
   field_list.push_back(item=new Item_int("Sub_part",0,3));
   item->maybe_null=1;
@@ -700,8 +700,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
       KEY *key=table->key_info+i;
       if (key->rec_per_key[j])
       {
-        ulong records=(table->file->records / key->rec_per_key[j]);
-        end=int10_to_str((long) records, buff, 10);
+        ha_rows records=(table->file->records / key->rec_per_key[j]);
+        end=longlong10_to_str((longlong) records, buff, 10);
         net_store_data(packet,convert,buff,(uint) (end-buff));
       }
       else