Skip to content

Commit f32a511

Browse files
committed
Merge branch '10.2' into bb-10.2-connector-c-integ-subm
2 parents f7640e1 + 2726378 commit f32a511

File tree

6 files changed

+119
-90
lines changed

6 files changed

+119
-90
lines changed

mysql-test/r/cte_recursive.result

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,54 @@ EXPLAIN
15561556
}
15571557
}
15581558
}
1559+
create table my_ancestors
1560+
with recursive
1561+
ancestor_ids (id)
1562+
as
1563+
(
1564+
select father from folks where name = 'Me'
1565+
union
1566+
select mother from folks where name = 'Me'
1567+
union
1568+
select father from folks, ancestor_ids a where folks.id = a.id
1569+
union
1570+
select mother from folks, ancestor_ids a where folks.id = a.id
1571+
)
1572+
select p.* from folks as p, ancestor_ids as a where p.id = a.id;
1573+
select * from my_ancestors;
1574+
id name dob father mother
1575+
20 Dad 1970-02-02 10 9
1576+
30 Mom 1975-03-03 8 7
1577+
10 Grandpa Bill 1940-04-05 NULL NULL
1578+
9 Grandma Ann 1941-10-15 NULL NULL
1579+
7 Grandma Sally 1943-08-23 NULL 6
1580+
8 Grandpa Ben 1940-10-21 NULL NULL
1581+
6 Grandgrandma Martha 1923-05-17 NULL NULL
1582+
delete from my_ancestors;
1583+
insert into my_ancestors
1584+
with recursive
1585+
ancestor_ids (id)
1586+
as
1587+
(
1588+
select father from folks where name = 'Me'
1589+
union
1590+
select mother from folks where name = 'Me'
1591+
union
1592+
select father from folks, ancestor_ids a where folks.id = a.id
1593+
union
1594+
select mother from folks, ancestor_ids a where folks.id = a.id
1595+
)
1596+
select p.* from folks as p, ancestor_ids as a where p.id = a.id;
1597+
select * from my_ancestors;
1598+
id name dob father mother
1599+
20 Dad 1970-02-02 10 9
1600+
30 Mom 1975-03-03 8 7
1601+
10 Grandpa Bill 1940-04-05 NULL NULL
1602+
9 Grandma Ann 1941-10-15 NULL NULL
1603+
7 Grandma Sally 1943-08-23 NULL 6
1604+
8 Grandpa Ben 1940-10-21 NULL NULL
1605+
6 Grandgrandma Martha 1923-05-17 NULL NULL
1606+
drop table my_ancestors;
15591607
drop table folks;
15601608
#
15611609
# MDEV-10372: [bb-10.2-mdev9864 tree] EXPLAIN with recursive CTE enters endless recursion

mysql-test/t/cte_recursive.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,44 @@ select h_name, h_dob, w_name, w_dob
11621162
from ancestor_couples;
11631163

11641164

1165+
create table my_ancestors
1166+
with recursive
1167+
ancestor_ids (id)
1168+
as
1169+
(
1170+
select father from folks where name = 'Me'
1171+
union
1172+
select mother from folks where name = 'Me'
1173+
union
1174+
select father from folks, ancestor_ids a where folks.id = a.id
1175+
union
1176+
select mother from folks, ancestor_ids a where folks.id = a.id
1177+
)
1178+
select p.* from folks as p, ancestor_ids as a where p.id = a.id;
1179+
1180+
select * from my_ancestors;
1181+
1182+
delete from my_ancestors;
1183+
1184+
insert into my_ancestors
1185+
with recursive
1186+
ancestor_ids (id)
1187+
as
1188+
(
1189+
select father from folks where name = 'Me'
1190+
union
1191+
select mother from folks where name = 'Me'
1192+
union
1193+
select father from folks, ancestor_ids a where folks.id = a.id
1194+
union
1195+
select mother from folks, ancestor_ids a where folks.id = a.id
1196+
)
1197+
select p.* from folks as p, ancestor_ids as a where p.id = a.id;
1198+
1199+
select * from my_ancestors;
1200+
1201+
drop table my_ancestors;
1202+
11651203
drop table folks;
11661204

11671205
--echo #

sql/sql_parse.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3781,7 +3781,8 @@ mysql_execute_command(THD *thd)
37813781
/* Copy temporarily the statement flags to thd for lock_table_names() */
37823782
uint save_thd_create_info_options= thd->lex->create_info.options;
37833783
thd->lex->create_info.options|= create_info.options;
3784-
res= open_and_lock_tables(thd, create_info, lex->query_tables, TRUE, 0);
3784+
if (!(res= check_dependencies_in_with_clauses(lex->with_clauses_list)))
3785+
res= open_and_lock_tables(thd, create_info, lex->query_tables, TRUE, 0);
37853786
thd->lex->create_info.options= save_thd_create_info_options;
37863787
if (res)
37873788
{
@@ -4394,7 +4395,8 @@ mysql_execute_command(THD *thd)
43944395

43954396
unit->set_limit(select_lex);
43964397

4397-
if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0)))
4398+
if (!(res= check_dependencies_in_with_clauses(lex->with_clauses_list)) &&
4399+
!(res=open_and_lock_tables(thd, all_tables, TRUE, 0)))
43984400
{
43994401
MYSQL_INSERT_SELECT_START(thd->query());
44004402
/*

sql/sql_yacc.yy

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4810,16 +4810,22 @@ create_like:
48104810

48114811
opt_create_select:
48124812
/* empty */ {}
4813-
| opt_duplicate opt_as create_select_query_expression_body
4813+
| opt_duplicate opt_as create_select_query_expression
48144814
;
48154815

4816-
create_select_query_expression_body:
4817-
SELECT_SYM create_select_part2 opt_table_expression
4816+
create_select_query_expression:
4817+
opt_with_clause SELECT_SYM create_select_part2 opt_table_expression
48184818
create_select_part4
4819-
{ Select->set_braces(0);}
4819+
{
4820+
Select->set_braces(0);
4821+
Select->set_with_clause($1);
4822+
}
48204823
union_clause
4821-
| SELECT_SYM create_select_part2 create_select_part3_union_not_ready
4822-
create_select_part4
4824+
| opt_with_clause SELECT_SYM create_select_part2
4825+
create_select_part3_union_not_ready create_select_part4
4826+
{
4827+
Select->set_with_clause($1);
4828+
}
48234829
| '(' create_select_query_specification ')'
48244830
| '(' create_select_query_specification ')'
48254831
{ Select->set_braces(1);} union_list {}
@@ -5519,7 +5525,11 @@ opt_part_option:
55195525
*/
55205526

55215527
create_select_query_specification:
5522-
SELECT_SYM create_select_part2 create_select_part3 create_select_part4
5528+
SELECT_SYM opt_with_clause create_select_part2 create_select_part3
5529+
create_select_part4
5530+
{
5531+
Select->set_with_clause($2);
5532+
}
55235533
;
55245534

55255535
create_select_part2:
@@ -12308,7 +12318,7 @@ fields:
1230812318
insert_values:
1230912319
VALUES values_list {}
1231012320
| VALUE_SYM values_list {}
12311-
| create_select_query_expression_body {}
12321+
| create_select_query_expression {}
1231212322
;
1231312323

1231412324
values_list:

storage/innobase/sync/sync0arr.cc

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ void
501501
sync_array_cell_print(
502502
/*==================*/
503503
FILE* file, /*!< in: file where to print */
504-
sync_cell_t* cell, /*!< in: sync cell */
505-
os_thread_id_t* reserver) /*!< out: write reserver or
506-
0 */
504+
sync_cell_t* cell) /*!< in: sync cell */
507505
{
508506
rw_lock_t* rwlock;
509507
ulint type;
@@ -601,7 +599,6 @@ sync_array_cell_print(
601599
writer == RW_LOCK_X ? " exclusive\n"
602600
: writer == RW_LOCK_SX ? " SX\n"
603601
: " wait exclusive\n");
604-
*reserver = rwlock->writer_thread;
605602
}
606603

607604
fprintf(file,
@@ -715,7 +712,7 @@ sync_array_report_error(
715712
sync_cell_t* cell)
716713
{
717714
fprintf(stderr, "rw-lock %p ", (void*) lock);
718-
sync_array_cell_print(stderr, cell, 0);
715+
sync_array_cell_print(stderr, cell);
719716
rw_lock_debug_print(stderr, debug);
720717
}
721718

@@ -788,7 +785,7 @@ sync_array_detect_deadlock(
788785
<< " file " << name << " line "
789786
<< policy.get_enter_line();
790787

791-
sync_array_cell_print(stderr, cell, 0);
788+
sync_array_cell_print(stderr, cell);
792789

793790
return(true);
794791
}
@@ -1152,7 +1149,7 @@ sync_array_print_long_waits_low(
11521149

11531150
if (diff > SYNC_ARRAY_TIMEOUT) {
11541151
ib::warn() << "A long semaphore wait:";
1155-
sync_array_cell_print(stderr, cell, 0);
1152+
sync_array_cell_print(stderr, cell);
11561153
*noticed = TRUE;
11571154
}
11581155

@@ -1167,14 +1164,12 @@ sync_array_print_long_waits_low(
11671164
}
11681165
}
11691166

1170-
/* We found a long semaphore wait, wait all threads that are
1167+
/* We found a long semaphore wait, print all threads that are
11711168
waiting for a semaphore. */
11721169
if (*noticed) {
11731170
for (i = 0; i < arr->n_cells; i++) {
11741171
void* wait_object;
1175-
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
11761172
sync_cell_t* cell;
1177-
ulint loop = 0;
11781173

11791174
cell = sync_array_get_nth_cell(arr, i);
11801175

@@ -1185,41 +1180,8 @@ sync_array_print_long_waits_low(
11851180
continue;
11861181
}
11871182

1188-
fputs("InnoDB: Warning: semaphore wait:\n",
1189-
stderr);
1190-
sync_array_cell_print(stderr, cell, 0);
1191-
1192-
/* Try to output cell information for writer recursive way */
1193-
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
1194-
sync_cell_t* reserver_wait;
1195-
1196-
reserver_wait = sync_array_find_thread(arr, reserver);
1197-
1198-
if (reserver_wait &&
1199-
reserver_wait->latch.mutex != NULL &&
1200-
reserver_wait->waiting) {
1201-
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
1202-
stderr);
1203-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1204-
sync_array_cell_print(stderr, reserver_wait, &reserver);
1205-
loop++;
1206-
1207-
/* TODO: FIXME:
1208-
if (reserver_wait->thread == reserver) {
1209-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1210-
}
1211-
*/
1212-
} else {
1213-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1214-
}
1215-
1216-
/* This is protection against loop */
1217-
if (loop > 100) {
1218-
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
1219-
break;
1220-
}
1221-
1222-
}
1183+
ib::info() << "A semaphore wait:";
1184+
sync_array_cell_print(stderr, cell);
12231185
}
12241186
}
12251187

@@ -1314,7 +1276,7 @@ sync_array_print_info_low(
13141276

13151277
if (cell->latch.mutex != 0) {
13161278
count++;
1317-
sync_array_cell_print(file, cell, 0);
1279+
sync_array_cell_print(file, cell);
13181280
}
13191281
}
13201282
}
@@ -1404,8 +1366,6 @@ sync_array_print_innodb(void)
14041366
for (i = 0; i < arr->n_cells; i++) {
14051367
void* wait_object;
14061368
sync_cell_t* cell;
1407-
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
1408-
ulint loop=0;
14091369

14101370
cell = sync_array_get_nth_cell(arr, i);
14111371

@@ -1418,36 +1378,7 @@ sync_array_print_innodb(void)
14181378

14191379
fputs("InnoDB: Warning: semaphore wait:\n",
14201380
stderr);
1421-
sync_array_cell_print(stderr, cell, &reserver);
1422-
1423-
/* Try to output cell information for writer recursive way */
1424-
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
1425-
sync_cell_t* reserver_wait;
1426-
1427-
reserver_wait = sync_array_find_thread(arr, reserver);
1428-
1429-
if (reserver_wait &&
1430-
reserver_wait->latch.mutex != NULL &&
1431-
reserver_wait->waiting) {
1432-
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
1433-
stderr);
1434-
sync_array_cell_print(stderr, reserver_wait, &reserver);
1435-
1436-
/* JAN: FIXME:
1437-
if (reserver_wait->thread == reserver) {
1438-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1439-
}
1440-
*/
1441-
} else {
1442-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1443-
}
1444-
1445-
/* This is protection against loop */
1446-
if (loop > 100) {
1447-
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
1448-
break;
1449-
}
1450-
}
1381+
sync_array_cell_print(stderr, cell);
14511382
}
14521383

14531384
fputs("InnoDB: Semaphore wait debug output ended:\n", stderr);

storage/innobase/ut/ut0crc32.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ static bool ut_crc32_slice8_table_initialized = false;
447447
/********************************************************************//**
448448
Initializes the table that is used to generate the CRC32 if the CPU does
449449
not have support for it. */
450-
#ifndef HAVE_CRC32_VPMSUM
451450
static
452451
void
453452
ut_crc32_slice8_table_init()
454453
/*========================*/
455454
{
455+
#ifndef HAVE_CRC32_VPMSUM
456456
/* bit-reversed poly 0x1EDC6F41 (from SSE42 crc32 instruction) */
457457
static const uint32_t poly = 0x82f63b78;
458458
uint32_t n;
@@ -476,8 +476,8 @@ ut_crc32_slice8_table_init()
476476
}
477477

478478
ut_crc32_slice8_table_initialized = true;
479-
}
480479
#endif
480+
}
481481

482482
/** Calculate CRC32 over 8-bit data using a software implementation.
483483
@param[in,out] crc crc32 checksum so far when this function is called,

0 commit comments

Comments
 (0)