Skip to content

Commit 26f6867

Browse files
Merge branch 'mysql-5.7' into mysql-trunk
2 parents 0bbe8f7 + 371cb91 commit 26f6867

File tree

4 files changed

+54
-36
lines changed

4 files changed

+54
-36
lines changed

mysql-test/suite/opt_trace/r/general_no_prot_all.result

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8217,15 +8217,15 @@ select * from t6 where d in (select f1() from t2 where s="c") {
82178217
"steps": [
82188218
{
82198219
"transformation": "equality_propagation",
8220-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
8220+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
82218221
},
82228222
{
82238223
"transformation": "constant_propagation",
8224-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
8224+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
82258225
},
82268226
{
82278227
"transformation": "trivial_condition_removal",
8228-
"resulting_condition": "((`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
8228+
"resulting_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
82298229
}
82308230
] /* steps */
82318231
} /* condition_processing */
@@ -8289,13 +8289,13 @@ select * from t6 where d in (select f1() from t2 where s="c") {
82898289
{
82908290
"rows_to_scan": 4,
82918291
"access_type": "scan",
8292-
"resulting_rows": 1,
8292+
"resulting_rows": 4,
82938293
"cost": 0.9017,
82948294
"chosen": true
82958295
}
82968296
] /* considered_access_paths */
82978297
} /* best_access_path */,
8298-
"condition_filtering_pct": 100,
8298+
"condition_filtering_pct": 25,
82998299
"rows_for_plan": 1,
83008300
"cost_for_plan": 0.9017,
83018301
"semijoin_strategy_choice": [
@@ -8410,7 +8410,7 @@ select * from t6 where d in (select f1() from t2 where s="c") {
84108410
},
84118411
{
84128412
"attaching_conditions_to_tables": {
8413-
"original_condition": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))",
8413+
"original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
84148414
"attached_conditions_computation": [
84158415
] /* attached_conditions_computation */,
84168416
"attached_conditions_summary": [
@@ -8420,7 +8420,7 @@ select * from t6 where d in (select f1() from t2 where s="c") {
84208420
},
84218421
{
84228422
"table": "`t2`",
8423-
"attached": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))"
8423+
"attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
84248424
}
84258425
] /* attached_conditions_summary */
84268426
} /* attaching_conditions_to_tables */
@@ -9191,15 +9191,15 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
91919191
"steps": [
91929192
{
91939193
"transformation": "equality_propagation",
9194-
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and multiple equal(`f1`(), `t6`.`d`))"
9194+
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
91959195
},
91969196
{
91979197
"transformation": "constant_propagation",
9198-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
9198+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
91999199
},
92009200
{
92019201
"transformation": "trivial_condition_removal",
9202-
"resulting_condition": "((`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
9202+
"resulting_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
92039203
}
92049204
] /* steps */
92059205
} /* condition_processing */
@@ -9263,13 +9263,13 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
92639263
{
92649264
"rows_to_scan": 4,
92659265
"access_type": "scan",
9266-
"resulting_rows": 1,
9266+
"resulting_rows": 4,
92679267
"cost": 0.9017,
92689268
"chosen": true
92699269
}
92709270
] /* considered_access_paths */
92719271
} /* best_access_path */,
9272-
"condition_filtering_pct": 100,
9272+
"condition_filtering_pct": 25,
92739273
"rows_for_plan": 1,
92749274
"cost_for_plan": 0.9017,
92759275
"semijoin_strategy_choice": [
@@ -9384,7 +9384,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
93849384
},
93859385
{
93869386
"attaching_conditions_to_tables": {
9387-
"original_condition": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))",
9387+
"original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
93889388
"attached_conditions_computation": [
93899389
] /* attached_conditions_computation */,
93909390
"attached_conditions_summary": [
@@ -9394,7 +9394,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
93949394
},
93959395
{
93969396
"table": "`t2`",
9397-
"attached": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))"
9397+
"attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
93989398
}
93999399
] /* attached_conditions_summary */
94009400
} /* attaching_conditions_to_tables */
@@ -11171,15 +11171,15 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1117111171
"steps": [
1117211172
{
1117311173
"transformation": "equality_propagation",
11174-
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and multiple equal(`f1`(), `t6`.`d`))"
11174+
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
1117511175
},
1117611176
{
1117711177
"transformation": "constant_propagation",
11178-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
11178+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1117911179
},
1118011180
{
1118111181
"transformation": "trivial_condition_removal",
11182-
"resulting_condition": "((`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
11182+
"resulting_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1118311183
}
1118411184
] /* steps */
1118511185
} /* condition_processing */
@@ -11273,13 +11273,13 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1127311273
{
1127411274
"rows_to_scan": 4,
1127511275
"access_type": "scan",
11276-
"resulting_rows": 1,
11276+
"resulting_rows": 4,
1127711277
"cost": 0.9017,
1127811278
"chosen": true
1127911279
}
1128011280
] /* considered_access_paths */
1128111281
} /* best_access_path */,
11282-
"condition_filtering_pct": 100,
11282+
"condition_filtering_pct": 25,
1128311283
"rows_for_plan": 1,
1128411284
"cost_for_plan": 0.9017,
1128511285
"semijoin_strategy_choice": [
@@ -11405,7 +11405,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1140511405
},
1140611406
{
1140711407
"attaching_conditions_to_tables": {
11408-
"original_condition": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))",
11408+
"original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
1140911409
"attached_conditions_computation": [
1141011410
] /* attached_conditions_computation */,
1141111411
"attached_conditions_summary": [
@@ -11415,7 +11415,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1141511415
},
1141611416
{
1141711417
"table": "`t2`",
11418-
"attached": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))"
11418+
"attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1141911419
}
1142011420
] /* attached_conditions_summary */
1142111421
} /* attaching_conditions_to_tables */

mysql-test/suite/opt_trace/r/general_ps_prot_all.result

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9041,15 +9041,15 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
90419041
"steps": [
90429042
{
90439043
"transformation": "equality_propagation",
9044-
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and multiple equal(`f1`(), `t6`.`d`))"
9044+
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
90459045
},
90469046
{
90479047
"transformation": "constant_propagation",
9048-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
9048+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
90499049
},
90509050
{
90519051
"transformation": "trivial_condition_removal",
9052-
"resulting_condition": "((`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
9052+
"resulting_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
90539053
}
90549054
] /* steps */
90559055
} /* condition_processing */
@@ -9113,13 +9113,13 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
91139113
{
91149114
"rows_to_scan": 4,
91159115
"access_type": "scan",
9116-
"resulting_rows": 1,
9116+
"resulting_rows": 4,
91179117
"cost": 0.9017,
91189118
"chosen": true
91199119
}
91209120
] /* considered_access_paths */
91219121
} /* best_access_path */,
9122-
"condition_filtering_pct": 100,
9122+
"condition_filtering_pct": 25,
91239123
"rows_for_plan": 1,
91249124
"cost_for_plan": 0.9017,
91259125
"semijoin_strategy_choice": [
@@ -9234,7 +9234,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
92349234
},
92359235
{
92369236
"attaching_conditions_to_tables": {
9237-
"original_condition": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))",
9237+
"original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
92389238
"attached_conditions_computation": [
92399239
] /* attached_conditions_computation */,
92409240
"attached_conditions_summary": [
@@ -9244,7 +9244,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
92449244
},
92459245
{
92469246
"table": "`t2`",
9247-
"attached": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))"
9247+
"attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
92489248
}
92499249
] /* attached_conditions_summary */
92509250
} /* attaching_conditions_to_tables */
@@ -11035,15 +11035,15 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1103511035
"steps": [
1103611036
{
1103711037
"transformation": "equality_propagation",
11038-
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and multiple equal(`f1`(), `t6`.`d`))"
11038+
"resulting_condition": "(1 and (`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
1103911039
},
1104011040
{
1104111041
"transformation": "constant_propagation",
11042-
"resulting_condition": "(1 and (`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
11042+
"resulting_condition": "(1 and (`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1104311043
},
1104411044
{
1104511045
"transformation": "trivial_condition_removal",
11046-
"resulting_condition": "((`t2`.`s` = 'c') and multiple equal(`f1`(), `t6`.`d`))"
11046+
"resulting_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1104711047
}
1104811048
] /* steps */
1104911049
} /* condition_processing */
@@ -11137,13 +11137,13 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1113711137
{
1113811138
"rows_to_scan": 4,
1113911139
"access_type": "scan",
11140-
"resulting_rows": 1,
11140+
"resulting_rows": 4,
1114111141
"cost": 0.9017,
1114211142
"chosen": true
1114311143
}
1114411144
] /* considered_access_paths */
1114511145
} /* best_access_path */,
11146-
"condition_filtering_pct": 100,
11146+
"condition_filtering_pct": 25,
1114711147
"rows_for_plan": 1,
1114811148
"cost_for_plan": 0.9017,
1114911149
"semijoin_strategy_choice": [
@@ -11269,7 +11269,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1126911269
},
1127011270
{
1127111271
"attaching_conditions_to_tables": {
11272-
"original_condition": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))",
11272+
"original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
1127311273
"attached_conditions_computation": [
1127411274
] /* attached_conditions_computation */,
1127511275
"attached_conditions_summary": [
@@ -11279,7 +11279,7 @@ select d into res from t6 where d in (select f1() from t2 where s=arg) {
1127911279
},
1128011280
{
1128111281
"table": "`t2`",
11282-
"attached": "((`t6`.`d` = `f1`()) and (`t2`.`s` = 'c'))"
11282+
"attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
1128311283
}
1128411284
] /* attached_conditions_summary */
1128511285
} /* attaching_conditions_to_tables */

sql/item_func.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9104,6 +9104,23 @@ void Item_func_sp::update_used_tables()
91049104
with_stored_program= true;
91059105
}
91069106

9107+
void Item_func_sp::fix_after_pullout(SELECT_LEX *parent_select,
9108+
SELECT_LEX *removed_select)
9109+
{
9110+
Item_func::fix_after_pullout(parent_select, removed_select);
9111+
9112+
/*
9113+
Prevents function from being evaluated before it is locked.
9114+
@todo - make this dependent on READS SQL or MODIFIES SQL.
9115+
Due to a limitation in how functions are evaluated, we need to
9116+
ensure that we are in a prelocked mode even though the function
9117+
doesn't reference any tables.
9118+
*/
9119+
used_tables_cache|= PARAM_TABLE_BIT;
9120+
9121+
const_item_cache= used_tables_cache == 0;
9122+
}
9123+
91079124

91089125
/*
91099126
uuid_short handling.

sql/item_func.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3353,7 +3353,8 @@ class Item_func_sp final : public Item_func
33533353
*/
33543354
table_map get_initial_pseudo_tables() const override;
33553355
void update_used_tables() override;
3356-
3356+
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select)
3357+
override;
33573358
void cleanup() override;
33583359

33593360
const char *func_name() const override;

0 commit comments

Comments
 (0)