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
6be67860
Commit
6be67860
authored
Dec 05, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11330 Split Item_func_hybrid_field_type::val_xxx() into methods in Type_handler
parent
69f80e5e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
611 additions
and
215 deletions
+611
-215
sql/item_func.cc
sql/item_func.cc
+168
-209
sql/item_func.h
sql/item_func.h
+88
-5
sql/sql_type.cc
sql/sql_type.cc
+242
-1
sql/sql_type.h
sql/sql_type.h
+113
-0
No files found.
sql/item_func.cc
View file @
6be67860
This diff is collapsed.
Click to expand it.
sql/item_func.h
View file @
6be67860
...
@@ -451,6 +451,62 @@ class Item_func_hybrid_field_type: public Item_hybrid_func
...
@@ -451,6 +451,62 @@ class Item_func_hybrid_field_type: public Item_hybrid_func
DBUG_ASSERT
((
res
!=
NULL
)
^
null_value
);
DBUG_ASSERT
((
res
!=
NULL
)
^
null_value
);
return
res
;
return
res
;
}
}
bool
make_zero_mysql_time
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
bzero
(
ltime
,
sizeof
(
*
ltime
));
return
null_value
|=
!
(
fuzzydate
&
TIME_FUZZY_DATES
);
}
public:
// Value methods that involve no conversion
String
*
val_str_from_str_op
(
String
*
str
)
{
return
str_op_with_null_check
(
&
str_value
);
}
my_decimal
*
val_decimal_from_decimal_op
(
my_decimal
*
dec
)
{
return
decimal_op_with_null_check
(
dec
);
}
longlong
val_int_from_int_op
()
{
return
int_op
();
}
double
val_real_from_real_op
()
{
return
real_op
();
}
bool
get_date_from_date_op
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
return
date_op
(
ltime
,
fuzzydate
|
(
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
));
}
// Value methods that involve conversion
String
*
val_str_from_decimal_op
(
String
*
str
);
String
*
val_str_from_real_op
(
String
*
str
);
String
*
val_str_from_int_op
(
String
*
str
);
String
*
val_str_from_date_op
(
String
*
str
);
my_decimal
*
val_decimal_from_str_op
(
my_decimal
*
dec
);
my_decimal
*
val_decimal_from_real_op
(
my_decimal
*
dec
);
my_decimal
*
val_decimal_from_int_op
(
my_decimal
*
dec
);
my_decimal
*
val_decimal_from_date_op
(
my_decimal
*
dec
);
longlong
val_int_from_str_op
();
longlong
val_int_from_real_op
();
longlong
val_int_from_decimal_op
();
longlong
val_int_from_date_op
();
double
val_real_from_str_op
();
double
val_real_from_decimal_op
();
double
val_real_from_date_op
();
double
val_real_from_int_op
();
bool
get_date_from_str_op
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
);
bool
get_date_from_real_op
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
);
bool
get_date_from_decimal_op
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
);
bool
get_date_from_int_op
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
);
public:
public:
Item_func_hybrid_field_type
(
THD
*
thd
)
:
Item_func_hybrid_field_type
(
THD
*
thd
)
:
...
@@ -469,11 +525,38 @@ class Item_func_hybrid_field_type: public Item_hybrid_func
...
@@ -469,11 +525,38 @@ class Item_func_hybrid_field_type: public Item_hybrid_func
Item_hybrid_func
(
thd
,
list
)
Item_hybrid_func
(
thd
,
list
)
{
collation
.
set_numeric
();
}
{
collation
.
set_numeric
();
}
double
val_real
();
double
val_real
()
longlong
val_int
();
{
my_decimal
*
val_decimal
(
my_decimal
*
);
DBUG_ASSERT
(
fixed
);
String
*
val_str
(
String
*
str
);
return
Item_func_hybrid_field_type
::
type_handler
()
->
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
);
Item_func_hybrid_field_type_val_real
(
this
);
}
longlong
val_int
()
{
DBUG_ASSERT
(
fixed
);
return
Item_func_hybrid_field_type
::
type_handler
()
->
Item_func_hybrid_field_type_val_int
(
this
);
}
my_decimal
*
val_decimal
(
my_decimal
*
dec
)
{
DBUG_ASSERT
(
fixed
);
return
Item_func_hybrid_field_type
::
type_handler
()
->
Item_func_hybrid_field_type_val_decimal
(
this
,
dec
);
}
String
*
val_str
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
);
String
*
res
=
Item_func_hybrid_field_type
::
type_handler
()
->
Item_func_hybrid_field_type_val_str
(
this
,
str
);
DBUG_ASSERT
(
null_value
==
(
res
==
NULL
));
return
res
;
}
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
)
{
DBUG_ASSERT
(
fixed
);
return
Item_func_hybrid_field_type
::
type_handler
()
->
Item_func_hybrid_field_type_get_date
(
this
,
res
,
fuzzy_date
);
}
/**
/**
@brief Performs the operation that this functions implements when the
@brief Performs the operation that this functions implements when the
...
...
sql/sql_type.cc
View file @
6be67860
...
@@ -899,4 +899,245 @@ Type_handler_string_result::Item_func_hex_val_str_ascii(Item_func_hex *item,
...
@@ -899,4 +899,245 @@ Type_handler_string_result::Item_func_hex_val_str_ascii(Item_func_hex *item,
return
item
->
val_str_ascii_from_val_str
(
str
);
return
item
->
val_str_ascii_from_val_str
(
str
);
}
}
/*************************************************************************/
/***************************************************************************/
String
*
Type_handler_decimal_result
::
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
item
,
String
*
str
)
const
{
return
item
->
val_str_from_decimal_op
(
str
);
}
double
Type_handler_decimal_result
::
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_real_from_decimal_op
();
}
longlong
Type_handler_decimal_result
::
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_int_from_decimal_op
();
}
my_decimal
*
Type_handler_decimal_result
::
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
item
,
my_decimal
*
dec
)
const
{
return
item
->
val_decimal_from_decimal_op
(
dec
);
}
bool
Type_handler_decimal_result
::
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
item
,
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
const
{
return
item
->
get_date_from_decimal_op
(
ltime
,
fuzzydate
);
}
/***************************************************************************/
String
*
Type_handler_int_result
::
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
item
,
String
*
str
)
const
{
return
item
->
val_str_from_int_op
(
str
);
}
double
Type_handler_int_result
::
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_real_from_int_op
();
}
longlong
Type_handler_int_result
::
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_int_from_int_op
();
}
my_decimal
*
Type_handler_int_result
::
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
item
,
my_decimal
*
dec
)
const
{
return
item
->
val_decimal_from_int_op
(
dec
);
}
bool
Type_handler_int_result
::
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
item
,
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
const
{
return
item
->
get_date_from_int_op
(
ltime
,
fuzzydate
);
}
/***************************************************************************/
String
*
Type_handler_real_result
::
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
item
,
String
*
str
)
const
{
return
item
->
val_str_from_real_op
(
str
);
}
double
Type_handler_real_result
::
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_real_from_real_op
();
}
longlong
Type_handler_real_result
::
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_int_from_real_op
();
}
my_decimal
*
Type_handler_real_result
::
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
item
,
my_decimal
*
dec
)
const
{
return
item
->
val_decimal_from_real_op
(
dec
);
}
bool
Type_handler_real_result
::
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
item
,
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
const
{
return
item
->
get_date_from_real_op
(
ltime
,
fuzzydate
);
}
/***************************************************************************/
String
*
Type_handler_temporal_result
::
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
item
,
String
*
str
)
const
{
return
item
->
val_str_from_date_op
(
str
);
}
double
Type_handler_temporal_result
::
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_real_from_date_op
();
}
longlong
Type_handler_temporal_result
::
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_int_from_date_op
();
}
my_decimal
*
Type_handler_temporal_result
::
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
item
,
my_decimal
*
dec
)
const
{
return
item
->
val_decimal_from_date_op
(
dec
);
}
bool
Type_handler_temporal_result
::
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
item
,
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
const
{
return
item
->
get_date_from_date_op
(
ltime
,
fuzzydate
);
}
/***************************************************************************/
String
*
Type_handler_string_result
::
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
item
,
String
*
str
)
const
{
return
item
->
val_str_from_str_op
(
str
);
}
double
Type_handler_string_result
::
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_real_from_str_op
();
}
longlong
Type_handler_string_result
::
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
item
)
const
{
return
item
->
val_int_from_str_op
();
}
my_decimal
*
Type_handler_string_result
::
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
item
,
my_decimal
*
dec
)
const
{
return
item
->
val_decimal_from_str_op
(
dec
);
}
bool
Type_handler_string_result
::
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
item
,
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
const
{
return
item
->
get_date_from_str_op
(
ltime
,
fuzzydate
);
}
/***************************************************************************/
sql/sql_type.h
View file @
6be67860
...
@@ -28,6 +28,7 @@ class Item;
...
@@ -28,6 +28,7 @@ class Item;
class
Item_cache
;
class
Item_cache
;
class
Item_sum_hybrid
;
class
Item_sum_hybrid
;
class
Item_func_hex
;
class
Item_func_hex
;
class
Item_func_hybrid_field_type
;
class
Type_std_attributes
;
class
Type_std_attributes
;
class
Sort_param
;
class
Sort_param
;
class
Arg_comparator
;
class
Arg_comparator
;
...
@@ -294,6 +295,25 @@ class Type_handler
...
@@ -294,6 +295,25 @@ class Type_handler
virtual
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
)
const
=
0
;
virtual
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
)
const
=
0
;
virtual
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
virtual
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
=
0
;
String
*
str
)
const
=
0
;
virtual
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
=
0
;
virtual
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
=
0
;
virtual
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
=
0
;
virtual
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
=
0
;
virtual
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
=
0
;
};
};
...
@@ -357,6 +377,39 @@ class Type_handler_row: public Type_handler
...
@@ -357,6 +377,39 @@ class Type_handler_row: public Type_handler
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
return
NULL
;
return
NULL
;
}
}
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
{
DBUG_ASSERT
(
0
);
return
NULL
;
}
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
{
DBUG_ASSERT
(
0
);
return
0.0
;
}
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
{
DBUG_ASSERT
(
0
);
return
0
;
}
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
{
DBUG_ASSERT
(
0
);
return
NULL
;
}
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
{
DBUG_ASSERT
(
0
);
return
true
;
}
};
};
...
@@ -392,6 +445,18 @@ class Type_handler_real_result: public Type_handler_numeric
...
@@ -392,6 +445,18 @@ class Type_handler_real_result: public Type_handler_numeric
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
;
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
;
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
;
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
;
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
;
};
};
...
@@ -412,6 +477,18 @@ class Type_handler_decimal_result: public Type_handler_numeric
...
@@ -412,6 +477,18 @@ class Type_handler_decimal_result: public Type_handler_numeric
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
;
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
;
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
;
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
;
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
;
};
};
...
@@ -432,6 +509,18 @@ class Type_handler_int_result: public Type_handler_numeric
...
@@ -432,6 +509,18 @@ class Type_handler_int_result: public Type_handler_numeric
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
;
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
;
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
;
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
;
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
;
};
};
...
@@ -450,6 +539,18 @@ class Type_handler_temporal_result: public Type_handler
...
@@ -450,6 +539,18 @@ class Type_handler_temporal_result: public Type_handler
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
;
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
;
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
;
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
;
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
;
};
};
...
@@ -472,6 +573,18 @@ class Type_handler_string_result: public Type_handler
...
@@ -472,6 +573,18 @@ class Type_handler_string_result: public Type_handler
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
set_comparator_func
(
Arg_comparator
*
cmp
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
bool
Item_sum_hybrid_fix_length_and_dec
(
Item_sum_hybrid
*
func
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
String
*
Item_func_hybrid_field_type_val_str
(
Item_func_hybrid_field_type
*
,
String
*
)
const
;
double
Item_func_hybrid_field_type_val_real
(
Item_func_hybrid_field_type
*
)
const
;
longlong
Item_func_hybrid_field_type_val_int
(
Item_func_hybrid_field_type
*
)
const
;
my_decimal
*
Item_func_hybrid_field_type_val_decimal
(
Item_func_hybrid_field_type
*
,
my_decimal
*
)
const
;
bool
Item_func_hybrid_field_type_get_date
(
Item_func_hybrid_field_type
*
,
MYSQL_TIME
*
,
ulonglong
fuzzydate
)
const
;
};
};
...
...
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