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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
54c7afd2
Commit
54c7afd2
authored
Dec 19, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Item_in_optimizer is changed to be used with row IN subselect (SCRUM)
removed unused items
parent
4cfb6d97
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
159 deletions
+46
-159
sql/item.cc
sql/item.cc
+0
-31
sql/item.h
sql/item.h
+0
-72
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+36
-42
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+7
-12
sql/item_subselect.cc
sql/item_subselect.cc
+3
-2
No files found.
sql/item.cc
View file @
54c7afd2
...
...
@@ -47,11 +47,6 @@ Item::Item():
loop_id
=
0
;
}
Item_ref_in_optimizer
::
Item_ref_in_optimizer
(
Item_in_optimizer
*
master
,
char
*
table_name_par
,
char
*
field_name_par
)
:
Item_ref
(
master
->
args
,
table_name_par
,
field_name_par
),
owner
(
master
)
{}
bool
Item
::
check_loop
(
uint
id
)
{
...
...
@@ -437,20 +432,6 @@ String *Item_copy_string::val_str(String *str)
return
&
str_value
;
}
double
Item_ref_in_optimizer
::
val
()
{
return
owner
->
get_cache
();
}
longlong
Item_ref_in_optimizer
::
val_int
()
{
return
owner
->
get_cache_int
();
}
String
*
Item_ref_in_optimizer
::
val_str
(
String
*
s
)
{
return
owner
->
get_cache_str
(
s
);
}
/*
Functions to convert item to field (for send_fields)
*/
...
...
@@ -464,18 +445,6 @@ bool Item::fix_fields(THD *thd,
return
0
;
}
bool
Item_outer_select_context_saver
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
list
,
Item
**
ref
)
{
DBUG_ENTER
(
"Item_outer_select_context_saver::fix_fields"
);
bool
res
=
item
->
fix_fields
(
thd
,
0
,
// do not show current subselect fields
&
item
);
*
ref
=
item
;
DBUG_RETURN
(
res
);
}
bool
Item_asterisk_remover
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
list
,
Item
**
ref
)
...
...
sql/item.h
View file @
54c7afd2
...
...
@@ -109,60 +109,6 @@ class Item {
};
/*
Wrapper base class
*/
class
Item_wrapper
:
public
Item
{
protected:
Item
*
item
;
public:
/*
Following methods should not be used, because fix_fields exclude this
item (it assign '*ref' with field 'item' in derived classes)
*/
enum
Type
type
()
const
{
return
item
->
type
();
}
enum_field_types
field_type
()
const
{
return
item
->
field_type
();
}
double
val
()
{
return
item
->
val
();
}
longlong
val_int
()
{
return
item
->
val_int
();
}
String
*
val_str
(
String
*
s
)
{
return
item
->
val_str
(
s
);
}
bool
check_cols
(
uint
col
)
{
return
item
->
check_cols
(
col
);
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
{
return
item
->
eq
(
item
,
binary_cmp
);
}
bool
is_null
()
{
item
->
val_int
();
return
item
->
null_value
;
}
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
)
{
return
(
null_value
=
item
->
get_date
(
ltime
,
fuzzydate
));
}
bool
send
(
Protocol
*
prot
,
String
*
tmp
)
{
return
item
->
send
(
prot
,
tmp
);
}
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
return
item
->
save_in_field
(
field
,
no_conversions
);
}
void
save_org_in_field
(
Field
*
field
)
{
item
->
save_org_in_field
(
field
);
}
enum
Item_result
result_type
()
const
{
return
item
->
result_type
();
}
table_map
used_tables
()
const
{
return
item
->
used_tables
();
}
};
/*
Save context of name resolution for Item, used in subselect transformer.
*/
class
Item_outer_select_context_saver
:
public
Item_wrapper
{
public:
Item_outer_select_context_saver
(
Item
*
it
)
{
item
=
it
;
}
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
ref
);
};
class
st_select_lex
;
class
Item_ident
:
public
Item
{
...
...
@@ -579,24 +525,6 @@ class Item_asterisk_remover :public Item_ref_null_helper
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
ref
);
};
class
Item_in_optimizer
;
class
Item_ref_in_optimizer
:
public
Item_ref
{
protected:
Item_in_optimizer
*
owner
;
public:
Item_ref_in_optimizer
(
Item_in_optimizer
*
master
,
char
*
table_name_par
,
char
*
field_name_par
);
double
val
();
longlong
val_int
();
String
*
val_str
(
String
*
s
);
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
ref
)
{
fixed
=
1
;
return
0
;
}
};
/*
The following class is used to optimize comparing of date columns
We need to save the original item, to be able to set the field to the
...
...
sql/item_cmpfunc.cc
View file @
54c7afd2
...
...
@@ -274,60 +274,54 @@ int Arg_comparator::compare_e_row()
return
1
;
}
longlong
Item_in_optimizer
::
val_int
()
bool
Item_in_optimizer
::
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tables
,
Item
**
ref
)
{
int_cache_ok
=
1
;
flt_cache_ok
=
0
;
str_cache_ok
=
0
;
int_cache
=
args
[
0
]
->
val_int_result
();
if
(
args
[
0
]
->
null_value
)
{
null_value
=
1
;
return
0
;
}
longlong
tmp
=
args
[
1
]
->
val_int_result
();
null_value
=
args
[
1
]
->
null_value
;
return
tmp
;
}
longlong
Item_in_optimizer
::
get_cache_int
()
{
if
(
!
int_cache_ok
)
if
(
args
[
0
]
->
check_cols
(
allowed_arg_cols
)
||
args
[
0
]
->
fix_fields
(
thd
,
tables
,
args
))
return
1
;
if
(
args
[
0
]
->
maybe_null
)
maybe_null
=
1
;
if
(
args
[
0
]
->
binary
())
set_charset
(
my_charset_bin
);
with_sum_func
=
args
[
0
]
->
with_sum_func
;
used_tables_cache
=
args
[
0
]
->
used_tables
();
const_item_cache
=
args
[
0
]
->
const_item
();
if
(
!
(
cache
=
Item_cache
::
get_cache
(
args
[
0
]
->
result_type
())))
{
int_cache_ok
=
1
;
flt_cache_ok
=
0
;
str_cache_ok
=
0
;
int_cache
=
args
[
0
]
->
val_int_result
();
null_value
=
args
[
0
]
->
null_value
;
my_message
(
ER_OUT_OF_RESOURCES
,
ER
(
ER_OUT_OF_RESOURCES
),
MYF
(
0
));
thd
->
fatal_error
=
1
;
return
1
;
}
return
int_cache
;
if
(
args
[
1
]
->
check_cols
(
allowed_arg_cols
)
||
args
[
1
]
->
fix_fields
(
thd
,
tables
,
args
))
return
1
;
if
(
args
[
1
]
->
maybe_null
)
maybe_null
=
1
;
with_sum_func
=
with_sum_func
||
args
[
1
]
->
with_sum_func
;
used_tables_cache
|=
args
[
1
]
->
used_tables
();
const_item_cache
&=
args
[
1
]
->
const_item
();
return
0
;
}
double
Item_in_optimizer
::
get_cache
()
longlong
Item_in_optimizer
::
val_int
()
{
if
(
!
flt_cache_ok
)
cache
->
store
(
args
[
0
]);
if
(
cache
->
null_value
)
{
flt_cache_ok
=
1
;
int_cache_ok
=
0
;
str_cache_ok
=
0
;
flt_cache
=
args
[
0
]
->
val_result
();
null_value
=
args
[
0
]
->
null_value
;
null_value
=
1
;
return
0
;
}
return
flt_cache
;
longlong
tmp
=
args
[
1
]
->
val_int_result
();
null_value
=
args
[
1
]
->
null_value
;
return
tmp
;
}
String
*
Item_in_optimizer
::
get_cache_str
(
String
*
s
)
bool
Item_in_optimizer
::
is_null
(
)
{
if
(
!
str_cache_ok
)
{
str_cache_ok
=
1
;
int_cache_ok
=
0
;
flt_cache_ok
=
0
;
str_value
.
set
(
buffer
,
sizeof
(
buffer
),
s
->
charset
());
str_cache
=
args
[
0
]
->
str_result
(
&
str_value
);
null_value
=
args
[
0
]
->
null_value
;
}
return
str_cache
;
cache
->
store
(
args
[
0
]);
return
(
null_value
=
(
cache
->
null_value
||
args
[
1
]
->
is_null
()));
}
longlong
Item_func_eq
::
val_int
()
...
...
sql/item_cmpfunc.h
View file @
54c7afd2
...
...
@@ -85,25 +85,20 @@ class Item_bool_func :public Item_int_func
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
1
;
}
};
class
Item_cache
;
class
Item_in_optimizer
:
public
Item_bool_func
{
protected:
char
buffer
[
80
];
longlong
int_cache
;
double
flt_cache
;
String
*
str_cache
;
bool
int_cache_ok
,
flt_cache_ok
,
str_cache_ok
;
Item_cache
*
cache
;
public:
Item_in_optimizer
(
Item
*
a
,
Item
*
b
)
:
Item_bool_func
(
a
,
b
),
int_cache_ok
(
0
),
flt_cache_ok
(
0
),
str_cache_ok
(
0
)
{}
bool
is_null
()
{
return
test
(
args
[
0
]
->
is_null
()
||
args
[
1
]
->
is_null
());
}
Item_bool_func
(
a
,
b
),
cache
(
0
)
{}
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
is_null
();
longlong
val_int
();
double
get_cache
();
longlong
get_cache_int
();
String
*
get_cache_str
(
String
*
s
);
Item
**
get_cache
()
{
return
(
Item
**
)
&
cache
;
}
friend
class
Item_ref_in_optimizer
;
};
class
Item_bool_func2
:
public
Item_int_func
...
...
sql/item_subselect.cc
View file @
54c7afd2
...
...
@@ -409,7 +409,8 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex,
As far as Item_ref_in_optimizer do not substitude itself on fix_fields
we can use same item for all selects.
*/
Item
*
expr
=
new
Item_ref_in_optimizer
(
optimizer
,
(
char
*
)
"<no matter>"
,
Item
*
expr
=
new
Item_ref
(
optimizer
->
get_cache
(),
(
char
*
)
"<no matter>"
,
(
char
*
)
"<left expr>"
);
select_lex
->
master_unit
()
->
dependent
=
1
;
for
(
SELECT_LEX
*
sl
=
select_lex
;
sl
;
sl
=
sl
->
next_select
())
...
...
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