Skip to content

Commit 717284b

Browse files
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1
2 parents 2e8d2e3 + 0bee93e commit 717284b

15 files changed

Lines changed: 98 additions & 38 deletions

File tree

.bzrignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ bdb/dist/autom4te.cache/requests
212212
bdb/dist/autom4te.cache/traces.0
213213
bdb/dist/config.hin
214214
bdb/dist/configure
215+
bdb/dist/db.h
216+
bdb/dist/db_config.h
217+
bdb/dist/db_cxx.h
218+
bdb/dist/db_int.h
219+
bdb/dist/include.tcl
215220
bdb/dist/tags
216221
bdb/dist/template/db_server_proc
217222
bdb/dist/template/gen_client_ret

include/heap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ typedef struct st_heapinfo /* Struct from heap_info */
4646
ulong records; /* Records in database */
4747
ulong deleted; /* Deleted records in database */
4848
ulong max_records;
49-
ulong data_length;
50-
ulong index_length;
49+
ulonglong data_length;
50+
ulonglong index_length;
5151
uint reclength; /* Length of one record */
5252
int errkey;
5353
ulonglong auto_increment;
@@ -135,7 +135,7 @@ typedef struct st_heap_share
135135
HP_BLOCK block;
136136
HP_KEYDEF *keydef;
137137
ulong min_records,max_records; /* Params to open */
138-
ulong data_length,index_length,max_table_size;
138+
ulonglong data_length,index_length,max_table_size;
139139
uint key_stat_version; /* version to indicate insert/delete */
140140
uint records; /* records */
141141
uint blength; /* records rounded up to 2^n */
@@ -187,7 +187,7 @@ typedef struct st_heap_create_info
187187
{
188188
uint auto_key; /* keynr [1 - maxkey] for auto key */
189189
uint auto_key_type;
190-
ulong max_table_size;
190+
ulonglong max_table_size;
191191
ulonglong auto_increment;
192192
my_bool with_auto_increment;
193193
} HP_CREATE_INFO;

include/my_pthread.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,13 @@ struct st_my_thread_var
599599
};
600600

601601
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
602+
extern uint my_thread_end_wait_time;
602603
#define my_thread_var (_my_thread_var())
603604
#define my_errno my_thread_var->thr_errno
604605
/*
605606
Keep track of shutdown,signal, and main threads so that my_end() will not
606607
report errors with them
607608
*/
608-
extern pthread_t shutdown_th, main_th, signal_th;
609-
610609
/* statistics_xxx functions are for not essential statistic */
611610

612611
#ifndef thread_safe_increment

mysql-test/r/show_check.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ SET sql_quote_show_create= @old_sql_quote_show_create;
334334
SET sql_mode= @old_sql_mode;
335335
select @@max_heap_table_size;
336336
@@max_heap_table_size
337-
1047552
337+
1048576
338338
CREATE TABLE t1 (
339339
a int(11) default NULL,
340340
KEY a USING BTREE (a)

mysql-test/r/type_bit.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,12 @@ select hex(a), b from t1;
610610
hex(a) b
611611
1 2
612612
drop table t1;
613+
create table t1(bit_field bit(2), int_field int, key a(bit_field));
614+
insert into t1 values (1,2);
615+
handler t1 open as t1;
616+
handler t1 read a=(1);
617+
bit_field int_field
618+
2
619+
handler t1 close;
620+
drop table t1;
613621
End of 5.0 tests

mysql-test/t/type_bit.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,15 @@ insert into t1 (b, a) values ('2', '1');
261261
select hex(a), b from t1;
262262
drop table t1;
263263

264+
#
265+
# type was not properly initalized, which caused key_copy to fail
266+
#
267+
268+
create table t1(bit_field bit(2), int_field int, key a(bit_field));
269+
insert into t1 values (1,2);
270+
handler t1 open as t1;
271+
handler t1 read a=(1);
272+
handler t1 close;
273+
drop table t1;
274+
264275
--echo End of 5.0 tests

mysys/my_thr_init.c

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys);
3030
#endif /* USE_TLS */
3131
pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,
3232
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap,
33-
THR_LOCK_net, THR_LOCK_charset;
33+
THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads;
34+
pthread_cond_t THR_COND_threads;
35+
uint THR_thread_count= 0;
36+
uint my_thread_end_wait_time= 5;
3437
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
3538
pthread_mutex_t LOCK_localtime_r;
3639
#endif
@@ -79,7 +82,7 @@ my_bool my_thread_global_init(void)
7982
#endif
8083
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
8184
/*
82-
Set mutex type to "errorcheck" a.k.a "adaptive"
85+
Set mutex type to "errorcheck"
8386
*/
8487
pthread_mutexattr_init(&my_errorcheck_mutexattr);
8588
pthread_mutexattr_settype(&my_errorcheck_mutexattr,
@@ -94,7 +97,7 @@ my_bool my_thread_global_init(void)
9497
pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
9598
pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
9699
pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
97-
#if defined( __WIN__)
100+
#if defined( __WIN__) || defined(OS2)
98101
win_pthread_init();
99102
#endif
100103
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
@@ -114,6 +117,25 @@ my_bool my_thread_global_init(void)
114117

115118
void my_thread_global_end(void)
116119
{
120+
struct timespec abstime;
121+
set_timespec(abstime, my_thread_end_wait_time);
122+
my_bool all_threads_killed= 1;
123+
124+
pthread_mutex_lock(&THR_LOCK_threads);
125+
while (THR_thread_count)
126+
{
127+
int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads,
128+
&abstime);
129+
if (error == ETIMEDOUT || error == ETIME)
130+
{
131+
if (THR_thread_count)
132+
fprintf(stderr,"error in my_thread_global_end(): %d threads didn't exit\n",
133+
THR_thread_count);
134+
all_threads_killed= 0;
135+
}
136+
}
137+
pthread_mutex_unlock(&THR_LOCK_threads);
138+
117139
pthread_key_delete(THR_KEY_mysys);
118140
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
119141
pthread_mutexattr_destroy(&my_fast_mutexattr);
@@ -129,6 +151,11 @@ void my_thread_global_end(void)
129151
pthread_mutex_destroy(&THR_LOCK_heap);
130152
pthread_mutex_destroy(&THR_LOCK_net);
131153
pthread_mutex_destroy(&THR_LOCK_charset);
154+
if (all_threads_killed)
155+
{
156+
pthread_mutex_destroy(&THR_LOCK_threads);
157+
pthread_cond_destroy (&THR_COND_threads);
158+
}
132159
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
133160
pthread_mutex_destroy(&LOCK_localtime_r);
134161
#endif
@@ -154,9 +181,6 @@ my_bool my_thread_init(void)
154181
#ifdef EXTRA_DEBUG_THREADS
155182
fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self());
156183
#endif
157-
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
158-
pthread_mutex_lock(&THR_LOCK_lock);
159-
#endif
160184

161185
#if !defined(__WIN__) || defined(USE_TLS)
162186
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
@@ -174,26 +198,26 @@ my_bool my_thread_init(void)
174198
}
175199
pthread_setspecific(THR_KEY_mysys,tmp);
176200

177-
#else
201+
#else /* defined(__WIN__) && !(defined(USE_TLS) */
178202
/*
179203
Skip initialization if the thread specific variable is already initialized
180204
*/
181205
if (THR_KEY_mysys.id)
182206
goto end;
183207
tmp= &THR_KEY_mysys;
184208
#endif
185-
tmp->id= ++thread_id;
186209
#if defined(__WIN__) && defined(EMBEDDED_LIBRARY)
187210
tmp->thread_self= (pthread_t)getpid();
188211
#endif
189212
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
190213
pthread_cond_init(&tmp->suspend, NULL);
191214
tmp->init= 1;
192215

216+
pthread_mutex_lock(&THR_LOCK_threads);
217+
tmp->id= ++thread_id;
218+
++THR_thread_count;
219+
pthread_mutex_unlock(&THR_LOCK_threads);
193220
end:
194-
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
195-
pthread_mutex_unlock(&THR_LOCK_lock);
196-
#endif
197221
return error;
198222
}
199223

@@ -232,6 +256,10 @@ void my_thread_end(void)
232256
#if !defined(__WIN__) || defined(USE_TLS)
233257
pthread_setspecific(THR_KEY_mysys,0);
234258
#endif
259+
pthread_mutex_lock(&THR_LOCK_threads);
260+
if (--THR_thread_count == 0)
261+
pthread_cond_signal(&THR_COND_threads);
262+
pthread_mutex_unlock(&THR_LOCK_threads);
235263
}
236264

237265
struct st_my_thread_var *_my_thread_var(void)

sql/item_sum.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,8 +3430,8 @@ bool Item_func_group_concat::setup(THD *thd)
34303430
duplicate values (according to the syntax of this function). If there
34313431
is no DISTINCT or ORDER BY clauses, we don't create this tree.
34323432
*/
3433-
init_tree(tree, min(thd->variables.max_heap_table_size,
3434-
thd->variables.sortbuff_size/16), 0,
3433+
init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
3434+
thd->variables.sortbuff_size/16), 0,
34353435
tree_key_length, compare_key, 0, NULL, (void*) this);
34363436
}
34373437

sql/mysqld.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
#define IF_PURIFY(A,B) (B)
6969
#endif
7070

71+
#if SIZEOF_CHARP == 4
72+
#define MAX_MEM_TABLE_SIZE ~(ulong) 0
73+
#else
74+
#define MAX_MEM_TABLE_SIZE ~(ulonglong) 0
75+
#endif
76+
7177
/* stack traces are only supported on linux intel */
7278
#if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK)
7379
#define HAVE_STACK_TRACE_ON_SEGV
@@ -5950,8 +5956,9 @@ The minimum value for this variable is 4096.",
59505956
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
59515957
"Don't allow creation of heap tables bigger than this.",
59525958
(gptr*) &global_system_variables.max_heap_table_size,
5953-
(gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULONG,
5954-
REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0},
5959+
(gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULL,
5960+
REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE,
5961+
MALLOC_OVERHEAD, 1024, 0},
59555962
{"max_join_size", OPT_MAX_JOIN_SIZE,
59565963
"Joins that are probably going to read more than max_join_size records return an error.",
59575964
(gptr*) &global_system_variables.max_join_size,
@@ -6237,8 +6244,8 @@ The minimum value for this variable is 4096.",
62376244
{"tmp_table_size", OPT_TMP_TABLE_SIZE,
62386245
"If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.",
62396246
(gptr*) &global_system_variables.tmp_table_size,
6240-
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG,
6241-
REQUIRED_ARG, 16*1024*1024L, 1024, ~0L, 0, 1, 0}, /* See max_heap_table_size . */
6247+
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL,
6248+
REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
62426249
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
62436250
"Allocation block size for transactions to be stored in binary log",
62446251
(gptr*) &global_system_variables.trans_alloc_block_size,

sql/set_var.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads",
299299
fix_max_connections);
300300
sys_var_thd_ulong sys_max_error_count("max_error_count",
301301
&SV::max_error_count);
302-
sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size",
302+
sys_var_thd_ulonglong sys_max_heap_table_size("max_heap_table_size",
303303
&SV::max_heap_table_size);
304304
sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id",
305305
&SV::pseudo_thread_id,
@@ -473,7 +473,7 @@ sys_var_thd_enum sys_tx_isolation("tx_isolation",
473473
&tx_isolation_typelib,
474474
fix_tx_isolation,
475475
check_tx_isolation);
476-
sys_var_thd_ulong sys_tmp_table_size("tmp_table_size",
476+
sys_var_thd_ulonglong sys_tmp_table_size("tmp_table_size",
477477
&SV::tmp_table_size);
478478
sys_var_bool_ptr sys_timed_mutexes("timed_mutexes",
479479
&timed_mutexes);

0 commit comments

Comments
 (0)