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
ddf4d1e5
Commit
ddf4d1e5
authored
Oct 12, 2003
by
bell@laptop.sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed printability of Items (all items except subselects)
(SCRUM) (WL#1274)
parent
d6d6c5e1
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
302 additions
and
37 deletions
+302
-37
sql/item.cc
sql/item.cc
+13
-3
sql/item.h
sql/item.h
+11
-1
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+51
-3
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+6
-2
sql/item_func.cc
sql/item_func.cc
+38
-0
sql/item_func.h
sql/item_func.h
+8
-0
sql/item_geofunc.h
sql/item_geofunc.h
+3
-0
sql/item_row.cc
sql/item_row.cc
+12
-0
sql/item_row.h
sql/item_row.h
+1
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+8
-0
sql/item_strfunc.h
sql/item_strfunc.h
+7
-2
sql/item_sum.cc
sql/item_sum.cc
+33
-0
sql/item_sum.h
sql/item_sum.h
+2
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+75
-3
sql/item_timefunc.h
sql/item_timefunc.h
+14
-10
sql/item_uniq.h
sql/item_uniq.h
+2
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+18
-13
No files found.
sql/item.cc
View file @
ddf4d1e5
...
...
@@ -474,9 +474,19 @@ String *Item_real::val_str(String *str)
void
Item_string
::
print
(
String
*
str
)
{
str
->
append
(
'\''
);
str
->
append
(
full_name
());
str
->
append
(
'\''
);
str
->
append
(
'_'
);
str
->
append
(
collation
.
collation
->
csname
);
if
(
varbin
)
{
str
->
append
(
' '
);
str
->
append
(
full_name
());
}
else
{
str
->
append
(
'\''
);
str
->
append
(
full_name
());
str
->
append
(
'\''
);
}
}
bool
Item_null
::
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
...
...
sql/item.h
View file @
ddf4d1e5
...
...
@@ -449,9 +449,11 @@ class Item_float :public Item_real
class
Item_string
:
public
Item
{
bool
varbin
;
public:
Item_string
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
Derivation
dv
=
DERIVATION_COERCIBLE
)
:
varbin
(
0
)
{
collation
.
set
(
cs
,
dv
);
str_value
.
set
(
str
,
length
,
cs
);
...
...
@@ -461,6 +463,7 @@ class Item_string :public Item
}
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
Derivation
dv
=
DERIVATION_COERCIBLE
)
:
varbin
(
0
)
{
collation
.
set
(
cs
,
dv
);
str_value
.
set
(
str
,
length
,
cs
);
...
...
@@ -494,6 +497,7 @@ class Item_string :public Item
}
String
*
const_string
()
{
return
&
str_value
;
}
inline
void
append
(
char
*
str
,
uint
length
)
{
str_value
.
append
(
str
,
length
);
}
inline
void
set_varbin_name
(
char
*
nm
)
{
name
=
nm
;
varbin
=
1
;
}
void
print
(
String
*
str
);
};
...
...
@@ -646,7 +650,7 @@ class Item_ref_null_helper: public Item_ref
bool
get_date
(
TIME
*
ltime
,
bool
fuzzydate
);
void
print
(
String
*
str
)
{
str
->
append
(
"
ref_null_helper
("
);
str
->
append
(
"
<ref_null_helper>
("
);
if
(
ref
&&
*
ref
)
(
*
ref
)
->
print
(
str
);
else
...
...
@@ -664,6 +668,12 @@ class Item_null_helper :public Item_ref_null_helper
:
Item_ref_null_helper
(
master
,
&
store
,
table_name_par
,
field_name_par
),
store
(
item
)
{}
void
print
(
String
*
str
)
{
str
->
append
(
"<null_helper>("
);
store
->
print
(
str
);
str
->
append
(
')'
);
}
};
/*
...
...
sql/item_cmpfunc.cc
View file @
ddf4d1e5
...
...
@@ -704,6 +704,18 @@ longlong Item_func_between::val_int()
return
0
;
}
void
Item_func_between
::
print
(
String
*
str
)
{
str
->
append
(
'('
);
args
[
0
]
->
print
(
str
);
str
->
append
(
" between "
);
args
[
1
]
->
print
(
str
);
str
->
append
(
" and "
);
args
[
2
]
->
print
(
str
);
str
->
append
(
')'
);
}
void
Item_func_ifnull
::
fix_length_and_dec
()
{
...
...
@@ -1097,7 +1109,27 @@ void Item_func_case::fix_length_and_dec()
void
Item_func_case
::
print
(
String
*
str
)
{
str
->
append
(
"case "
);
// Not yet complete
str
->
append
(
"(case "
);
if
(
first_expr_num
!=
-
1
)
{
args
[
first_expr_num
]
->
print
(
str
);
str
->
append
(
' '
);
}
for
(
uint
i
=
0
;
i
<
ncases
;
i
+=
2
)
{
str
->
append
(
"when "
);
args
[
i
]
->
print
(
str
);
str
->
append
(
" then "
);
args
[
i
+
1
]
->
print
(
str
);
str
->
append
(
' '
);
}
if
(
else_expr_num
!=
-
1
)
{
str
->
append
(
"else "
);
args
[
else_expr_num
]
->
print
(
str
);
str
->
append
(
' '
);
}
str
->
append
(
"end)"
);
}
/*
...
...
@@ -1504,8 +1536,15 @@ void Item_func_in::fix_length_and_dec()
void
Item_func_in
::
print
(
String
*
str
)
{
str
->
append
(
'('
);
Item_func
::
print
(
str
);
str
->
append
(
')'
);
args
[
0
]
->
print
(
str
);
str
->
append
(
" IN ("
);
for
(
uint
i
=
1
;
i
<
arg_count
;
i
++
)
{
if
(
i
>
1
)
str
->
append
(
','
);
args
[
i
]
->
print
(
str
);
}
str
->
append
(
"))"
);
}
...
...
@@ -1866,12 +1905,21 @@ void Item_is_not_null_test::update_used_tables()
}
}
longlong
Item_func_isnotnull
::
val_int
()
{
return
args
[
0
]
->
is_null
()
?
0
:
1
;
}
void
Item_func_isnotnull
::
print
(
String
*
str
)
{
str
->
append
(
'('
);
args
[
0
]
->
print
(
str
);
str
->
append
(
" is not null)"
);
}
longlong
Item_func_like
::
val_int
()
{
String
*
res
=
args
[
0
]
->
val_str
(
&
tmp_value1
);
...
...
sql/item_cmpfunc.h
View file @
ddf4d1e5
...
...
@@ -105,7 +105,7 @@ class Item_in_optimizer: public Item_bool_func
Item_in_optimizer return NULL, else it evaluate Item_in_subselect.
*/
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"
IN_OPTIMIZER
"
;
}
const
char
*
func_name
()
const
{
return
"
<in_optimizer>
"
;
}
Item_cache
**
get_cache
()
{
return
&
cache
;
}
};
...
...
@@ -262,6 +262,7 @@ class Item_func_between :public Item_int_func
enum
Functype
functype
()
const
{
return
BETWEEN
;
}
const
char
*
func_name
()
const
{
return
"between"
;
}
void
fix_length_and_dec
();
void
print
(
String
*
str
);
};
...
...
@@ -704,7 +705,7 @@ class Item_is_not_null_test :public Item_func_isnull
{}
enum
Functype
functype
()
const
{
return
ISNOTNULLTEST_FUNC
;
}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"
is_not_null_test
"
;
}
const
char
*
func_name
()
const
{
return
"
<is_not_null_test>
"
;
}
void
update_used_tables
();
};
...
...
@@ -722,6 +723,7 @@ class Item_func_isnotnull :public Item_bool_func
const
char
*
func_name
()
const
{
return
"isnotnull"
;
}
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_NULL
;
}
table_map
not_null_tables
()
const
{
return
0
;
}
void
print
(
String
*
str
);
};
...
...
@@ -775,6 +777,7 @@ class Item_func_regex :public Item_bool_func
longlong
val_int
();
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
,
Item
**
ref
);
const
char
*
func_name
()
const
{
return
"regex"
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
#else
...
...
@@ -785,6 +788,7 @@ class Item_func_regex :public Item_bool_func
Item_func_regex
(
Item
*
a
,
Item
*
b
)
:
Item_bool_func
(
a
,
b
)
{}
longlong
val_int
()
{
return
0
;}
const
char
*
func_name
()
const
{
return
"regex"
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
#endif
/* USE_REGEX */
...
...
sql/item_func.cc
View file @
ddf4d1e5
...
...
@@ -462,6 +462,24 @@ String *Item_num_op::val_str(String *str)
}
void
Item_func_signed
::
print
(
String
*
str
)
{
str
->
append
(
"cast("
);
args
[
0
]
->
print
(
str
);
str
->
append
(
"as signed)"
);
}
void
Item_func_unsigned
::
print
(
String
*
str
)
{
str
->
append
(
"cast("
);
args
[
0
]
->
print
(
str
);
str
->
append
(
"as unsigned)"
);
}
double
Item_func_plus
::
val
()
{
double
value
=
args
[
0
]
->
val
()
+
args
[
1
]
->
val
();
...
...
@@ -2762,6 +2780,26 @@ double Item_func_match::val()
DBUG_RETURN
(
ft_handler
->
please
->
find_relevance
(
ft_handler
,
record
,
0
));
}
void
Item_func_match
::
print
(
String
*
str
)
{
str
->
append
(
"(match "
);
List_iterator_fast
<
Item
>
li
(
fields
);
Item
*
item
;
bool
first
=
1
;
while
((
item
=
li
++
))
{
if
(
first
)
first
=
0
;
else
str
->
append
(
','
);
item
->
print
(
str
);
}
str
->
append
(
" against ("
);
args
[
0
]
->
print
(
str
);
if
(
mode
==
FT_BOOL
)
str
->
append
(
" in boolean mode"
);
str
->
append
(
"))"
);
}
longlong
Item_func_bit_xor
::
val_int
()
{
...
...
sql/item_func.h
View file @
ddf4d1e5
...
...
@@ -214,6 +214,7 @@ class Item_func_signed :public Item_int_func
longlong
val_int
()
{
return
args
[
0
]
->
val_int
();
}
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
unsigned_flag
=
0
;
}
void
print
(
String
*
str
);
};
...
...
@@ -225,6 +226,7 @@ class Item_func_unsigned :public Item_int_func
longlong
val_int
()
{
return
args
[
0
]
->
val_int
();
}
void
fix_length_and_dec
()
{
max_length
=
args
[
0
]
->
max_length
;
unsigned_flag
=
1
;
}
void
print
(
String
*
str
);
};
...
...
@@ -662,6 +664,7 @@ class Item_func_bit_or :public Item_int_func
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"|"
;
}
void
fix_length_and_dec
()
{
unsigned_flag
=
1
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
class
Item_func_bit_and
:
public
Item_int_func
...
...
@@ -671,6 +674,7 @@ class Item_func_bit_and :public Item_int_func
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"&"
;
}
void
fix_length_and_dec
()
{
unsigned_flag
=
1
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
class
Item_func_bit_count
:
public
Item_int_func
...
...
@@ -689,6 +693,7 @@ class Item_func_shift_left :public Item_int_func
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"<<"
;
}
void
fix_length_and_dec
()
{
unsigned_flag
=
1
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
class
Item_func_shift_right
:
public
Item_int_func
...
...
@@ -697,6 +702,7 @@ class Item_func_shift_right :public Item_int_func
Item_func_shift_right
(
Item
*
a
,
Item
*
b
)
:
Item_int_func
(
a
,
b
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
">>"
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
class
Item_func_bit_neg
:
public
Item_int_func
...
...
@@ -996,6 +1002,7 @@ class Item_func_match :public Item_real_func
bool
eq
(
const
Item
*
,
bool
binary_cmp
)
const
;
longlong
val_int
()
{
return
val
()
!=
0.0
;
}
double
val
();
void
print
(
String
*
str
);
bool
fix_index
();
void
init_search
(
bool
no_order
);
...
...
@@ -1031,6 +1038,7 @@ class Item_func_bit_xor : public Item_int_func
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"^"
;
}
void
fix_length_xor_dec
()
{
unsigned_flag
=
1
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
};
class
Item_func_is_free_lock
:
public
Item_int_func
...
...
sql/item_geofunc.h
View file @
ddf4d1e5
...
...
@@ -118,6 +118,7 @@ class Item_func_spatial_decomp: public Item_str_func
case
SP_EXTERIORRING
:
return
"exteriorring"
;
default:
DBUG_ASSERT
(
0
);
// Should never happened
return
"spatial_decomp_unknown"
;
}
}
...
...
@@ -142,6 +143,7 @@ class Item_func_spatial_decomp_n: public Item_str_func
case
SP_INTERIORRINGN
:
return
"interiorringn"
;
default:
DBUG_ASSERT
(
0
);
// Should never happened
return
"spatial_decomp_n_unknown"
;
}
}
...
...
@@ -210,6 +212,7 @@ class Item_func_spatial_rel: public Item_bool_func2
case
SP_OVERLAPS_FUNC
:
return
"overlaps"
;
default:
DBUG_ASSERT
(
0
);
// Should never happened
return
"sp_unknown"
;
}
}
...
...
sql/item_row.cc
View file @
ddf4d1e5
...
...
@@ -118,6 +118,18 @@ bool Item_row::check_cols(uint c)
return
0
;
}
void
Item_row
::
print
(
String
*
str
)
{
str
->
append
(
'('
);
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
i
)
str
->
append
(
','
);
items
[
i
]
->
print
(
str
);
}
str
->
append
(
')'
);
}
bool
Item_row
::
walk
(
Item_processor
processor
,
byte
*
arg
)
{
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
...
...
sql/item_row.h
View file @
ddf4d1e5
...
...
@@ -68,6 +68,7 @@ class Item_row: public Item
bool
const_item
()
const
{
return
const_item_cache
;
};
enum
Item_result
result_type
()
const
{
return
ROW_RESULT
;
}
void
update_used_tables
();
void
print
(
String
*
str
);
bool
walk
(
Item_processor
processor
,
byte
*
arg
);
...
...
sql/item_strfunc.cc
View file @
ddf4d1e5
...
...
@@ -2269,6 +2269,14 @@ String *Item_func_hex::val_str(String *str)
}
void
Item_func_binary
::
print
(
String
*
str
)
{
str
->
append
(
"cast("
);
args
[
0
]
->
print
(
str
);
str
->
append
(
"as binary)"
);
}
#include <my_dir.h> // For my_stat
String
*
Item_load_file
::
val_str
(
String
*
str
)
...
...
sql/item_strfunc.h
View file @
ddf4d1e5
...
...
@@ -120,6 +120,7 @@ class Item_func_reverse :public Item_str_func
Item_func_reverse
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"reverse"
;
}
};
...
...
@@ -324,10 +325,12 @@ class Item_func_encrypt :public Item_str_func
Item_func_encrypt
(
Item
*
a
,
Item
*
b
)
:
Item_str_func
(
a
,
b
)
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
maybe_null
=
1
;
max_length
=
13
;
}
const
char
*
func_name
()
const
{
return
"ecrypt"
;
}
};
#include "sql_crypt.h"
class
Item_func_encode
:
public
Item_str_func
{
protected:
...
...
@@ -337,13 +340,16 @@ class Item_func_encode :public Item_str_func
Item_str_func
(
a
),
sql_crypt
(
seed
)
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"encode"
;
}
};
class
Item_func_decode
:
public
Item_func_encode
{
public:
Item_func_decode
(
Item
*
a
,
char
*
seed
)
:
Item_func_encode
(
a
,
seed
)
{}
String
*
val_str
(
String
*
);
const
char
*
func_name
()
const
{
return
"decode"
;
}
};
...
...
@@ -520,7 +526,6 @@ class Item_func_binary :public Item_str_func
{
public:
Item_func_binary
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
const
char
*
func_name
()
const
{
return
"binary"
;
}
String
*
val_str
(
String
*
a
)
{
String
*
tmp
=
args
[
0
]
->
val_str
(
a
);
...
...
@@ -534,7 +539,7 @@ class Item_func_binary :public Item_str_func
collation
.
set
(
&
my_charset_bin
);
max_length
=
args
[
0
]
->
max_length
;
}
void
print
(
String
*
str
)
{
print_op
(
str
);
}
void
print
(
String
*
str
)
;
};
...
...
sql/item_sum.cc
View file @
ddf4d1e5
...
...
@@ -1343,6 +1343,14 @@ longlong Item_sum_count_distinct::val_int()
return
table
->
file
->
records
;
}
void
Item_sum_count_distinct
::
print
(
String
*
str
)
{
str
->
append
(
"count(distinct "
);
args
[
0
]
->
print
(
str
);
str
->
append
(
')'
);
}
/****************************************************************************
** Functions to handle dynamic loadable aggregates
** Original source by: Alexis Mikhailov <root@medinf.chuvashia.su>
...
...
@@ -1936,3 +1944,28 @@ String* Item_func_group_concat::val_str(String* str)
}
return
&
result
;
}
void
Item_func_group_concat
::
print
(
String
*
str
)
{
str
->
append
(
"group concat("
);
if
(
distinct
)
str
->
append
(
" distinct "
);
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
i
)
str
->
append
(
','
);
args
[
i
]
->
print
(
str
);
}
if
(
arg_count_order
)
{
for
(
uint
i
=
0
;
i
<
arg_count_order
;
i
++
)
{
if
(
i
)
str
->
append
(
','
);
(
*
order
[
i
]
->
item
)
->
print
(
str
);
}
}
str
->
append
(
" seperator
\'
"
);
str
->
append
(
*
separator
);
str
->
append
(
"
\'
)"
);
}
sql/item_sum.h
View file @
ddf4d1e5
...
...
@@ -238,6 +238,7 @@ class Item_sum_count_distinct :public Item_sum_int
void
make_unique
();
Item
*
copy_or_same
(
THD
*
thd
);
void
no_rows_in_result
()
{}
void
print
(
String
*
str
);
};
...
...
@@ -736,4 +737,5 @@ class Item_func_group_concat : public Item_sum
String
*
val_str
(
String
*
str
);
Item
*
copy_or_same
(
THD
*
thd
);
void
no_rows_in_result
()
{}
void
print
(
String
*
str
);
};
sql/item_timefunc.cc
View file @
ddf4d1e5
...
...
@@ -1359,6 +1359,35 @@ longlong Item_date_add_interval::val_int()
((
date
*
100L
+
ltime
.
hour
)
*
100L
+
ltime
.
minute
)
*
100L
+
ltime
.
second
;
}
static
const
char
*
interval_names
[]
=
{
"year"
,
"month"
,
"day"
,
"hour"
,
"minute"
,
"second"
,
"microsecond"
,
"year_month"
,
"day_hour"
,
"day_minute"
,
"day_second"
,
"hour_minute"
,
"hour_second"
,
"minute_second"
,
"day_microsecond"
,
"hour_microsecond"
,
"minute_microsecond"
,
"second_microsecond"
};
void
Item_date_add_interval
::
print
(
String
*
str
)
{
str
->
append
(
'('
);
args
[
0
]
->
print
(
str
);
str
->
append
(
date_sub_interval
?
" - interval "
:
" + interval "
);
args
[
1
]
->
print
(
str
);
str
->
append
(
interval_names
[
int_type
]);
str
->
append
(
')'
);
}
void
Item_extract
::
print
(
String
*
str
)
{
str
->
append
(
"extract("
);
str
->
append
(
interval_names
[
int_type
]);
str
->
append
(
' '
);
args
[
0
]
->
print
(
str
);
str
->
append
(
')'
);
}
void
Item_extract
::
fix_length_and_dec
()
{
value
.
alloc
(
32
);
// alloc buffer
...
...
@@ -1467,10 +1496,31 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const
void
Item_typecast
::
print
(
String
*
str
)
{
str
->
append
(
"
CAST
("
);
str
->
append
(
"
cast
("
);
args
[
0
]
->
print
(
str
);
str
->
append
(
" AS "
);
str
->
append
(
func_name
());
str
->
append
(
" as "
);
str
->
append
(
cast_type
());
str
->
append
(
')'
);
}
void
Item_char_typecast
::
print
(
String
*
str
)
{
str
->
append
(
"cast("
);
args
[
0
]
->
print
(
str
);
str
->
append
(
" as char"
);
if
(
cast_length
>=
0
)
{
str
->
append
(
'('
);
char
buff
[
10
];
snprintf
(
buff
,
10
,
"%d"
,
cast_length
);
str
->
append
(
buff
);
str
->
append
(
')'
);
}
if
(
cast_cs
)
{
str
->
append
(
" charset "
);
str
->
append
(
cast_cs
->
name
);
}
str
->
append
(
')'
);
}
...
...
@@ -1740,6 +1790,28 @@ String *Item_func_add_time::val_str(String *str)
return
0
;
}
void
Item_func_add_time
::
print
(
String
*
str
)
{
if
(
is_date
)
{
DBUG_ASSERT
(
sign
>
0
);
str
->
append
(
"timestamp("
);
}
else
{
if
(
sign
>
0
)
str
->
append
(
"addtime("
);
else
str
->
append
(
"subtime("
);
}
args
[
0
]
->
print
(
str
);
str
->
append
(
','
);
args
[
0
]
->
print
(
str
);
str
->
append
(
')'
);
}
/*
TIMEDIFF(t,s) is a time function that calculates the
time value between a start and end time.
...
...
sql/item_timefunc.h
View file @
ddf4d1e5
...
...
@@ -544,13 +544,13 @@ class Item_func_sec_to_time :public Item_str_func
enum
interval_type
{
INTERVAL_YEAR
,
INTERVAL_MONTH
,
INTERVAL_DAY
,
INTERVAL_HOUR
,
INTERVAL_MINUTE
,
INTERVAL_SECOND
,
INTERVAL_MICROSECOND
,
INTERVAL_YEAR_MONTH
,
INTERVAL_DAY_HOUR
,
INTERVAL_DAY_MINUTE
,
INTERVAL_DAY_SECOND
,
INTERVAL_HOUR_MINUTE
,
INTERVAL_HOUR_SECOND
,
INTERVAL_MINUTE_SECOND
,
INTERVAL_DAY_MICROSECOND
,
INTERVAL_HOUR_MICROSECOND
,
INTERVAL_MINUTE_MICROSECOND
,
INTERVAL_SECOND_MICROSECOND
INTERVAL_SECOND
,
INTERVAL_MICROSECOND
,
INTERVAL_YEAR_MONTH
,
INTERVAL_DAY_HOUR
,
INTERVAL_DAY_MINUTE
,
INTERVAL_DAY_SECOND
,
INTERVAL_HOUR_MINUTE
,
INTERVAL_HOUR_SECOND
,
INTERVAL_MINUTE_SECOND
,
INTERVAL_DAY_MICROSECOND
,
INTERVAL_HOUR_MICROSECOND
,
INTERVAL_MINUTE_MICROSECOND
,
INTERVAL_SECOND_MICROSECOND
};
class
Item_date_add_interval
:
public
Item_date_func
{
const
interval_type
int_type
;
...
...
@@ -568,6 +568,7 @@ class Item_date_add_interval :public Item_date_func
double
val
()
{
return
(
double
)
val_int
();
}
longlong
val_int
();
bool
get_date
(
TIME
*
res
,
bool
fuzzy_date
);
void
print
(
String
*
str
);
};
...
...
@@ -583,6 +584,7 @@ class Item_extract :public Item_int_func
const
char
*
func_name
()
const
{
return
"extract"
;
}
void
fix_length_and_dec
();
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
void
print
(
String
*
str
);
};
...
...
@@ -590,7 +592,6 @@ class Item_typecast :public Item_str_func
{
public:
Item_typecast
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
const
char
*
func_name
()
const
{
return
"char"
;
}
String
*
val_str
(
String
*
a
)
{
String
*
tmp
=
args
[
0
]
->
val_str
(
a
);
...
...
@@ -604,6 +605,7 @@ class Item_typecast :public Item_str_func
collation
.
set
(
default_charset
());
max_length
=
args
[
0
]
->
max_length
;
}
virtual
const
char
*
cast_type
()
const
=
0
;
void
print
(
String
*
str
);
};
...
...
@@ -617,8 +619,10 @@ class Item_char_typecast :public Item_typecast
public:
Item_char_typecast
(
Item
*
a
,
int
length_arg
,
CHARSET_INFO
*
cs_arg
)
:
Item_typecast
(
a
),
cast_length
(
length_arg
),
cast_cs
(
cs_arg
)
{}
const
char
*
cast_type
()
const
{
return
"char"
;
};
String
*
val_str
(
String
*
a
);
void
fix_length_and_dec
();
void
print
(
String
*
str
);
};
...
...
@@ -628,7 +632,7 @@ class Item_date_typecast :public Item_typecast
Item_date_typecast
(
Item
*
a
)
:
Item_typecast
(
a
)
{}
String
*
val_str
(
String
*
str
);
bool
get_date
(
TIME
*
ltime
,
bool
fuzzy_date
);
const
char
*
func_nam
e
()
const
{
return
"date"
;
}
const
char
*
cast_typ
e
()
const
{
return
"date"
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_DATE
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
)
{
...
...
@@ -643,7 +647,7 @@ class Item_time_typecast :public Item_typecast
Item_time_typecast
(
Item
*
a
)
:
Item_typecast
(
a
)
{}
String
*
val_str
(
String
*
str
);
bool
get_time
(
TIME
*
ltime
);
const
char
*
func_nam
e
()
const
{
return
"time"
;
}
const
char
*
cast_typ
e
()
const
{
return
"time"
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_TIME
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
)
{
...
...
@@ -657,7 +661,7 @@ class Item_datetime_typecast :public Item_typecast
public:
Item_datetime_typecast
(
Item
*
a
)
:
Item_typecast
(
a
)
{}
String
*
val_str
(
String
*
str
);
const
char
*
func_nam
e
()
const
{
return
"datetime"
;
}
const
char
*
cast_typ
e
()
const
{
return
"datetime"
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_DATETIME
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
)
{
...
...
@@ -694,7 +698,6 @@ class Item_func_add_time :public Item_str_func
Item_func_add_time
(
Item
*
a
,
Item
*
b
,
bool
type_arg
,
bool
neg_arg
)
:
Item_str_func
(
a
,
b
),
is_date
(
type_arg
)
{
sign
=
neg_arg
?
-
1
:
1
;
}
String
*
val_str
(
String
*
str
);
const
char
*
func_name
()
const
{
return
"addtime"
;
}
enum_field_types
field_type
()
const
{
return
cached_field_type
;
}
void
fix_length_and_dec
();
...
...
@@ -711,6 +714,7 @@ class Item_func_add_time :public Item_str_func
return
(
new
Field_datetime
(
maybe_null
,
name
,
t_arg
,
&
my_charset_bin
));
return
(
new
Field_string
(
max_length
,
maybe_null
,
name
,
t_arg
,
&
my_charset_bin
));
}
void
print
(
String
*
str
);
};
class
Item_func_timediff
:
public
Item_str_func
...
...
sql/item_uniq.h
View file @
ddf4d1e5
...
...
@@ -29,6 +29,7 @@ class Item_func_unique_users :public Item_real_func
:
Item_real_func
(
list
)
{}
double
val
()
{
return
0.0
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
6
;
}
void
print
(
String
*
str
)
{
str
->
append
(
"0.0"
);
}
};
...
...
@@ -54,4 +55,5 @@ class Item_sum_unique_users :public Item_sum_num
{
return
new
Item_sum_unique_users
(
thd
,
*
this
);
}
void
print
(
String
*
str
)
{
str
->
append
(
"0.0"
);
}
};
sql/sql_yacc.yy
View file @
ddf4d1e5
...
...
@@ -2879,17 +2879,19 @@ opt_gconcat_separator:
opt_gorder_clause:
/* empty */
{
LEX *lex=Lex;
lex->gorder_list = NULL;
}
| order_clause
{
LEX *lex=Lex;
lex->gorder_list= (SQL_LIST*) sql_memdup((char*) &lex->current_select->order_list,sizeof(st_sql_list));
lex->current_select->order_list.empty();
};
/* empty */
{
LEX *lex=Lex;
lex->gorder_list = NULL;
}
| order_clause
{
LEX *lex=Lex;
lex->gorder_list=
(SQL_LIST*) sql_memdup((char*) &lex->current_select->order_list,
sizeof(st_sql_list));
lex->current_select->order_list.empty();
};
in_sum_expr:
...
...
@@ -4289,8 +4291,11 @@ literal:
{
Item *tmp= new Item_varbinary($2.str,$2.length);
String *str= tmp ? tmp->val_str((String*) 0) : (String*) 0;
$$ = new Item_string(str ? str->ptr() : "", str ? str->length() :
0, Lex->charset);
Item_string *item = new Item_string(str ? str->ptr() : "",
str ? str->length() :
0, Lex->charset);
item->set_varbin_name(tmp->name);
$$= item;
}
| DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; }
...
...
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