Skip to content

Commit e18679c

Browse files
Merge mysql.com:/home/jimw/my/mysql-4.1-clean
into mysql.com:/home/jimw/my/mysql-5.0-clean
2 parents c34595c + f7ff3d6 commit e18679c

6 files changed

Lines changed: 50 additions & 15 deletions

File tree

mysql-test/r/bdb.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,25 @@ SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
12891289
id
12901290
4
12911291
DROP TABLE t1;
1292+
create table t1 (a int, key(a)) engine=bdb;
1293+
create table t2 (b int, key(b)) engine=bdb;
1294+
insert into t1 values (1),(1),(2),(3),(4);
1295+
insert into t2 values (1),(5),(6),(7);
1296+
delete from t1 where (a in (select b from t2));
1297+
select count(*) from t1;
1298+
count(*)
1299+
3
1300+
insert into t1 set a=(select b from t2);
1301+
ERROR 21000: Subquery returns more than 1 row
1302+
select count(*) from t1;
1303+
count(*)
1304+
3
1305+
update t1 set a = a + 1 where (a in (select b from t2));
1306+
select count(*) from t1;
1307+
count(*)
1308+
3
1309+
drop table t1, t2;
1310+
End of 4.1 tests
12921311
create temporary table t1 (a int, primary key(a)) engine=bdb;
12931312
select * from t1;
12941313
a

mysql-test/t/bdb.test

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,25 @@ SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
938938
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
939939
DROP TABLE t1;
940940

941-
# End of 4.1 tests
941+
#
942+
# Bug #15536: Crash when DELETE with subquery using BDB tables
943+
#
944+
create table t1 (a int, key(a)) engine=bdb;
945+
create table t2 (b int, key(b)) engine=bdb;
946+
insert into t1 values (1),(1),(2),(3),(4);
947+
insert into t2 values (1),(5),(6),(7);
948+
delete from t1 where (a in (select b from t2));
949+
select count(*) from t1;
950+
# INSERT also blows up
951+
--error 1242
952+
insert into t1 set a=(select b from t2);
953+
select count(*) from t1;
954+
# UPDATE also blows up
955+
update t1 set a = a + 1 where (a in (select b from t2));
956+
select count(*) from t1;
957+
drop table t1, t2;
958+
959+
--echo End of 4.1 tests
942960

943961
#
944962
# alter temp table

sql/share/charsets/latin5.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@
112112

113113

114114
<collation name="latin5_turkish_ci">
115-
<!--
116-
# Note: all accented characters are compared separately (this
117-
# is different from the default latin1 character set, where
118-
# e.g. a = ä = á, etc.).
119-
-->
120115
<map>
121116
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
122117
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
@@ -130,10 +125,10 @@
130125
9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB
131126
AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB
132127
BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB
133-
CC CD CE CF D0 D1 D2 44 D3 D4 D5 D6 D7 D8 D9 DA
134-
49 DB DC DD DE DF 53 E0 E1 E2 E3 E4 5B 4C 58 E5
135-
CC CD CE CF D0 D1 D2 44 D3 D4 D5 D6 D7 D8 D9 DA
136-
49 DB DC DD DE DF 53 FA E1 E2 E3 E4 5B 4B 58 FF
128+
41 41 41 41 41 41 41 44 46 46 46 46 4C 4C 4C 4C
129+
49 51 52 52 52 52 53 E0 52 5A 5A 5A 5B 4C 58 57
130+
41 41 41 41 41 41 41 44 46 46 46 46 4C 4C 4C 4C
131+
49 51 52 52 52 52 53 FA 52 5A 5A 5A 5B 4B 58 5F
137132
</map>
138133
</collation>
139134

sql/sql_delete.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
293293
if (!transactional_table)
294294
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
295295
}
296+
free_underlaid_joins(thd, select_lex);
296297
if (transactional_table)
297298
{
298299
if (ha_autocommit_or_rollback(thd,error >= 0))
@@ -304,7 +305,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
304305
mysql_unlock_tables(thd, thd->lock);
305306
thd->lock=0;
306307
}
307-
free_underlaid_joins(thd, select_lex);
308308
if (error < 0)
309309
{
310310
thd->row_count_func= deleted;

sql/sql_insert.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
257257
*/
258258
bool log_on= (thd->options & OPTION_BIN_LOG) ||
259259
(!(thd->security_ctx->master_access & SUPER_ACL));
260-
bool transactional_table;
260+
bool transactional_table, joins_freed= FALSE;
261261
uint value_count;
262262
ulong counter = 1;
263263
ulonglong id;
@@ -513,6 +513,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
513513
thd->row_count++;
514514
}
515515

516+
free_underlaid_joins(thd, &thd->lex->select_lex);
517+
joins_freed= TRUE;
518+
516519
/*
517520
Now all rows are inserted. Time to update logs and sends response to
518521
user
@@ -611,7 +614,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
611614
thd->row_count_func= info.copied+info.deleted+info.updated;
612615
::send_ok(thd, (ulong) thd->row_count_func, id, buff);
613616
}
614-
free_underlaid_joins(thd, &thd->lex->select_lex);
615617
thd->abort_on_warning= 0;
616618
DBUG_RETURN(FALSE);
617619

@@ -620,7 +622,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
620622
if (lock_type == TL_WRITE_DELAYED)
621623
end_delayed_insert(thd);
622624
#endif
623-
free_underlaid_joins(thd, &thd->lex->select_lex);
625+
if (!joins_freed)
626+
free_underlaid_joins(thd, &thd->lex->select_lex);
624627
thd->abort_on_warning= 0;
625628
DBUG_RETURN(TRUE);
626629
}

sql/sql_update.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ int mysql_update(THD *thd,
527527
if (!transactional_table)
528528
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
529529
}
530+
free_underlaid_joins(thd, select_lex);
530531
if (transactional_table)
531532
{
532533
if (ha_autocommit_or_rollback(thd, error >= 0))
@@ -539,7 +540,6 @@ int mysql_update(THD *thd,
539540
thd->lock=0;
540541
}
541542

542-
free_underlaid_joins(thd, select_lex);
543543
if (error < 0)
544544
{
545545
char buff[STRING_BUFFER_USUAL_SIZE];

0 commit comments

Comments
 (0)