Skip to content

Commit c1b5a5b

Browse files
Removed not used variable 'last_ref'
Fixed problem with negative DECIMAL() keys Fixed some bugs with NULL keys in BDB More mysql-test tests
1 parent 3857c6a commit c1b5a5b

23 files changed

Lines changed: 463 additions & 177 deletions

Docs/manual.texi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40383,6 +40383,8 @@ though, so Version 3.23 is not released as a stable version yet.
4038340383
@appendixsubsec Changes in release 3.23.31
4038440384
@itemize @bullet
4038540385
@item
40386+
Fixed problem when using @code{DECIMAL()} keys on negative numbers.
40387+
@item
4038640388
@code{HOUR()} on a @code{CHAR} column always returned @code{NULL}.
4038740389
@item
4038840390
Fixed security bug in something (please upgrade if you are using a earlier

client/mysqltest.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define INIT_Q_LINES 1024
7171
#define MIN_VAR_ALLOC 32
7272
#define BLOCK_STACK_DEPTH 32
73+
#define MAX_EXPECTED_ERRORS 10
7374

7475
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
7576
static char *db = 0, *pass=0;
@@ -88,7 +89,7 @@ static char TMPDIR[FN_REFLEN];
8889

8990
static int block_stack[BLOCK_STACK_DEPTH];
9091
static int *cur_block, *block_stack_end;
91-
static uint global_expected_errno=0;
92+
static uint global_expected_errno[MAX_EXPECTED_ERRORS];
9293

9394
DYNAMIC_ARRAY q_lines;
9495

@@ -132,7 +133,7 @@ struct st_query
132133
char *query, *first_argument;
133134
int first_word_len;
134135
my_bool abort_on_error, require_file;
135-
uint expected_errno;
136+
uint expected_errno[MAX_EXPECTED_ERRORS];
136137
char record_file[FN_REFLEN];
137138
/* Add new commands before Q_UNKNOWN */
138139
enum { Q_CONNECTION=1, Q_QUERY, Q_CONNECT,
@@ -542,17 +543,24 @@ static void get_file_name(char *filename, struct st_query* q)
542543
}
543544

544545

545-
static int get_int(struct st_query* q)
546+
static void get_ints(uint *to,struct st_query* q)
546547
{
547548
char* p=q->first_argument;
548-
int res;
549-
DBUG_ENTER("get_int");
549+
long val;
550+
DBUG_ENTER("get_ints");
551+
550552
while (*p && isspace(*p)) p++;
551553
if (!*p)
552554
die("Missing argument in %s\n", q->query);
553-
res=atoi(p);
554-
DBUG_PRINT("result",("res: %d",res));
555-
DBUG_RETURN(res);
555+
556+
for (; (p=str2int(p,10,(long) INT_MIN, (long) INT_MAX, &val)) ; p++)
557+
{
558+
*to++= (uint) val;
559+
if (*p != ',')
560+
break;
561+
}
562+
*to++=0; /* End of data */
563+
DBUG_VOID_RETURN;
556564
}
557565

558566

@@ -918,9 +926,10 @@ int read_query(struct st_query** q_ptr)
918926
q->record_file[0] = 0;
919927
q->require_file=0;
920928
q->first_word_len = 0;
921-
q->expected_errno = global_expected_errno;
922-
q->abort_on_error = global_expected_errno == 0;
923-
global_expected_errno=0;
929+
memcpy((gptr) q->expected_errno, (gptr) global_expected_errno,
930+
sizeof(global_expected_errno));
931+
q->abort_on_error = global_expected_errno[0] == 0;
932+
bzero((gptr) global_expected_errno,sizeof(global_expected_errno));
924933
q->type = Q_UNKNOWN;
925934
q->query=0;
926935
if (read_line(read_query_buf, sizeof(read_query_buf)))
@@ -947,7 +956,8 @@ int read_query(struct st_query** q_ptr)
947956
p++;
948957
for (;isdigit(*p);p++)
949958
expected_errno = expected_errno * 10 + *p - '0';
950-
q->expected_errno = expected_errno;
959+
q->expected_errno[0] = expected_errno;
960+
q->expected_errno[1] = 0;
951961
}
952962
}
953963

@@ -1178,15 +1188,17 @@ int run_query(MYSQL* mysql, struct st_query* q)
11781188
mysql_errno(mysql), mysql_error(mysql));
11791189
else
11801190
{
1181-
if (q->expected_errno)
1191+
for (i=0 ; q->expected_errno[i] ; i++)
1192+
{
1193+
if ((q->expected_errno[i] == mysql_errno(mysql)))
1194+
goto end; /* Ok */
1195+
}
1196+
if (i)
11821197
{
1183-
error = (q->expected_errno != mysql_errno(mysql));
1184-
if (error)
1185-
verbose_msg("query '%s' failed with wrong errno\
1186-
%d instead of %d", q->query, mysql_errno(mysql), q->expected_errno);
1198+
verbose_msg("query '%s' failed with wrong errno\
1199+
%d instead of %d...", q->query, mysql_errno(mysql), q->expected_errno[0]);
11871200
goto end;
11881201
}
1189-
11901202
verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
11911203
mysql_error(mysql));
11921204
/* if we do not abort on error, failure to run the query does
@@ -1196,11 +1208,11 @@ int run_query(MYSQL* mysql, struct st_query* q)
11961208
}
11971209
}
11981210

1199-
if (q->expected_errno)
1211+
if (q->expected_errno[0])
12001212
{
12011213
error = 1;
1202-
verbose_msg("query '%s' succeeded - should have failed with errno %d",
1203-
q->query, q->expected_errno);
1214+
verbose_msg("query '%s' succeeded - should have failed with errno %d...",
1215+
q->query, q->expected_errno[0]);
12041216
goto end;
12051217
}
12061218

@@ -1373,7 +1385,7 @@ int main(int argc, char** argv)
13731385
require_file=0;
13741386
break;
13751387
case Q_ERROR:
1376-
global_expected_errno=get_int(q);
1388+
get_ints(global_expected_errno,q);
13771389
break;
13781390
case Q_REQUIRE:
13791391
get_file_name(save_file,q);

heap/hp_info.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ ulong heap_position_old(HP_INFO *info)
4444
/* Note that heap_info does NOT return information about the
4545
current position anymore; Use heap_position instead */
4646

47-
int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x,int flag)
47+
int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x,
48+
int flag __attribute__((unused)))
4849
{
4950
DBUG_ENTER("heap_info");
5051
x->records = info->s->records;

include/thr_lock.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,36 @@ extern "C" {
2929
struct st_thr_lock;
3030

3131
enum thr_lock_type { TL_IGNORE=-1,
32-
TL_UNLOCK, TL_READ, TL_READ_HIGH_PRIORITY,
32+
TL_UNLOCK, /* UNLOCK ANY LOCK */
33+
TL_READ, /* Read lock */
34+
/* High prior. than TL_WRITE. Allow concurrent insert */
35+
TL_READ_HIGH_PRIORITY,
36+
/* READ, Don't allow concurrent insert */
3337
TL_READ_NO_INSERT,
34-
TL_WRITE_ALLOW_WRITE, TL_WRITE_ALLOW_READ,
38+
/*
39+
Write lock, but allow other threads to read / write.
40+
Used by BDB tables in MySQL to mark that someone is
41+
reading/writing to the table.
42+
*/
43+
TL_WRITE_ALLOW_WRITE,
44+
/*
45+
Write lock, but allow other threads to read / write.
46+
Used by ALTER TABLE in MySQL to mark to allow readers
47+
to use the table until ALTER TABLE is finished.
48+
*/
49+
TL_WRITE_ALLOW_READ,
50+
/*
51+
WRITE lock used by concurrent insert. Will allow
52+
READ, if one could use concurrent insert on table.
53+
*/
3554
TL_WRITE_CONCURRENT_INSERT,
36-
TL_WRITE_DELAYED, TL_WRITE_LOW_PRIORITY, TL_WRITE,
55+
/* Write used by INSERT DELAYED. Allows READ locks */
56+
TL_WRITE_DELAYED,
57+
/* WRITE lock that has lower priority than TL_READ */
58+
TL_WRITE_LOW_PRIORITY,
59+
/* Normal WRITE lock */
60+
TL_WRITE,
61+
/* Abort new lock request with an error */
3762
TL_WRITE_ONLY};
3863

3964
extern ulong max_write_lock_count;

isam/pack_isam.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static int compress(MRG_INFO *mrg,char *result_table)
576576
if (verbose && mrg->records)
577577
printf("Min record length: %6d Max length: %6d Mean total length: %6lu\n",
578578
mrg->min_pack_length,mrg->max_pack_length,
579-
(ulong) new_length/mrg->records);
579+
(ulong) (new_length/mrg->records));
580580

581581
if (!test_only)
582582
{
@@ -763,11 +763,11 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
763763
{
764764
global_count=count;
765765
if (!(element=tree_insert(&count->int_tree,pos,0)) ||
766-
(element->count == 1 &&
766+
((element->count == 1 &&
767767
count->tree_buff + tree_buff_length <
768-
count->tree_pos + count->field_length ||
769-
count->field_length == 1 &&
770-
count->int_tree.elements_in_tree > 1))
768+
count->tree_pos + count->field_length) ||
769+
(count->field_length == 1 &&
770+
count->int_tree.elements_in_tree > 1)))
771771
{
772772
delete_tree(&count->int_tree);
773773
my_free(count->tree_buff,MYF(0));
@@ -862,7 +862,8 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
862862
DBUG_RETURN(0);
863863
}
864864

865-
static int compare_huff_elements(void *not_used, byte *a, byte *b)
865+
static int compare_huff_elements(void *not_used __attribute__((unused)),
866+
byte *a, byte *b)
866867
{
867868
return *((my_off_t*) a) < *((my_off_t*) b) ? -1 :
868869
(*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1);

myisam/mi_check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
11821182
That is the next line for... (serg)
11831183
*/
11841184

1185-
share->state.key_map= (((ulonglong) 1L << share->base.keys)-1 &
1185+
share->state.key_map= ((((ulonglong) 1L << share->base.keys)-1) &
11861186
param->keys_in_use);
11871187

11881188
info->state->key_file_length=share->base.keystart;

myisam/mi_extra.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function)
151151
{
152152
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
153153
error=end_io_cache(&info->rec_cache);
154+
/* Sergei will insert full text index caching here */
154155
}
155156
#if defined(HAVE_MMAP) && defined(HAVE_MADVICE)
156157
if (info->opt_flag & MEMMAP_USED)

myisammrg/myrg_rkey.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
4646
int err;
4747
byte *buf=((search_flag == HA_READ_KEY_EXACT) ? record: 0);
4848
LINT_INIT(key_buff);
49+
LINT_INIT(pack_key_length);
4950

5051
if (_myrg_init_queue(info,inx,search_flag))
5152
return my_errno;

mysql-test/mysql-test-run.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# Access Definitions
1111
#--
1212
DB=test
13-
DBUSER=test
1413
DBPASSWD=
1514
VERBOSE=""
1615
TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
@@ -209,6 +208,9 @@ fi
209208
if [ -n "$USE_RUNNING_SERVER" ]
210209
then
211210
MASTER_MYSOCK="/tmp/mysql.sock"
211+
DBUSER=test
212+
else
213+
DBUSER=root # We want to do FLUSH xxx commands
212214
fi
213215

214216
if [ -w / ]

mysql-test/r/bdb.result

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,23 @@ level id parent_id
130130
1 1005 101
131131
1 1006 101
132132
1 1007 101
133+
Table Op Msg_type Msg_text
134+
test.t1 optimize status OK
135+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
136+
t1 0 PRIMARY 1 id A 39 NULL NULL
137+
t1 1 parent_id 1 parent_id A 9 NULL NULL
138+
t1 1 level 1 level A 3 NULL NULL
133139
gesuchnr benutzer_id
134140
1 1
135141
2 1
142+
Table Op Msg_type Msg_text
143+
test.t1 optimize status OK
136144
a
137145
2
146+
Table Op Msg_type Msg_text
147+
test.t1 check error The handler for the table doesn't support check/repair
148+
a b
149+
2 testing
138150
a b
139151
a 1
140152
a 2
@@ -152,6 +164,8 @@ d 2
152164
d 5
153165
e 1
154166
k 1
167+
count(*)
168+
16
155169
n after rollback
156170
n after commit
157171
4 after commit
@@ -249,6 +263,12 @@ id ggid email passwd
249263
1 test1 xxx
250264
id ggid email passwd
251265
2 test2 yyy
266+
id ggid email passwd
267+
1 this will work
268+
3 test2 this will work
269+
id ggid email passwd
270+
1 this will work
271+
id ggid email passwd
252272
user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key
253273
user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1
254274
user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2
@@ -402,14 +422,50 @@ id parent_id level
402422
1180 105 2
403423
count(*)
404424
1
425+
count(*)
426+
1
427+
count(*)
428+
2
429+
count(*)
430+
1
431+
count(*)
432+
1
433+
count(*)
434+
1
435+
sca_pic
436+
NULL
437+
NULL
405438
a
406439
1
407440
2
408441
3
442+
a
443+
2
444+
3
445+
5
409446
b
410447
this is a blob
411448
b i
412449
this is a blob 1
413450
b i
414451
this is a blob 1
452+
1
453+
2
454+
3
455+
b i
415456
b i
457+
NULL NULL
458+
b i
459+
updated 1
460+
NULL -1
461+
NULL NULL
462+
updated 1
463+
2
464+
3
465+
a b
466+
world 2
467+
hello 1
468+
Table Op Msg_type Msg_text
469+
test.t1 optimize status OK
470+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
471+
t1 0 PRIMARY 1 a A 1 NULL NULL

0 commit comments

Comments
 (0)