summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@donna.mysql.com <>2000-10-05 01:01:07 +0300
committermonty@donna.mysql.com <>2000-10-05 01:01:07 +0300
commita8a15e837c92fdb8ada66277013b5ad35b93739f (patch)
tree16fa08864848073712f9ca53a3929d1e7cf2d356 /sql
parente0e65542e0bd04d8394d4367cde7dfc7ff4ff7c9 (diff)
parenta7c5cc01b3d2afb5c2465e39e401cd7f337bf3dc (diff)
downloadmariadb-git-a8a15e837c92fdb8ada66277013b5ad35b93739f.tar.gz
Merge work:/home/bk/mysql into donna.mysql.com:/home/my/bk/mysql
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc1
-rw-r--r--sql/ha_myisam.cc69
-rw-r--r--sql/ha_myisam.h20
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/handler.h2
-rw-r--r--sql/key.cc9
-rw-r--r--sql/log.cc5
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc76
-rw-r--r--sql/sql_base.cc7
-rw-r--r--sql/sql_cache.cc4
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_insert.cc13
-rw-r--r--sql/sql_repl.cc1
-rw-r--r--sql/sql_show.cc55
-rw-r--r--sql/table.cc8
17 files changed, 192 insertions, 84 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 96ce57fc683..10984af5510 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -861,7 +861,6 @@ static int merge_index(SORTPARAM *param, uchar **sort_keys,
buffpek+maxbuffer,1))
DBUG_RETURN(1); /* purecov: inspected */
DBUG_RETURN(0);
- /* Was: DBUG_RETURN(my_b_write(outfile,last_ref,param->ref_length)); */
} /* merge_index */
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 768e663bfa5..1c5356e0c32 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -31,10 +31,11 @@
#endif
ulong myisam_sort_buffer_size;
-myisam_recover_types myisam_recover_type= HA_RECOVER_NONE;
+ulong myisam_recover_options= HA_RECOVER_NONE;
+/* bits in myisam_recover_options */
const char *myisam_recover_names[] =
-{ "NO","DEFAULT", "BACKUP"};
+{ "DEFAULT", "BACKUP", "FORCE"};
TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names),"",
myisam_recover_names};
@@ -152,7 +153,7 @@ int ha_myisam::dump(THD* thd, int fd)
my_off_t bytes_to_read = share->state.state.data_file_length;
int data_fd = file->dfile;
byte * buf = (byte*) my_malloc(blocksize, MYF(MY_WME));
- if(!buf)
+ if (!buf)
return ENOMEM;
int error = 0;
@@ -342,19 +343,19 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
char* backup_dir = thd->lex.backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->real_name;
- if(!fn_format(src_path, table_name, backup_dir, MI_NAME_DEXT, 4 + 64))
+ if (!fn_format(src_path, table_name, backup_dir, MI_NAME_DEXT, 4 + 64))
return HA_ADMIN_INVALID;
int error = 0;
const char* errmsg = "";
- if(my_copy(src_path, fn_format(dst_path, table->path, "",
- MI_NAME_DEXT, 4), MYF(MY_WME)))
- {
- error = HA_ADMIN_FAILED;
- errmsg = "failed in my_copy( Error %d)";
- goto err;
- }
+ if (my_copy(src_path, fn_format(dst_path, table->path, "",
+ MI_NAME_DEXT, 4), MYF(MY_WME)))
+ {
+ error = HA_ADMIN_FAILED;
+ errmsg = "failed in my_copy( Error %d)";
+ goto err;
+ }
tmp_check_opt.init();
tmp_check_opt.quick = 1;
@@ -373,26 +374,27 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
}
}
+
int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
{
char* backup_dir = thd->lex.backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char* table_name = table->real_name;
- if(!fn_format(dst_path, table_name, backup_dir, reg_ext, 4 + 64))
+ if (!fn_format(dst_path, table_name, backup_dir, reg_ext, 4 + 64))
return HA_ADMIN_INVALID;
- if(my_copy(fn_format(src_path, table->path,"", reg_ext, 4),
+ if (my_copy(fn_format(src_path, table->path,"", reg_ext, 4),
dst_path,
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES )))
- {
- return HA_ADMIN_FAILED;
- }
+ {
+ return HA_ADMIN_FAILED;
+ }
- if(!fn_format(dst_path, table_name, backup_dir, MI_NAME_DEXT, 4 + 64))
+ if (!fn_format(dst_path, table_name, backup_dir, MI_NAME_DEXT, 4 + 64))
return HA_ADMIN_INVALID;
- if(my_copy(fn_format(src_path, table->path,"", MI_NAME_DEXT, 4),
- dst_path,
- MYF(MY_WME | MY_HOLD_ORIGINAL_MODES )) )
+ if (my_copy(fn_format(src_path, table->path,"", MI_NAME_DEXT, 4),
+ dst_path,
+ MYF(MY_WME | MY_HOLD_ORIGINAL_MODES )) )
return HA_ADMIN_FAILED;
return HA_ADMIN_OK;
@@ -572,6 +574,33 @@ bool ha_myisam::activate_all_index(THD *thd)
DBUG_RETURN(error);
}
+
+bool ha_myisam::check_and_repair(THD *thd, const char *name)
+{
+ int error=0;
+ HA_CHECK_OPT check_opt;
+ DBUG_ENTER("ha_myisam::auto_check_and_repair");
+
+ if (open(name, O_RDWR, HA_OPEN_WAIT_IF_LOCKED))
+ DBUG_RETURN(1);
+
+ check_opt.init();
+ check_opt.flags=T_MEDIUM;
+ if (mi_is_crashed(file) || check(thd, &check_opt))
+ {
+ check_opt.flags=(((myisam_recover_options & HA_RECOVER_BACKUP) ?
+ T_BACKUP_DATA : 0) |
+ (!(myisam_recover_options & HA_RECOVER_FORCE) ?
+ T_SAFE_REPAIR : 0));
+ if (repair(thd, &check_opt))
+ error=1;
+ }
+ if (close())
+ error=1;
+ DBUG_RETURN(error);
+}
+
+
int ha_myisam::update_row(const byte * old_data, byte * new_data)
{
statistic_increment(ha_update_count,&LOCK_status);
diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h
index f1e5b217762..d33fc52c937 100644
--- a/sql/ha_myisam.h
+++ b/sql/ha_myisam.h
@@ -24,12 +24,14 @@
#include <myisam.h>
#include <ft_global.h>
-enum myisam_recover_types { HA_RECOVER_NONE, HA_RECOVER_DEFAULT,
- HA_RECOVER_BACKUP};
+#define HA_RECOVER_NONE 0 // No automatic recover
+#define HA_RECOVER_DEFAULT 1 // Automatic recover active
+#define HA_RECOVER_BACKUP 2 // Make a backupfile on recover
+#define HA_RECOVER_FORCE 4 // Recover even if we loose rows
extern ulong myisam_sort_buffer_size;
extern TYPELIB myisam_recover_typelib;
-extern myisam_recover_types myisam_recover_type;
+extern ulong myisam_recover_options;
class ha_myisam: public handler
{
@@ -39,11 +41,12 @@ class ha_myisam: public handler
public:
ha_myisam(TABLE *table): handler(table), file(0),
- int_option_flag(HA_READ_NEXT+HA_READ_PREV+HA_READ_RND_SAME+
- HA_KEYPOS_TO_RNDPOS+ HA_READ_ORDER+ HA_LASTKEY_ORDER+
- HA_HAVE_KEY_READ_ONLY+ HA_READ_NOT_EXACT_KEY+
- HA_LONGLONG_KEYS+ HA_NULL_KEY +
- HA_DUPP_POS + HA_BLOB_KEY + HA_AUTO_PART_KEY)
+ int_option_flag(HA_READ_NEXT | HA_READ_PREV | HA_READ_RND_SAME |
+ HA_KEYPOS_TO_RNDPOS | HA_READ_ORDER | HA_LASTKEY_ORDER |
+ HA_HAVE_KEY_READ_ONLY | HA_READ_NOT_EXACT_KEY |
+ HA_LONGLONG_KEYS | HA_NULL_KEY |
+ HA_DUPP_POS | HA_BLOB_KEY | HA_AUTO_PART_KEY |
+ HA_CHECK_AND_REPAIR)
{}
~ha_myisam() {}
const char *table_type() const { return "MyISAM"; }
@@ -100,6 +103,7 @@ class ha_myisam: public handler
int check(THD* thd, HA_CHECK_OPT* check_opt);
int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int repair(THD* thd, HA_CHECK_OPT* check_opt);
+ bool check_and_repair(THD *thd, const char *name);
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
int restore(THD* thd, HA_CHECK_OPT* check_opt);
int backup(THD* thd, HA_CHECK_OPT* check_opt);
diff --git a/sql/handler.cc b/sql/handler.cc
index 68d12a96f98..a0ec18d3614 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -594,7 +594,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
TABLE table;
DBUG_ENTER("ha_create_table");
- if (openfrm(name,"",0,(uint) READ_ALL,&table))
+ if (openfrm(name,"",0,(uint) READ_ALL, 0, &table))
DBUG_RETURN(1);
if (update_create_info)
{
diff --git a/sql/handler.h b/sql/handler.h
index 7f39b78deee..d256ee944e7 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -66,6 +66,7 @@
#define HA_NO_WRITE_DELAYED (HA_NOT_EXACT_COUNT*2)
#define HA_PRIMARY_KEY_IN_READ_INDEX (HA_NO_WRITE_DELAYED*2)
#define HA_DROP_BEFORE_CREATE (HA_PRIMARY_KEY_IN_READ_INDEX*2)
+#define HA_CHECK_AND_REPAIR (HA_DROP_BEFORE_CREATE*2)
/* Parameters for open() (in register form->filestat) */
/* HA_GET_INFO does a implicit HA_ABORT_IF_LOCKED */
@@ -248,6 +249,7 @@ public:
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
virtual int check(THD* thd, HA_CHECK_OPT* check_opt );
virtual int repair(THD* thd, HA_CHECK_OPT* check_opt);
+ virtual bool check_and_repair(THD *thd, const char *name) {return 1;}
virtual int optimize(THD* thd,HA_CHECK_OPT* check_opt);
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt);
virtual int backup(THD* thd, HA_CHECK_OPT* check_opt);
diff --git a/sql/key.cc b/sql/key.cc
index df3f0fe25d5..8678202922e 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -243,7 +243,10 @@ void key_unpack(String *to,TABLE *table,uint idx)
}
-/* Return 1 if any field in a list is part of key */
+/*
+ Return 1 if any field in a list is part of key or the key uses a field
+ that is automaticly updated (like a timestamp)
+*/
bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields)
{
@@ -255,6 +258,10 @@ bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields)
key_part++)
{
Item_field *field;
+
+ if (key_part->field == table->timestamp_field)
+ return 1; // Can't be used for update
+
f.rewind();
while ((field=(Item_field*) f++))
{
diff --git a/sql/log.cc b/sql/log.cc
index 94cd553bfce..1f12bcacf6c 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -149,7 +149,8 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
fn_format(index_file_name, name, mysql_data_home, ".index", 6);
db[0]=0;
- file=my_fopen(log_file_name,O_APPEND | O_WRONLY,MYF(MY_WME | ME_WAITTANG));
+ file=my_fopen(log_file_name,O_APPEND | O_WRONLY | O_BINARY,
+ MYF(MY_WME | ME_WAITTANG));
if (!file)
{
my_free(name,MYF(0));
@@ -188,7 +189,7 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
{
Start_log_event s;
if(!index_file &&
- !(index_file = my_fopen(index_file_name,O_APPEND | O_RDWR,
+ !(index_file = my_fopen(index_file_name,O_APPEND | O_BINARY | O_RDWR,
MYF(MY_WME))))
{
my_fclose(file,MYF(MY_WME));
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index e9eb3f970d4..82674453c40 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -533,7 +533,7 @@ int rea_create_table(my_string file_name,HA_CREATE_INFO *create_info,
int format_number(uint inputflag,uint max_length,my_string pos,uint length,
my_string *errpos);
int openfrm(const char *name,const char *alias,uint filestat,uint prgflag,
- TABLE *outparam);
+ uint ha_open_flags, TABLE *outparam);
int closefrm(TABLE *table);
db_type get_table_type(const char *name);
int read_string(File file, gptr *to, uint length);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 38d8b5ddcab..8daea8aad88 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -284,7 +284,7 @@ extern pthread_handler_decl(handle_slave,arg);
#ifdef SET_RLIMIT_NOFILE
static uint set_maximum_open_files(uint max_file_limit);
#endif
-
+static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
/****************************************************************************
** Code to end mysqld
@@ -1066,6 +1066,7 @@ static void init_signals(void)
sigaddset(&set,SIGTERM);
sigaddset(&set,SIGHUP);
signal(SIGTERM,SIG_DFL); // If it's blocked by parent
+ signal(SIGHUP,SIG_DFL); // If it's blocked by parent
#ifdef SIGTSTP
sigaddset(&set,SIGTSTP);
#endif
@@ -2588,6 +2589,8 @@ static void usage(void)
Log slow queries to this log file. Defaults logging\n\
to hostname-slow.log\n\
--pid-file=path Pid file used by safe_mysqld\n\
+ --myisam-recover[=option[,option...]] where options is one of DEAULT,\n\
+ BACKUP or FORCE.\n\
--memlock Lock mysqld in memory\n\
-n, --new Use very new possible 'unsafe' functions\n\
-o, --old-protocol Use the old (3.20) protocol\n\
@@ -2879,13 +2882,13 @@ static void get_options(int argc,char **argv)
default_table_type=DB_TYPE_ISAM;
myisam_delay_key_write=0;
myisam_concurrent_insert=0;
- myisam_recover_type= HA_RECOVER_NONE;
+ myisam_recover_options= 0;
break;
case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE;
myisam_delay_key_write=0;
myisam_concurrent_insert=0;
- myisam_recover_type= HA_RECOVER_NONE; // For now
+ myisam_recover_options= HA_RECOVER_NONE; // To be changed
break;
case (int) OPT_SKIP_CONCURRENT_INSERT:
myisam_concurrent_insert=0;
@@ -3052,13 +3055,14 @@ static void get_options(int argc,char **argv)
#endif
case OPT_MYISAM_RECOVER:
{
- int type;
- if ((type=find_type(optarg, &myisam_recover_typelib, 2)) <= 0)
+ if (!optarg || !optarg[0])
+ myisam_recover_options=HA_RECOVER_DEFAULT;
+ else if ((myisam_recover_options=
+ find_bit_type(optarg, &myisam_recover_typelib)) == ~(ulong) 0)
{
- fprintf(stderr,"Unknown option to myisam-recover: %s\n",optarg);
+ fprintf(stderr, "Unknown option to myisam-recover: %s\n",optarg);
exit(1);
}
- myisam_recover_type=(myisam_recover_types) (type-1);
break;
}
case OPT_MASTER_HOST:
@@ -3594,6 +3598,64 @@ static uint set_maximum_open_files(uint max_file_limit)
#endif
+ /*
+ Return a bitfield from a string of substrings separated by ','
+ returns ~(ulong) 0 on error.
+ */
+
+static ulong find_bit_type(const char *x, TYPELIB *bit_lib)
+{
+ bool found_end;
+ int found_count;
+ const char *end,*i,*j;
+ const char **array, *pos;
+ ulong found,found_int,bit;
+ DBUG_ENTER("find_bit_type");
+ DBUG_PRINT("enter",("x: '%s'",x));
+
+ found=0;
+ found_end= 0;
+ pos=(my_string) x;
+ do
+ {
+ if (!*(end=strcend(pos,','))) /* Let end point at fieldend */
+ {
+ while (end > pos && end[-1] == ' ')
+ end--; /* Skipp end-space */
+ found_end=1;
+ }
+ found_int=0; found_count=0;
+ for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
+ {
+ j=pos;
+ while (j != end)
+ {
+ if (toupper(*i++) != toupper(*j++))
+ goto skipp;
+ }
+ found_int=bit;
+ if (! *i)
+ {
+ found_count=1;
+ break;
+ }
+ else if (j != pos) // Half field found
+ {
+ found_count++; // Could be one of two values
+ }
+skipp: ;
+ }
+ if (found_count != 1)
+ DBUG_RETURN(~(ulong) 0); // No unique value
+ found|=found_int;
+ pos=end+1;
+ } while (! found_end);
+
+ DBUG_PRINT("exit",("bit-field: %ld",(ulong) found));
+ DBUG_RETURN(found);
+} /* find_bit_type */
+
+
/*****************************************************************************
** Instantiate templates
*****************************************************************************/
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4a05f2370f6..ed018eb3337 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -388,7 +388,7 @@ void close_thread_tables(THD *thd, bool locked)
}
thd->open_tables=0;
/* Free tables to hold down open files */
- while (open_cache.records >= table_cache_size && unused_tables)
+ while (open_cache.records > table_cache_size && unused_tables)
VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */
check_unused();
if (found_old_table)
@@ -700,7 +700,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
else
{
/* Free cache if too big */
- while (open_cache.records >= table_cache_size && unused_tables)
+ while (open_cache.records > table_cache_size && unused_tables)
VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */
/* make a new table */
@@ -1123,6 +1123,7 @@ static int open_unireg_entry(TABLE *entry,const char *db,const char *name,
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX |
HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
+ ha_open_options,
entry))
{
DBUG_RETURN(1);
@@ -1288,6 +1289,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX |
HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
+ ha_open_options,
tmp_table))
{
DBUG_RETURN(0);
@@ -1572,6 +1574,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
DBUG_RETURN(-1); /* purecov: inspected */
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
item->split_sum_func(*sum_func_list);
+ thd->used_tables|=item->used_tables();
}
}
DBUG_RETURN(test(thd->fatal_error));
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 78053d0d3e3..09d436c0c9c 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -19,10 +19,10 @@
#include <my_dir.h>
#include <hash.h>
-#define SQL_CACHE_LENGTH 300
+#define SQL_CACHE_LENGTH 30 // 300 crashes apple gcc.
HASH sql_cache;
-LEX lex_array_static[SQL_CACHE_LENGTH];
+static LEX lex_array_static[SQL_CACHE_LENGTH];
LEX * lex_array = lex_array_static;
int last_lex_array_item = SQL_CACHE_LENGTH - 1;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 64fd281ee3a..31d54a621ac 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -89,6 +89,7 @@ THD::THD()
open_tables=temporary_tables=0;
tmp_table=0;
lock=locked_tables=0;
+ used_tables=0;
cuted_fields=0L;
options=thd_startup_options;
update_lock_default= low_priority_updates ? TL_WRITE_LOW_PRIORITY : TL_WRITE;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 212a641f335..0543221799f 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -264,6 +264,7 @@ public:
ulonglong next_insert_id,last_insert_id,current_insert_id;
ha_rows select_limit,offset_limit,default_select_limit,cuted_fields,
max_join_size,sent_row_count;
+ table_map used_tables;
ulong query_id,version, inactive_timeout,options,thread_id;
long dbug_thread_id;
pthread_t real_id;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 13feba9ab9c..26d110ba31c 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -140,6 +140,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
if (!table)
DBUG_RETURN(-1);
thd->proc_info="init";
+ thd->used_tables=0;
save_time_stamp=table->time_stamp;
values= its++;
if (check_insert_fields(thd,table,fields,*values,1) ||
@@ -200,7 +201,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
}
else
{
- table->record[0][0]=table->record[2][0]; // Fix delete marker
+ if (thd->used_tables) // Column used in values()
+ restore_record(table,2); // Get empty record
+ else
+ table->record[0][0]=table->record[2][0]; // Fix delete marker
if (fill_record(table->field,*values))
{
if (values_list.elements != 1)
@@ -1166,12 +1170,7 @@ select_insert::prepare(List<Item> &values)
if (check_insert_fields(thd,table,*fields,values,1))
DBUG_RETURN(1);
- if (fields->elements)
- {
- restore_record(table,2); // Get empty record
- }
- else
- table->record[0][0]=table->record[2][0]; // Fix delete marker
+ restore_record(table,2); // Get empty record
table->next_number_field=table->found_next_number_field;
thd->count_cuted_fields=1; /* calc cuted fields */
thd->cuted_fields=0;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 011638afc93..ad3b03ca238 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -21,6 +21,7 @@
#include "sql_repl.h"
#include "sql_acl.h"
#include "log_event.h"
+#include <thr_alarm.h>
#include <my_dir.h>
extern const char* any_db;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ea6e09f6cb5..83a53467426 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -476,6 +476,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->real_name));
+ /* Only one table for now */
if (!(table = open_ltable(thd, table_list, TL_UNLOCK)))
{
send_error(&thd->net);
@@ -490,34 +491,32 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(1);
String *packet = &thd->packet;
- for(;table; table = table->next)
- {
- packet->length(0);
- net_store_data(packet, table->table_name);
- // a hack - we need to reserve some space for the length before
- // we know what it is - let's assume that the length of create table
- // statement will fit into 3 bytes ( 16 MB max :-) )
- ulong store_len_offset = packet->length();
- packet->length(store_len_offset + 4);
- if(store_create_info(thd, table, packet))
- DBUG_RETURN(-1);
- ulong create_len = packet->length() - store_len_offset - 4;
- if(create_len > 0x00ffffff) // better readable in HEX ...
- DBUG_RETURN(1); // just in case somebody manages to create a table
- // with *that* much stuff in the definition
-
- // now we have to store the length in three bytes, even if it would fit
- // into fewer, so we cannot use net_store_data() anymore,
- // and do it ourselves
- char* p = (char*)packet->ptr() + store_len_offset;
- *p++ = (char) 253; // The client the length is stored using 3-bytes
- int3store(p, create_len);
-
- // now we are in business :-)
- if(my_net_write(&thd->net, (char*)packet->ptr(), packet->length()))
- DBUG_RETURN(1);
- }
-
+ {
+ packet->length(0);
+ net_store_data(packet, table->table_name);
+ // a hack - we need to reserve some space for the length before
+ // we know what it is - let's assume that the length of create table
+ // statement will fit into 3 bytes ( 16 MB max :-) )
+ ulong store_len_offset = packet->length();
+ packet->length(store_len_offset + 4);
+ if (store_create_info(thd, table, packet))
+ DBUG_RETURN(-1);
+ ulong create_len = packet->length() - store_len_offset - 4;
+ if (create_len > 0x00ffffff) // better readable in HEX ...
+ DBUG_RETURN(1); // just in case somebody manages to create a table
+ // with *that* much stuff in the definition
+
+ // now we have to store the length in three bytes, even if it would fit
+ // into fewer, so we cannot use net_store_data() anymore,
+ // and do it ourselves
+ char* p = (char*)packet->ptr() + store_len_offset;
+ *p++ = (char) 253; // The client the length is stored using 3-bytes
+ int3store(p, create_len);
+
+ // now we are in business :-)
+ if (my_net_write(&thd->net, (char*)packet->ptr(), packet->length()))
+ DBUG_RETURN(1);
+ }
send_eof(&thd->net);
DBUG_RETURN(0);
}
diff --git a/sql/table.cc b/sql/table.cc
index 66a2ef767b0..c7fe81c182c 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -40,7 +40,7 @@ static byte* get_field_name(Field *buff,uint *length,
/* Open a .frm file */
int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
- TABLE *outparam)
+ uint ha_open_flags, TABLE *outparam)
{
reg1 uint i;
reg2 uchar *strpos;
@@ -216,12 +216,12 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
ha_open(index_file,
(db_stat & HA_READ_ONLY ? O_RDONLY : O_RDWR),
(db_stat & HA_OPEN_TEMPORARY ? HA_OPEN_TMP_TABLE :
- db_stat & HA_WAIT_IF_LOCKED ||
- specialflag & SPECIAL_WAIT_IF_LOCKED ?
+ (db_stat & HA_WAIT_IF_LOCKED ||
+ specialflag & SPECIAL_WAIT_IF_LOCKED) ?
HA_OPEN_WAIT_IF_LOCKED :
(db_stat & (HA_ABORT_IF_LOCKED | HA_GET_INFO)) ?
HA_OPEN_ABORT_IF_LOCKED :
- HA_OPEN_IGNORE_IF_LOCKED) | ha_open_options)))
+ HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags)))
goto err_not_open; /* purecov: inspected */
}
outparam->db_low_byte_first=outparam->file->low_byte_first();