Commit 0f44a0c8 authored by unknown's avatar unknown

Merge monty@work:/home/bk/mysql into donna.mysql.com:/home/my/bk/mysql


configure.in:
  Auto merged
Docs/manual.texi:
  Auto merged
include/global.h:
  Auto merged
parents 9080d675 1b6d911e
This diff is collapsed.
......@@ -1700,10 +1700,10 @@ CHARSET_COMP_CS_INIT="$CHARSET_COMP_CS_INIT
{
0, /* end-of-list marker */
NullS,
\"\",
\"\",
\"\",
\"\",
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
......
......@@ -113,6 +113,12 @@
#define HAVE_ATOMIC_SUB
#endif
/* In Linux-ia64 including atomic.h will give us an error */
#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__ia64__)
#undef HAVE_ATOMIC_ADD
#undef HAVE_ATOMIC_SUB
#endif
#if defined(_lint) && !defined(lint)
#define lint
#endif
......@@ -207,6 +213,7 @@
#endif
/* Define void to stop lint from generating "null effekt" comments */
#ifndef DONT_DEFINE_VOID
#ifdef _lint
int __void__;
#define VOID(X) (__void__ = (int) (X))
......@@ -214,6 +221,7 @@ int __void__;
#undef VOID
#define VOID(X) (X)
#endif
#endif /* DONT_DEFINE_VOID */
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT(var) var=0 /* No uninitialize-warning */
......@@ -515,6 +523,8 @@ typedef long my_ptrdiff_t;
#define NEAR /* Who needs segments ? */
#define FAR /* On a good machine */
#define HUGE_PTR
#endif
#ifndef STDCALL
#define STDCALL
#endif
......
......@@ -192,4 +192,5 @@
#define ER_MASTER_NET_READ 1189
#define ER_MASTER_NET_WRITE 1190
#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
#define ER_ERROR_MESSAGES 192
#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192
#define ER_ERROR_MESSAGES 193
......@@ -190,7 +190,7 @@ static struct option long_options[] =
static void print_version(void)
{
printf("%s Ver 1.29 for %s at %s\n",my_progname,SYSTEM_TYPE,
printf("%s Ver 1.30 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
......@@ -295,7 +295,7 @@ static void get_options(register int *argc,register char ***argv)
set_all_changeable_vars(changeable_vars);
if (isatty(fileno(stdout)))
check_param.testflag|=T_WRITE_LOOP;
while ((c=getopt_long(*argc,*argv,"acCdeif?lqrmosSTuUvVw#:b:D:k:O:R:A::t:",
while ((c=getopt_long(*argc,*argv,"acCdeifF?lqrmosSTuUvVw#:b:D:k:O:R:A::t:",
long_options, &option_index)) != EOF)
{
switch(c) {
......@@ -520,10 +520,30 @@ static int myisamchk(MI_CHECK *param, my_string filename)
We are using --fast and the table is closed properly
We are using --check-only-changed-tables and the table hasn't changed
*/
if (((param->testflag & T_CHECK_ONLY_CHANGED) &&
if (param->testflag & (T_FAST | T_CHECK_ONLY_CHANGED))
{
my_bool need_to_check= mi_is_crashed(info) || share->state.open_count != 0;
if ((param->testflag & (T_REP_BY_SORT | T_REP | T_SORT_RECORDS)) &&
((share->state.changed & (STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR) ||
!(param->testflag & T_CHECK_ONLY_CHANGED))))
need_to_check=1;
if ((param->testflag & T_STATISTICS) &&
(share->state.changed & STATE_NOT_ANALYZED))
need_to_check=1;
if ((param->testflag & T_SORT_INDEX) &&
(share->state.changed & STATE_NOT_SORTED_PAGES))
need_to_check=1;
if ((param->testflag & T_REP_BY_SORT) &&
(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))
need_to_check=1;
if ((param->testflag & T_CHECK_ONLY_CHANGED) &&
(share->state.changed & (STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR))) ||
(param->testflag & T_FAST) && share->state.open_count == 0)
STATE_CRASHED_ON_REPAIR)))
need_to_check=1;
if (!need_to_check)
{
if (!(param->testflag & T_SILENT) || param->testflag & T_INFO)
printf("MyISAM file: %s is already checked\n",filename);
......@@ -535,7 +555,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
}
DBUG_RETURN(0);
}
}
if ((param->testflag & (T_REP_BY_SORT | T_REP | T_STATISTICS |
T_SORT_RECORDS | T_SORT_INDEX)) &&
(((param->testflag & T_UNPACK) &&
......
......@@ -48,5 +48,6 @@ int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag)
info->open_tables->table->s->keyinfo[inx].seg))
return my_errno;
}
return 0;
}
......@@ -25,6 +25,9 @@
SerG
*/
int _mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
enum ha_rkey_function search_flag, bool raw_key);
int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
uint key_len, enum ha_rkey_function search_flag)
{
......
......@@ -224,7 +224,7 @@ if ($limits->{'unique_index'})
$tmpvar^= ((($tmpvar + 63) + $i)*3 % $opt_loop_count);
$tmp=$tmpvar % ($total_rows);
$tmpquery = "$query ($tmp,1,2,'D')";
if ($dbh->do($tmpquery))
if (!$dbh->do($tmpquery))
{
die "Didn't get an error when inserting duplicate record $tmp\n";
}
......
2000-08-20 Michael Widenius <monty@mysql.com>
* Added memory as inline functions to THD to get them a bit faster
* Don't count entries with NULL in COUNT(DISTINCT ..)
2000-08-08 Michael Widenius <monty@mysql.com>
* Changed ALTER TABLE and LOAD DATA INFILE to create non unique, small keys
......
......@@ -66,7 +66,7 @@ mysqld_SOURCES = sql_lex.cc \
records.cc filesort.cc handler.cc \
ha_isam.cc ha_isammrg.cc ha_heap.cc \
ha_myisam.cc ha_myisammrg.cc ha_berkeley.cc \
sql_db.cc sql_table.cc sql_crypt.cc \
sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
slave.cc \
......
......@@ -839,6 +839,10 @@ bool Item_sum_count_distinct::add()
copy_fields(tmp_table_param);
copy_funcs(tmp_table_param->funcs);
for (Field **field=table->field ; *field ; field++)
if ((*field)->is_real_null(0))
return 0; // Don't count NULL
if ((error=table->file->write_row(table->record[0])))
{
if (error != HA_ERR_FOUND_DUPP_KEY &&
......
......@@ -384,3 +384,87 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
}
return sql_lock;
}
/*****************************************************************************
** Lock table based on the name.
** This is used when we need total access to a closed, not open table
*****************************************************************************/
/*
Put a not open table with an old refresh version in the table cache.
This will force any other threads that uses the table to release it
as soon as possible.
One must have a lock on LOCK_open !
Return values:
< 0 error
== 0 table locked
> 0 table locked, but someone is using it
*/
int lock_table_name(THD *thd, TABLE_LIST *table_list)
{
TABLE *table;
char key[MAX_DBKEY_LENGTH];
uint key_length;
key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->name)-key)+
1;
/* Only insert the table if we haven't insert it already */
for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ;
table ;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
if (table->in_use == thd)
return 0;
/* Create a table entry with the right key and with an old refresh version */
if (!(table= (TABLE*) thd->calloc(sizeof(*table)+key_length)))
return -1;
memcpy((table->table_cache_key= (char*) (table+1)), key, key_length);
table->key_length=key_length;
table->in_use=thd;
table_list->table=table;
if (hash_insert(&open_cache, (byte*) table))
return -1;
if (remove_table_from_cache(thd, table_list->db, table_list->name))
return 1; // Table is in use
return 0;
}
void unlock_table_name(THD *thd, TABLE_LIST *table_list)
{
if (table_list->table)
hash_delete(&open_cache, (gptr) table_list->table);
}
static bool locked_named_table(THD *thd, TABLE_LIST *table_list)
{
for ( ; table_list ; table_list=table_list->next)
{
if (table_list->table && table_is_used(table_list->table))
return 1;
}
return 0; // All tables are locked
}
bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list)
{
bool result=0;
while (locked_named_table(thd,table_list))
{
if (thd->killed)
{
result=1;
break;
}
wait_for_refresh(thd);
}
pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex=0;
thd->mysys_var->current_cond=0;
pthread_mutex_unlock(&thd->mysys_var->mutex);
return result;
}
This diff is collapsed.
......@@ -196,3 +196,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -197,3 +197,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -196,3 +196,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -195,3 +195,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Errore di rete ricevendo dal master",
"Errore di rete inviando al master",
"Impossibile trovare un indice FULLTEXT che corrisponda all'elenco delle colonne",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -195,3 +195,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -195,3 +195,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -195,3 +195,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -197,3 +197,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -197,3 +197,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -196,3 +196,4 @@
"Net error reading from master",
"Net error writing to master",
"FULLTEXT , , ",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -201,3 +201,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -194,3 +194,4 @@
"Net error reading from master",
"Net error writing to master",
"Can't find FULLTEXT index matching the column list",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,5 @@
"Fick nätverksfel vid läsning från master",
"Fick nätverksfel vid skrivning till master",
"Hittar inte ett FULLTEXT index i kolumnlist",
#ER_LOCK_OR_ACTIVE_TRANSACTION
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -193,3 +193,4 @@
"Fick nätverksfel vid läsning från master",
"Fick nätverksfel vid skrivning till master",
"Hittar inte ett FULLTEXT index i kolumnlist",
"Can't execute the given command because you have active locked tables or an active transaction",
......@@ -406,7 +406,7 @@ static int init_slave_thread(THD* thd)
if (init_thr_lock() ||
my_pthread_setspecific_ptr(THR_THD, thd) ||
my_pthread_setspecific_ptr(THR_MALLOC, &thd->alloc) ||
my_pthread_setspecific_ptr(THR_MALLOC, &thd->mem_root) ||
my_pthread_setspecific_ptr(THR_NET, &thd->net))
{
close_connection(&thd->net,ER_OUT_OF_RESOURCES); // is this needed?
......@@ -422,7 +422,7 @@ static int init_slave_thread(THD* thd)
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
#endif
thd->alloc.free=thd->alloc.used=0;
thd->mem_root.free=thd->mem_root.used=0; // Probably not needed
if (thd->max_join_size == (ulong) ~0L)
thd->options |= OPTION_BIG_SELECTS;
......@@ -557,7 +557,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
{
Query_log_event* qev = (Query_log_event*)ev;
int q_len = qev->q_len;
init_sql_alloc(&thd->alloc, 8192);
init_sql_alloc(&thd->mem_root, 8192);
thd->db = (char*)qev->db;
if(db_ok(thd->db, replicate_do_db, replicate_ignore_db))
{
......@@ -602,8 +602,8 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
thd->db = 0;// prevent db from being freed
thd->query = 0; // just to be sure
close_thread_tables(thd);
free_root(&thd->alloc);
if(thd->query_error)
free_root(&thd->mem_root);
if (thd->query_error)
{
sql_print_error("Slave: error running query '%s' ",
qev->query);
......@@ -626,7 +626,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
case LOAD_EVENT:
{
Load_log_event* lev = (Load_log_event*)ev;
init_sql_alloc(&thd->alloc, 8192);
init_sql_alloc(&thd->mem_root, 8192);
thd->db = (char*)lev->db;
thd->query = 0;
thd->query_error = 0;
......
......@@ -29,8 +29,6 @@
#include <io.h>
#endif
#define MAX_DBKEY_LENGTH (FN_LEN*2+2)
static int key_cache_used=0;
TABLE *unused_tables; /* Used by mysql_test */
HASH open_cache; /* Used by mysql_test */
......@@ -120,7 +118,7 @@ static byte *cache_key(const byte *record,uint *length,
void table_cache_init(void)
{
VOID(hash_init(&open_cache,table_cache_size,0,0,cache_key,
VOID(hash_init(&open_cache,table_cache_size+16,0,0,cache_key,
(void (*)(void*)) free_cache_entry,0));
mysql_rm_tmp_tables();
}
......@@ -1234,7 +1232,7 @@ void close_old_data_files(THD *thd, TABLE *table, bool abort_locks)
if the table is closed
*/
static bool table_is_used(TABLE *table)
bool table_is_used(TABLE *table)
{
do
{
......@@ -2171,4 +2169,3 @@ int setup_ftfuncs(THD *thd,TABLE_LIST *tables, List<Item_func_match> &ftfuncs)
return 0;
}
......@@ -109,7 +109,7 @@ THD::THD()
net.vio=0;
ull=0;
system_thread=0;
bzero((char*) &alloc,sizeof(alloc));
bzero((char*) &mem_root,sizeof(mem_root));
#ifdef __WIN__
real_id = 0 ;
#endif
......@@ -154,7 +154,7 @@ THD::~THD()
safeFree(user);
safeFree(db);
safeFree(ip);
free_root(&alloc);
free_root(&mem_root);
mysys_var=0; // Safety (shouldn't be needed)
DBUG_VOID_RETURN;
}
......@@ -165,11 +165,10 @@ THD::~THD()
bool THD::store_globals()
{
return (my_pthread_setspecific_ptr(THR_THD, this) ||
my_pthread_setspecific_ptr(THR_MALLOC, &alloc) ||
my_pthread_setspecific_ptr(THR_MALLOC, &mem_root) ||
my_pthread_setspecific_ptr(THR_NET, &net));
}
/*****************************************************************************
** Functions to provide a interface to select results
*****************************************************************************/
......
......@@ -223,7 +223,7 @@ class THD :public ilink {
public:
NET net;
LEX lex;
MEM_ROOT alloc;
MEM_ROOT mem_root;
HASH user_vars;
String packet; /* Room for 1 row */
struct sockaddr_in remote;
......@@ -287,6 +287,19 @@ class THD :public ilink {
}
return last_insert_id;
}
inline bool active_transaction() { return transaction.bdb_tid != 0; }
inline gptr alloc(unsigned int size) { return alloc_root(&mem_root,size); }
inline gptr calloc(unsigned int size)
{
gptr ptr;
if ((ptr=alloc_root(&mem_root,size)))
bzero((char*) ptr,size);
return ptr;
}
inline char *strdup(const char *str)
{ return strdup_root(&mem_root,str); }
inline char *memdup(const char *str, unsigned int size)
{ return memdup_root(&mem_root,str,size); }
};
......
......@@ -1215,14 +1215,19 @@ void select_insert::send_error(uint errcode,const char *err)
::send_error(&thd->net,errcode,err);
table->file->extra(HA_EXTRA_NO_CACHE);
table->file->activate_all_index(thd);
ha_rollback(thd);
}
bool select_insert::send_eof()
{
int error;
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)) ||
(error=table->file->activate_all_index(thd)))
int error,error2;
if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
error=table->file->activate_all_index(thd);
if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error)
error=error2;
if (error)
{
table->file->print_error(error,MYF(0));
::send_error(&thd->net);
......
......@@ -46,7 +46,8 @@ enum enum_sql_command {
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_SHOW_GRANTS, SQLCOM_ANALYZE,
SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_SHOW_CREATE,
SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_CHANGE_MASTER
SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_CHANGE_MASTER,
SQLCOM_RENAME_TABLE
};
enum lex_states { STATE_START, STATE_CHAR, STATE_IDENT,
......
......@@ -773,9 +773,9 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
DBUG_ENTER("make_join_statistics");
table_count=join->tables;
stat=(JOIN_TAB*) sql_calloc(sizeof(JOIN_TAB)*table_count);
stat_ref=(JOIN_TAB**) sql_alloc(sizeof(JOIN_TAB*)*MAX_TABLES);
table_vector=(TABLE**) sql_alloc(sizeof(TABLE**)*(table_count*2));
stat=(JOIN_TAB*) join->thd->calloc(sizeof(JOIN_TAB)*table_count);
stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*MAX_TABLES);
table_vector=(TABLE**) join->thd->alloc(sizeof(TABLE**)*(table_count*2));
if (!stat || !stat_ref || !table_vector)
DBUG_RETURN(1); // Eom /* purecov: inspected */
select=0;
......@@ -1832,7 +1832,7 @@ get_best_combination(JOIN *join)
table_count=join->tables;
if (!(join->join_tab=join_tab=
(JOIN_TAB*) sql_alloc(sizeof(JOIN_TAB)*table_count)))
(JOIN_TAB*) join->thd->alloc(sizeof(JOIN_TAB)*table_count)))
return TRUE;
join->const_tables=0; /* for checking */
......@@ -2056,8 +2056,8 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
TABLE **tableptr;
JOIN_TAB *join_tab;
if (!(tableptr=(TABLE**) sql_alloc(sizeof(TABLE*))) ||
!(join_tab=(JOIN_TAB*) sql_alloc(sizeof(JOIN_TAB))))
if (!(tableptr=(TABLE**) join->thd->alloc(sizeof(TABLE*))) ||
!(join_tab=(JOIN_TAB*) join->thd->alloc(sizeof(JOIN_TAB))))
return TRUE;
join->join_tab=join_tab;
join->table=tableptr; tableptr[0]=tmp_table;
......
......@@ -55,7 +55,7 @@ mysqld_show_dbs(THD *thd,const char *wild)
char *file_name;
DBUG_ENTER("mysqld_show_dbs");
field->name=(char*) sql_alloc(20+ (wild ? strlen(wild)+4: 0));
field->name=(char*) thd->alloc(20+ (wild ? strlen(wild)+4: 0));
field->max_length=NAME_LEN;
end=strmov(field->name,"Database");
if (wild && wild[0])
......@@ -92,7 +92,7 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
char *file_name;
DBUG_ENTER("mysqld_show_tables");
field->name=(char*) sql_alloc(20+strlen(db)+(wild ? strlen(wild)+4:0));
field->name=(char*) thd->alloc(20+strlen(db)+(wild ? strlen(wild)+4:0));
end=strxmov(field->name,"Tables_in_",db,NullS);
if (wild && wild[0])
strxmov(end," (",wild,")",NullS);
......@@ -170,7 +170,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
if (check_grant(thd,TABLE_ACLS,&table_list,1))
continue;
}
if (files->push_back(sql_strdup(file->name)))
if (files->push_back(thd->strdup(file->name)))
{
my_dirend(dirp);
DBUG_RETURN(-1);
......@@ -868,12 +868,12 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
thread_info *thd_info=new thread_info;
thd_info->thread_id=tmp->thread_id;
thd_info->user=sql_strdup(tmp->user ? tmp->user : (tmp->system_thread ?
thd_info->user=thd->strdup(tmp->user ? tmp->user : (tmp->system_thread ?
"system user" : "unauthenticated user"));
thd_info->host=sql_strdup(tmp->host ? tmp->host : (tmp->ip ? tmp->ip :
thd_info->host=thd->strdup(tmp->host ? tmp->host : (tmp->ip ? tmp->ip :
(tmp->system_thread ? "none" : "connecting host")));
if ((thd_info->db=tmp->db)) // Safe test
thd_info->db=sql_strdup(thd_info->db);
thd_info->db=thd->strdup(thd_info->db);
thd_info->command=(int) tmp->command;
if (tmp->mysys_var)
pthread_mutex_lock(&tmp->mysys_var->mutex);
......@@ -902,7 +902,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
uint length=strlen(tmp->query);
if (length > max_query_length)
length=max_query_length;
thd_info->query=(char*) sql_memdup(tmp->query,length+1);
thd_info->query=(char*) thd->memdup(tmp->query,length+1);
thd_info->query[length]=0;
}
thread_infos.append(thd_info);
......
......@@ -644,7 +644,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
** Alter a table definition
****************************************************************************/
static bool
bool
mysql_rename_table(enum db_type base,
const char *old_db,
const char * old_name,
......@@ -659,9 +659,17 @@ mysql_rename_table(enum db_type base,
(void) sprintf(to,"%s/%s/%s",mysql_data_home,new_db,new_name);
fn_format(from,from,"","",4);
fn_format(to,to, "","",4);
if (file->rename_table((const char*) from,(const char *) to) ||
rename_file_ext(from,to,reg_ext))
if (file->rename_table((const char*) from,(const char *) to))
error=1;
else
{
if (rename_file_ext(from,to,reg_ext))
{
error=1;
/* Restore old file name */
file->rename_table((const char*) to,(const char *) from);
}
}
delete file;
DBUG_RETURN(error);
}
......@@ -1412,7 +1420,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
#ifdef __WIN__
// Win32 can't rename an open table, so we must close the org table!
table_name=sql_strdup(table_name); // must be saved
table_name=thd->strdup(table_name); // must be saved
if (close_cached_table(thd,table))
{ // Aborted
VOID(quick_rm_table(new_db_type,new_db,tmp_name));
......
......@@ -488,7 +488,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
query verb_clause create change select drop insert replace insert2
insert_values update delete show describe load alter optimize flush
begin commit rollback slave master_def master_defs
repair analyze check field_list field_list_item field_spec kill
repair analyze check rename
field_list field_list_item field_spec kill
select_item_list select_item values_list no_braces
limit_clause delete_limit_clause fields opt_values values
procedure_list procedure_list2 procedure_item
......@@ -504,6 +505,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
flush_options flush_option insert_lock_option replace_lock_option
equal optional_braces opt_key_definition key_usage_list2
opt_mi_check_type opt_to mi_check_types normal_join
table_to_table_list table_to_table
END_OF_INPUT
%type <NONE>
......@@ -539,6 +541,7 @@ verb_clause:
| lock
| kill
| optimize
| rename
| repair
| replace
| revoke
......@@ -1078,6 +1081,7 @@ opt_place:
opt_to:
/* empty */ {}
| TO_SYM {}
| AS {}
slave:
SLAVE START_SYM
......@@ -1134,6 +1138,24 @@ optimize:
YYABORT;
}
rename:
RENAME table_or_tables
{
Lex->sql_command=SQLCOM_RENAME_TABLE;
}
table_to_table_list
table_to_table_list:
table_to_table
| table_to_table_list ',' table_to_table
table_to_table:
table_ident TO_SYM table_ident
{ if (add_table_to_list($1,NULL,TL_IGNORE) ||
add_table_to_list($3,NULL,TL_IGNORE))
YYABORT;
}
/*
** Select : retrieve data from table
*/
......
......@@ -23,6 +23,7 @@ extern "C" {
void sql_alloc_error_handler(void)
{
current_thd->fatal_error=1; /* purecov: inspected */
sql_print_error(ER(ER_OUT_OF_RESOURCES));
}
}
......@@ -37,10 +38,6 @@ gptr sql_alloc(uint Size)
{
MEM_ROOT *root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC);
char *ptr= (char*) alloc_root(root,Size);
if (!ptr)
{
sql_print_error(ER(ER_OUT_OF_RESOURCES));
}
return ptr;
}
......
......@@ -40,6 +40,7 @@
#define ERRMAPP 1 /* Errormap f|r my_error */
#define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */
#define MAX_DBKEY_LENGTH (FN_LEN*2+2)
#define MAX_FIELD_NAME 34 /* Max colum name length +2 */
#define MAX_KEY 32 /* Max used keys */
#define MAX_REF_PARTS 16 /* Max parts used as ref */
......
......@@ -224,7 +224,8 @@ int my_strnncoll_sjis(const uchar *s1, int len1, const uchar *s2, int len2)
int my_strcoll_sjis(const uchar *s1, const uchar *s2)
{
return (uint) my_strnncoll_sjis(s1,(uint) strlen(s1), s2,(uint) strlen(s2));
return (uint) my_strnncoll_sjis(s1,(uint) strlen((char*) s1),
s2,(uint) strlen((char*) s2));
}
int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
......@@ -245,7 +246,7 @@ int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
int my_strxfrm_sjis(uchar *dest, uchar *src, int len)
{
return my_strnxfrm_sjis(dest, src, len, (uint) strlen(src));
return my_strnxfrm_sjis(dest, src, len, (uint) strlen((char*) src));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment