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
6179a8ef
Commit
6179a8ef
authored
Aug 15, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-13526 Add Type_handler::Item_val_bool()
parent
9822fb1f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
31 deletions
+47
-31
sql/item.cc
sql/item.cc
+0
-30
sql/item.h
sql/item.h
+4
-1
sql/sql_type.cc
sql/sql_type.cc
+32
-0
sql/sql_type.h
sql/sql_type.h
+11
-0
No files found.
sql/item.cc
View file @
6179a8ef
...
...
@@ -109,36 +109,6 @@ void Item::push_note_converted_to_positive_complement(THD *thd)
}
/**
@todo
Make this functions class dependent
*/
bool
Item
::
val_bool
()
{
switch
(
result_type
())
{
case
INT_RESULT
:
return
val_int
()
!=
0
;
case
DECIMAL_RESULT
:
{
my_decimal
decimal_value
;
my_decimal
*
val
=
val_decimal
(
&
decimal_value
);
if
(
val
)
return
!
my_decimal_is_zero
(
val
);
return
0
;
}
case
REAL_RESULT
:
case
STRING_RESULT
:
return
val_real
()
!=
0.0
;
case
ROW_RESULT
:
case
TIME_RESULT
:
DBUG_ASSERT
(
0
);
return
0
;
// Wrong (but safe)
}
return
0
;
// Wrong (but safe)
}
/**
Get date/time/datetime.
Optionally extend TIME result to DATETIME.
...
...
sql/item.h
View file @
6179a8ef
...
...
@@ -1047,7 +1047,10 @@ class Item: public Value_source,
FALSE value is false or NULL
TRUE value is true (not equal to 0)
*/
virtual
bool
val_bool
();
virtual
bool
val_bool
()
{
return
type_handler
()
->
Item_val_bool
(
this
);
}
virtual
String
*
val_nodeset
(
String
*
)
{
return
0
;
}
/*
...
...
sql/sql_type.cc
View file @
6179a8ef
...
...
@@ -3077,6 +3077,38 @@ bool Type_handler_geometry::
#endif
/*************************************************************************/
bool
Type_handler_real_result
::
Item_val_bool
(
Item
*
item
)
const
{
return
item
->
val_real
()
!=
0.0
;
}
bool
Type_handler_int_result
::
Item_val_bool
(
Item
*
item
)
const
{
return
item
->
val_int
()
!=
0
;
}
bool
Type_handler_decimal_result
::
Item_val_bool
(
Item
*
item
)
const
{
my_decimal
decimal_value
;
my_decimal
*
val
=
item
->
val_decimal
(
&
decimal_value
);
if
(
val
)
return
!
my_decimal_is_zero
(
val
);
return
false
;
}
bool
Type_handler_temporal_result
::
Item_val_bool
(
Item
*
item
)
const
{
return
item
->
val_real
()
!=
0.0
;
}
bool
Type_handler_string_result
::
Item_val_bool
(
Item
*
item
)
const
{
return
item
->
val_real
()
!=
0.0
;
}
/*************************************************************************/
longlong
Type_handler_real_result
::
...
...
sql/sql_type.h
View file @
6179a8ef
...
...
@@ -891,6 +891,7 @@ class Type_handler
virtual
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
=
0
;
virtual
bool
Item_val_bool
(
Item
*
item
)
const
=
0
;
virtual
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
=
0
;
virtual
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
=
0
;
...
...
@@ -1147,6 +1148,11 @@ class Type_handler_row: public Type_handler
DBUG_ASSERT
(
0
);
return
true
;
}
bool
Item_val_bool
(
Item
*
item
)
const
{
DBUG_ASSERT
(
0
);
return
false
;
}
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
{
DBUG_ASSERT
(
0
);
...
...
@@ -1352,6 +1358,7 @@ class Type_handler_real_result: public Type_handler_numeric
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
;
bool
Item_func_signed_fix_length_and_dec
(
Item_func_signed
*
item
)
const
;
bool
Item_func_unsigned_fix_length_and_dec
(
Item_func_unsigned
*
item
)
const
;
bool
Item_val_bool
(
Item
*
item
)
const
;
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
;
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
...
...
@@ -1427,6 +1434,7 @@ class Type_handler_decimal_result: public Type_handler_numeric
bool
Item_sum_sum_fix_length_and_dec
(
Item_sum_sum
*
)
const
;
bool
Item_sum_avg_fix_length_and_dec
(
Item_sum_avg
*
)
const
;
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
;
bool
Item_val_bool
(
Item
*
item
)
const
;
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
;
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
...
...
@@ -1494,6 +1502,7 @@ class Type_handler_int_result: public Type_handler_numeric
bool
Item_sum_sum_fix_length_and_dec
(
Item_sum_sum
*
)
const
;
bool
Item_sum_avg_fix_length_and_dec
(
Item_sum_avg
*
)
const
;
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
;
bool
Item_val_bool
(
Item
*
item
)
const
;
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
;
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
...
...
@@ -1564,6 +1573,7 @@ class Type_handler_temporal_result: public Type_handler
bool
Item_sum_sum_fix_length_and_dec
(
Item_sum_sum
*
)
const
;
bool
Item_sum_avg_fix_length_and_dec
(
Item_sum_avg
*
)
const
;
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
;
bool
Item_val_bool
(
Item
*
item
)
const
;
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
;
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
const
;
...
...
@@ -1673,6 +1683,7 @@ class Type_handler_string_result: public Type_handler
bool
Item_sum_variance_fix_length_and_dec
(
Item_sum_variance
*
)
const
;
bool
Item_func_signed_fix_length_and_dec
(
Item_func_signed
*
item
)
const
;
bool
Item_func_unsigned_fix_length_and_dec
(
Item_func_unsigned
*
item
)
const
;
bool
Item_val_bool
(
Item
*
item
)
const
;
longlong
Item_val_int_signed_typecast
(
Item
*
item
)
const
;
longlong
Item_val_int_unsigned_typecast
(
Item
*
item
)
const
;
String
*
Item_func_hex_val_str_ascii
(
Item_func_hex
*
item
,
String
*
str
)
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