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
37d228e6
Commit
37d228e6
authored
Jan 30, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes based on partial revie of task 577 (SCRUM)
parent
5ed5dac0
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
149 additions
and
116 deletions
+149
-116
sql/item.cc
sql/item.cc
+33
-19
sql/item.h
sql/item.h
+26
-15
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+3
-6
sql/item_func.cc
sql/item_func.cc
+2
-5
sql/item_func.h
sql/item_func.h
+1
-1
sql/item_sum.cc
sql/item_sum.cc
+5
-4
sql/item_sum.h
sql/item_sum.h
+62
-51
sql/item_uniq.h
sql/item_uniq.h
+6
-2
sql/sql_base.cc
sql/sql_base.cc
+1
-3
sql/sql_select.cc
sql/sql_select.cc
+10
-10
No files found.
sql/item.cc
View file @
37d228e6
...
...
@@ -37,16 +37,22 @@ void item_init(void)
Item
::
Item
()
:
fixed
(
0
)
{
marker
=
0
;
marker
=
0
;
maybe_null
=
null_value
=
with_sum_func
=
unsigned_flag
=
0
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
next
=
current_thd
->
free_list
;
// Put in free list
current_thd
->
free_list
=
this
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
THD
*
thd
=
current_thd
;
next
=
thd
->
free_list
;
// Put in free list
thd
->
free_list
=
this
;
loop_id
=
0
;
}
Item
::
Item
(
Item
&
item
)
:
/*
Constructor used by Item_field, Item_ref & agregate (sum) functions.
Used for duplicating lists in processing queries with temporary
tables
*/
Item
::
Item
(
THD
*
thd
,
Item
&
item
)
:
loop_id
(
0
),
str_value
(
item
.
str_value
),
name
(
item
.
name
),
...
...
@@ -59,12 +65,13 @@ Item::Item(Item &item):
with_sum_func
(
item
.
with_sum_func
),
fixed
(
item
.
fixed
)
{
next
=
current_
thd
->
free_list
;
// Put in free list
current_
thd
->
free_list
=
this
;
next
=
thd
->
free_list
;
// Put in free list
thd
->
free_list
=
this
;
}
Item_ident
::
Item_ident
(
Item_ident
&
item
)
:
Item
(
item
),
// Constructor used by Item_field & Item_ref (see Item comment)
Item_ident
::
Item_ident
(
THD
*
thd
,
Item_ident
&
item
)
:
Item
(
thd
,
item
),
db_name
(
item
.
db_name
),
table_name
(
item
.
table_name
),
field_name
(
item
.
field_name
),
...
...
@@ -165,8 +172,9 @@ Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
fixed
=
1
;
// This item is not needed in fix_fields
}
Item_field
::
Item_field
(
Item_field
&
item
)
:
Item_ident
(
item
),
// Constructor need to process subselect with temporary tables (see Item)
Item_field
::
Item_field
(
THD
*
thd
,
Item_field
&
item
)
:
Item_ident
(
thd
,
item
),
field
(
item
.
field
),
result_field
(
item
.
result_field
)
{}
...
...
@@ -281,9 +289,9 @@ table_map Item_field::used_tables() const
return
(
depended_from
?
RAND_TABLE_BIT
:
field
->
table
->
map
);
}
Item
*
Item_field
::
get_tmp_table_item
(
)
Item
*
Item_field
::
get_tmp_table_item
(
THD
*
thd
)
{
Item_field
*
new_item
=
new
Item_field
(
*
this
);
Item_field
*
new_item
=
new
Item_field
(
thd
,
*
this
);
if
(
new_item
)
new_item
->
field
=
new_item
->
result_field
;
return
new_item
;
...
...
@@ -617,7 +625,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
thd
->
net
.
last_errno
=
0
;
#endif
Item
**
refer
=
(
Item
**
)
not_found_item
;
uint
counter
=
0
;
uint
counter
;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX
*
cursel
=
(
SELECT_LEX
*
)
thd
->
lex
.
current_select
;
if
(
outer_resolving
||
...
...
@@ -658,19 +666,21 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
Item_ref
*
r
;
*
ref
=
r
=
new
Item_ref
(
last
->
ref_pointer_array
+
counter
-
1
*
ref
=
r
=
new
Item_ref
(
last
->
ref_pointer_array
+
counter
,
(
char
*
)
table_name
,
(
char
*
)
field_name
);
if
(
!
r
)
return
1
;
if
(
r
->
fix_fields
(
thd
,
tables
,
ref
)
||
r
->
check_cols
(
1
))
return
1
;
// store pointer on SELECT_LEX from wich item is dependent
r
->
depended_from
=
last
;
cursel
->
mark_as_dependent
(
last
);
return
0
;
}
else
{
// store pointer on SELECT_LEX from wich item is dependent
depended_from
=
last
;
/*
Mark all selects from resolved to 1 before select where was
...
...
@@ -1071,7 +1081,7 @@ bool Item_field::send(Protocol *protocol, String *buffer)
bool
Item_ref
::
fix_fields
(
THD
*
thd
,
TABLE_LIST
*
tables
,
Item
**
reference
)
{
uint
counter
=
0
;
uint
counter
;
if
(
!
ref
)
{
TABLE_LIST
*
where
=
0
;
...
...
@@ -1142,6 +1152,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
Item_field
*
f
;
if
(
!
((
*
reference
)
=
f
=
new
Item_field
(
tmp
)))
return
1
;
// store pointer on SELECT_LEX from wich item is dependent
f
->
depended_from
=
last
;
thd
->
lex
.
current_select
->
mark_as_dependent
(
last
);
return
0
;
...
...
@@ -1154,7 +1165,10 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
"forward reference in item list"
);
return
-
1
;
}
ref
=
(
depended_from
=
last
)
->
ref_pointer_array
+
counter
-
1
;
/*
depended_from: pointer on SELECT_LEX from wich item is dependent
*/
ref
=
(
depended_from
=
last
)
->
ref_pointer_array
+
counter
;
thd
->
lex
.
current_select
->
mark_as_dependent
(
last
);
}
}
...
...
@@ -1168,7 +1182,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
"forward reference in item list"
);
return
-
1
;
}
ref
=
thd
->
lex
.
current_select
->
ref_pointer_array
+
counter
-
1
;
ref
=
thd
->
lex
.
current_select
->
ref_pointer_array
+
counter
;
}
}
...
...
sql/item.h
View file @
37d228e6
...
...
@@ -53,8 +53,12 @@ class Item {
// alloc & destruct is done as start of select using sql_alloc
Item
();
// copy constructor used by Item_field, Item_ref & agregate (sum) functions
Item
(
Item
&
item
);
/*
Constructor used by Item_field, Item_ref & agregate (sum) functions.
Used for duplicating lists in processing queries with temporary
tables
*/
Item
(
THD
*
thd
,
Item
&
item
);
virtual
~
Item
()
{
name
=
0
;
}
/*lint -e1509 */
void
set_name
(
const
char
*
str
,
uint
length
=
0
);
void
init_make_field
(
Send_field
*
tmp_field
,
enum
enum_field_types
type
);
...
...
@@ -93,8 +97,8 @@ class Item {
virtual
bool
get_time
(
TIME
*
ltime
);
virtual
bool
is_null
()
{
return
0
;
};
virtual
void
top_level_item
()
{}
virtual
Item
*
get_same
(
)
{
return
this
;
}
virtual
Item
*
get_tmp_table_item
()
{
return
get_same
(
);
}
virtual
Item
*
copy_or_same
(
THD
*
thd
)
{
return
this
;
}
virtual
Item
*
get_tmp_table_item
(
THD
*
thd
)
{
return
copy_or_same
(
thd
);
}
virtual
bool
binary
()
const
{
return
str_value
.
charset
()
->
state
&
MY_CS_BINSORT
?
1
:
0
;
}
...
...
@@ -129,8 +133,8 @@ class Item_ident :public Item
:
db_name
(
db_name_par
),
table_name
(
table_name_par
),
field_name
(
field_name_par
),
depended_from
(
0
),
outer_resolving
(
0
)
{
name
=
(
char
*
)
field_name_par
;
}
//
copy constructor used by Item_field & Item_ref
Item_ident
(
Item_ident
&
item
);
//
Constructor used by Item_field & Item_ref (see Item comment)
Item_ident
(
THD
*
thd
,
Item_ident
&
item
);
const
char
*
full_name
()
const
;
void
set_outer_resolving
()
{
outer_resolving
=
1
;
}
};
...
...
@@ -147,8 +151,8 @@ class Item_field :public Item_ident
const
char
*
field_name_par
)
:
Item_ident
(
db_par
,
table_name_par
,
field_name_par
),
field
(
0
),
result_field
(
0
)
{}
//
copy constructor need to process subselect with temporary tables
Item_field
(
Item_field
&
item
);
//
Constructor need to process subselect with temporary tables (see Item)
Item_field
(
THD
*
thd
,
Item_field
&
item
);
Item_field
(
Field
*
field
);
enum
Type
type
()
const
{
return
FIELD_ITEM
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
...
...
@@ -177,7 +181,7 @@ class Item_field :public Item_ident
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
);
bool
get_time
(
TIME
*
ltime
);
bool
is_null
()
{
return
field
->
is_null
();
}
Item
*
get_tmp_table_item
(
);
Item
*
get_tmp_table_item
(
THD
*
thd
);
friend
class
Item_default_value
;
};
...
...
@@ -437,10 +441,10 @@ class Item_result_field :public Item /* Item with result field */
public:
Field
*
result_field
;
/* Save result here */
Item_result_field
()
:
result_field
(
0
)
{}
Item_result_field
(
Item_result_field
&
item
)
:
Item
(
item
)
{
result_field
=
item
.
result_field
;
}
// Constructor used for Item_sum (see Item comment
)
Item_result_field
(
THD
*
thd
,
Item_result_field
&
item
)
:
Item
(
thd
,
item
),
result_field
(
item
.
result_field
)
{
}
~
Item_result_field
()
{}
/* Required with gcc 2.95 */
Field
*
tmp_table_field
()
{
return
result_field
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
)
{
return
result_field
;
}
...
...
@@ -457,8 +461,9 @@ class Item_ref :public Item_ident
:
Item_ident
(
db_par
,
table_name_par
,
field_name_par
),
ref
(
0
)
{}
Item_ref
(
Item
**
item
,
char
*
table_name_par
,
char
*
field_name_par
)
:
Item_ident
(
NullS
,
table_name_par
,
field_name_par
),
ref
(
item
)
{}
// copy constructor need to process subselect with temporary tables
Item_ref
(
Item_ref
&
item
)
:
Item_ident
(
item
),
ref
(
item
.
ref
)
{}
// Constructor need to process subselect with temporary tables (see Item)
Item_ref
(
THD
*
thd
,
Item_ref
&
item
)
:
Item_ident
(
thd
,
item
),
ref
(
item
.
ref
)
{}
enum
Type
type
()
const
{
return
REF_ITEM
;
}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
{
return
ref
&&
(
*
ref
)
->
eq
(
item
,
binary_cmp
);
}
...
...
@@ -527,6 +532,12 @@ class Item_ref_null_helper: public Item_ref
class
Item_ref_on_list_position
:
public
Item_ref_null_helper
{
protected:
/*
select_lex used for:
1) receiving expanded variant of item list (to check max possible
nunber of elements);
2) to have access to ref_pointer_array, via wich item will refered.
*/
st_select_lex
*
select_lex
;
uint
pos
;
public:
...
...
sql/item_cmpfunc.cc
View file @
37d228e6
...
...
@@ -1063,7 +1063,8 @@ int in_vector::find(Item *item)
}
in_string
::
in_string
(
uint
elements
,
qsort_cmp
cmp_func
)
:
in_vector
(
elements
,
sizeof
(
String
),
cmp_func
),
tmp
(
buff
,
sizeof
(
buff
),
default_charset_info
)
:
in_vector
(
elements
,
sizeof
(
String
),
cmp_func
),
tmp
(
buff
,
sizeof
(
buff
),
default_charset_info
)
{}
in_string
::~
in_string
()
...
...
@@ -1102,11 +1103,7 @@ in_row::in_row(uint elements, Item * item)
in_row
::~
in_row
()
{
if
(
base
)
{
cmp_item_row
*
arr
=
(
cmp_item_row
*
)
base
;
for
(
uint
i
=
0
;
i
<
count
;
i
++
)
arr
[
i
].
~
cmp_item_row
();
}
delete
[]
(
cmp_item_row
*
)
base
;
}
byte
*
in_row
::
get_value
(
Item
*
item
)
...
...
sql/item_func.cc
View file @
37d228e6
...
...
@@ -294,14 +294,11 @@ void Item_func::fix_num_length_and_dec()
max_length
=
float_length
(
decimals
);
}
Item
*
Item_func
::
get_tmp_table_item
(
)
Item
*
Item_func
::
get_tmp_table_item
(
THD
*
thd
)
{
if
(
!
with_sum_func
&&
!
const_item
())
{
return
new
Item_field
(
result_field
);
}
else
return
get_same
();
return
copy_or_same
(
thd
);
}
String
*
Item_int_func
::
val_str
(
String
*
str
)
...
...
sql/item_func.h
View file @
37d228e6
...
...
@@ -134,7 +134,7 @@ class Item_func :public Item_result_field
Field
*
tmp_table_field
()
{
return
result_field
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
);
void
set_outer_resolving
();
Item
*
get_tmp_table_item
(
);
Item
*
get_tmp_table_item
(
THD
*
thd
);
};
...
...
sql/item_sum.cc
View file @
37d228e6
...
...
@@ -41,8 +41,9 @@ Item_sum::Item_sum(List<Item> &list)
list
.
empty
();
// Fields are used
}
Item_sum
::
Item_sum
(
Item_sum
&
item
)
:
Item_result_field
(
item
),
quick_group
(
item
.
quick_group
)
// Constructor used in processing select with temporary tebles
Item_sum
::
Item_sum
(
THD
*
thd
,
Item_sum
&
item
)
:
Item_result_field
(
thd
,
item
),
quick_group
(
item
.
quick_group
)
{
arg_count
=
item
.
arg_count
;
if
(
arg_count
<=
2
)
...
...
@@ -96,9 +97,9 @@ void Item_sum::fix_num_length_and_dec()
max_length
=
float_length
(
decimals
);
}
Item
*
Item_sum
::
get_tmp_table_item
(
)
Item
*
Item_sum
::
get_tmp_table_item
(
THD
*
thd
)
{
Item_sum
*
sum_item
=
(
Item_sum
*
)
get_same
(
);
Item_sum
*
sum_item
=
(
Item_sum
*
)
copy_or_same
(
thd
);
if
(
sum_item
&&
sum_item
->
result_field
)
// If not a const sum func
{
Field
*
result_field
=
sum_item
->
result_field
;
...
...
sql/item_sum.h
View file @
37d228e6
...
...
@@ -55,7 +55,7 @@ class Item_sum :public Item_result_field
}
Item_sum
(
List
<
Item
>
&
list
);
//Copy constructor, need to perform subselects with temporary tables
Item_sum
(
Item_sum
&
item
);
Item_sum
(
THD
*
thd
,
Item_sum
&
item
);
~
Item_sum
()
{
result_field
=
0
;
}
enum
Type
type
()
const
{
return
SUM_FUNC_ITEM
;
}
...
...
@@ -77,7 +77,7 @@ class Item_sum :public Item_result_field
void
print
(
String
*
str
);
void
fix_num_length_and_dec
();
virtual
bool
setup
(
THD
*
thd
)
{
return
0
;}
Item
*
get_tmp_table_item
(
);
Item
*
get_tmp_table_item
(
THD
*
thd
);
};
...
...
@@ -88,7 +88,7 @@ class Item_sum_num :public Item_sum
Item_sum_num
(
Item
*
item_par
)
:
Item_sum
(
item_par
)
{}
Item_sum_num
(
Item
*
a
,
Item
*
b
)
:
Item_sum
(
a
,
b
)
{}
Item_sum_num
(
List
<
Item
>
&
list
)
:
Item_sum
(
list
)
{}
Item_sum_num
(
Item_sum_num
&
item
)
:
Item_sum
(
item
)
{}
Item_sum_num
(
THD
*
thd
,
Item_sum_num
&
item
)
:
Item_sum
(
thd
,
item
)
{}
bool
fix_fields
(
THD
*
,
TABLE_LIST
*
,
Item
**
);
longlong
val_int
()
{
return
(
longlong
)
val
();
}
/* Real as default */
String
*
val_str
(
String
*
str
);
...
...
@@ -104,7 +104,7 @@ class Item_sum_int :public Item_sum_num
public:
Item_sum_int
(
Item
*
item_par
)
:
Item_sum_num
(
item_par
)
{}
Item_sum_int
(
List
<
Item
>
&
list
)
:
Item_sum_num
(
list
)
{}
Item_sum_int
(
Item_sum_int
&
item
)
:
Item_sum_num
(
item
)
{}
Item_sum_int
(
THD
*
thd
,
Item_sum_int
&
item
)
:
Item_sum_num
(
thd
,
item
)
{}
double
val
()
{
return
(
double
)
val_int
();
}
String
*
val_str
(
String
*
str
);
enum
Item_result
result_type
()
const
{
return
INT_RESULT
;
}
...
...
@@ -118,7 +118,8 @@ class Item_sum_sum :public Item_sum_num
public:
Item_sum_sum
(
Item
*
item_par
)
:
Item_sum_num
(
item_par
),
sum
(
0.0
)
{}
Item_sum_sum
(
Item_sum_sum
&
item
)
:
Item_sum_num
(
item
),
sum
(
item
.
sum
)
{}
Item_sum_sum
(
THD
*
thd
,
Item_sum_sum
&
item
)
:
Item_sum_num
(
thd
,
item
),
sum
(
item
.
sum
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
SUM_FUNC
;}
void
reset
();
bool
add
();
...
...
@@ -126,7 +127,7 @@ class Item_sum_sum :public Item_sum_num
void
reset_field
();
void
update_field
(
int
offset
);
const
char
*
func_name
()
const
{
return
"sum"
;
}
Item
*
get_same
()
{
return
new
Item_sum_sum
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_sum
(
thd
,
*
this
);
}
};
...
...
@@ -139,8 +140,8 @@ class Item_sum_count :public Item_sum_int
Item_sum_count
(
Item
*
item_par
)
:
Item_sum_int
(
item_par
),
count
(
0
),
used_table_cache
(
~
(
table_map
)
0
)
{}
Item_sum_count
(
Item_sum_count
&
item
)
:
Item_sum_int
(
item
),
count
(
item
.
count
),
Item_sum_count
(
THD
*
thd
,
Item_sum_count
&
item
)
:
Item_sum_int
(
thd
,
item
),
count
(
item
.
count
),
used_table_cache
(
item
.
used_table_cache
)
{}
table_map
used_tables
()
const
{
return
used_table_cache
;
}
...
...
@@ -153,7 +154,7 @@ class Item_sum_count :public Item_sum_int
void
reset_field
();
void
update_field
(
int
offset
);
const
char
*
func_name
()
const
{
return
"count"
;
}
Item
*
get_same
()
{
return
new
Item_sum_count
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_count
(
thd
,
*
this
);
}
};
...
...
@@ -206,8 +207,8 @@ class Item_sum_count_distinct :public Item_sum_int
tmp_table_param
(
0
),
tree
(
&
tree_base
),
original
(
0
),
use_tree
(
0
),
always_null
(
0
)
{
quick_group
=
0
;
}
Item_sum_count_distinct
(
Item_sum_count_distinct
&
item
)
:
Item_sum_int
(
item
),
table
(
item
.
table
),
Item_sum_count_distinct
(
THD
*
thd
,
Item_sum_count_distinct
&
item
)
:
Item_sum_int
(
thd
,
item
),
table
(
item
.
table
),
used_table_cache
(
item
.
used_table_cache
),
field_lengths
(
item
.
field_lengths
),
tmp_table_param
(
item
.
tmp_table_param
),
tree
(
item
.
tree
),
original
(
&
item
),
key_length
(
item
.
key_length
),
...
...
@@ -225,7 +226,10 @@ class Item_sum_count_distinct :public Item_sum_int
void
update_field
(
int
offset
)
{
return
;
}
// Never called
const
char
*
func_name
()
const
{
return
"count_distinct"
;
}
bool
setup
(
THD
*
thd
);
Item
*
get_same
()
{
return
new
Item_sum_count_distinct
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_count_distinct
(
thd
,
*
this
);
}
};
...
...
@@ -257,8 +261,8 @@ class Item_sum_avg :public Item_sum_num
public:
Item_sum_avg
(
Item
*
item_par
)
:
Item_sum_num
(
item_par
),
count
(
0
)
{}
Item_sum_avg
(
Item_sum_avg
&
item
)
:
Item_sum_num
(
item
),
sum
(
item
.
sum
),
count
(
item
.
count
)
{}
Item_sum_avg
(
THD
*
thd
,
Item_sum_avg
&
item
)
:
Item_sum_num
(
thd
,
item
),
sum
(
item
.
sum
),
count
(
item
.
count
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
AVG_FUNC
;}
void
reset
();
bool
add
();
...
...
@@ -268,7 +272,7 @@ class Item_sum_avg :public Item_sum_num
Item
*
result_item
(
Field
*
field
)
{
return
new
Item_avg_field
(
this
);
}
const
char
*
func_name
()
const
{
return
"avg"
;
}
Item
*
get_same
()
{
return
new
Item_sum_avg
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_avg
(
thd
,
*
this
);
}
};
class
Item_sum_variance
;
...
...
@@ -309,8 +313,8 @@ class Item_sum_variance : public Item_sum_num
public:
Item_sum_variance
(
Item
*
item_par
)
:
Item_sum_num
(
item_par
),
count
(
0
)
{}
Item_sum_variance
(
Item_sum_variance
&
item
)
:
Item_sum_num
(
item
),
sum
(
item
.
sum
),
sum_sqr
(
item
.
sum_sqr
),
Item_sum_variance
(
THD
*
thd
,
Item_sum_variance
&
item
)
:
Item_sum_num
(
thd
,
item
),
sum
(
item
.
sum
),
sum_sqr
(
item
.
sum_sqr
),
count
(
item
.
count
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
VARIANCE_FUNC
;
}
void
reset
();
...
...
@@ -321,7 +325,7 @@ class Item_sum_variance : public Item_sum_num
Item
*
result_item
(
Field
*
field
)
{
return
new
Item_variance_field
(
this
);
}
const
char
*
func_name
()
const
{
return
"variance"
;
}
Item
*
get_same
()
{
return
new
Item_sum_variance
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_variance
(
thd
,
*
this
);
}
};
class
Item_sum_std
;
...
...
@@ -366,8 +370,8 @@ class Item_sum_hybrid :public Item_sum
Item_sum_hybrid
(
Item
*
item_par
,
int
sign
)
:
Item_sum
(
item_par
),
cmp_sign
(
sign
),
used_table_cache
(
~
(
table_map
)
0
)
{}
Item_sum_hybrid
(
Item_sum_hybrid
&
item
)
:
Item_sum
(
item
),
value
(
item
.
value
),
tmp_value
(
item
.
tmp_value
),
Item_sum_hybrid
(
THD
*
thd
,
Item_sum_hybrid
&
item
)
:
Item_sum
(
thd
,
item
),
value
(
item
.
value
),
tmp_value
(
item
.
tmp_value
),
sum
(
item
.
sum
),
sum_int
(
item
.
sum_int
),
hybrid_type
(
item
.
hybrid_type
),
cmp_sign
(
item
.
cmp_sign
),
used_table_cache
(
used_table_cache
)
{}
bool
fix_fields
(
THD
*
,
TABLE_LIST
*
,
Item
**
);
...
...
@@ -401,12 +405,12 @@ class Item_sum_min :public Item_sum_hybrid
{
public:
Item_sum_min
(
Item
*
item_par
)
:
Item_sum_hybrid
(
item_par
,
1
)
{}
Item_sum_min
(
Item_sum_min
&
item
)
:
Item_sum_hybrid
(
item
)
{}
Item_sum_min
(
THD
*
thd
,
Item_sum_min
&
item
)
:
Item_sum_hybrid
(
thd
,
item
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
MIN_FUNC
;}
bool
add
();
const
char
*
func_name
()
const
{
return
"min"
;
}
Item
*
get_same
()
{
return
new
Item_sum_min
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_min
(
thd
,
*
this
);
}
};
...
...
@@ -414,12 +418,12 @@ class Item_sum_max :public Item_sum_hybrid
{
public:
Item_sum_max
(
Item
*
item_par
)
:
Item_sum_hybrid
(
item_par
,
-
1
)
{}
Item_sum_max
(
Item_sum_max
&
item
)
:
Item_sum_hybrid
(
item
)
{}
Item_sum_max
(
THD
*
thd
,
Item_sum_max
&
item
)
:
Item_sum_hybrid
(
thd
,
item
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
MAX_FUNC
;}
bool
add
();
const
char
*
func_name
()
const
{
return
"max"
;
}
Item
*
get_same
()
{
return
new
Item_sum_max
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_max
(
thd
,
*
this
);
}
};
...
...
@@ -431,8 +435,8 @@ class Item_sum_bit :public Item_sum_int
public:
Item_sum_bit
(
Item
*
item_par
,
ulonglong
reset_arg
)
:
Item_sum_int
(
item_par
),
reset_bits
(
reset_arg
),
bits
(
reset_arg
)
{}
Item_sum_bit
(
Item_sum_bit
&
item
)
:
Item_sum_int
(
item
),
reset_bits
(
item
.
reset_bits
),
bits
(
item
.
bits
)
{}
Item_sum_bit
(
THD
*
thd
,
Item_sum_bit
&
item
)
:
Item_sum_int
(
thd
,
item
),
reset_bits
(
item
.
reset_bits
),
bits
(
item
.
bits
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
SUM_BIT_FUNC
;}
void
reset
();
longlong
val_int
();
...
...
@@ -444,11 +448,11 @@ class Item_sum_or :public Item_sum_bit
{
public:
Item_sum_or
(
Item
*
item_par
)
:
Item_sum_bit
(
item_par
,
LL
(
0
))
{}
Item_sum_or
(
Item_sum_or
&
item
)
:
Item_sum_bit
(
item
)
{}
Item_sum_or
(
THD
*
thd
,
Item_sum_or
&
item
)
:
Item_sum_bit
(
thd
,
item
)
{}
bool
add
();
void
update_field
(
int
offset
);
const
char
*
func_name
()
const
{
return
"bit_or"
;
}
Item
*
get_same
()
{
return
new
Item_sum_or
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_or
(
thd
,
*
this
);
}
};
...
...
@@ -456,11 +460,11 @@ class Item_sum_and :public Item_sum_bit
{
public:
Item_sum_and
(
Item
*
item_par
)
:
Item_sum_bit
(
item_par
,
~
(
ulonglong
)
LL
(
0
))
{}
Item_sum_and
(
Item_sum_and
&
item
)
:
Item_sum_bit
(
item
)
{}
Item_sum_and
(
THD
*
thd
,
Item_sum_and
&
item
)
:
Item_sum_bit
(
thd
,
item
)
{}
bool
add
();
void
update_field
(
int
offset
);
const
char
*
func_name
()
const
{
return
"bit_and"
;
}
Item
*
get_same
()
{
return
new
Item_sum_and
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_and
(
thd
,
*
this
);
}
};
/*
...
...
@@ -478,7 +482,8 @@ class Item_udf_sum : public Item_sum
Item_udf_sum
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum
(
list
),
udf
(
udf_arg
)
{
quick_group
=
0
;}
Item_udf_sum
(
Item_udf_sum
&
item
)
:
Item_sum
(
item
),
udf
(
item
.
udf
)
{}
Item_udf_sum
(
THD
*
thd
,
Item_udf_sum
&
item
)
:
Item_sum
(
thd
,
item
),
udf
(
item
.
udf
)
{}
~
Item_udf_sum
()
{}
const
char
*
func_name
()
const
{
return
udf
.
name
();
}
bool
fix_fields
(
THD
*
thd
,
TABLE_LIST
*
tables
,
Item
**
ref
)
...
...
@@ -502,13 +507,14 @@ class Item_sum_udf_float :public Item_udf_sum
Item_sum_udf_float
(
udf_func
*
udf_arg
)
:
Item_udf_sum
(
udf_arg
)
{}
Item_sum_udf_float
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_udf_sum
(
udf_arg
,
list
)
{}
Item_sum_udf_float
(
Item_sum_udf_float
&
item
)
:
Item_udf_sum
(
item
)
{}
Item_sum_udf_float
(
THD
*
thd
,
Item_sum_udf_float
&
item
)
:
Item_udf_sum
(
thd
,
item
)
{}
~
Item_sum_udf_float
()
{}
longlong
val_int
()
{
return
(
longlong
)
Item_sum_udf_float
::
val
();
}
double
val
();
String
*
val_str
(
String
*
str
);
void
fix_length_and_dec
()
{
fix_num_length_and_dec
();
}
Item
*
get_same
()
{
return
new
Item_sum_udf_float
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_float
(
thd
,
*
this
);
}
};
...
...
@@ -518,14 +524,15 @@ class Item_sum_udf_int :public Item_udf_sum
Item_sum_udf_int
(
udf_func
*
udf_arg
)
:
Item_udf_sum
(
udf_arg
)
{}
Item_sum_udf_int
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_udf_sum
(
udf_arg
,
list
)
{}
Item_sum_udf_int
(
Item_sum_udf_int
&
item
)
:
Item_udf_sum
(
item
)
{}
Item_sum_udf_int
(
THD
*
thd
,
Item_sum_udf_int
&
item
)
:
Item_udf_sum
(
thd
,
item
)
{}
~
Item_sum_udf_int
()
{}
longlong
val_int
();
double
val
()
{
return
(
double
)
Item_sum_udf_int
::
val_int
();
}
String
*
val_str
(
String
*
str
);
enum
Item_result
result_type
()
const
{
return
INT_RESULT
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
21
;
}
Item
*
get_same
()
{
return
new
Item_sum_udf_int
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_int
(
thd
,
*
this
);
}
};
...
...
@@ -535,7 +542,8 @@ class Item_sum_udf_str :public Item_udf_sum
Item_sum_udf_str
(
udf_func
*
udf_arg
)
:
Item_udf_sum
(
udf_arg
)
{}
Item_sum_udf_str
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_udf_sum
(
udf_arg
,
list
)
{}
Item_sum_udf_str
(
Item_sum_udf_str
&
item
)
:
Item_udf_sum
(
item
)
{}
Item_sum_udf_str
(
THD
*
thd
,
Item_sum_udf_str
&
item
)
:
Item_udf_sum
(
thd
,
item
)
{}
~
Item_sum_udf_str
()
{}
String
*
val_str
(
String
*
);
double
val
()
...
...
@@ -553,7 +561,7 @@ class Item_sum_udf_str :public Item_udf_sum
}
enum
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
void
fix_length_and_dec
();
Item
*
get_same
()
{
return
new
Item_sum_udf_str
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_str
(
thd
,
*
this
);
}
};
#else
/* Dummy functions to get sql_yacc.cc compiled */
...
...
@@ -563,14 +571,15 @@ class Item_sum_udf_float :public Item_sum_num
public:
Item_sum_udf_float
(
udf_func
*
udf_arg
)
:
Item_sum_num
()
{}
Item_sum_udf_float
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_num
()
{}
Item_sum_udf_float
(
Item_sum_udf_float
&
item
)
:
Item_sum_num
(
item
)
{}
Item_sum_udf_float
(
THD
*
thd
,
Item_sum_udf_float
&
item
)
:
Item_sum_num
(
thd
,
item
)
{}
~
Item_sum_udf_float
()
{}
enum
Sumfunctype
sum_func
()
const
{
return
UDF_SUM_FUNC
;
}
double
val
()
{
return
0.0
;
}
void
reset
()
{}
bool
add
()
{
return
0
;
}
void
update_field
(
int
offset
)
{}
Item
*
get_same
()
{
return
new
Item_sum_udf_float
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_float
(
thd
,
*
this
);
}
};
...
...
@@ -579,7 +588,8 @@ class Item_sum_udf_int :public Item_sum_num
public:
Item_sum_udf_int
(
udf_func
*
udf_arg
)
:
Item_sum_num
()
{}
Item_sum_udf_int
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_num
()
{}
Item_sum_udf_int
(
Item_sum_udf_int
&
item
)
:
Item_sum_num
(
item
)
{}
Item_sum_udf_int
(
THD
*
thd
,
Item_sum_udf_int
&
item
)
:
Item_sum_num
(
thd
,
item
)
{}
~
Item_sum_udf_int
()
{}
enum
Sumfunctype
sum_func
()
const
{
return
UDF_SUM_FUNC
;
}
longlong
val_int
()
{
return
0
;
}
...
...
@@ -587,7 +597,7 @@ class Item_sum_udf_int :public Item_sum_num
void
reset
()
{}
bool
add
()
{
return
0
;
}
void
update_field
(
int
offset
)
{}
Item
*
get_same
()
{
return
new
Item_sum_udf_int
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_int
(
thd
,
*
this
);
}
};
...
...
@@ -596,7 +606,8 @@ class Item_sum_udf_str :public Item_sum_num
public:
Item_sum_udf_str
(
udf_func
*
udf_arg
)
:
Item_sum_num
()
{}
Item_sum_udf_str
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_num
()
{}
Item_sum_udf_str
(
Item_sum_udf_str
&
item
)
:
Item_sum_num
(
item
)
{}
Item_sum_udf_str
(
THD
*
thd
,
Item_sum_udf_str
&
item
)
:
Item_sum_num
(
thd
,
item
)
{}
~
Item_sum_udf_str
()
{}
String
*
val_str
(
String
*
)
{
null_value
=
1
;
return
0
;
}
double
val
()
{
null_value
=
1
;
return
0.0
;
}
...
...
@@ -607,7 +618,7 @@ class Item_sum_udf_str :public Item_sum_num
void
reset
()
{}
bool
add
()
{
return
0
;
}
void
update_field
(
int
offset
)
{}
Item
*
get_same
()
{
return
new
Item_sum_udf_str
(
*
this
);
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_udf_str
(
thd
,
*
this
);
}
};
#endif
/* HAVE_DLOPEN */
sql/item_uniq.h
View file @
37d228e6
...
...
@@ -37,7 +37,8 @@ class Item_sum_unique_users :public Item_sum_num
public:
Item_sum_unique_users
(
Item
*
name_arg
,
int
start
,
int
end
,
Item
*
item_arg
)
:
Item_sum_num
(
item_arg
)
{}
Item_sum_unique_users
(
Item_sum_unique_users
&
item
)
:
Item_sum_num
(
item
)
{}
Item_sum_unique_users
(
THD
*
thd
,
Item_sum_unique_users
&
item
)
:
Item_sum_num
(
thd
,
item
)
{}
double
val
()
{
return
0.0
;
}
enum
Sumfunctype
sum_func
()
const
{
return
UNIQUE_USERS_FUNC
;}
void
reset
()
{}
...
...
@@ -49,5 +50,8 @@ class Item_sum_unique_users :public Item_sum_num
fixed
=
1
;
return
0
;
}
Item_sum
*
get_same
()
{
return
new
Item_sum_unique_users
(
*
this
);
}
Item_sum
*
copy_or_same
(
THD
*
thd
)
{
return
new
Item_sum_unique_users
(
thd
,
*
this
);
}
};
sql/sql_base.cc
View file @
37d228e6
...
...
@@ -1845,10 +1845,8 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
table_name
=
((
Item_ident
*
)
find
)
->
table_name
;
}
uint
i
=
0
;
while
((
item
=
li
++
))
for
(
uint
i
=
0
;
(
item
=
li
++
);
i
++
)
{
i
++
;
if
(
field_name
&&
item
->
type
()
==
Item
::
FIELD_ITEM
)
{
if
(
!
my_strcasecmp
(
system_charset_info
,
...
...
sql/sql_select.cc
View file @
37d228e6
...
...
@@ -140,7 +140,7 @@ static void calc_group_buffer(JOIN *join,ORDER *group);
static
bool
alloc_group_fields
(
JOIN
*
join
,
ORDER
*
group
);
static
bool
make_sum_func_list
(
JOIN
*
join
,
List
<
Item
>
&
fields
);
// Create list for using with tempory table
static
bool
change_to_use_tmp_fields
(
Item
**
ref_pointer_array
,
static
bool
change_to_use_tmp_fields
(
THD
*
thd
,
Item
**
ref_pointer_array
,
List
<
Item
>
&
new_list1
,
List
<
Item
>
&
new_list2
,
uint
elements
,
List
<
Item
>
&
items
);
...
...
@@ -968,7 +968,7 @@ JOIN::exec()
items1
=
items0
+
all_fields
.
elements
;
if
(
sort_and_group
||
curr_tmp_table
->
group
)
{
if
(
change_to_use_tmp_fields
(
items1
,
if
(
change_to_use_tmp_fields
(
thd
,
items1
,
tmp_fields_list1
,
tmp_all_fields1
,
fields_list
.
elements
,
all_fields
))
DBUG_VOID_RETURN
;
...
...
@@ -1088,7 +1088,7 @@ JOIN::exec()
if
(
!
items2
)
{
items2
=
items1
+
all_fields
.
elements
;
if
(
change_to_use_tmp_fields
(
items2
,
if
(
change_to_use_tmp_fields
(
thd
,
items2
,
tmp_fields_list2
,
tmp_all_fields2
,
fields_list
.
elements
,
tmp_all_fields1
))
DBUG_VOID_RETURN
;
...
...
@@ -7069,12 +7069,12 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
order
->
in_field_list
=
1
;
return
0
;
}
uint
counter
=
0
;
uint
counter
;
Item
**
item
=
find_item_in_list
(
*
order
->
item
,
fields
,
&
counter
,
IGNORE_ERRORS
);
if
(
item
)
{
order
->
item
=
ref_pointer_array
+
counter
-
1
;
order
->
item
=
ref_pointer_array
+
counter
;
order
->
in_field_list
=
1
;
return
0
;
}
...
...
@@ -7192,7 +7192,7 @@ setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields,
DBUG_ENTER
(
"setup_new_fields"
);
thd
->
set_query_id
=
1
;
// Not really needed, but...
uint
counter
=
0
;
uint
counter
;
for
(;
new_field
;
new_field
=
new_field
->
next
)
{
if
((
item
=
find_item_in_list
(
*
new_field
->
item
,
fields
,
&
counter
,
...
...
@@ -7471,7 +7471,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
if
(
pos
->
type
()
==
Item
::
FIELD_ITEM
)
{
Item_field
*
item
;
if
(
!
(
item
=
new
Item_field
(
*
((
Item_field
*
)
pos
))))
if
(
!
(
item
=
new
Item_field
(
thd
,
*
((
Item_field
*
)
pos
))))
goto
err
;
pos
=
item
;
if
(
item
->
field
->
flags
&
BLOB_FLAG
)
...
...
@@ -7590,7 +7590,7 @@ make_sum_func_list(JOIN *join,List<Item> &fields)
*/
static
bool
change_to_use_tmp_fields
(
Item
**
ref_pointer_array
,
change_to_use_tmp_fields
(
THD
*
thd
,
Item
**
ref_pointer_array
,
List
<
Item
>
&
new_list1
,
List
<
Item
>
&
new_list2
,
uint
elements
,
List
<
Item
>
&
items
)
{
...
...
@@ -7609,7 +7609,7 @@ change_to_use_tmp_fields(Item **ref_pointer_array,
else
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
)
{
item_field
=
item
->
get_tmp_table_item
();
item_field
=
item
->
get_tmp_table_item
(
thd
);
}
else
if
((
field
=
item
->
tmp_table_field
()))
{
...
...
@@ -7665,7 +7665,7 @@ change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array,
uint
i
,
border
=
items
.
elements
-
elements
;
for
(
i
=
0
;
(
item
=
it
++
);
i
++
)
{
new_list2
.
push_back
(
new_item
=
item
->
get_tmp_table_item
());
new_list2
.
push_back
(
new_item
=
item
->
get_tmp_table_item
(
thd
));
ref_pointer_array
[((
i
<
border
)
?
items
.
elements
-
i
-
1
:
i
-
border
)]
=
new_item
;
}
...
...
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