Skip to content

Commit dbb117b

Browse files
Alexey KopytovAlexey Kopytov
Alexey Kopytov
authored and
Alexey Kopytov
committed
Automerge.
2 parents 4ae19af + 49e7152 commit dbb117b

8 files changed

+60
-11
lines changed

dbug/dbug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ int DbugParse(CODE_STATE *cs, const char *control)
496496
rel= control[0] == '+' || control[0] == '-';
497497
if ((!rel || (!stack->out_file && !stack->next)))
498498
{
499+
/* Free memory associated with the state before resetting its members */
499500
FreeState(cs, stack, 0);
500501
stack->flags= 0;
501502
stack->delay= 0;
@@ -1608,7 +1609,7 @@ static void PushState(CODE_STATE *cs)
16081609
struct settings *new_malloc;
16091610

16101611
new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings));
1611-
bzero(new_malloc, sizeof(*new_malloc));
1612+
bzero(new_malloc, sizeof(struct settings));
16121613
new_malloc->next= cs->stack;
16131614
cs->stack= new_malloc;
16141615
}
@@ -2088,7 +2089,7 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name)
20882089

20892090
static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
20902091
{
2091-
if (fp && fp != stderr && fp != stdout && fclose(fp) == EOF)
2092+
if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF)
20922093
{
20932094
pthread_mutex_lock(&THR_LOCK_dbug);
20942095
(void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);

mysql-test/r/partition_error.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,4 +1209,14 @@ PARTITION p VALUES LESS THAN (1219089600),
12091209
PARTITION pmax VALUES LESS THAN MAXVALUE);
12101210
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
12111211
DROP TABLE old;
1212+
#
1213+
# Bug #56709: Memory leaks at running the 5.1 test suite
1214+
#
1215+
CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY);
1216+
ALTER TABLE t1
1217+
PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
1218+
PARTITION p VALUES LESS THAN (18),
1219+
PARTITION pmax VALUES LESS THAN MAXVALUE);
1220+
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
1221+
DROP TABLE t1;
12121222
End of 5.1 tests

mysql-test/r/variables_debug.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ SELECT @@global.debug;
3131
@@global.debug
3232

3333
SET GLOBAL debug=@old_debug;
34+
#
35+
# Bug #56709: Memory leaks at running the 5.1 test suite
36+
#
37+
SET @old_local_debug = @@debug;
38+
SET @@debug='d,foo';
39+
SELECT @@debug;
40+
@@debug
41+
d,foo
42+
SET @@debug='';
43+
SELECT @@debug;
44+
@@debug
45+
46+
SET @@debug = @old_local_debug;
3447
End of 5.1 tests
3548
#
3649
# Bug#46165 server crash in dbug

mysql-test/t/partition_error.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,4 +1398,18 @@ PARTITION pmax VALUES LESS THAN MAXVALUE);
13981398

13991399
DROP TABLE old;
14001400

1401+
--echo #
1402+
--echo # Bug #56709: Memory leaks at running the 5.1 test suite
1403+
--echo #
1404+
1405+
CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY);
1406+
1407+
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
1408+
ALTER TABLE t1
1409+
PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
1410+
PARTITION p VALUES LESS THAN (18),
1411+
PARTITION pmax VALUES LESS THAN MAXVALUE);
1412+
1413+
DROP TABLE t1;
1414+
14011415
--echo End of 5.1 tests

mysql-test/t/variables_debug.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ SELECT @@global.debug;
3535

3636
SET GLOBAL debug=@old_debug;
3737

38+
--echo #
39+
--echo # Bug #56709: Memory leaks at running the 5.1 test suite
40+
--echo #
41+
42+
SET @old_local_debug = @@debug;
43+
44+
SET @@debug='d,foo';
45+
SELECT @@debug;
46+
SET @@debug='';
47+
SELECT @@debug;
48+
49+
SET @@debug = @old_local_debug;
50+
3851
--echo End of 5.1 tests
3952

4053

sql/item_timefunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,8 +2338,6 @@ void Item_extract::print(String *str, enum_query_type query_type)
23382338

23392339
void Item_extract::fix_length_and_dec()
23402340
{
2341-
value.alloc(32); // alloc buffer
2342-
23432341
maybe_null=1; // If wrong date
23442342
switch (int_type) {
23452343
case INTERVAL_YEAR: max_length=4; date_value=1; break;
@@ -2382,6 +2380,8 @@ longlong Item_extract::val_int()
23822380
}
23832381
else
23842382
{
2383+
char buf[40];
2384+
String value(buf, sizeof(buf), &my_charset_bin);;
23852385
String *res= args[0]->val_str(&value);
23862386
if (!res ||
23872387
str_to_time_with_warn(res->charset(), res->ptr(), res->length(),

sql/item_timefunc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,6 @@ class Item_date_add_interval :public Item_date_func
733733

734734
class Item_extract :public Item_int_func
735735
{
736-
String value;
737736
bool date_value;
738737
public:
739738
const interval_type int_type; // keep it public

sql/sql_load.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
13451345
MYF(MY_WME)))
13461346
{
13471347
my_free(buffer); /* purecov: inspected */
1348+
buffer= NULL;
13481349
error=1;
13491350
}
13501351
else
@@ -1371,13 +1372,11 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
13711372

13721373
READ_INFO::~READ_INFO()
13731374
{
1374-
if (!error)
1375-
{
1376-
if (need_end_io_cache)
1377-
::end_io_cache(&cache);
1375+
if (!error && need_end_io_cache)
1376+
::end_io_cache(&cache);
1377+
1378+
if (buffer != NULL)
13781379
my_free(buffer);
1379-
error=1;
1380-
}
13811380
List_iterator<XML_TAG> xmlit(taglist);
13821381
XML_TAG *t;
13831382
while ((t= xmlit++))

0 commit comments

Comments
 (0)