Merge dfischer@bk-internal.mysql.com:/home/bk/mysql-5.0-marvel

into  kahlann.erinye.com:/home/df/mysql/build/mysql-5.0-build
This commit is contained in:
df@kahlann.erinye.com 2006-12-01 13:02:54 +01:00
commit da7820c37d
77 changed files with 387 additions and 285 deletions

View File

@ -1323,3 +1323,10 @@ win/vs8cache.txt
zlib/*.ds? zlib/*.ds?
zlib/*.vcproj zlib/*.vcproj
mysql-test/r/*.warnings mysql-test/r/*.warnings
bdb/dist/db.h
bdb/dist/db_config.h
bdb/dist/db_cxx.h
bdb/dist/db_int.h
bdb/dist/include.tcl
*.gcda
*.gcno

View File

@ -2397,7 +2397,6 @@ print_table_data(MYSQL_RES *result)
const char *buffer; const char *buffer;
uint data_length; uint data_length;
uint field_max_length; uint field_max_length;
bool right_justified;
uint visible_length; uint visible_length;
uint extra_padding; uint extra_padding;
@ -3446,7 +3445,6 @@ server_version_string(MYSQL *mysql)
{ {
char *bufp = buf; char *bufp = buf;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW cur;
bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf); bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf);

View File

@ -1419,7 +1419,7 @@ static uint dump_routines_for_db(char *db)
routine body of other routines that are not the creator of! routine body of other routines that are not the creator of!
*/ */
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d", DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
routine_name, row[2], strlen(row[2]))); routine_name, row[2], (int) strlen(row[2])));
if (strlen(row[2])) if (strlen(row[2]))
{ {
char *query_str= NULL; char *query_str= NULL;
@ -2001,7 +2001,7 @@ continue_xml:
write_footer(sql_file); write_footer(sql_file);
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
} }
DBUG_RETURN(num_fields); DBUG_RETURN((uint) num_fields);
} /* get_table_structure */ } /* get_table_structure */

View File

@ -948,8 +948,8 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
die(NullS); die(NullS);
if (!eval_result && (uint) stat_info.st_size != ds->length) if (!eval_result && (uint) stat_info.st_size != ds->length)
{ {
DBUG_PRINT("info",("Size differs: result size: %u file size: %llu", DBUG_PRINT("info",("Size differs: result size: %u file size: %lu",
ds->length, stat_info.st_size)); ds->length, (ulong) stat_info.st_size));
DBUG_PRINT("info",("result: '%s'", ds->str)); DBUG_PRINT("info",("result: '%s'", ds->str));
DBUG_RETURN(RESULT_LENGTH_MISMATCH); DBUG_RETURN(RESULT_LENGTH_MISMATCH);
} }
@ -3132,14 +3132,15 @@ void do_connect(struct st_command *command)
else if (!strncmp(con_options, "COMPRESS", 8)) else if (!strncmp(con_options, "COMPRESS", 8))
con_compress= 1; con_compress= 1;
else else
die("Illegal option to connect: %.*s", end - con_options, con_options); die("Illegal option to connect: %.*s",
(int) (end - con_options), con_options);
/* Process next option */ /* Process next option */
con_options= end; con_options= end;
} }
if (next_con == connections_end) if (next_con == connections_end)
die("Connection limit exhausted, you can have max %d connections", die("Connection limit exhausted, you can have max %d connections",
(sizeof(connections)/sizeof(struct st_connection))); (int) (sizeof(connections)/sizeof(struct st_connection)));
if (find_connection_by_name(ds_connection_name.str)) if (find_connection_by_name(ds_connection_name.str))
die("Connection %s already exists", ds_connection_name.str); die("Connection %s already exists", ds_connection_name.str);
@ -3460,10 +3461,10 @@ int read_line(char *buf, int size)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
else if ((c == '{' && else if ((c == '{' &&
(!my_strnncoll_simple(charset_info, "while", 5, (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
buf, min(5, p - buf), 0) || (uchar*) buf, min(5, p - buf), 0) ||
!my_strnncoll_simple(charset_info, "if", 2, !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
buf, min(2, p - buf), 0)))) (uchar*) buf, min(2, p - buf), 0))))
{ {
/* Only if and while commands can be terminated by { */ /* Only if and while commands can be terminated by { */
*p++= c; *p++= c;

View File

@ -337,6 +337,7 @@ rl_generic_bind (type, keyseq, data, map)
KEYMAP_ENTRY k; KEYMAP_ENTRY k;
k.function = 0; k.function = 0;
k.type= 0;
/* If no keys to bind to, exit right away. */ /* If no keys to bind to, exit right away. */
if (!keyseq || !*keyseq) if (!keyseq || !*keyseq)
@ -735,7 +736,8 @@ _rl_read_file (filename, sizep)
file_size = (size_t)finfo.st_size; file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */ /* check for overflow on very large files */
if (file_size != finfo.st_size || file_size + 1 < file_size) if ((long long) file_size != (long long) finfo.st_size ||
file_size + 1 < file_size)
{ {
if (file >= 0) if (file >= 0)
close (file); close (file);

View File

@ -184,7 +184,8 @@ read_history_range (filename, from, to)
file_size = (size_t)finfo.st_size; file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */ /* check for overflow on very large files */
if (file_size != finfo.st_size || file_size + 1 < file_size) if ((long long) file_size != (long long) finfo.st_size ||
file_size + 1 < file_size)
{ {
errno = overflow_errno; errno = overflow_errno;
goto error_and_exit; goto error_and_exit;

View File

@ -1052,8 +1052,10 @@ static int convert_file(REPLACE *rep, my_string name)
{ {
int error; int error;
FILE *in,*out; FILE *in,*out;
char dir_buff[FN_REFLEN], tempname[FN_REFLEN]; char dir_buff[FN_REFLEN], tempname[FN_REFLEN], *org_name = name;
char link_name[FN_REFLEN], *org_name = name; #ifdef HAVE_READLINK
char link_name[FN_REFLEN];
#endif
File temp_file; File temp_file;
DBUG_ENTER("convert_file"); DBUG_ENTER("convert_file");

View File

@ -75,7 +75,7 @@ public:
typedef Integer Element; typedef Integer Element;
AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;} AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;}
AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} AbstractRing(const AbstractRing &source) :AbstractGroup() {m_mg.m_pRing = this;}
AbstractRing& operator=(const AbstractRing &source) {return *this;} AbstractRing& operator=(const AbstractRing &source) {return *this;}
virtual bool IsUnit(const Element &a) const =0; virtual bool IsUnit(const Element &a) const =0;

View File

@ -36,7 +36,8 @@ void hp_clear(HP_SHARE *info)
(byte*) 0)); (byte*) 0));
info->block.levels=0; info->block.levels=0;
hp_clear_keys(info); hp_clear_keys(info);
info->records=info->deleted=info->data_length=0; info->records= info->deleted= 0;
info->data_length= 0;
info->blength=1; info->blength=1;
info->changed=0; info->changed=0;
info->del_link=0; info->del_link=0;

View File

@ -68,7 +68,7 @@ int heap_write(HP_INFO *info, const byte *record)
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef)); DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef)));
info->errkey= keydef - share->keydef; info->errkey= keydef - share->keydef;
if (keydef->algorithm == HA_KEY_ALG_BTREE) if (keydef->algorithm == HA_KEY_ALG_BTREE)
{ {

View File

@ -46,8 +46,8 @@ typedef struct st_heapinfo /* Struct from heap_info */
ulong records; /* Records in database */ ulong records; /* Records in database */
ulong deleted; /* Deleted records in database */ ulong deleted; /* Deleted records in database */
ulong max_records; ulong max_records;
ulong data_length; ulonglong data_length;
ulong index_length; ulonglong index_length;
uint reclength; /* Length of one record */ uint reclength; /* Length of one record */
int errkey; int errkey;
ulonglong auto_increment; ulonglong auto_increment;
@ -135,7 +135,7 @@ typedef struct st_heap_share
HP_BLOCK block; HP_BLOCK block;
HP_KEYDEF *keydef; HP_KEYDEF *keydef;
ulong min_records,max_records; /* Params to open */ ulong min_records,max_records; /* Params to open */
ulong data_length,index_length,max_table_size; ulonglong data_length,index_length,max_table_size;
uint key_stat_version; /* version to indicate insert/delete */ uint key_stat_version; /* version to indicate insert/delete */
uint records; /* records */ uint records; /* records */
uint blength; /* records rounded up to 2^n */ uint blength; /* records rounded up to 2^n */
@ -187,7 +187,7 @@ typedef struct st_heap_create_info
{ {
uint auto_key; /* keynr [1 - maxkey] for auto key */ uint auto_key; /* keynr [1 - maxkey] for auto key */
uint auto_key_type; uint auto_key_type;
ulong max_table_size; ulonglong max_table_size;
ulonglong auto_increment; ulonglong auto_increment;
my_bool with_auto_increment; my_bool with_auto_increment;
} HP_CREATE_INFO; } HP_CREATE_INFO;

View File

@ -1040,8 +1040,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define set_timespec_nsec(ABSTIME,NSEC) \ #define set_timespec_nsec(ABSTIME,NSEC) \
{\ {\
ulonglong now= my_getsystime() + (NSEC/100); \ ulonglong now= my_getsystime() + (NSEC/100); \
(ABSTIME).tv_sec= (now / ULL(10000000)); \ (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \
(ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
} }
#endif /* !set_timespec_nsec */ #endif /* !set_timespec_nsec */
#endif /* HAVE_TIMESPEC_TS_SEC */ #endif /* HAVE_TIMESPEC_TS_SEC */

View File

@ -677,14 +677,13 @@ struct st_my_thread_var
}; };
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
extern uint my_thread_end_wait_time;
#define my_thread_var (_my_thread_var()) #define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno #define my_errno my_thread_var->thr_errno
/* /*
Keep track of shutdown,signal, and main threads so that my_end() will not Keep track of shutdown,signal, and main threads so that my_end() will not
report errors with them report errors with them
*/ */
extern pthread_t shutdown_th, main_th, signal_th;
/* statistics_xxx functions are for not essential statistic */ /* statistics_xxx functions are for not essential statistic */
#ifndef thread_safe_increment #ifndef thread_safe_increment

View File

@ -59,7 +59,8 @@ typedef struct st_tree_element {
typedef struct st_tree { typedef struct st_tree {
TREE_ELEMENT *root,null_element; TREE_ELEMENT *root,null_element;
TREE_ELEMENT **parents[MAX_TREE_HEIGHT]; TREE_ELEMENT **parents[MAX_TREE_HEIGHT];
uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated; uint offset_to_key,elements_in_tree,size_of_element;
ulong memory_limit, allocated;
qsort_cmp2 compare; qsort_cmp2 compare;
void *custom_arg; void *custom_arg;
MEM_ROOT mem_root; MEM_ROOT mem_root;
@ -69,7 +70,7 @@ typedef struct st_tree {
} TREE; } TREE;
/* Functions on whole tree */ /* Functions on whole tree */
void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit,
int size, qsort_cmp2 compare, my_bool with_delete, int size, qsort_cmp2 compare, my_bool with_delete,
tree_element_free free_element, void *custom_arg); tree_element_free free_element, void *custom_arg);
void delete_tree(TREE*); void delete_tree(TREE*);

View File

@ -1718,7 +1718,7 @@ os_file_set_size(
} }
/* Print about progress for each 100 MB written */ /* Print about progress for each 100 MB written */
if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) if ((ib_longlong) (current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024)
!= current_size / (ib_longlong)(100 * 1024 * 1024)) { != current_size / (ib_longlong)(100 * 1024 * 1024)) {
fprintf(stderr, " %lu00", fprintf(stderr, " %lu00",

View File

@ -175,6 +175,9 @@ void STDCALL mysql_server_end()
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
end_embedded_server(); end_embedded_server();
#endif #endif
finish_client_errs();
vio_end();
/* If library called my_init(), free memory allocated by it */ /* If library called my_init(), free memory allocated by it */
if (!org_my_init_done) if (!org_my_init_done)
{ {
@ -185,10 +188,11 @@ void STDCALL mysql_server_end()
#endif #endif
} }
else else
{
free_charsets();
mysql_thread_end(); mysql_thread_end();
finish_client_errs(); }
free_charsets();
vio_end();
mysql_client_init= org_my_init_done= 0; mysql_client_init= org_my_init_done= 0;
#ifdef EMBEDDED_SERVER #ifdef EMBEDDED_SERVER
if (stderror_file) if (stderror_file)

View File

@ -428,8 +428,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_segs) key_segs)
share.state.rec_per_key_part[key_segs-1]=1L; share.state.rec_per_key_part[key_segs-1]=1L;
length+=key_length; length+=key_length;
keydef->block_length= MI_BLOCK_SIZE(length-real_length_diff, keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
pointer,MI_MAX_KEYPTR_SIZE); pointer,MI_MAX_KEYPTR_SIZE);
if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH || if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH ||
length >= MI_MAX_KEY_BUFF) length >= MI_MAX_KEY_BUFF)
{ {

View File

@ -1105,18 +1105,18 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
my_off_t total_count; my_off_t total_count;
char llbuf[32]; char llbuf[32];
DBUG_PRINT("info", ("column: %3u", count - huff_counts + 1)); DBUG_PRINT("info", ("column: %3u", (uint) (count - huff_counts + 1)));
if (verbose >= 2) if (verbose >= 2)
VOID(printf("column: %3u\n", count - huff_counts + 1)); VOID(printf("column: %3u\n", (uint) (count - huff_counts + 1)));
if (count->tree_buff) if (count->tree_buff)
{ {
DBUG_PRINT("info", ("number of distinct values: %u", DBUG_PRINT("info", ("number of distinct values: %u",
(count->tree_pos - count->tree_buff) / (uint) ((count->tree_pos - count->tree_buff) /
count->field_length)); count->field_length)));
if (verbose >= 2) if (verbose >= 2)
VOID(printf("number of distinct values: %u\n", VOID(printf("number of distinct values: %u\n",
(count->tree_pos - count->tree_buff) / (uint) ((count->tree_pos - count->tree_buff) /
count->field_length)); count->field_length)));
} }
total_count= 0; total_count= 0;
for (idx= 0; idx < 256; idx++) for (idx= 0; idx < 256; idx++)
@ -1965,7 +1965,7 @@ static char *bindigits(ulonglong value, uint bits)
DBUG_ASSERT(idx < sizeof(digits)); DBUG_ASSERT(idx < sizeof(digits));
while (idx) while (idx)
*(ptr++)= '0' + ((value >> (--idx)) & 1); *(ptr++)= '0' + ((char) (value >> (--idx)) & (char) 1);
*ptr= '\0'; *ptr= '\0';
return digits; return digits;
} }
@ -1995,7 +1995,7 @@ static char *hexdigits(ulonglong value)
DBUG_ASSERT(idx < sizeof(digits)); DBUG_ASSERT(idx < sizeof(digits));
while (idx) while (idx)
{ {
if ((*(ptr++)= '0' + ((value >> (4 * (--idx))) & 0xf)) > '9') if ((*(ptr++)= '0' + ((char) (value >> (4 * (--idx))) & (char) 0xf)) > '9')
*(ptr - 1)+= 'a' - '9' - 1; *(ptr - 1)+= 'a' - '9' - 1;
} }
*ptr= '\0'; *ptr= '\0';
@ -2280,11 +2280,11 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees)
{ {
VOID(fflush(stdout)); VOID(fflush(stdout));
VOID(fprintf(stderr, "error: Huffman code too long: %u/%u\n", VOID(fprintf(stderr, "error: Huffman code too long: %u/%u\n",
bits, 8 * sizeof(code))); bits, (uint) (8 * sizeof(code))));
errors++; errors++;
break; break;
} }
idx+= code & 1; idx+= (uint) code & 1;
if (idx >= length) if (idx >= length)
{ {
VOID(fflush(stdout)); VOID(fflush(stdout));

View File

@ -88,7 +88,7 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key,
mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
mi->once_flags|= RRND_PRESERVE_LASTINX; mi->once_flags|= RRND_PRESERVE_LASTINX;
DBUG_PRINT("info", ("using table no: %d", DBUG_PRINT("info", ("using table no: %d",
info->current_table - info->open_tables + 1)); (int) (info->current_table - info->open_tables + 1)));
DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length); DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length);
DBUG_RETURN(_myrg_mi_read_record(mi,buf)); DBUG_RETURN(_myrg_mi_read_record(mi,buf));
} }

View File

@ -296,7 +296,7 @@ SET sql_quote_show_create= @old_sql_quote_show_create;
SET sql_mode= @old_sql_mode; SET sql_mode= @old_sql_mode;
select @@max_heap_table_size; select @@max_heap_table_size;
@@max_heap_table_size @@max_heap_table_size
1047552 1048576
CREATE TABLE t1 ( CREATE TABLE t1 (
a int(11) default NULL, a int(11) default NULL,
KEY a USING BTREE (a) KEY a USING BTREE (a)

View File

@ -610,4 +610,12 @@ select hex(a), b from t1;
hex(a) b hex(a) b
1 2 1 2
drop table t1; drop table t1;
create table t1(bit_field bit(2), int_field int, key a(bit_field));
insert into t1 values (1,2);
handler t1 open as t1;
handler t1 read a=(1);
bit_field int_field
 2
handler t1 close;
drop table t1;
End of 5.0 tests End of 5.0 tests

View File

@ -261,4 +261,15 @@ insert into t1 (b, a) values ('2', '1');
select hex(a), b from t1; select hex(a), b from t1;
drop table t1; drop table t1;
#
# type was not properly initalized, which caused key_copy to fail
#
create table t1(bit_field bit(2), int_field int, key a(bit_field));
insert into t1 values (1,2);
handler t1 open as t1;
handler t1 read a=(1);
handler t1 close;
drop table t1;
--echo End of 5.0 tests --echo End of 5.0 tests

View File

@ -40,7 +40,7 @@ base64_needed_encoded_length(int length_of_data)
int int
base64_needed_decoded_length(int length_of_encoded_data) base64_needed_decoded_length(int length_of_encoded_data)
{ {
return ceil(length_of_encoded_data * 3 / 4); return (int) ceil(length_of_encoded_data * 3 / 4);
} }

View File

@ -30,7 +30,10 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys);
#endif /* USE_TLS */ #endif /* USE_TLS */
pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open, pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap,
THR_LOCK_net, THR_LOCK_charset; THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads;
pthread_cond_t THR_COND_threads;
uint THR_thread_count= 0;
uint my_thread_end_wait_time= 5;
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
pthread_mutex_t LOCK_localtime_r; pthread_mutex_t LOCK_localtime_r;
#endif #endif
@ -79,7 +82,7 @@ my_bool my_thread_global_init(void)
#endif #endif
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
/* /*
Set mutex type to "errorcheck" a.k.a "adaptive" Set mutex type to "errorcheck"
*/ */
pthread_mutexattr_init(&my_errorcheck_mutexattr); pthread_mutexattr_init(&my_errorcheck_mutexattr);
pthread_mutexattr_settype(&my_errorcheck_mutexattr, pthread_mutexattr_settype(&my_errorcheck_mutexattr,
@ -94,6 +97,8 @@ my_bool my_thread_global_init(void)
pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST);
pthread_cond_init(&THR_COND_threads, NULL);
#if defined( __WIN__) || defined(OS2) #if defined( __WIN__) || defined(OS2)
win_pthread_init(); win_pthread_init();
#endif #endif
@ -114,6 +119,27 @@ my_bool my_thread_global_init(void)
void my_thread_global_end(void) void my_thread_global_end(void)
{ {
struct timespec abstime;
my_bool all_threads_killed= 1;
set_timespec(abstime, my_thread_end_wait_time);
pthread_mutex_lock(&THR_LOCK_threads);
while (THR_thread_count > 0)
{
int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads,
&abstime);
if (error == ETIMEDOUT || error == ETIME)
{
if (THR_thread_count)
fprintf(stderr,
"Error in my_thread_global_end(): %d threads didn't exit\n",
THR_thread_count);
all_threads_killed= 0;
break;
}
}
pthread_mutex_unlock(&THR_LOCK_threads);
pthread_key_delete(THR_KEY_mysys); pthread_key_delete(THR_KEY_mysys);
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_destroy(&my_fast_mutexattr); pthread_mutexattr_destroy(&my_fast_mutexattr);
@ -129,6 +155,11 @@ void my_thread_global_end(void)
pthread_mutex_destroy(&THR_LOCK_heap); pthread_mutex_destroy(&THR_LOCK_heap);
pthread_mutex_destroy(&THR_LOCK_net); pthread_mutex_destroy(&THR_LOCK_net);
pthread_mutex_destroy(&THR_LOCK_charset); pthread_mutex_destroy(&THR_LOCK_charset);
if (all_threads_killed)
{
pthread_mutex_destroy(&THR_LOCK_threads);
pthread_cond_destroy (&THR_COND_threads);
}
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
pthread_mutex_destroy(&LOCK_localtime_r); pthread_mutex_destroy(&LOCK_localtime_r);
#endif #endif
@ -140,10 +171,23 @@ void my_thread_global_end(void)
static long thread_id=0; static long thread_id=0;
/* /*
We can't use mutex_locks here if we are using windows as Allocate thread specific memory for the thread, used by mysys and dbug
we may have compiled the program with SAFE_MUTEX, in which
case the checking of mutex_locks will not work until SYNOPSIS
the pthread_self thread specific variable is initialized. my_thread_init()
NOTES
We can't use mutex_locks here if we are using windows as
we may have compiled the program with SAFE_MUTEX, in which
case the checking of mutex_locks will not work until
the pthread_self thread specific variable is initialized.
This function may called multiple times for a thread, for example
if one uses my_init() followed by mysql_server_init().
RETURN
0 ok
1 Fatal error; mysys/dbug functions can't be used
*/ */
my_bool my_thread_init(void) my_bool my_thread_init(void)
@ -154,9 +198,6 @@ my_bool my_thread_init(void)
#ifdef EXTRA_DEBUG_THREADS #ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self()); fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self());
#endif #endif
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
pthread_mutex_lock(&THR_LOCK_lock);
#endif
#if !defined(__WIN__) || defined(USE_TLS) #if !defined(__WIN__) || defined(USE_TLS)
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys)) if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
@ -174,7 +215,7 @@ my_bool my_thread_init(void)
} }
pthread_setspecific(THR_KEY_mysys,tmp); pthread_setspecific(THR_KEY_mysys,tmp);
#else #else /* defined(__WIN__) && !(defined(USE_TLS) */
/* /*
Skip initialization if the thread specific variable is already initialized Skip initialization if the thread specific variable is already initialized
*/ */
@ -182,7 +223,6 @@ my_bool my_thread_init(void)
goto end; goto end;
tmp= &THR_KEY_mysys; tmp= &THR_KEY_mysys;
#endif #endif
tmp->id= ++thread_id;
#if defined(__WIN__) && defined(EMBEDDED_LIBRARY) #if defined(__WIN__) && defined(EMBEDDED_LIBRARY)
tmp->thread_self= (pthread_t)getpid(); tmp->thread_self= (pthread_t)getpid();
#endif #endif
@ -190,22 +230,35 @@ my_bool my_thread_init(void)
pthread_cond_init(&tmp->suspend, NULL); pthread_cond_init(&tmp->suspend, NULL);
tmp->init= 1; tmp->init= 1;
pthread_mutex_lock(&THR_LOCK_threads);
tmp->id= ++thread_id;
++THR_thread_count;
pthread_mutex_unlock(&THR_LOCK_threads);
end: end:
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
pthread_mutex_unlock(&THR_LOCK_lock);
#endif
return error; return error;
} }
/*
Deallocate memory used by the thread for book-keeping
SYNOPSIS
my_thread_end()
NOTE
This may be called multiple times for a thread.
This happens for example when one calls 'mysql_server_init()'
mysql_server_end() and then ends with a mysql_end().
*/
void my_thread_end(void) void my_thread_end(void)
{ {
struct st_my_thread_var *tmp; struct st_my_thread_var *tmp;
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
#ifdef EXTRA_DEBUG_THREADS #ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_end(): tmp=%p,thread_id=%ld\n", fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n",
tmp,pthread_self()); (long) tmp, pthread_self());
#endif #endif
if (tmp && tmp->init) if (tmp && tmp->init)
{ {
@ -227,6 +280,18 @@ void my_thread_end(void)
#else #else
tmp->init= 0; tmp->init= 0;
#endif #endif
/*
Decrement counter for number of running threads. We are using this
in my_thread_global_end() to wait until all threads have called
my_thread_end and thus freed all memory they have allocated in
my_thread_init() and DBUG_xxxx
*/
pthread_mutex_lock(&THR_LOCK_threads);
DBUG_ASSERT(THR_thread_count != 0);
if (--THR_thread_count == 0)
pthread_cond_signal(&THR_COND_threads);
pthread_mutex_unlock(&THR_LOCK_threads);
} }
/* The following free has to be done, even if my_thread_var() is 0 */ /* The following free has to be done, even if my_thread_var() is 0 */
#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)

View File

@ -84,7 +84,7 @@ static void rb_delete_fixup(TREE *tree,TREE_ELEMENT ***parent);
static int test_rb_tree(TREE_ELEMENT *element); static int test_rb_tree(TREE_ELEMENT *element);
#endif #endif
void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit,
int size, qsort_cmp2 compare, my_bool with_delete, int size, qsort_cmp2 compare, my_bool with_delete,
tree_element_free free_element, void *custom_arg) tree_element_free free_element, void *custom_arg)
{ {
@ -128,7 +128,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
} }
if (!(tree->with_delete=with_delete)) if (!(tree->with_delete=with_delete))
{ {
init_alloc_root(&tree->mem_root, default_alloc_size,0); init_alloc_root(&tree->mem_root, (uint) default_alloc_size, 0);
tree->mem_root.min_malloc=(sizeof(TREE_ELEMENT)+tree->size_of_element); tree->mem_root.min_malloc=(sizeof(TREE_ELEMENT)+tree->size_of_element);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;

View File

@ -178,7 +178,7 @@ ndb_mgm_create_handle()
h->mgmd_version_minor= -1; h->mgmd_version_minor= -1;
h->mgmd_version_build= -1; h->mgmd_version_build= -1;
DBUG_PRINT("info", ("handle=0x%x", (UintPtr)h)); DBUG_PRINT("info", ("handle: 0x%lx", (long)h));
DBUG_RETURN(h); DBUG_RETURN(h);
} }
@ -195,7 +195,7 @@ int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
{ {
DBUG_ENTER("ndb_mgm_set_connectstring"); DBUG_ENTER("ndb_mgm_set_connectstring");
DBUG_PRINT("info", ("handle=0x%x", (UintPtr)handle)); DBUG_PRINT("info", ("handle: 0x%lx", (long)handle));
handle->cfg.~LocalConfig(); handle->cfg.~LocalConfig();
new (&(handle->cfg)) LocalConfig; new (&(handle->cfg)) LocalConfig;
if (!handle->cfg.init(mgmsrv, 0) || if (!handle->cfg.init(mgmsrv, 0) ||
@ -237,7 +237,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
DBUG_ENTER("ndb_mgm_destroy_handle"); DBUG_ENTER("ndb_mgm_destroy_handle");
if(!handle) if(!handle)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
DBUG_PRINT("info", ("handle=0x%x", (UintPtr)(* handle))); DBUG_PRINT("info", ("handle: 0x%lx", (long)(* handle)));
/** /**
* important! only disconnect if connected * important! only disconnect if connected
* other code relies on this * other code relies on this

View File

@ -777,7 +777,7 @@ Ndb::getAutoIncrementValue(const char* aTableName,
} }
if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1)
DBUG_RETURN(-1); DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); DBUG_PRINT("info", ("value %lu", (ulong) tupleId));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -798,7 +798,7 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
} }
if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1)
DBUG_RETURN(-1); DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -811,7 +811,7 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_info* info,
{ {
assert(info->m_first_tuple_id < info->m_last_tuple_id); assert(info->m_first_tuple_id < info->m_last_tuple_id);
tupleId = ++info->m_first_tuple_id; tupleId = ++info->m_first_tuple_id;
DBUG_PRINT("info", ("next cached value %llu", (ulonglong)tupleId)); DBUG_PRINT("info", ("next cached value %lu", (ulong)tupleId));
} }
else else
{ {
@ -845,7 +845,7 @@ Ndb::readAutoIncrementValue(const char* aTableName,
} }
if (readTupleIdFromNdb(info, tupleId) == -1) if (readTupleIdFromNdb(info, tupleId) == -1)
DBUG_RETURN(-1); DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -866,7 +866,7 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable,
} }
if (readTupleIdFromNdb(info, tupleId) == -1) if (readTupleIdFromNdb(info, tupleId) == -1)
DBUG_RETURN(-1); DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -948,8 +948,8 @@ Ndb::setTupleIdInNdb(Ndb_local_table_info* info,
{ {
info->m_first_tuple_id = tupleId - 1; info->m_first_tuple_id = tupleId - 1;
DBUG_PRINT("info", DBUG_PRINT("info",
("Setting next auto increment cached value to %llu", ("Setting next auto increment cached value to %lu",
(ulonglong)tupleId)); (ulong)tupleId));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
} }
@ -976,7 +976,8 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op)
{ {
DBUG_ENTER("Ndb::opTupleIdOnNdb"); DBUG_ENTER("Ndb::opTupleIdOnNdb");
Uint32 aTableId = info->m_table_impl->m_tableId; Uint32 aTableId = info->m_table_impl->m_tableId;
DBUG_PRINT("enter", ("table=%u value=%llu op=%u", aTableId, opValue, op)); DBUG_PRINT("enter", ("table: %u value: %lu op: %u",
aTableId, (ulong) opValue, op));
NdbTransaction* tConnection; NdbTransaction* tConnection;
NdbOperation* tOperation= 0; // Compiler warning if not initialized NdbOperation* tOperation= 0; // Compiler warning if not initialized
@ -1050,8 +1051,8 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op)
else else
{ {
DBUG_PRINT("info", DBUG_PRINT("info",
("Setting next auto increment value (db) to %llu", ("Setting next auto increment value (db) to %lu",
(ulonglong)opValue)); (ulong)opValue));
info->m_first_tuple_id = info->m_last_tuple_id = opValue - 1; info->m_first_tuple_id = info->m_last_tuple_id = opValue - 1;
} }
break; break;
@ -1247,7 +1248,7 @@ Ndb::internalize_index_name(const NdbTableImpl * table,
if (!table) if (!table)
{ {
DBUG_PRINT("error", ("!table")); DBUG_PRINT("error", ("!table"));
return ret; DBUG_RETURN(ret);
} }
if (fullyQualifiedNames) if (fullyQualifiedNames)

View File

@ -653,9 +653,9 @@ NdbScanOperation::doSend(int ProcessorId)
void NdbScanOperation::close(bool forceSend, bool releaseOp) void NdbScanOperation::close(bool forceSend, bool releaseOp)
{ {
DBUG_ENTER("NdbScanOperation::close"); DBUG_ENTER("NdbScanOperation::close");
DBUG_PRINT("enter", ("this=%x tcon=%x con=%x force=%d release=%d", DBUG_PRINT("enter", ("this: 0x%lx tcon: 0x%lx con: 0x%lx force: %d release: %d",
(UintPtr)this, (long)this,
(UintPtr)m_transConnection, (UintPtr)theNdbCon, (long)m_transConnection, (long)theNdbCon,
forceSend, releaseOp)); forceSend, releaseOp));
if(m_transConnection){ if(m_transConnection){

View File

@ -1007,7 +1007,8 @@ void
NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp) NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp)
{ {
DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation"); DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation");
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)); DBUG_PRINT("enter", ("this: 0x%lx op=0x%lx",
(long)this, (long)cursorOp));
releaseScanOperation(&m_firstExecutedScanOp, 0, cursorOp); releaseScanOperation(&m_firstExecutedScanOp, 0, cursorOp);

View File

@ -361,7 +361,7 @@ void
Ndb::releaseScanOperation(NdbIndexScanOperation* aScanOperation) Ndb::releaseScanOperation(NdbIndexScanOperation* aScanOperation)
{ {
DBUG_ENTER("Ndb::releaseScanOperation"); DBUG_ENTER("Ndb::releaseScanOperation");
DBUG_PRINT("enter", ("op=%x", (UintPtr)aScanOperation)); DBUG_PRINT("enter", ("op: 0x%lx", (long)aScanOperation));
#ifdef ndb_release_check_dup #ifdef ndb_release_check_dup
{ NdbIndexScanOperation* tOp = theScanOpIdleList; { NdbIndexScanOperation* tOp = theScanOpIdleList;
while (tOp != NULL) { while (tOp != NULL) {

View File

@ -222,8 +222,6 @@ void Guardian_thread::run()
while (node != NULL) while (node != NULL)
{ {
struct timespec timeout;
GUARD_NODE *current_node= (GUARD_NODE *) node->data; GUARD_NODE *current_node= (GUARD_NODE *) node->data;
instance= ((GUARD_NODE *) node->data)->instance; instance= ((GUARD_NODE *) node->data)->instance;
process_instance(instance, current_node, &guarded_instances, node); process_instance(instance, current_node, &guarded_instances, node);

View File

@ -15,7 +15,6 @@
#define snprintf _snprintf #define snprintf _snprintf
#define SIGKILL 9 #define SIGKILL 9
#define SHUT_RDWR 0x2
/*TODO: fix this */ /*TODO: fix this */
#define PROTOCOL_VERSION 10 #define PROTOCOL_VERSION 10

View File

@ -1217,7 +1217,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
{ {
uchar *pos; uchar *pos;
/* fields count may be wrong */ /* fields count may be wrong */
DBUG_ASSERT ((field - result) < fields); DBUG_ASSERT((uint) (field - result) < fields);
cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7);
field->catalog = strdup_root(alloc,(char*) row->data[0]); field->catalog = strdup_root(alloc,(char*) row->data[0]);
field->db = strdup_root(alloc,(char*) row->data[1]); field->db = strdup_root(alloc,(char*) row->data[1]);

View File

@ -429,7 +429,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
goto err; goto err;
} }
if (check_date(l_time, not_zero_date, flags, was_cut)) if (check_date(l_time, not_zero_date != 0, flags, was_cut))
goto err; goto err;
l_time->time_type= (number_of_fields <= 3 ? l_time->time_type= (number_of_fields <= 3 ?
@ -530,15 +530,15 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
if ((uint) (end-str) > 1 && str != end_of_days && if ((uint) (end-str) > 1 && str != end_of_days &&
my_isdigit(&my_charset_latin1, *str)) my_isdigit(&my_charset_latin1, *str))
{ /* Found days part */ { /* Found days part */
date[0]= value; date[0]= (ulong) value;
state= 1; /* Assume next is hours */ state= 1; /* Assume next is hours */
found_days= 1; found_days= 1;
} }
else if ((end-str) > 1 && *str == time_separator && else if ((end-str) > 1 && *str == time_separator &&
my_isdigit(&my_charset_latin1, str[1])) my_isdigit(&my_charset_latin1, str[1]))
{ {
date[0]=0; /* Assume we found hours */ date[0]= 0; /* Assume we found hours */
date[1]=value; date[1]= (ulong) value;
state=2; state=2;
found_hours=1; found_hours=1;
str++; /* skip ':' */ str++; /* skip ':' */
@ -547,9 +547,9 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
{ {
/* String given as one number; assume HHMMSS format */ /* String given as one number; assume HHMMSS format */
date[0]= 0; date[0]= 0;
date[1]= value/10000; date[1]= (ulong) (value/10000);
date[2]= value/100 % 100; date[2]= (ulong) (value/100 % 100);
date[3]= value % 100; date[3]= (ulong) (value % 100);
state=4; state=4;
goto fractional; goto fractional;
} }
@ -559,7 +559,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
{ {
for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++) for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++)
value=value*10L + (long) (*str - '0'); value=value*10L + (long) (*str - '0');
date[state++]=value; date[state++]= (ulong) value;
if (state == 4 || (end-str) < 2 || *str != time_separator || if (state == 4 || (end-str) < 2 || *str != time_separator ||
!my_isdigit(&my_charset_latin1,str[1])) !my_isdigit(&my_charset_latin1,str[1]))
break; break;
@ -594,7 +594,7 @@ fractional:
value*= (long) log_10_int[field_length]; value*= (long) log_10_int[field_length];
else if (field_length < 0) else if (field_length < 0)
*warning|= MYSQL_TIME_WARN_TRUNCATED; *warning|= MYSQL_TIME_WARN_TRUNCATED;
date[4]=value; date[4]= (ulong) value;
} }
else else
date[4]=0; date[4]=0;

View File

@ -4815,7 +4815,7 @@ int Field_time::store_time(TIME *ltime, timestamp_type type)
(ltime->minute * 100 + ltime->second); (ltime->minute * 100 + ltime->second);
if (ltime->neg) if (ltime->neg)
tmp= -tmp; tmp= -tmp;
return Field_time::store((longlong) tmp); return Field_time::store((longlong) tmp, FALSE);
} }
@ -5411,11 +5411,11 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type)
if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME)
{ {
tmp=ltime->year*16*32+ltime->month*32+ltime->day; tmp=ltime->year*16*32+ltime->month*32+ltime->day;
if ((my_bool)check_date(ltime, tmp, if (check_date(ltime, tmp != 0,
(TIME_FUZZY_DATE | (TIME_FUZZY_DATE |
(current_thd->variables.sql_mode & (current_thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error)) MODE_INVALID_DATES))), &error))
{ {
char buff[12]; char buff[12];
String str(buff, sizeof(buff), &my_charset_latin1); String str(buff, sizeof(buff), &my_charset_latin1);
@ -5635,11 +5635,11 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
{ {
tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+ tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+
(ltime->hour*10000L+ltime->minute*100+ltime->second)); (ltime->hour*10000L+ltime->minute*100+ltime->second));
if ((my_bool)check_date(ltime, tmp, if (check_date(ltime, tmp != 0,
(TIME_FUZZY_DATE | (TIME_FUZZY_DATE |
(current_thd->variables.sql_mode & (current_thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))), &error)) MODE_INVALID_DATES))), &error))
{ {
char buff[19]; char buff[19];
String str(buff, sizeof(buff), &my_charset_latin1); String str(buff, sizeof(buff), &my_charset_latin1);
@ -8120,7 +8120,7 @@ int Field_bit::store_decimal(const my_decimal *val)
{ {
int err= 0; int err= 0;
longlong i= convert_decimal2longlong(val, 1, &err); longlong i= convert_decimal2longlong(val, 1, &err);
return test(err | store(i)); return test(err | store(i, TRUE));
} }
@ -8273,7 +8273,7 @@ Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg,
int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
{ {
int delta; int delta;
uchar bits= field_length & 7; uchar bits= (uchar) (field_length & 7);
for (; length && !*from; from++, length--); // skip left 0's for (; length && !*from; from++, length--); // skip left 0's
delta= bytes_in_rec - length; delta= bytes_in_rec - length;

View File

@ -206,9 +206,10 @@ void insert_symbols()
void insert_sql_functions() void insert_sql_functions()
{ {
size_t i= 0; int i= 0;
SYMBOL *cur; SYMBOL *cur;
for (cur= sql_functions; i<array_elements(sql_functions); cur++, i++){ for (cur= sql_functions; i < (int) array_elements(sql_functions); cur++, i++)
{
hash_lex_struct *root= hash_lex_struct *root=
get_hash_struct_by_len(&root_by_len,cur->length,&max_len); get_hash_struct_by_len(&root_by_len,cur->length,&max_len);
insert_into_hash(root,cur->name,0,-i-1,1); insert_into_hash(root,cur->name,0,-i-1,1);

View File

@ -211,7 +211,7 @@ bool archive_db_init()
max_zfile_size= INT_MAX16; max_zfile_size= INT_MAX16;
break; break;
case 8: case 8:
max_zfile_size= LONGLONG_MAX; max_zfile_size= (z_off_t) LONGLONG_MAX;
break; break;
case 4: case 4:
default: default:
@ -327,8 +327,8 @@ int ha_archive::read_meta_file(File meta_file, ha_rows *rows)
DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0])); DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0]));
DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1])); DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1]));
DBUG_PRINT("ha_archive::read_meta_file", ("Rows %lld", *rows)); DBUG_PRINT("ha_archive::read_meta_file", ("Rows %lu", (ulong) *rows));
DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %lld", check_point)); DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %lu", (ulong) check_point));
DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)meta_buffer[18])); DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)meta_buffer[18]));
if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) || if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) ||
@ -359,8 +359,8 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows, bool dirty)
*(meta_buffer + 18)= (uchar)dirty; *(meta_buffer + 18)= (uchar)dirty;
DBUG_PRINT("ha_archive::write_meta_file", ("Check %d", (uint)ARCHIVE_CHECK_HEADER)); DBUG_PRINT("ha_archive::write_meta_file", ("Check %d", (uint)ARCHIVE_CHECK_HEADER));
DBUG_PRINT("ha_archive::write_meta_file", ("Version %d", (uint)ARCHIVE_VERSION)); DBUG_PRINT("ha_archive::write_meta_file", ("Version %d", (uint)ARCHIVE_VERSION));
DBUG_PRINT("ha_archive::write_meta_file", ("Rows %llu", (ulonglong)rows)); DBUG_PRINT("ha_archive::write_meta_file", ("Rows %lu", (ulong)rows));
DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %llu", check_point)); DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %lu", (ulong) check_point));
DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty)); DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty));
VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0))); VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
@ -495,7 +495,7 @@ int ha_archive::init_archive_writer()
} }
share->archive_write_open= TRUE; share->archive_write_open= TRUE;
info(HA_STATUS_TIME); info(HA_STATUS_TIME);
share->approx_file_size= data_file_length; share->approx_file_size= (ulong) data_file_length;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -676,7 +676,7 @@ int ha_archive::real_write_row(byte *buf, gzFile writer)
if (share->approx_file_size > max_zfile_size - total_row_length) if (share->approx_file_size > max_zfile_size - total_row_length)
{ {
info(HA_STATUS_TIME); info(HA_STATUS_TIME);
share->approx_file_size= data_file_length; share->approx_file_size= (ulong) data_file_length;
if (share->approx_file_size > max_zfile_size - total_row_length) if (share->approx_file_size > max_zfile_size - total_row_length)
DBUG_RETURN(HA_ERR_RECORD_FILE_FULL); DBUG_RETURN(HA_ERR_RECORD_FILE_FULL);
} }
@ -783,7 +783,7 @@ int ha_archive::rnd_init(bool scan)
if (scan) if (scan)
{ {
scan_rows= share->rows_recorded; scan_rows= share->rows_recorded;
DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows)); DBUG_PRINT("info", ("archive will retrieve %lu rows", (ulong) scan_rows));
records= 0; records= 0;
/* /*
@ -1019,7 +1019,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
share->rows_recorded++; share->rows_recorded++;
} }
} }
DBUG_PRINT("info", ("recovered %llu archive rows", share->rows_recorded)); DBUG_PRINT("info", ("recovered %lu archive rows",
(ulong) share->rows_recorded));
my_free((char*)buf, MYF(0)); my_free((char*)buf, MYF(0));
if (rc && rc != HA_ERR_END_OF_FILE) if (rc && rc != HA_ERR_END_OF_FILE)

View File

@ -1249,7 +1249,6 @@ bool ha_federated::create_where_from_key(String *to,
if (tmp.append(FEDERATED_CLOSEPAREN)) if (tmp.append(FEDERATED_CLOSEPAREN))
DBUG_RETURN(1); DBUG_RETURN(1);
next_loop:
if (store_length >= length) if (store_length >= length)
break; break;
DBUG_PRINT("info", ("remainder %d", remainder)); DBUG_PRINT("info", ("remainder %d", remainder));
@ -1914,8 +1913,8 @@ int ha_federated::delete_row(const byte *buf)
{ {
DBUG_RETURN(stash_remote_error()); DBUG_RETURN(stash_remote_error());
} }
deleted+= mysql->affected_rows; deleted+= (ha_rows) mysql->affected_rows;
records-= mysql->affected_rows; records-= (ha_rows) mysql->affected_rows;
DBUG_PRINT("info", DBUG_PRINT("info",
("rows deleted %ld rows deleted for all time %ld", ("rows deleted %ld rows deleted for all time %ld",
(long) mysql->affected_rows, (long) deleted)); (long) mysql->affected_rows, (long) deleted));
@ -2270,7 +2269,6 @@ int ha_federated::rnd_next(byte *buf)
int ha_federated::read_next(byte *buf, MYSQL_RES *result) int ha_federated::read_next(byte *buf, MYSQL_RES *result)
{ {
int retval; int retval;
my_ulonglong num_rows;
MYSQL_ROW row; MYSQL_ROW row;
DBUG_ENTER("ha_federated::read_next"); DBUG_ENTER("ha_federated::read_next");

View File

@ -631,7 +631,7 @@ int ha_heap::create(const char *name, TABLE *table_arg,
} }
mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*)); mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*));
max_rows = (ha_rows) (table->in_use->variables.max_heap_table_size / max_rows = (ha_rows) (table->in_use->variables.max_heap_table_size /
mem_per_row); (ulonglong) mem_per_row);
if (table_arg->found_next_number_field) if (table_arg->found_next_number_field)
{ {
keydef[share->next_number_index].flag|= HA_AUTO_KEY; keydef[share->next_number_index].flag|= HA_AUTO_KEY;

View File

@ -2739,7 +2739,6 @@ ha_innobase::store_key_val_for_row(
CHARSET_INFO* cs; CHARSET_INFO* cs;
ulint key_len; ulint key_len;
ulint len;
ulint true_len; ulint true_len;
int error=0; int error=0;
ulint blob_len; ulint blob_len;

View File

@ -822,8 +822,8 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob,
{ {
char *buf= m_blobs_buffer + offset; char *buf= m_blobs_buffer + offset;
uint32 len= 0xffffffff; // Max uint32 uint32 len= 0xffffffff; // Max uint32
DBUG_PRINT("value", ("read blob ptr=%x len=%u", DBUG_PRINT("value", ("read blob ptr: 0x%lx len: %u",
(UintPtr)buf, (uint)blob_len)); (long)buf, (uint)blob_len));
if (ndb_blob->readData(buf, len) != 0) if (ndb_blob->readData(buf, len) != 0)
DBUG_RETURN(-1); DBUG_RETURN(-1);
DBUG_ASSERT(len == blob_len); DBUG_ASSERT(len == blob_len);

View File

@ -474,7 +474,6 @@ int ha_init()
{ {
int error= 0; int error= 0;
handlerton **types; handlerton **types;
show_table_alias_st *table_alias;
total_ha= savepoint_alloc_size= 0; total_ha= savepoint_alloc_size= 0;
if (ha_init_errors()) if (ha_init_errors())
@ -885,8 +884,8 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit)
if ((*types)->state == SHOW_OPTION_YES && (*types)->recover) if ((*types)->state == SHOW_OPTION_YES && (*types)->recover)
{ {
if ((*(commit ? (*types)->commit_by_xid : if ((*(commit ? (*types)->commit_by_xid :
(*types)->rollback_by_xid))(xid)); (*types)->rollback_by_xid))(xid))
res= 0; res= 0;
} }
} }
return res; return res;
@ -1779,7 +1778,7 @@ void handler::print_error(int error, myf errflag)
{ {
/* Key is unknown */ /* Key is unknown */
str.copy("", 0, system_charset_info); str.copy("", 0, system_charset_info);
key_nr= -1; key_nr= (uint) -1;
} }
else else
{ {

View File

@ -276,7 +276,6 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; TIME ltime;
longlong date;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
{ {
my_decimal_set_zero(decimal_value); my_decimal_set_zero(decimal_value);
@ -290,7 +289,6 @@ my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; TIME ltime;
longlong date;
if (get_time(&ltime)) if (get_time(&ltime))
{ {
my_decimal_set_zero(decimal_value); my_decimal_set_zero(decimal_value);
@ -5656,7 +5654,7 @@ void Item_trigger_field::set_required_privilege(bool rw)
} }
bool Item_trigger_field::set_value(THD *thd, sp_rcontext */*ctx*/, Item **it) bool Item_trigger_field::set_value(THD *thd, sp_rcontext * /*ctx*/, Item **it)
{ {
Item *item= sp_prepare_func_item(thd, it); Item *item= sp_prepare_func_item(thd, it);

View File

@ -2333,7 +2333,7 @@ longlong Item_func_locate::val_int()
return 0; return 0;
/* start is now sufficiently valid to pass to charpos function */ /* start is now sufficiently valid to pass to charpos function */
start= a->charpos(start); start= a->charpos((int) start);
if (start + b->length() > a->length()) if (start + b->length() > a->length())
return 0; return 0;
@ -2343,7 +2343,8 @@ longlong Item_func_locate::val_int()
return start + 1; return start + 1;
if (!cmp_collation.collation->coll->instr(cmp_collation.collation, if (!cmp_collation.collation->coll->instr(cmp_collation.collation,
a->ptr()+start, a->length()-start, a->ptr()+start,
(uint) (a->length()-start),
b->ptr(), b->length(), b->ptr(), b->length(),
&match, 1)) &match, 1))
return 0; return 0;
@ -4288,7 +4289,7 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const
bool Item_func_get_user_var::set_value(THD *thd, bool Item_func_get_user_var::set_value(THD *thd,
sp_rcontext */*ctx*/, Item **it) sp_rcontext * /*ctx*/, Item **it)
{ {
Item_func_set_user_var *suv= new Item_func_set_user_var(get_name(), *it); Item_func_set_user_var *suv= new Item_func_set_user_var(get_name(), *it);
/* /*

View File

@ -983,8 +983,8 @@ String *Item_func_insert::val_str(String *str)
length= res->length() + 1; length= res->length() + 1;
/* start and length are now sufficiently valid to pass to charpos function */ /* start and length are now sufficiently valid to pass to charpos function */
start= res->charpos(start); start= res->charpos((int) start);
length= res->charpos(length, start); length= res->charpos((int) length, (uint32) start);
/* Re-testing with corrected params */ /* Re-testing with corrected params */
if (start > res->length() + 1) if (start > res->length() + 1)
@ -992,8 +992,8 @@ String *Item_func_insert::val_str(String *str)
if (length > res->length() - start) if (length > res->length() - start)
length= res->length() - start; length= res->length() - start;
if (res->length() - length + res2->length() > if ((ulonglong) (res->length() - length + res2->length()) >
current_thd->variables.max_allowed_packet) (ulonglong) current_thd->variables.max_allowed_packet)
{ {
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_ALLOWED_PACKET_OVERFLOWED, ER_WARN_ALLOWED_PACKET_OVERFLOWED,
@ -1002,7 +1002,7 @@ String *Item_func_insert::val_str(String *str)
goto null; goto null;
} }
res=copy_if_not_alloced(str,res,res->length()); res=copy_if_not_alloced(str,res,res->length());
res->replace(start,length,*res2); res->replace((uint32) start,(uint32) length,*res2);
return res; return res;
null: null:
null_value=1; null_value=1;
@ -1078,7 +1078,7 @@ String *Item_func_left::val_str(String *str)
return &my_empty_string; return &my_empty_string;
if ((res->length() <= (ulonglong) length) || if ((res->length() <= (ulonglong) length) ||
(res->length() <= (char_pos= res->charpos(length)))) (res->length() <= (char_pos= res->charpos((int) length))))
return res; return res;
tmp_value.set(*res, 0, char_pos); tmp_value.set(*res, 0, char_pos);
@ -1170,17 +1170,17 @@ String *Item_func_substr::val_str(String *str)
return &my_empty_string; return &my_empty_string;
start= ((start < 0) ? res->numchars() + start : start - 1); start= ((start < 0) ? res->numchars() + start : start - 1);
start= res->charpos(start); start= res->charpos((int) start);
if ((start < 0) || ((uint) start + 1 > res->length())) if ((start < 0) || ((uint) start + 1 > res->length()))
return &my_empty_string; return &my_empty_string;
length= res->charpos(length, start); length= res->charpos((int) length, (uint32) start);
tmp_length= res->length() - start; tmp_length= res->length() - start;
length= min(length, tmp_length); length= min(length, tmp_length);
if (!start && res->length() == (ulonglong) length) if (!start && (longlong) res->length() == length)
return res; return res;
tmp_value.set(*res, (ulonglong) start, (ulonglong) length); tmp_value.set(*res, (uint32) start, (uint32) length);
return &tmp_value; return &tmp_value;
} }
@ -2228,7 +2228,7 @@ String *Item_func_repeat::val_str(String *str)
char *to; char *to;
/* must be longlong to avoid truncation */ /* must be longlong to avoid truncation */
longlong tmp_count= args[1]->val_int(); longlong tmp_count= args[1]->val_int();
long count= tmp_count; long count= (long) tmp_count;
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
/* Assumes that the maximum length of a String is < INT_MAX32. */ /* Assumes that the maximum length of a String is < INT_MAX32. */
@ -2330,7 +2330,7 @@ String *Item_func_rpad::val_str(String *str)
if (count <= (res_char_length= res->numchars())) if (count <= (res_char_length= res->numchars()))
{ // String to pad is big enough { // String to pad is big enough
res->length(res->charpos(count)); // Shorten result if longer res->length(res->charpos((int) count)); // Shorten result if longer
return (res); return (res);
} }
pad_char_length= rpad->numchars(); pad_char_length= rpad->numchars();
@ -2347,7 +2347,7 @@ String *Item_func_rpad::val_str(String *str)
if (args[2]->null_value || !pad_char_length) if (args[2]->null_value || !pad_char_length)
goto err; goto err;
res_byte_length= res->length(); /* Must be done before alloc_buffer */ res_byte_length= res->length(); /* Must be done before alloc_buffer */
if (!(res= alloc_buffer(res,str,&tmp_value,byte_count))) if (!(res= alloc_buffer(res,str,&tmp_value, (ulong) byte_count)))
goto err; goto err;
to= (char*) res->ptr()+res_byte_length; to= (char*) res->ptr()+res_byte_length;
@ -2361,7 +2361,7 @@ String *Item_func_rpad::val_str(String *str)
} }
if (count) if (count)
{ {
pad_byte_length= rpad->charpos(count); pad_byte_length= rpad->charpos((int) count);
memcpy(to,ptr_pad,(size_t) pad_byte_length); memcpy(to,ptr_pad,(size_t) pad_byte_length);
to+= pad_byte_length; to+= pad_byte_length;
} }
@ -2433,14 +2433,14 @@ String *Item_func_lpad::val_str(String *str)
if (count <= res_char_length) if (count <= res_char_length)
{ {
res->length(res->charpos(count)); res->length(res->charpos((int) count));
return res; return res;
} }
pad_char_length= pad->numchars(); pad_char_length= pad->numchars();
byte_count= count * collation.collation->mbmaxlen; byte_count= count * collation.collation->mbmaxlen;
if (byte_count > current_thd->variables.max_allowed_packet) if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet)
{ {
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_ALLOWED_PACKET_OVERFLOWED, ER_WARN_ALLOWED_PACKET_OVERFLOWED,
@ -2449,7 +2449,8 @@ String *Item_func_lpad::val_str(String *str)
goto err; goto err;
} }
if (args[2]->null_value || !pad_char_length || str->alloc(byte_count)) if (args[2]->null_value || !pad_char_length ||
str->alloc((uint32) byte_count))
goto err; goto err;
str->length(0); str->length(0);
@ -2461,7 +2462,7 @@ String *Item_func_lpad::val_str(String *str)
count-= pad_char_length; count-= pad_char_length;
} }
if (count > 0) if (count > 0)
str->append(pad->ptr(), pad->charpos(count), collation.collation); str->append(pad->ptr(), pad->charpos((int) count), collation.collation);
str->append(*res); str->append(*res);
null_value= 0; null_value= 0;
@ -2791,7 +2792,7 @@ String *Item_load_file::val_str(String *str)
tmp_value.length(stat_info.st_size); tmp_value.length(stat_info.st_size);
my_close(file, MYF(0)); my_close(file, MYF(0));
null_value = 0; null_value = 0;
return &tmp_value; DBUG_RETURN(&tmp_value);
err: err:
null_value = 1; null_value = 1;
@ -3281,4 +3282,3 @@ String *Item_func_uuid::val_str(String *str)
strmov(s+18, clock_seq_and_node_str); strmov(s+18, clock_seq_and_node_str);
return str; return str;
} }

View File

@ -3413,8 +3413,8 @@ bool Item_func_group_concat::setup(THD *thd)
duplicate values (according to the syntax of this function). If there duplicate values (according to the syntax of this function). If there
is no DISTINCT or ORDER BY clauses, we don't create this tree. is no DISTINCT or ORDER BY clauses, we don't create this tree.
*/ */
init_tree(tree, min(thd->variables.max_heap_table_size, init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
thd->variables.sortbuff_size/16), 0, thd->variables.sortbuff_size/16), 0,
tree_key_length, compare_key, 0, NULL, (void*) this); tree_key_length, compare_key, 0, NULL, (void*) this);
} }

View File

@ -110,7 +110,6 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
String *str) String *str)
{ {
int warning= 0; int warning= 0;
bool rc;
if (make_datetime(format, ltime, str)) if (make_datetime(format, ltime, str))
return 1; return 1;
@ -1645,7 +1644,7 @@ double Item_func_sysdate_local::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
store_now_in_TIME(&ltime); store_now_in_TIME(&ltime);
return (longlong) TIME_to_ulonglong_datetime(&ltime); return (double) TIME_to_ulonglong_datetime(&ltime);
} }

View File

@ -1676,14 +1676,14 @@ bool MYSQL_LOG::write(Log_event *event_info)
} }
trans_log->end_of_file= max_binlog_cache_size; trans_log->end_of_file= max_binlog_cache_size;
trans_register_ha(thd, trans_register_ha(thd,
thd->options & (OPTION_NOT_AUTOCOMMIT | test(thd->options & (OPTION_NOT_AUTOCOMMIT |
OPTION_BEGIN), OPTION_BEGIN)),
&binlog_hton); &binlog_hton);
} }
else if (!my_b_tell(trans_log)) else if (!my_b_tell(trans_log))
trans_register_ha(thd, trans_register_ha(thd,
thd->options & (OPTION_NOT_AUTOCOMMIT | test(thd->options & (OPTION_NOT_AUTOCOMMIT |
OPTION_BEGIN), OPTION_BEGIN)),
&binlog_hton); &binlog_hton);
file= trans_log; file= trans_log;
} }

View File

@ -745,7 +745,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
bool mysql_select(THD *thd, Item ***rref_pointer_array, bool mysql_select(THD *thd, Item ***rref_pointer_array,
TABLE_LIST *tables, uint wild_num, List<Item> &list, TABLE_LIST *tables, uint wild_num, List<Item> &list,
COND *conds, uint og_num, ORDER *order, ORDER *group, COND *conds, uint og_num, ORDER *order, ORDER *group,
Item *having, ORDER *proc_param, ulong select_type, Item *having, ORDER *proc_param, ulonglong select_type,
select_result *result, SELECT_LEX_UNIT *unit, select_result *result, SELECT_LEX_UNIT *unit,
SELECT_LEX *select_lex); SELECT_LEX *select_lex);
void free_underlaid_joins(THD *thd, SELECT_LEX *select); void free_underlaid_joins(THD *thd, SELECT_LEX *select);

View File

@ -70,6 +70,12 @@
#define IF_PURIFY(A,B) (B) #define IF_PURIFY(A,B) (B)
#endif #endif
#if SIZEOF_CHARP == 4
#define MAX_MEM_TABLE_SIZE ~(ulong) 0
#else
#define MAX_MEM_TABLE_SIZE ~(ulonglong) 0
#endif
/* stack traces are only supported on linux intel */ /* stack traces are only supported on linux intel */
#if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK) #if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK)
#define HAVE_STACK_TRACE_ON_SEGV #define HAVE_STACK_TRACE_ON_SEGV
@ -1532,7 +1538,7 @@ static void network_init(void)
if (strlen(mysqld_unix_port) > (sizeof(UNIXaddr.sun_path) - 1)) if (strlen(mysqld_unix_port) > (sizeof(UNIXaddr.sun_path) - 1))
{ {
sql_print_error("The socket file path is too long (> %u): %s", sql_print_error("The socket file path is too long (> %u): %s",
sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); (uint) sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port);
unireg_abort(1); unireg_abort(1);
} }
if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
@ -5718,8 +5724,9 @@ The minimum value for this variable is 4096.",
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
"Don't allow creation of heap tables bigger than this.", "Don't allow creation of heap tables bigger than this.",
(gptr*) &global_system_variables.max_heap_table_size, (gptr*) &global_system_variables.max_heap_table_size,
(gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULONG, (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULL,
REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0}, REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE,
MALLOC_OVERHEAD, 1024, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, {"max_join_size", OPT_MAX_JOIN_SIZE,
"Joins that are probably going to read more than max_join_size records return an error.", "Joins that are probably going to read more than max_join_size records return an error.",
(gptr*) &global_system_variables.max_join_size, (gptr*) &global_system_variables.max_join_size,
@ -5994,8 +6001,8 @@ The minimum value for this variable is 4096.",
{"tmp_table_size", OPT_TMP_TABLE_SIZE, {"tmp_table_size", OPT_TMP_TABLE_SIZE,
"If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.",
(gptr*) &global_system_variables.tmp_table_size, (gptr*) &global_system_variables.tmp_table_size,
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG, (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL,
REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, REQUIRED_ARG, 32*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
"Allocation block size for transactions to be stored in binary log", "Allocation block size for transactions to be stored in binary log",
(gptr*) &global_system_variables.trans_alloc_block_size, (gptr*) &global_system_variables.trans_alloc_block_size,

View File

@ -1924,7 +1924,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
key_parts->null_bit= key_part_info->null_bit; key_parts->null_bit= key_part_info->null_bit;
key_parts->image_type = key_parts->image_type =
(key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW; (key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW;
key_parts->flag= key_part_info->key_part_flag; key_parts->flag= (uint8) key_part_info->key_part_flag;
} }
param.real_keynr[param.keys++]=idx; param.real_keynr[param.keys++]=idx;
} }
@ -6240,7 +6240,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
key_part->length= key_info->key_part[part].length; key_part->length= key_info->key_part[part].length;
key_part->store_length= key_info->key_part[part].store_length; key_part->store_length= key_info->key_part[part].store_length;
key_part->null_bit= key_info->key_part[part].null_bit; key_part->null_bit= key_info->key_part[part].null_bit;
key_part->flag= key_info->key_part[part].key_part_flag; key_part->flag= (uint8) key_info->key_part[part].key_part_flag;
} }
if (insert_dynamic(&quick->ranges,(gptr)&range)) if (insert_dynamic(&quick->ranges,(gptr)&range))
goto err; goto err;

View File

@ -406,7 +406,7 @@ make_scrambled_password(char *to, const char *password)
mysql_sha1_result(&sha1_context, hash_stage2); mysql_sha1_result(&sha1_context, hash_stage2);
/* convert hash_stage2 to hex string */ /* convert hash_stage2 to hex string */
*to++= PVERSION41_CHAR; *to++= PVERSION41_CHAR;
octet2hex(to, hash_stage2, SHA1_HASH_SIZE); octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE);
} }
@ -520,5 +520,5 @@ void get_salt_from_password(uint8 *hash_stage2, const char *password)
void make_password_from_salt(char *to, const uint8 *hash_stage2) void make_password_from_salt(char *to, const uint8 *hash_stage2)
{ {
*to++= PVERSION41_CHAR; *to++= PVERSION41_CHAR;
octet2hex(to, hash_stage2, SHA1_HASH_SIZE); octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE);
} }

View File

@ -247,7 +247,7 @@ sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads",
fix_max_connections); fix_max_connections);
sys_var_thd_ulong sys_max_error_count("max_error_count", sys_var_thd_ulong sys_max_error_count("max_error_count",
&SV::max_error_count); &SV::max_error_count);
sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size", sys_var_thd_ulonglong sys_max_heap_table_size("max_heap_table_size",
&SV::max_heap_table_size); &SV::max_heap_table_size);
sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id", sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id",
&SV::pseudo_thread_id, &SV::pseudo_thread_id,
@ -414,7 +414,7 @@ sys_var_thd_enum sys_tx_isolation("tx_isolation",
&SV::tx_isolation, &SV::tx_isolation,
&tx_isolation_typelib, &tx_isolation_typelib,
fix_tx_isolation); fix_tx_isolation);
sys_var_thd_ulong sys_tmp_table_size("tmp_table_size", sys_var_thd_ulonglong sys_tmp_table_size("tmp_table_size",
&SV::tmp_table_size); &SV::tmp_table_size);
sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", sys_var_bool_ptr sys_timed_mutexes("timed_mutexes",
&timed_mutexes); &timed_mutexes);
@ -2830,7 +2830,7 @@ static bool set_option_autocommit(THD *thd, set_var *var)
{ {
/* The test is negative as the flag we use is NOT autocommit */ /* The test is negative as the flag we use is NOT autocommit */
ulong org_options=thd->options; ulonglong org_options= thd->options;
if (var->save_result.ulong_value != 0) if (var->save_result.ulong_value != 0)
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag; thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;

View File

@ -1513,7 +1513,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
TABLE_LIST tables; TABLE_LIST tables;
int error= 1; int error= 1;
handler *file; handler *file;
ulong save_options; ulonglong save_options;
NET *net= &mysql->net; NET *net= &mysql->net;
DBUG_ENTER("create_table_from_dump"); DBUG_ENTER("create_table_from_dump");

View File

@ -539,17 +539,17 @@ db_create_routine(THD *thd, int type, sp_head *sp)
table->field[MYSQL_PROC_FIELD_NAME]-> table->field[MYSQL_PROC_FIELD_NAME]->
store(sp->m_name.str, sp->m_name.length, system_charset_info); store(sp->m_name.str, sp->m_name.length, system_charset_info);
table->field[MYSQL_PROC_FIELD_TYPE]-> table->field[MYSQL_PROC_FIELD_TYPE]->
store((longlong)type); store((longlong)type, 1);
table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]-> table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]->
store(sp->m_name.str, sp->m_name.length, system_charset_info); store(sp->m_name.str, sp->m_name.length, system_charset_info);
if (sp->m_chistics->daccess != SP_DEFAULT_ACCESS) if (sp->m_chistics->daccess != SP_DEFAULT_ACCESS)
table->field[MYSQL_PROC_FIELD_ACCESS]-> table->field[MYSQL_PROC_FIELD_ACCESS]->
store((longlong)sp->m_chistics->daccess); store((longlong)sp->m_chistics->daccess, 1);
table->field[MYSQL_PROC_FIELD_DETERMINISTIC]-> table->field[MYSQL_PROC_FIELD_DETERMINISTIC]->
store((longlong)(sp->m_chistics->detistic ? 1 : 2)); store((longlong)(sp->m_chistics->detistic ? 1 : 2), 1);
if (sp->m_chistics->suid != SP_IS_DEFAULT_SUID) if (sp->m_chistics->suid != SP_IS_DEFAULT_SUID)
table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->
store((longlong)sp->m_chistics->suid); store((longlong)sp->m_chistics->suid, 1);
table->field[MYSQL_PROC_FIELD_PARAM_LIST]-> table->field[MYSQL_PROC_FIELD_PARAM_LIST]->
store(sp->m_params.str, sp->m_params.length, system_charset_info); store(sp->m_params.str, sp->m_params.length, system_charset_info);
if (sp->m_type == TYPE_ENUM_FUNCTION) if (sp->m_type == TYPE_ENUM_FUNCTION)
@ -566,7 +566,7 @@ db_create_routine(THD *thd, int type, sp_head *sp)
((Field_timestamp *)table->field[MYSQL_PROC_FIELD_CREATED])->set_time(); ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_CREATED])->set_time();
((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time();
table->field[MYSQL_PROC_FIELD_SQL_MODE]-> table->field[MYSQL_PROC_FIELD_SQL_MODE]->
store((longlong)thd->variables.sql_mode); store((longlong)thd->variables.sql_mode, 1);
if (sp->m_chistics->comment.str) if (sp->m_chistics->comment.str)
table->field[MYSQL_PROC_FIELD_COMMENT]-> table->field[MYSQL_PROC_FIELD_COMMENT]->
store(sp->m_chistics->comment.str, sp->m_chistics->comment.length, store(sp->m_chistics->comment.str, sp->m_chistics->comment.length,
@ -672,7 +672,6 @@ db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
{ {
TABLE *table; TABLE *table;
int ret; int ret;
bool opened;
DBUG_ENTER("db_update_routine"); DBUG_ENTER("db_update_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s", DBUG_PRINT("enter", ("type: %d name: %.*s",
type, name->m_name.length, name->m_name.str)); type, name->m_name.length, name->m_name.str));
@ -686,10 +685,10 @@ db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time();
if (chistics->suid != SP_IS_DEFAULT_SUID) if (chistics->suid != SP_IS_DEFAULT_SUID)
table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->
store((longlong)chistics->suid); store((longlong)chistics->suid, 1);
if (chistics->daccess != SP_DEFAULT_ACCESS) if (chistics->daccess != SP_DEFAULT_ACCESS)
table->field[MYSQL_PROC_FIELD_ACCESS]-> table->field[MYSQL_PROC_FIELD_ACCESS]->
store((longlong)chistics->daccess); store((longlong)chistics->daccess, 1);
if (chistics->comment.str) if (chistics->comment.str)
table->field[MYSQL_PROC_FIELD_COMMENT]->store(chistics->comment.str, table->field[MYSQL_PROC_FIELD_COMMENT]->store(chistics->comment.str,
chistics->comment.length, chistics->comment.length,

View File

@ -124,7 +124,6 @@ void sp_cache_clear(sp_cache **cp)
void sp_cache_insert(sp_cache **cp, sp_head *sp) void sp_cache_insert(sp_cache **cp, sp_head *sp)
{ {
sp_cache *c; sp_cache *c;
ulong v;
if (!(c= *cp)) if (!(c= *cp))
{ {

View File

@ -444,9 +444,12 @@ sp_head::operator delete(void *ptr, size_t size)
sp_head::sp_head() sp_head::sp_head()
:Query_arena(&main_mem_root, INITIALIZED_FOR_SP), :Query_arena(&main_mem_root, INITIALIZED_FOR_SP),
m_flags(0), m_recursion_level(0), m_next_cached_sp(0), m_flags(0), m_recursion_level(0), m_next_cached_sp(0),
m_first_instance(this), m_first_free_instance(this), m_last_cached_sp(this),
m_cont_level(0) m_cont_level(0)
{ {
m_first_instance= this;
m_first_free_instance= this;
m_last_cached_sp= this;
m_return_field_def.charset = NULL; m_return_field_def.charset = NULL;
extern byte * extern byte *
@ -1648,7 +1651,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
Item_null *null_item= new Item_null(); Item_null *null_item= new Item_null();
if (!null_item || if (!null_item ||
nctx->set_variable(thd, i, (struct Item **)&null_item)) nctx->set_variable(thd, i, (Item **)&null_item))
{ {
err_status= TRUE; err_status= TRUE;
break; break;
@ -2789,7 +2792,7 @@ void
sp_instr_freturn::print(String *str) sp_instr_freturn::print(String *str)
{ {
/* freturn type expr... */ /* freturn type expr... */
if (str->reserve(UINT_MAX+8+32)) // Add some for the expr. too if (str->reserve(1024+8+32)) // Add some for the expr. too
return; return;
str->qs_append(STRING_WITH_LEN("freturn ")); str->qs_append(STRING_WITH_LEN("freturn "));
str->qs_append((uint)m_type); str->qs_append((uint)m_type);

View File

@ -1898,7 +1898,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
table->field[next_field+2]->store((longlong) mqh.conn_per_hour, TRUE); table->field[next_field+2]->store((longlong) mqh.conn_per_hour, TRUE);
if (table->s->fields >= 36 && if (table->s->fields >= 36 &&
(mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS)) (mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS))
table->field[next_field+3]->store((longlong) mqh.user_conn); table->field[next_field+3]->store((longlong) mqh.user_conn, TRUE);
mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour; mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour;
} }
if (old_row_exists) if (old_row_exists)

View File

@ -686,7 +686,7 @@ void close_temporary_tables(THD *thd)
/* We always quote db,table names though it is slight overkill */ /* We always quote db,table names though it is slight overkill */
if (found_user_tables && if (found_user_tables &&
!(was_quote_show= (thd->options & OPTION_QUOTE_SHOW_CREATE))) !(was_quote_show= test(thd->options & OPTION_QUOTE_SHOW_CREATE)))
{ {
thd->options |= OPTION_QUOTE_SHOW_CREATE; thd->options |= OPTION_QUOTE_SHOW_CREATE;
} }

View File

@ -906,7 +906,7 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
if (thd->db_length) if (thd->db_length)
{ {
memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length); memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database : %s length %u", DBUG_PRINT("qcache", ("database: %s length: %u",
thd->db, thd->db_length)); thd->db, thd->db_length));
} }
else else
@ -1052,7 +1052,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
(pre-space is removed in dispatch_command) (pre-space is removed in dispatch_command)
First '/' looks like comment before command it is not First '/' looks like comment before command it is not
frequently appeared in real lihe, consequently we can frequently appeared in real life, consequently we can
check all such queries, too. check all such queries, too.
*/ */
if ((my_toupper(system_charset_info, sql[i]) != 'S' || if ((my_toupper(system_charset_info, sql[i]) != 'S' ||
@ -1081,7 +1081,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
if (thd->db_length) if (thd->db_length)
{ {
memcpy(sql+query_length+1, thd->db, thd->db_length); memcpy(sql+query_length+1, thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database: '%s' length %u", DBUG_PRINT("qcache", ("database: '%s' length: %u",
thd->db, thd->db_length)); thd->db, thd->db_length));
} }
else else
@ -1234,9 +1234,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
if (engine_data != table->engine_data()) if (engine_data != table->engine_data())
{ {
DBUG_PRINT("qcache", DBUG_PRINT("qcache",
("Handler require invalidation queries of %s.%s %lld-%lld", ("Handler require invalidation queries of %s.%s %lu-%lu",
table_list.db, table_list.alias, table_list.db, table_list.alias,
engine_data, table->engine_data())); (ulong) engine_data, (ulong) table->engine_data()));
invalidate_table((byte *) table->db(), table->key_length()); invalidate_table((byte *) table->db(), table->key_length());
} }
else else
@ -1257,10 +1257,10 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
do do
{ {
DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)", DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %lu)",
result_block->length, result_block->used, result_block->length, result_block->used,
result_block->headers_len()+ (ulong) (result_block->headers_len()+
ALIGN_SIZE(sizeof(Query_cache_result)))); ALIGN_SIZE(sizeof(Query_cache_result)))));
Query_cache_result *result = result_block->result(); Query_cache_result *result = result_block->result();
if (net_real_write(&thd->net, result->data(), if (net_real_write(&thd->net, result->data(),
@ -1342,7 +1342,7 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
for (; tables_used; tables_used= tables_used->next) for (; tables_used; tables_used= tables_used->next)
{ {
invalidate_table((byte*) tables_used->key, tables_used->key_length); invalidate_table((byte*) tables_used->key, tables_used->key_length);
DBUG_PRINT("qcache", (" db %s, table %s", tables_used->key, DBUG_PRINT("qcache", ("db: %s table: %s", tables_used->key,
tables_used->key+ tables_used->key+
strlen(tables_used->key)+1)); strlen(tables_used->key)+1));
} }
@ -2353,7 +2353,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used,
{ {
char key[MAX_DBKEY_LENGTH]; char key[MAX_DBKEY_LENGTH];
uint key_length; uint key_length;
DBUG_PRINT("qcache", ("view %s, db %s", DBUG_PRINT("qcache", ("view: %s db: %s",
tables_used->view_name.str, tables_used->view_name.str,
tables_used->view_db.str)); tables_used->view_db.str));
key_length= (uint) (strmov(strmov(key, tables_used->view_db.str) + 1, key_length= (uint) (strmov(strmov(key, tables_used->view_db.str) + 1,
@ -2474,11 +2474,11 @@ Query_cache::insert_table(uint key_len, char *key,
table_block->table()->engine_data() != engine_data) table_block->table()->engine_data() != engine_data)
{ {
DBUG_PRINT("qcache", DBUG_PRINT("qcache",
("Handler require invalidation queries of %s.%s %lld-%lld", ("Handler require invalidation queries of %s.%s %lu-%lu",
table_block->table()->db(), table_block->table()->db(),
table_block->table()->table(), table_block->table()->table(),
engine_data, (ulong) engine_data,
table_block->table()->engine_data())); (ulong) table_block->table()->engine_data()));
/* /*
as far as we delete all queries with this table, table block will be as far as we delete all queries with this table, table block will be
deleted, too deleted, too
@ -2976,7 +2976,7 @@ static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used,
table_count++; table_count++;
if (tables_used->view) if (tables_used->view)
{ {
DBUG_PRINT("qcache", ("view %s, db %s", DBUG_PRINT("qcache", ("view: %s db: %s",
tables_used->view_name.str, tables_used->view_name.str,
tables_used->view_db.str)); tables_used->view_db.str));
*tables_type|= HA_CACHE_TBL_NONTRANSACT; *tables_type|= HA_CACHE_TBL_NONTRANSACT;
@ -3042,7 +3042,7 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex,
lex->safe_to_cache_query) lex->safe_to_cache_query)
{ {
DBUG_PRINT("qcache", ("options: %lx %lx type: %u", DBUG_PRINT("qcache", ("options: %lx %lx type: %u",
OPTION_TO_QUERY_CACHE, (long) OPTION_TO_QUERY_CACHE,
(long) lex->select_lex.options, (long) lex->select_lex.options,
(int) thd->variables.query_cache_type)); (int) thd->variables.query_cache_type));
@ -3062,7 +3062,7 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex,
DBUG_PRINT("qcache", DBUG_PRINT("qcache",
("not interesting query: %d or not cacheable, options %lx %lx type: %u", ("not interesting query: %d or not cacheable, options %lx %lx type: %u",
(int) lex->sql_command, (int) lex->sql_command,
OPTION_TO_QUERY_CACHE, (long) OPTION_TO_QUERY_CACHE,
(long) lex->select_lex.options, (long) lex->select_lex.options,
(int) thd->variables.query_cache_type)); (int) thd->variables.query_cache_type));
DBUG_RETURN(0); DBUG_RETURN(0);
@ -3772,8 +3772,8 @@ my_bool Query_cache::check_integrity(bool locked)
(((long)first_block) % (long)ALIGN_SIZE(1))) (((long)first_block) % (long)ALIGN_SIZE(1)))
{ {
DBUG_PRINT("error", DBUG_PRINT("error",
("block 0x%lx do not aligned by %d", (ulong) block, ("block 0x%lx do not aligned by %d", (long) block,
ALIGN_SIZE(1))); (int) ALIGN_SIZE(1)));
result = 1; result = 1;
} }
// Check memory allocation // Check memory allocation

View File

@ -495,6 +495,8 @@ struct system_variables
{ {
ulonglong myisam_max_extra_sort_file_size; ulonglong myisam_max_extra_sort_file_size;
ulonglong myisam_max_sort_file_size; ulonglong myisam_max_sort_file_size;
ulonglong max_heap_table_size;
ulonglong tmp_table_size;
ha_rows select_limit; ha_rows select_limit;
ha_rows max_join_size; ha_rows max_join_size;
ulong auto_increment_increment, auto_increment_offset; ulong auto_increment_increment, auto_increment_offset;
@ -503,7 +505,6 @@ struct system_variables
ulong long_query_time; ulong long_query_time;
ulong max_allowed_packet; ulong max_allowed_packet;
ulong max_error_count; ulong max_error_count;
ulong max_heap_table_size;
ulong max_length_for_sort_data; ulong max_length_for_sort_data;
ulong max_sort_length; ulong max_sort_length;
ulong max_tmp_tables; ulong max_tmp_tables;
@ -527,7 +528,6 @@ struct system_variables
ulong div_precincrement; ulong div_precincrement;
ulong sortbuff_size; ulong sortbuff_size;
ulong table_type; ulong table_type;
ulong tmp_table_size;
ulong tx_isolation; ulong tx_isolation;
ulong completion_type; ulong completion_type;
/* Determines which non-standard SQL behaviour should be enabled */ /* Determines which non-standard SQL behaviour should be enabled */
@ -2074,7 +2074,8 @@ class user_var_entry
class Unique :public Sql_alloc class Unique :public Sql_alloc
{ {
DYNAMIC_ARRAY file_ptrs; DYNAMIC_ARRAY file_ptrs;
ulong max_elements, max_in_memory_size; ulong max_elements;
ulonglong max_in_memory_size;
IO_CACHE file; IO_CACHE file;
TREE tree; TREE tree;
byte *record_pointers; byte *record_pointers;
@ -2084,7 +2085,7 @@ class Unique :public Sql_alloc
public: public:
ulong elements; ulong elements;
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg, Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
uint size_arg, ulong max_in_memory_size_arg); uint size_arg, ulonglong max_in_memory_size_arg);
~Unique(); ~Unique();
ulong elements_in_tree() { return tree.elements_in_tree; } ulong elements_in_tree() { return tree.elements_in_tree; }
inline bool unique_add(void *ptr) inline bool unique_add(void *ptr)
@ -2098,13 +2099,13 @@ public:
bool get(TABLE *table); bool get(TABLE *table);
static double get_use_cost(uint *buffer, uint nkeys, uint key_size, static double get_use_cost(uint *buffer, uint nkeys, uint key_size,
ulong max_in_memory_size); ulonglong max_in_memory_size);
inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size,
ulong max_in_memory_size) ulonglong max_in_memory_size)
{ {
register ulong max_elems_in_tree= register ulonglong max_elems_in_tree=
(1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size)); (1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
return sizeof(uint)*(1 + nkeys/max_elems_in_tree); return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
} }
void reset(); void reset();

View File

@ -1172,7 +1172,7 @@ err:
bool mysql_change_db(THD *thd, const char *name, bool no_access_check) bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
{ {
int path_length, db_length; int db_length;
char *db_name; char *db_name;
bool system_db= 0; bool system_db= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS

View File

@ -902,7 +902,7 @@ end:
trunc_by_del: trunc_by_del:
/* Probably InnoDB table */ /* Probably InnoDB table */
ulong save_options= thd->options; ulonglong save_options= thd->options;
table_list->lock_type= TL_WRITE; table_list->lock_type= TL_WRITE;
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
ha_enable_transaction(thd, FALSE); ha_enable_transaction(thd, FALSE);

View File

@ -338,7 +338,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
ha_rows select_limit_cnt, ha_rows offset_limit_cnt) ha_rows select_limit_cnt, ha_rows offset_limit_cnt)
{ {
TABLE_LIST *hash_tables; TABLE_LIST *hash_tables;
TABLE **table_ptr;
TABLE *table; TABLE *table;
MYSQL_LOCK *lock; MYSQL_LOCK *lock;
List<Item> list; List<Item> list;

View File

@ -397,7 +397,7 @@ protected:
TABLE *table; /* temporary table using for appending UNION results */ TABLE *table; /* temporary table using for appending UNION results */
select_result *result; select_result *result;
ulong found_rows_for_union; ulonglong found_rows_for_union;
bool res; bool res;
public: public:
bool prepared, // prepare phase already performed for UNION (unit) bool prepared, // prepare phase already performed for UNION (unit)

View File

@ -2879,7 +2879,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
{ {
Statement stmt_backup; Statement stmt_backup;
Query_arena *old_stmt_arena; Query_arena *old_stmt_arena;
Item *old_free_list;
bool error= TRUE; bool error= TRUE;
statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status); statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status);

View File

@ -257,7 +257,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
static TABLE_LIST * static TABLE_LIST *
rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
{ {
TABLE_LIST *ren_table,*new_table, *tmp_table; TABLE_LIST *ren_table, *new_table;
DBUG_ENTER("rename_tables"); DBUG_ENTER("rename_tables");

View File

@ -82,7 +82,7 @@ static store_key *get_store_key(THD *thd,
static bool make_simple_join(JOIN *join,TABLE *tmp_table); static bool make_simple_join(JOIN *join,TABLE *tmp_table);
static void make_outerjoin_info(JOIN *join); static void make_outerjoin_info(JOIN *join);
static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item); static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item);
static void make_join_readinfo(JOIN *join,uint options); static void make_join_readinfo(JOIN *join, ulonglong options);
static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables); static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables);
static void update_depend_map(JOIN *join); static void update_depend_map(JOIN *join);
static void update_depend_map(JOIN *join, ORDER *order); static void update_depend_map(JOIN *join, ORDER *order);
@ -90,7 +90,7 @@ static ORDER *remove_const(JOIN *join,ORDER *first_order,COND *cond,
bool change_list, bool *simple_order); bool change_list, bool *simple_order);
static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables, static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables,
List<Item> &fields, bool send_row, List<Item> &fields, bool send_row,
uint select_options, const char *info, ulonglong select_options, const char *info,
Item *having); Item *having);
static COND *build_equal_items(THD *thd, COND *cond, static COND *build_equal_items(THD *thd, COND *cond,
COND_EQUAL *inherited, COND_EQUAL *inherited,
@ -114,7 +114,7 @@ static bool resolve_nested_join (TABLE_LIST *table);
static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
static bool open_tmp_table(TABLE *table); static bool open_tmp_table(TABLE *table);
static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
ulong options); ulonglong options);
static int do_select(JOIN *join,List<Item> *fields,TABLE *tmp_table, static int do_select(JOIN *join,List<Item> *fields,TABLE *tmp_table,
Procedure *proc); Procedure *proc);
@ -1974,7 +1974,7 @@ bool
mysql_select(THD *thd, Item ***rref_pointer_array, mysql_select(THD *thd, Item ***rref_pointer_array,
TABLE_LIST *tables, uint wild_num, List<Item> &fields, TABLE_LIST *tables, uint wild_num, List<Item> &fields,
COND *conds, uint og_num, ORDER *order, ORDER *group, COND *conds, uint og_num, ORDER *order, ORDER *group,
Item *having, ORDER *proc_param, ulong select_options, Item *having, ORDER *proc_param, ulonglong select_options,
select_result *result, SELECT_LEX_UNIT *unit, select_result *result, SELECT_LEX_UNIT *unit,
SELECT_LEX *select_lex) SELECT_LEX *select_lex)
{ {
@ -4123,7 +4123,7 @@ choose_plan(JOIN *join, table_map join_tables)
{ {
uint search_depth= join->thd->variables.optimizer_search_depth; uint search_depth= join->thd->variables.optimizer_search_depth;
uint prune_level= join->thd->variables.optimizer_prune_level; uint prune_level= join->thd->variables.optimizer_prune_level;
bool straight_join= join->select_options & SELECT_STRAIGHT_JOIN; bool straight_join= test(join->select_options & SELECT_STRAIGHT_JOIN);
DBUG_ENTER("choose_plan"); DBUG_ENTER("choose_plan");
join->cur_embedding_map= 0; join->cur_embedding_map= 0;
@ -4725,8 +4725,6 @@ static void
find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
double read_time) double read_time)
{ {
ha_rows rec;
double tmp;
THD *thd= join->thd; THD *thd= join->thd;
if (!rest_tables) if (!rest_tables)
{ {
@ -5780,7 +5778,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
} }
static void static void
make_join_readinfo(JOIN *join, uint options) make_join_readinfo(JOIN *join, ulonglong options)
{ {
uint i; uint i;
@ -6435,7 +6433,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
static int static int
return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables, return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
List<Item> &fields, bool send_row, uint select_options, List<Item> &fields, bool send_row, ulonglong select_options,
const char *info, Item *having) const char *info, Item *having)
{ {
DBUG_ENTER("return_zero_rows"); DBUG_ENTER("return_zero_rows");
@ -6986,7 +6984,6 @@ static COND *build_equal_items_for_cond(COND *cond,
Item_equal *item_equal; Item_equal *item_equal;
uint members; uint members;
COND_EQUAL cond_equal; COND_EQUAL cond_equal;
COND *new_cond;
cond_equal.upper_levels= inherited; cond_equal.upper_levels= inherited;
if (cond->type() == Item::COND_ITEM) if (cond->type() == Item::COND_ITEM)
@ -9320,13 +9317,14 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
param->recinfo=recinfo; param->recinfo=recinfo;
store_record(table,s->default_values); // Make empty default record store_record(table,s->default_values); // Make empty default record
if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit if (thd->variables.tmp_table_size == ~ (ulonglong) 0) // No limit
table->s->max_rows= ~(ha_rows) 0; table->s->max_rows= ~(ha_rows) 0;
else else
table->s->max_rows= (((table->s->db_type == DB_TYPE_HEAP) ? table->s->max_rows= (ha_rows) (((table->s->db_type == DB_TYPE_HEAP) ?
min(thd->variables.tmp_table_size, min(thd->variables.tmp_table_size,
thd->variables.max_heap_table_size) : thd->variables.max_heap_table_size) :
thd->variables.tmp_table_size)/ table->s->reclength); thd->variables.tmp_table_size)/
table->s->reclength);
set_if_bigger(table->s->max_rows,1); // For dummy start options set_if_bigger(table->s->max_rows,1); // For dummy start options
/* /*
Push the LIMIT clause to the temporary table creation, so that we Push the LIMIT clause to the temporary table creation, so that we
@ -9628,7 +9626,7 @@ static bool open_tmp_table(TABLE *table)
static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
ulong options) ulonglong options)
{ {
int error; int error;
MI_KEYDEF keydef; MI_KEYDEF keydef;

View File

@ -464,7 +464,6 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
HA_CREATE_INFO *create_info) HA_CREATE_INFO *create_info)
{ {
Security_context *sctx= thd->security_ctx; Security_context *sctx= thd->security_ctx;
int length;
char buff[2048]; char buff[2048];
String buffer(buff, sizeof(buff), system_charset_info); String buffer(buff, sizeof(buff), system_charset_info);
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -2367,7 +2366,6 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
INDEX_FIELD_VALUES idx_field_vals; INDEX_FIELD_VALUES idx_field_vals;
List<char> files; List<char> files;
char *file_name; char *file_name;
uint length;
bool with_i_schema; bool with_i_schema;
HA_CREATE_INFO create; HA_CREATE_INFO create;
TABLE *table= tables->table; TABLE *table= tables->table;
@ -2939,7 +2937,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
restore_record(table, s->default_values); restore_record(table, s->default_values);
if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0)) if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0))
{ {
int enum_idx= proc_table->field[5]->val_int(); int enum_idx= (int) proc_table->field[5]->val_int();
table->field[3]->store(sp_name.ptr(), sp_name.length(), cs); table->field[3]->store(sp_name.ptr(), sp_name.length(), cs);
get_field(thd->mem_root, proc_table->field[3], &tmp_string); get_field(thd->mem_root, proc_table->field[3], &tmp_string);
table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs);
@ -3105,7 +3103,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
show_table->field[key_part->fieldnr-1]->key_length())) show_table->field[key_part->fieldnr-1]->key_length()))
{ {
table->field[10]->store((longlong) key_part->length / table->field[10]->store((longlong) key_part->length /
key_part->field->charset()->mbmaxlen); key_part->field->charset()->mbmaxlen, 1);
table->field[10]->set_notnull(); table->field[10]->set_notnull();
} }
uint flags= key_part->field ? key_part->field->flags : 0; uint flags= key_part->field ? key_part->field->flags : 0;

View File

@ -356,7 +356,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
char dir_buff[FN_REFLEN], file_buff[FN_REFLEN], trigname_buff[FN_REFLEN], char dir_buff[FN_REFLEN], file_buff[FN_REFLEN], trigname_buff[FN_REFLEN],
trigname_path[FN_REFLEN]; trigname_path[FN_REFLEN];
LEX_STRING dir, file, trigname_file; LEX_STRING dir, file, trigname_file;
LEX_STRING *trg_def, *name; LEX_STRING *trg_def;
LEX_STRING definer_user; LEX_STRING definer_user;
LEX_STRING definer_host; LEX_STRING definer_host;
ulonglong *trg_sql_mode; ulonglong *trg_sql_mode;
@ -879,7 +879,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
DBUG_RETURN(1); DBUG_RETURN(1);
List_iterator_fast<LEX_STRING> it(triggers->definitions_list); List_iterator_fast<LEX_STRING> it(triggers->definitions_list);
LEX_STRING *trg_create_str, *trg_name_str; LEX_STRING *trg_create_str;
ulonglong *trg_sql_mode; ulonglong *trg_sql_mode;
if (triggers->definition_modes_list.is_empty() && if (triggers->definition_modes_list.is_empty() &&
@ -996,7 +996,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
goto err_with_lex_cleanup; goto err_with_lex_cleanup;
} }
lex.sphead->set_info(0, 0, &lex.sp_chistics, *trg_sql_mode); lex.sphead->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
triggers->bodies[lex.trg_chistics.event] triggers->bodies[lex.trg_chistics.event]
[lex.trg_chistics.action_time]= lex.sphead; [lex.trg_chistics.action_time]= lex.sphead;
@ -1337,7 +1337,6 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd,
{ {
char path_buff[FN_REFLEN]; char path_buff[FN_REFLEN];
LEX_STRING *def, *on_table_name, new_def; LEX_STRING *def, *on_table_name, new_def;
ulonglong *sql_mode;
ulong save_sql_mode= thd->variables.sql_mode; ulong save_sql_mode= thd->variables.sql_mode;
List_iterator_fast<LEX_STRING> it_def(definitions_list); List_iterator_fast<LEX_STRING> it_def(definitions_list);
List_iterator_fast<LEX_STRING> it_on_table_name(on_table_names_list); List_iterator_fast<LEX_STRING> it_on_table_name(on_table_names_list);
@ -1351,7 +1350,7 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd,
while ((def= it_def++)) while ((def= it_def++))
{ {
on_table_name= it_on_table_name++; on_table_name= it_on_table_name++;
thd->variables.sql_mode= *(it_mode++); thd->variables.sql_mode= (ulong) *(it_mode++);
/* Construct CREATE TRIGGER statement with new table name. */ /* Construct CREATE TRIGGER statement with new table name. */
buff.length(0); buff.length(0);

View File

@ -118,7 +118,7 @@ int mysql_update(THD *thd,
enum enum_duplicates handle_duplicates, bool ignore) enum enum_duplicates handle_duplicates, bool ignore)
{ {
bool using_limit= limit != HA_POS_ERROR; bool using_limit= limit != HA_POS_ERROR;
bool safe_update= thd->options & OPTION_SAFE_UPDATES; bool safe_update= test(thd->options & OPTION_SAFE_UPDATES);
bool used_key_is_modified, transactional_table; bool used_key_is_modified, transactional_table;
bool can_compare_record; bool can_compare_record;
int res; int res;

View File

@ -197,7 +197,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view)
lex->definer= &view->definer; lex->definer= &view->definer;
} }
if (lex->create_view_algorithm == VIEW_ALGORITHM_UNDEFINED) if (lex->create_view_algorithm == VIEW_ALGORITHM_UNDEFINED)
lex->create_view_algorithm= decoy.algorithm; lex->create_view_algorithm= (uint8) decoy.algorithm;
if (lex->create_view_suid == VIEW_SUID_DEFAULT) if (lex->create_view_suid == VIEW_SUID_DEFAULT)
lex->create_view_suid= decoy.view_suid ? lex->create_view_suid= decoy.view_suid ?
VIEW_SUID_DEFINER : VIEW_SUID_INVOKER; VIEW_SUID_DEFINER : VIEW_SUID_INVOKER;
@ -1477,7 +1477,6 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
TABLE *table; TABLE *table;
Field_translator *trans, *end_of_trans; Field_translator *trans, *end_of_trans;
KEY *key_info, *key_info_end; KEY *key_info, *key_info_end;
uint i;
DBUG_ENTER("check_key_in_view"); DBUG_ENTER("check_key_in_view");
/* /*

View File

@ -1626,7 +1626,6 @@ sp_decl:
uint num_vars= pctx->context_var_count(); uint num_vars= pctx->context_var_count();
enum enum_field_types var_type= (enum enum_field_types) $4; enum enum_field_types var_type= (enum enum_field_types) $4;
Item *dflt_value_item= $5; Item *dflt_value_item= $5;
create_field *create_field_op;
if (!dflt_value_item) if (!dflt_value_item)
{ {

View File

@ -730,6 +730,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
if (key_part->fieldnr) if (key_part->fieldnr)
{ // Should always be true ! { // Should always be true !
Field *field=key_part->field=outparam->field[key_part->fieldnr-1]; Field *field=key_part->field=outparam->field[key_part->fieldnr-1];
key_part->type= field->key_type();
if (field->null_ptr) if (field->null_ptr)
{ {
key_part->null_offset=(uint) ((byte*) field->null_ptr - key_part->null_offset=(uint) ((byte*) field->null_ptr -

View File

@ -1729,9 +1729,9 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
tz_leapcnt++; tz_leapcnt++;
DBUG_PRINT("info", DBUG_PRINT("info",
("time_zone_leap_second table: tz_leapcnt=%u tt_time=%lld offset=%ld", ("time_zone_leap_second table: tz_leapcnt: %u tt_time: %lu offset=%ld",
tz_leapcnt, (longlong)tz_lsis[tz_leapcnt-1].ls_trans, tz_leapcnt, (ulong) tz_lsis[tz_leapcnt-1].ls_trans,
tz_lsis[tz_leapcnt-1].ls_corr)); tz_lsis[tz_leapcnt-1].ls_corr));
res= table->file->index_next(table->record[0]); res= table->file->index_next(table->record[0]);
} }
@ -2041,8 +2041,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
tz_info->timecnt++; tz_info->timecnt++;
DBUG_PRINT("info", DBUG_PRINT("info",
("time_zone_transition table: tz_id=%u tt_time=%lld tt_id=%u", ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u",
tzid, (longlong)ttime, ttid)); tzid, (ulong) ttime, ttid));
res= table->file->index_next_same(table->record[0], res= table->file->index_next_same(table->record[0],
(byte*)table->field[0]->ptr, 4); (byte*)table->field[0]->ptr, 4);

View File

@ -55,18 +55,19 @@ int unique_write_to_ptrs(gptr key, element_count count, Unique *unique)
} }
Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
uint size_arg, ulong max_in_memory_size_arg) uint size_arg, ulonglong max_in_memory_size_arg)
:max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0) :max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0)
{ {
my_b_clear(&file); my_b_clear(&file);
init_tree(&tree, max_in_memory_size / 16, 0, size, comp_func, 0, NULL, init_tree(&tree, (ulong) (max_in_memory_size / 16), 0, size, comp_func, 0,
comp_func_fixed_arg); NULL, comp_func_fixed_arg);
/* If the following fail's the next add will also fail */ /* If the following fail's the next add will also fail */
my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16); my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16);
/* /*
If you change the following, change it in get_max_elements function, too. If you change the following, change it in get_max_elements function, too.
*/ */
max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size); max_elements= (ulong) (max_in_memory_size /
ALIGN_SIZE(sizeof(TREE_ELEMENT)+size));
VOID(open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, VOID(open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
MYF(MY_WME))); MYF(MY_WME)));
} }
@ -260,15 +261,15 @@ static double get_merge_many_buffs_cost(uint *buffer,
*/ */
double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size, double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size,
ulong max_in_memory_size) ulonglong max_in_memory_size)
{ {
ulong max_elements_in_tree; ulong max_elements_in_tree;
ulong last_tree_elems; ulong last_tree_elems;
int n_full_trees; /* number of trees in unique - 1 */ int n_full_trees; /* number of trees in unique - 1 */
double result; double result;
max_elements_in_tree= max_elements_in_tree= ((ulong) max_in_memory_size /
max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size); ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
n_full_trees= nkeys / max_elements_in_tree; n_full_trees= nkeys / max_elements_in_tree;
last_tree_elems= nkeys % max_elements_in_tree; last_tree_elems= nkeys % max_elements_in_tree;
@ -386,9 +387,11 @@ C_MODE_END
/* /*
DESCRIPTION DESCRIPTION
Function is very similar to merge_buffers, but instead of writing sorted Function is very similar to merge_buffers, but instead of writing sorted
unique keys to the output file, it invokes walk_action for each key. unique keys to the output file, it invokes walk_action for each key.
This saves I/O if you need to pass through all unique keys only once. This saves I/O if you need to pass through all unique keys only once.
SYNOPSIS SYNOPSIS
merge_walk() merge_walk()
All params are 'IN' (but see comment for begin, end): All params are 'IN' (but see comment for begin, end):
@ -416,7 +419,7 @@ C_MODE_END
<> 0 error <> 0 error
*/ */
static bool merge_walk(uchar *merge_buffer, uint merge_buffer_size, static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size,
uint key_length, BUFFPEK *begin, BUFFPEK *end, uint key_length, BUFFPEK *begin, BUFFPEK *end,
tree_walk_action walk_action, void *walk_action_arg, tree_walk_action walk_action, void *walk_action_arg,
qsort_cmp2 compare, void *compare_arg, qsort_cmp2 compare, void *compare_arg,
@ -425,14 +428,15 @@ static bool merge_walk(uchar *merge_buffer, uint merge_buffer_size,
BUFFPEK_COMPARE_CONTEXT compare_context = { compare, compare_arg }; BUFFPEK_COMPARE_CONTEXT compare_context = { compare, compare_arg };
QUEUE queue; QUEUE queue;
if (end <= begin || if (end <= begin ||
merge_buffer_size < key_length * (end - begin + 1) || merge_buffer_size < (ulong) (key_length * (end - begin + 1)) ||
init_queue(&queue, end - begin, offsetof(BUFFPEK, key), 0, init_queue(&queue, (uint) (end - begin), offsetof(BUFFPEK, key), 0,
buffpek_compare, &compare_context)) buffpek_compare, &compare_context))
return 1; return 1;
/* we need space for one key when a piece of merge buffer is re-read */ /* we need space for one key when a piece of merge buffer is re-read */
merge_buffer_size-= key_length; merge_buffer_size-= key_length;
uchar *save_key_buff= merge_buffer + merge_buffer_size; uchar *save_key_buff= merge_buffer + merge_buffer_size;
uint max_key_count_per_piece= merge_buffer_size/(end-begin)/key_length; uint max_key_count_per_piece= (uint) (merge_buffer_size/(end-begin) /
key_length);
/* if piece_size is aligned reuse_freed_buffer will always hit */ /* if piece_size is aligned reuse_freed_buffer will always hit */
uint piece_size= max_key_count_per_piece * key_length; uint piece_size= max_key_count_per_piece * key_length;
uint bytes_read; /* to hold return value of read_to_buffer */ uint bytes_read; /* to hold return value of read_to_buffer */
@ -548,6 +552,9 @@ end:
bool Unique::walk(tree_walk_action action, void *walk_action_arg) bool Unique::walk(tree_walk_action action, void *walk_action_arg)
{ {
int res;
uchar *merge_buffer;
if (elements == 0) /* the whole tree is in memory */ if (elements == 0) /* the whole tree is in memory */
return tree_walk(&tree, action, walk_action_arg, left_root_right); return tree_walk(&tree, action, walk_action_arg, left_root_right);
@ -556,15 +563,14 @@ bool Unique::walk(tree_walk_action action, void *walk_action_arg)
return 1; return 1;
if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0)) if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0))
return 1; return 1;
uchar *merge_buffer= (uchar *) my_malloc(max_in_memory_size, MYF(0)); if (!(merge_buffer= (uchar *) my_malloc((ulong) max_in_memory_size, MYF(0))))
if (merge_buffer == 0)
return 1; return 1;
int res= merge_walk(merge_buffer, max_in_memory_size, size, res= merge_walk(merge_buffer, (ulong) max_in_memory_size, size,
(BUFFPEK *) file_ptrs.buffer, (BUFFPEK *) file_ptrs.buffer,
(BUFFPEK *) file_ptrs.buffer + file_ptrs.elements, (BUFFPEK *) file_ptrs.buffer + file_ptrs.elements,
action, walk_action_arg, action, walk_action_arg,
tree.compare, tree.custom_arg, &file); tree.compare, tree.custom_arg, &file);
x_free(merge_buffer); my_free((char*) merge_buffer, MYF(0));
return res; return res;
} }
@ -615,7 +621,7 @@ bool Unique::get(TABLE *table)
sort_param.sort_form=table; sort_param.sort_form=table;
sort_param.rec_length= sort_param.sort_length= sort_param.ref_length= sort_param.rec_length= sort_param.sort_length= sort_param.ref_length=
size; size;
sort_param.keys= max_in_memory_size / sort_param.sort_length; sort_param.keys= (uint) (max_in_memory_size / sort_param.sort_length);
sort_param.not_killable=1; sort_param.not_killable=1;
if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) * if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) *

View File

@ -1503,7 +1503,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
else else
{ {
*error= 0; *error= 0;
return (ulonglong) (longlong) (long) -ul; return (ulonglong) (longlong) -(long) ul;
} }
} }
else else
@ -1654,7 +1654,7 @@ ret_sign:
return (ulonglong) LONGLONG_MIN; return (ulonglong) LONGLONG_MIN;
} }
*error= 0; *error= 0;
return (ulonglong) -ull; return (ulonglong) -(longlong) ull;
} }
else else
{ {