Skip to content

Commit d378a46

Browse files
montywicvicentiu
authored andcommitted
Change Item_true and Item_false to pointers
This is a prerequisite for moving them to a readonly segment.
1 parent b32b1f2 commit d378a46

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

sql/item.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const char *item_empty_name="";
5555
const char *item_used_name= "\0";
5656

5757
static int save_field_in_field(Field *, bool *, Field *, bool);
58-
const Item_bool_static Item_false("FALSE", 0);
59-
const Item_bool_static Item_true("TRUE", 1);
58+
Item_bool_static *Item_false;
59+
Item_bool_static *Item_true;
6060

6161
/**
6262
Compare two Items for List<Item>::add_unique()
@@ -445,7 +445,7 @@ Item::Item(THD *thd):
445445
Item::Item():
446446
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
447447
{
448-
DBUG_ASSERT(my_progname == NULL); // before main()
448+
DBUG_ASSERT(!mysqld_server_started); // Created early
449449
base_flags= item_base_t::FIXED;
450450
with_flags= item_with_t::NONE;
451451
null_value= 0;

sql/item.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4424,7 +4424,8 @@ class Item_bool_static :public Item_bool
44244424
{ DBUG_ASSERT(0); }
44254425
};
44264426

4427-
extern const Item_bool_static Item_false, Item_true;
4427+
/* The following variablese are stored in a read only segment */
4428+
extern Item_bool_static *Item_false, *Item_true;
44284429

44294430
class Item_uint :public Item_int
44304431
{

sql/item_xmlfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,13 +1232,13 @@ my_xpath_keyword(MY_XPATH *x,
12321232

12331233
static Item *create_func_true(MY_XPATH *xpath, Item **args, uint nargs)
12341234
{
1235-
return (Item*) &Item_true;
1235+
return (Item*) Item_true;
12361236
}
12371237

12381238

12391239
static Item *create_func_false(MY_XPATH *xpath, Item **args, uint nargs)
12401240
{
1241-
return (Item*) &Item_false;
1241+
return (Item*) Item_false;
12421242
}
12431243

12441244

sql/mysqld.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5368,6 +5368,9 @@ static int init_server_components()
53685368
if (!opt_bootstrap)
53695369
servers_init(0);
53705370
init_status_vars();
5371+
Item_false= new (&startup_root) Item_bool_static("FALSE", 0);
5372+
Item_true= new (&startup_root) Item_bool_static("TRUE", 1);
5373+
53715374
DBUG_RETURN(0);
53725375
}
53735376

sql/sql_base.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7427,7 +7427,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
74277427
/* Add a TRUE condition to outer joins that have no common columns. */
74287428
if (table_ref_2->outer_join &&
74297429
!table_ref_1->on_expr && !table_ref_2->on_expr)
7430-
table_ref_2->on_expr= (Item*) &Item_true;
7430+
table_ref_2->on_expr= (Item*) Item_true;
74317431

74327432
/* Change this table reference to become a leaf for name resolution. */
74337433
if (left_neighbor)

sql/sql_select.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ int JOIN::optimize_stage2()
25602560
if (!conds && outer_join)
25612561
{
25622562
/* Handle the case where we have an OUTER JOIN without a WHERE */
2563-
conds= (Item*) &Item_true;
2563+
conds= (Item*) Item_true;
25642564
}
25652565

25662566
if (impossible_where)
@@ -2730,9 +2730,7 @@ int JOIN::optimize_stage2()
27302730

27312731
if (conds && const_table_map != found_const_table_map &&
27322732
(select_options & SELECT_DESCRIBE))
2733-
{
2734-
conds= (Item*) &Item_false;
2735-
}
2733+
conds= (Item*) Item_false;
27362734

27372735
/* Cache constant expressions in WHERE, HAVING, ON clauses. */
27382736
cache_const_exprs();
@@ -3049,7 +3047,7 @@ int JOIN::optimize_stage2()
30493047
having= having->remove_eq_conds(thd, &select_lex->having_value, true);
30503048
if (select_lex->having_value == Item::COND_FALSE)
30513049
{
3052-
having= (Item*) &Item_false;
3050+
having= (Item*) Item_false;
30533051
zero_result_cause= "Impossible HAVING noticed after reading const tables";
30543052
error= 0;
30553053
select_lex->mark_const_derived(zero_result_cause);
@@ -5625,7 +5623,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
56255623
if (join->cond_value == Item::COND_FALSE)
56265624
{
56275625
join->impossible_where= true;
5628-
conds= (Item*) &Item_false;
5626+
conds= (Item*) Item_false;
56295627
}
56305628

56315629
join->cond_equal= NULL;
@@ -11872,7 +11870,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
1187211870
below to check if we should use 'quick' instead.
1187311871
*/
1187411872
DBUG_PRINT("info", ("Item_int"));
11875-
tmp= (Item*) &Item_true;
11873+
tmp= (Item*) Item_true;
1187611874
}
1187711875

1187811876
}
@@ -15455,7 +15453,7 @@ COND *Item_cond_and::build_equal_items(THD *thd,
1545515453
if (!cond_args->elements &&
1545615454
!cond_equal.current_level.elements &&
1545715455
!eq_list.elements)
15458-
return (Item*) &Item_true;
15456+
return (Item*) Item_true;
1545915457

1546015458
List_iterator_fast<Item_equal> it(cond_equal.current_level);
1546115459
while ((item_equal= it++))
@@ -15562,7 +15560,7 @@ COND *Item_func_eq::build_equal_items(THD *thd,
1556215560
Item_equal *item_equal;
1556315561
int n= cond_equal.current_level.elements + eq_list.elements;
1556415562
if (n == 0)
15565-
return (Item*) &Item_true;
15563+
return (Item*) Item_true;
1556615564
else if (n == 1)
1556715565
{
1556815566
if ((item_equal= cond_equal.current_level.pop()))
@@ -15966,7 +15964,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
1596615964
List<Item> eq_list;
1596715965
Item_func_eq *eq_item= 0;
1596815966
if (((Item *) item_equal)->const_item() && !item_equal->val_int())
15969-
return (Item*) &Item_false;
15967+
return (Item*) Item_false;
1597015968
Item *item_const= item_equal->get_const();
1597115969
Item_equal_fields_iterator it(*item_equal);
1597215970
Item *head;
@@ -16111,7 +16109,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
1611116109
switch (eq_list.elements)
1611216110
{
1611316111
case 0:
16114-
res= cond ? cond : (Item*) &Item_true;
16112+
res= cond ? cond : (Item*) Item_true;
1611516113
break;
1611616114
case 1:
1611716115
if (!cond || cond->is_bool_literal())
@@ -17949,7 +17947,7 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
1794917947

1795017948
*/
1795117949

17952-
Item *item0= (Item*) &Item_false;
17950+
Item *item0= (Item*) Item_false;
1795317951
Item *eq_cond= new(thd->mem_root) Item_func_eq(thd, args[0], item0);
1795417952
if (!eq_cond)
1795517953
return this;
@@ -29630,7 +29628,7 @@ void JOIN::make_notnull_conds_for_range_scans()
2963029628
Found a IS NULL conjunctive predicate for a null-rejected field
2963129629
in the WHERE clause
2963229630
*/
29633-
conds= (Item*) &Item_false;
29631+
conds= (Item*) Item_false;
2963429632
cond_equal= 0;
2963529633
impossible_where= true;
2963629634
DBUG_VOID_RETURN;
@@ -29653,7 +29651,7 @@ void JOIN::make_notnull_conds_for_range_scans()
2965329651
Found a IS NULL conjunctive predicate for a null-rejected field
2965429652
of the inner table of an outer join with ON expression tbl->on_expr
2965529653
*/
29656-
tbl->on_expr= (Item*) &Item_false;
29654+
tbl->on_expr= (Item*) Item_false;
2965729655
}
2965829656
}
2965929657
}
@@ -29804,7 +29802,7 @@ void build_notnull_conds_for_inner_nest_of_outer_join(JOIN *join,
2980429802
if (used_tables &&
2980529803
build_notnull_conds_for_range_scans(join, nest_tbl->on_expr, used_tables))
2980629804
{
29807-
nest_tbl->on_expr= (Item*) &Item_false;
29805+
nest_tbl->on_expr= (Item*) Item_false;
2980829806
}
2980929807

2981029808
li.rewind();
@@ -29818,7 +29816,7 @@ void build_notnull_conds_for_inner_nest_of_outer_join(JOIN *join,
2981829816
}
2981929817
else if (build_notnull_conds_for_range_scans(join, tbl->on_expr,
2982029818
tbl->table->map))
29821-
tbl->on_expr= (Item*) &Item_false;
29819+
tbl->on_expr= (Item*) Item_false;
2982229820
}
2982329821
}
2982429822
}

0 commit comments

Comments
 (0)