Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
703e396b
Commit
703e396b
authored
Oct 10, 2004
by
konstantin@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A small simplification: perform two actions at once, register a
change, and perform it (the new Item changes registry).
parent
e08febea
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
41 deletions
+31
-41
sql/item.cc
sql/item.cc
+10
-15
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+3
-6
sql/item_func.cc
sql/item_func.cc
+2
-2
sql/item_row.cc
sql/item_row.cc
+2
-2
sql/item_strfunc.cc
sql/item_strfunc.cc
+4
-4
sql/sql_class.h
sql/sql_class.h
+5
-4
sql/sql_select.cc
sql/sql_select.cc
+5
-8
No files found.
sql/item.cc
View file @
703e396b
...
@@ -1332,13 +1332,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -1332,13 +1332,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return
-
1
;
return
-
1
;
}
}
Item_ref
*
rf
;
Item_ref
*
rf
=
new
Item_ref
(
last
->
ref_pointer_array
+
counter
,
*
ref
=
rf
=
new
Item_ref
(
last
->
ref_pointer_array
+
counter
,
(
char
*
)
table_name
,
(
char
*
)
field_name
);
(
char
*
)
table_name
,
(
char
*
)
field_name
);
thd
->
register_item_tree_change
(
ref
,
this
,
&
thd
->
mem_root
);
if
(
!
rf
)
if
(
!
rf
)
return
1
;
return
1
;
thd
->
change_item_tree
(
ref
,
rf
);
/*
/*
rf is Item_ref => never substitute other items (in this case)
rf is Item_ref => never substitute other items (in this case)
during fix_fields() => we can use rf after fix_fields()
during fix_fields() => we can use rf after fix_fields()
...
@@ -1355,11 +1353,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -1355,11 +1353,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if
(
last
->
having_fix_field
)
if
(
last
->
having_fix_field
)
{
{
Item_ref
*
rf
;
Item_ref
*
rf
;
thd
->
register_item_tree_change
(
ref
,
*
ref
,
&
thd
->
mem_root
);
rf
=
new
Item_ref
((
where
->
db
[
0
]
?
where
->
db
:
0
),
*
ref
=
rf
=
new
Item_ref
((
where
->
db
[
0
]
?
where
->
db
:
0
),
(
char
*
)
where
->
alias
,
(
char
*
)
field_name
);
(
char
*
)
where
->
alias
,
(
char
*
)
field_name
);
if
(
!
rf
)
if
(
!
rf
)
return
1
;
return
1
;
thd
->
change_item_tree
(
ref
,
rf
);
/*
/*
rf is Item_ref => never substitute other items (in this case)
rf is Item_ref => never substitute other items (in this case)
during fix_fields() => we can use rf after fix_fields()
during fix_fields() => we can use rf after fix_fields()
...
@@ -1992,10 +1990,10 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
...
@@ -1992,10 +1990,10 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
else
if
(
tmp
!=
not_found_field
)
else
if
(
tmp
!=
not_found_field
)
{
{
ref
=
0
;
// To prevent "delete *ref;" on ~Item_ref() of this item
ref
=
0
;
// To prevent "delete *ref;" on ~Item_ref() of this item
Item_field
*
fld
;
Item_field
*
fld
=
new
Item_field
(
tmp
)
;
if
(
!
((
*
reference
)
=
fld
=
new
Item_field
(
tmp
))
)
if
(
!
fld
)
return
1
;
return
1
;
thd
->
register_item_tree_change
(
reference
,
this
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
reference
,
fld
);
mark_as_dependent
(
thd
,
last
,
thd
->
lex
->
current_select
,
fld
);
mark_as_dependent
(
thd
,
last
,
thd
->
lex
->
current_select
,
fld
);
return
0
;
return
0
;
}
}
...
@@ -2250,10 +2248,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
...
@@ -2250,10 +2248,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
new
Item_real
(
name
,
result
,
decimals
,
length
));
new
Item_real
(
name
,
result
,
decimals
,
length
));
}
}
if
(
new_item
)
if
(
new_item
)
{
thd
->
change_item_tree
(
ref
,
new_item
);
thd
->
register_item_tree_change
(
ref
,
item
,
&
thd
->
mem_root
);
*
ref
=
new_item
;
}
}
}
/*
/*
...
...
sql/item_cmpfunc.cc
View file @
703e396b
...
@@ -153,10 +153,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
...
@@ -153,10 +153,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
{
{
Item
*
tmp
=
new
Item_int_with_ref
(
field
->
val_int
(),
*
item
);
Item
*
tmp
=
new
Item_int_with_ref
(
field
->
val_int
(),
*
item
);
if
(
tmp
)
if
(
tmp
)
{
thd
->
change_item_tree
(
item
,
tmp
);
thd
->
register_item_tree_change
(
item
,
*
item
,
&
thd
->
mem_root
);
*
item
=
tmp
;
}
return
1
;
// Item was replaced
return
1
;
// Item was replaced
}
}
}
}
...
@@ -2033,10 +2030,10 @@ void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
...
@@ -2033,10 +2030,10 @@ void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
{
{
Item
**
ref
=
li
.
ref
();
Item
**
ref
=
li
.
ref
();
uint
el
=
fields
.
elements
;
uint
el
=
fields
.
elements
;
Item
*
new_item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
fields
.
push_front
(
item
);
fields
.
push_front
(
item
);
ref_pointer_array
[
el
]
=
item
;
ref_pointer_array
[
el
]
=
item
;
thd
->
register_item_tree_change
(
ref
,
*
ref
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
ref
,
new_item
);
li
.
replace
(
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
));
}
}
item
->
update_used_tables
();
item
->
update_used_tables
();
used_tables_cache
|=
item
->
used_tables
();
used_tables_cache
|=
item
->
used_tables
();
...
...
sql/item_func.cc
View file @
703e396b
...
@@ -269,10 +269,10 @@ void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
...
@@ -269,10 +269,10 @@ void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
{
uint
el
=
fields
.
elements
;
uint
el
=
fields
.
elements
;
Item
*
new_item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
fields
.
push_front
(
item
);
fields
.
push_front
(
item
);
ref_pointer_array
[
el
]
=
item
;
ref_pointer_array
[
el
]
=
item
;
thd
->
register_item_tree_change
(
arg
,
*
arg
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
arg
,
new_item
);
*
arg
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
}
}
}
}
}
}
...
...
sql/item_row.cc
View file @
703e396b
...
@@ -95,10 +95,10 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
...
@@ -95,10 +95,10 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
else
if
((
*
arg
)
->
used_tables
()
||
(
*
arg
)
->
type
()
==
SUM_FUNC_ITEM
)
else
if
((
*
arg
)
->
used_tables
()
||
(
*
arg
)
->
type
()
==
SUM_FUNC_ITEM
)
{
{
uint
el
=
fields
.
elements
;
uint
el
=
fields
.
elements
;
Item
*
new_item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
(
*
arg
)
->
name
);
fields
.
push_front
(
*
arg
);
fields
.
push_front
(
*
arg
);
ref_pointer_array
[
el
]
=
*
arg
;
ref_pointer_array
[
el
]
=
*
arg
;
thd
->
register_item_tree_change
(
arg
,
*
arg
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
arg
,
new_item
);
*
arg
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
(
*
arg
)
->
name
);
}
}
}
}
}
}
...
...
sql/item_strfunc.cc
View file @
703e396b
...
@@ -643,10 +643,10 @@ void Item_func_concat_ws::split_sum_func(THD *thd, Item **ref_pointer_array,
...
@@ -643,10 +643,10 @@ void Item_func_concat_ws::split_sum_func(THD *thd, Item **ref_pointer_array,
else
if
(
separator
->
used_tables
()
||
separator
->
type
()
==
SUM_FUNC_ITEM
)
else
if
(
separator
->
used_tables
()
||
separator
->
type
()
==
SUM_FUNC_ITEM
)
{
{
uint
el
=
fields
.
elements
;
uint
el
=
fields
.
elements
;
Item
*
new_item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
separator
->
name
);
fields
.
push_front
(
separator
);
fields
.
push_front
(
separator
);
ref_pointer_array
[
el
]
=
separator
;
ref_pointer_array
[
el
]
=
separator
;
thd
->
register_item_tree_change
(
&
separator
,
separator
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
&
separator
,
new_item
);
separator
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
separator
->
name
);
}
}
Item_str_func
::
split_sum_func
(
thd
,
ref_pointer_array
,
fields
);
Item_str_func
::
split_sum_func
(
thd
,
ref_pointer_array
,
fields
);
}
}
...
@@ -1779,10 +1779,10 @@ void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
...
@@ -1779,10 +1779,10 @@ void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
{
uint
el
=
fields
.
elements
;
uint
el
=
fields
.
elements
;
Item
*
new_item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
fields
.
push_front
(
item
);
fields
.
push_front
(
item
);
ref_pointer_array
[
el
]
=
item
;
ref_pointer_array
[
el
]
=
item
;
thd
->
register_item_tree_change
(
&
item
,
item
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
&
item
,
new_item
);
item
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
item
->
name
);
}
}
Item_str_func
::
split_sum_func
(
thd
,
ref_pointer_array
,
fields
);
Item_str_func
::
split_sum_func
(
thd
,
ref_pointer_array
,
fields
);
}
}
...
...
sql/sql_class.h
View file @
703e396b
...
@@ -1054,14 +1054,15 @@ public:
...
@@ -1054,14 +1054,15 @@ public:
inline
CHARSET_INFO
*
charset
()
{
return
variables
.
character_set_client
;
}
inline
CHARSET_INFO
*
charset
()
{
return
variables
.
character_set_client
;
}
void
update_charset
();
void
update_charset
();
void
register_item_tree_change
(
Item
**
place
,
Item
*
old_value
,
void
change_item_tree
(
Item
**
place
,
Item
*
new_value
)
MEM_ROOT
*
runtime_memroot
)
{
{
/* TODO: check for OOM condition here */
if
(
!
current_arena
->
is_conventional_execution
())
if
(
!
current_arena
->
is_conventional_execution
())
nocheck_register_item_tree_change
(
place
,
old_value
,
runtime_memroot
);
nocheck_register_item_tree_change
(
place
,
*
place
,
&
mem_root
);
*
place
=
new_value
;
}
}
void
nocheck_register_item_tree_change
(
Item
**
place
,
Item
*
old_value
,
void
nocheck_register_item_tree_change
(
Item
**
place
,
Item
*
old_value
,
MEM_ROOT
*
runtime_memroot
);
MEM_ROOT
*
runtime_memroot
);
void
rollback_item_tree_changes
();
void
rollback_item_tree_changes
();
};
};
...
...
sql/sql_select.cc
View file @
703e396b
...
@@ -4203,8 +4203,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
...
@@ -4203,8 +4203,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
Item
*
tmp
=
value
->
new_item
();
Item
*
tmp
=
value
->
new_item
();
if
(
tmp
)
if
(
tmp
)
{
{
thd
->
register_item_tree_change
(
args
+
1
,
args
[
1
],
&
thd
->
mem_root
);
thd
->
change_item_tree
(
args
+
1
,
tmp
);
args
[
1
]
=
tmp
;
func
->
update_used_tables
();
func
->
update_used_tables
();
if
((
functype
==
Item_func
::
EQ_FUNC
||
functype
==
Item_func
::
EQUAL_FUNC
)
if
((
functype
==
Item_func
::
EQ_FUNC
||
functype
==
Item_func
::
EQUAL_FUNC
)
&&
and_father
!=
cond
&&
!
left_item
->
const_item
())
&&
and_father
!=
cond
&&
!
left_item
->
const_item
())
...
@@ -4225,15 +4224,14 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
...
@@ -4225,15 +4224,14 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
Item
*
tmp
=
value
->
new_item
();
Item
*
tmp
=
value
->
new_item
();
if
(
tmp
)
if
(
tmp
)
{
{
thd
->
register_item_tree_change
(
args
,
args
[
0
],
&
thd
->
mem_root
);
thd
->
change_item_tree
(
args
,
tmp
);
args
[
0
]
=
value
=
tmp
;
value
=
tmp
;
func
->
update_used_tables
();
func
->
update_used_tables
();
if
((
functype
==
Item_func
::
EQ_FUNC
||
functype
==
Item_func
::
EQUAL_FUNC
)
if
((
functype
==
Item_func
::
EQ_FUNC
||
functype
==
Item_func
::
EQUAL_FUNC
)
&&
and_father
!=
cond
&&
!
right_item
->
const_item
())
&&
and_father
!=
cond
&&
!
right_item
->
const_item
())
{
{
args
[
0
]
=
args
[
1
];
// For easy check
args
[
0
]
=
args
[
1
];
// For easy check
thd
->
register_item_tree_change
(
args
+
1
,
args
[
1
],
&
thd
->
mem_root
);
thd
->
change_item_tree
(
args
+
1
,
value
);
args
[
1
]
=
value
;
cond
->
marker
=
1
;
cond
->
marker
=
1
;
COND_CMP
*
tmp2
;
COND_CMP
*
tmp2
;
if
((
tmp2
=
new
COND_CMP
(
and_father
,
func
)))
if
((
tmp2
=
new
COND_CMP
(
and_father
,
func
)))
...
@@ -4959,8 +4957,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
...
@@ -4959,8 +4957,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
*
blob_field
++=
new_field
;
*
blob_field
++=
new_field
;
blob_count
++
;
blob_count
++
;
}
}
thd
->
register_item_tree_change
(
argp
,
arg
,
&
thd
->
mem_root
);
thd
->
change_item_tree
(
argp
,
new
Item_field
(
new_field
));
*
argp
=
new
Item_field
(
new_field
);
if
(
!
(
new_field
->
flags
&
NOT_NULL_FLAG
))
if
(
!
(
new_field
->
flags
&
NOT_NULL_FLAG
))
{
{
null_count
++
;
null_count
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment