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
7a19c59c
Commit
7a19c59c
authored
Apr 29, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-9395 Add Type_handler::Item_decimal_scale() and Item_divisor_precision_increment()
parent
ea18b112
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
29 deletions
+65
-29
sql/field.h
sql/field.h
+0
-21
sql/item.h
sql/item.h
+2
-8
sql/sql_type.cc
sql/sql_type.cc
+30
-0
sql/sql_type.h
sql/sql_type.h
+33
-0
No files found.
sql/field.h
View file @
7a19c59c
...
...
@@ -525,27 +525,6 @@ inline bool is_temporal_type(enum_field_types type)
}
/**
Tests if field type is temporal and has time part,
i.e. represents TIME, DATETIME or TIMESTAMP types in SQL.
@param type Field type, as returned by field->type().
@retval true If field type is temporal type with time part.
@retval false If field type is not temporal type with time part.
*/
inline
bool
is_temporal_type_with_time
(
enum_field_types
type
)
{
switch
(
type
)
{
case
MYSQL_TYPE_TIME
:
case
MYSQL_TYPE_DATETIME
:
case
MYSQL_TYPE_TIMESTAMP
:
return
true
;
default:
return
false
;
}
}
enum
enum_vcol_info_type
{
VCOL_GENERATED_VIRTUAL
,
VCOL_GENERATED_STORED
,
...
...
sql/item.h
View file @
7a19c59c
...
...
@@ -1162,10 +1162,7 @@ class Item: public Value_source,
*/
uint
decimal_scale
()
const
{
return
decimals
<
NOT_FIXED_DEC
?
decimals
:
is_temporal_type_with_time
(
field_type
())
?
TIME_SECOND_PART_DIGITS
:
MY_MIN
(
max_length
,
DECIMAL_MAX_SCALE
);
return
type_handler
()
->
Item_decimal_scale
(
this
);
}
/*
Returns how many digits a divisor adds into a division result.
...
...
@@ -1186,10 +1183,7 @@ class Item: public Value_source,
*/
uint
divisor_precision_increment
()
const
{
return
decimals
<
NOT_FIXED_DEC
?
decimals
:
is_temporal_type_with_time
(
field_type
())
?
TIME_SECOND_PART_DIGITS
:
decimals
;
return
type_handler
()
->
Item_divisor_precision_increment
(
this
);
}
/**
TIME or DATETIME precision of the item: 0..6
...
...
sql/sql_type.cc
View file @
7a19c59c
...
...
@@ -3696,6 +3696,36 @@ uint Type_handler_string_result::Item_temporal_precision(Item *item,
/***************************************************************************/
uint
Type_handler
::
Item_decimal_scale
(
const
Item
*
item
)
const
{
return
item
->
decimals
<
NOT_FIXED_DEC
?
item
->
decimals
:
MY_MIN
(
item
->
max_length
,
DECIMAL_MAX_SCALE
);
}
uint
Type_handler_temporal_result
::
Item_decimal_scale_with_seconds
(
const
Item
*
item
)
const
{
return
item
->
decimals
<
NOT_FIXED_DEC
?
item
->
decimals
:
TIME_SECOND_PART_DIGITS
;
}
uint
Type_handler
::
Item_divisor_precision_increment
(
const
Item
*
item
)
const
{
return
item
->
decimals
;
}
uint
Type_handler_temporal_result
::
Item_divisor_precision_increment_with_seconds
(
const
Item
*
item
)
const
{
return
item
->
decimals
<
NOT_FIXED_DEC
?
item
->
decimals
:
TIME_SECOND_PART_DIGITS
;
}
/***************************************************************************/
bool
Type_handler_real_result
::
subquery_type_allows_materialization
(
const
Item
*
inner
,
const
Item
*
outer
)
const
...
...
sql/sql_type.h
View file @
7a19c59c
...
...
@@ -479,6 +479,12 @@ class Type_handler
}
virtual
uint
Item_time_precision
(
Item
*
item
)
const
;
virtual
uint
Item_datetime_precision
(
Item
*
item
)
const
;
virtual
uint
Item_decimal_scale
(
const
Item
*
item
)
const
;
/*
Returns how many digits a divisor adds into a division result.
See Item::divisor_precision_increment() in item.h for more comments.
*/
virtual
uint
Item_divisor_precision_increment
(
const
Item
*
)
const
;
/**
Makes a temporary table Field to handle numeric aggregate functions,
e.g. SUM(DISTINCT expr), AVG(DISTINCT expr), etc.
...
...
@@ -1110,6 +1116,9 @@ class Type_handler_int_result: public Type_handler_numeric
class
Type_handler_temporal_result
:
public
Type_handler
{
protected:
uint
Item_decimal_scale_with_seconds
(
const
Item
*
item
)
const
;
uint
Item_divisor_precision_increment_with_seconds
(
const
Item
*
)
const
;
public:
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
Item_result
cmp_type
()
const
{
return
TIME_RESULT
;
}
...
...
@@ -1441,6 +1450,14 @@ class Type_handler_time_common: public Type_handler_temporal_result
{
return
MYSQL_TIMESTAMP_TIME
;
}
uint
Item_decimal_scale
(
const
Item
*
item
)
const
{
return
Item_decimal_scale_with_seconds
(
item
);
}
uint
Item_divisor_precision_increment
(
const
Item
*
item
)
const
{
return
Item_divisor_precision_increment_with_seconds
(
item
);
}
const
Type_handler
*
type_handler_for_comparison
()
const
;
int
Item_save_in_field
(
Item
*
item
,
Field
*
field
,
bool
no_conversions
)
const
;
String
*
print_item_value
(
THD
*
thd
,
Item
*
item
,
String
*
str
)
const
;
...
...
@@ -1543,6 +1560,14 @@ class Type_handler_datetime_common: public Type_handler_temporal_with_date
{
return
MYSQL_TIMESTAMP_DATETIME
;
}
uint
Item_decimal_scale
(
const
Item
*
item
)
const
{
return
Item_decimal_scale_with_seconds
(
item
);
}
uint
Item_divisor_precision_increment
(
const
Item
*
item
)
const
{
return
Item_divisor_precision_increment_with_seconds
(
item
);
}
String
*
print_item_value
(
THD
*
thd
,
Item
*
item
,
String
*
str
)
const
;
bool
Item_hybrid_func_fix_attributes
(
THD
*
thd
,
Item_hybrid_func
*
func
,
Item
**
items
,
uint
nitems
)
const
;
...
...
@@ -1587,6 +1612,14 @@ class Type_handler_timestamp_common: public Type_handler_temporal_with_date
{
return
MYSQL_TIMESTAMP_DATETIME
;
}
uint
Item_decimal_scale
(
const
Item
*
item
)
const
{
return
Item_decimal_scale_with_seconds
(
item
);
}
uint
Item_divisor_precision_increment
(
const
Item
*
item
)
const
{
return
Item_divisor_precision_increment_with_seconds
(
item
);
}
String
*
print_item_value
(
THD
*
thd
,
Item
*
item
,
String
*
str
)
const
;
bool
Item_hybrid_func_fix_attributes
(
THD
*
thd
,
Item_hybrid_func
*
func
,
Item
**
items
,
uint
nitems
)
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