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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2043e3d4
Commit
2043e3d4
authored
Feb 12, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing the Hybrid_type_traits framework. It's not used since 5.5.
parent
0ed60af4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
243 deletions
+0
-243
sql/item.cc
sql/item.cc
+0
-128
sql/item.h
sql/item.h
+0
-115
No files found.
sql/item.cc
View file @
2043e3d4
...
...
@@ -58,134 +58,6 @@ bool cmp_items(Item *a, Item *b)
return
a
->
eq
(
b
,
FALSE
);
}
/****************************************************************************/
/* Hybrid_type_traits {_real} */
void
Hybrid_type_traits
::
fix_length_and_dec
(
Item
*
item
,
Item
*
arg
)
const
{
item
->
decimals
=
NOT_FIXED_DEC
;
item
->
max_length
=
item
->
float_length
(
arg
->
decimals
);
}
static
const
Hybrid_type_traits
real_traits_instance
;
const
Hybrid_type_traits
*
Hybrid_type_traits
::
instance
()
{
return
&
real_traits_instance
;
}
my_decimal
*
Hybrid_type_traits
::
val_decimal
(
Hybrid_type
*
val
,
my_decimal
*
to
)
const
{
double2my_decimal
(
E_DEC_FATAL_ERROR
,
val
->
real
,
val
->
dec_buf
);
return
val
->
dec_buf
;
}
String
*
Hybrid_type_traits
::
val_str
(
Hybrid_type
*
val
,
String
*
to
,
uint8
decimals
)
const
{
to
->
set_real
(
val
->
real
,
decimals
,
&
my_charset_bin
);
return
to
;
}
/* Hybrid_type_traits_decimal */
static
const
Hybrid_type_traits_decimal
decimal_traits_instance
;
const
Hybrid_type_traits_decimal
*
Hybrid_type_traits_decimal
::
instance
()
{
return
&
decimal_traits_instance
;
}
void
Hybrid_type_traits_decimal
::
fix_length_and_dec
(
Item
*
item
,
Item
*
arg
)
const
{
item
->
decimals
=
arg
->
decimals
;
item
->
max_length
=
MY_MIN
(
arg
->
max_length
+
DECIMAL_LONGLONG_DIGITS
,
DECIMAL_MAX_STR_LENGTH
);
}
void
Hybrid_type_traits_decimal
::
set_zero
(
Hybrid_type
*
val
)
const
{
my_decimal_set_zero
(
&
val
->
dec_buf
[
0
]);
val
->
used_dec_buf_no
=
0
;
}
void
Hybrid_type_traits_decimal
::
add
(
Hybrid_type
*
val
,
Field
*
f
)
const
{
my_decimal_add
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
val
->
used_dec_buf_no
^
1
],
&
val
->
dec_buf
[
val
->
used_dec_buf_no
],
f
->
val_decimal
(
&
val
->
dec_buf
[
2
]));
val
->
used_dec_buf_no
^=
1
;
}
/**
@todo
what is '4' for scale?
*/
void
Hybrid_type_traits_decimal
::
div
(
Hybrid_type
*
val
,
ulonglong
u
)
const
{
int2my_decimal
(
E_DEC_FATAL_ERROR
,
u
,
TRUE
,
&
val
->
dec_buf
[
2
]);
/* XXX: what is '4' for scale? */
my_decimal_div
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
val
->
used_dec_buf_no
^
1
],
&
val
->
dec_buf
[
val
->
used_dec_buf_no
],
&
val
->
dec_buf
[
2
],
4
);
val
->
used_dec_buf_no
^=
1
;
}
longlong
Hybrid_type_traits_decimal
::
val_int
(
Hybrid_type
*
val
,
bool
unsigned_flag
)
const
{
longlong
result
;
my_decimal2int
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
val
->
used_dec_buf_no
],
unsigned_flag
,
&
result
);
return
result
;
}
double
Hybrid_type_traits_decimal
::
val_real
(
Hybrid_type
*
val
)
const
{
my_decimal2double
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
val
->
used_dec_buf_no
],
&
val
->
real
);
return
val
->
real
;
}
String
*
Hybrid_type_traits_decimal
::
val_str
(
Hybrid_type
*
val
,
String
*
to
,
uint8
decimals
)
const
{
my_decimal_round
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
val
->
used_dec_buf_no
],
decimals
,
FALSE
,
&
val
->
dec_buf
[
2
]);
my_decimal2string
(
E_DEC_FATAL_ERROR
,
&
val
->
dec_buf
[
2
],
0
,
0
,
0
,
to
);
return
to
;
}
/* Hybrid_type_traits_integer */
static
const
Hybrid_type_traits_integer
integer_traits_instance
;
const
Hybrid_type_traits_integer
*
Hybrid_type_traits_integer
::
instance
()
{
return
&
integer_traits_instance
;
}
void
Hybrid_type_traits_integer
::
fix_length_and_dec
(
Item
*
item
,
Item
*
arg
)
const
{
item
->
decimals
=
0
;
item
->
max_length
=
MY_INT64_NUM_DECIMAL_DIGITS
;
item
->
unsigned_flag
=
0
;
}
/*****************************************************************************
** Item functions
...
...
sql/item.h
View file @
2043e3d4
...
...
@@ -176,121 +176,6 @@ public:
}
};
/*************************************************************************/
/*
A framework to easily handle different return types for hybrid items
(hybrid item is an item whose operand can be of any type, e.g. integer,
real, decimal).
*/
struct
Hybrid_type_traits
;
struct
Hybrid_type
{
longlong
integer
;
double
real
;
/*
Use two decimal buffers interchangeably to speed up += operation
which has no native support in decimal library.
Hybrid_type+= arg is implemented as dec_buf[1]= dec_buf[0] + arg.
The third decimal is used as a handy temporary storage.
*/
my_decimal
dec_buf
[
3
];
int
used_dec_buf_no
;
/*
Traits moved to a separate class to
a) be able to easily change object traits in runtime
b) they work as a differentiator for the union above
*/
const
Hybrid_type_traits
*
traits
;
Hybrid_type
()
{}
/* XXX: add traits->copy() when needed */
Hybrid_type
(
const
Hybrid_type
&
rhs
)
:
traits
(
rhs
.
traits
)
{}
};
/* Hybryd_type_traits interface + default implementation for REAL_RESULT */
struct
Hybrid_type_traits
{
virtual
Item_result
type
()
const
{
return
REAL_RESULT
;
}
virtual
void
fix_length_and_dec
(
Item
*
item
,
Item
*
arg
)
const
;
/* Hybrid_type operations. */
virtual
void
set_zero
(
Hybrid_type
*
val
)
const
{
val
->
real
=
0.0
;
}
virtual
void
add
(
Hybrid_type
*
val
,
Field
*
f
)
const
{
val
->
real
+=
f
->
val_real
();
}
virtual
void
div
(
Hybrid_type
*
val
,
ulonglong
u
)
const
{
val
->
real
/=
ulonglong2double
(
u
);
}
virtual
longlong
val_int
(
Hybrid_type
*
val
,
bool
unsigned_flag
)
const
{
return
(
longlong
)
rint
(
val
->
real
);
}
virtual
double
val_real
(
Hybrid_type
*
val
)
const
{
return
val
->
real
;
}
virtual
my_decimal
*
val_decimal
(
Hybrid_type
*
val
,
my_decimal
*
buf
)
const
;
virtual
String
*
val_str
(
Hybrid_type
*
val
,
String
*
buf
,
uint8
decimals
)
const
;
static
const
Hybrid_type_traits
*
instance
();
Hybrid_type_traits
()
{}
virtual
~
Hybrid_type_traits
()
{}
};
struct
Hybrid_type_traits_decimal
:
public
Hybrid_type_traits
{
virtual
Item_result
type
()
const
{
return
DECIMAL_RESULT
;
}
virtual
void
fix_length_and_dec
(
Item
*
arg
,
Item
*
item
)
const
;
/* Hybrid_type operations. */
virtual
void
set_zero
(
Hybrid_type
*
val
)
const
;
virtual
void
add
(
Hybrid_type
*
val
,
Field
*
f
)
const
;
virtual
void
div
(
Hybrid_type
*
val
,
ulonglong
u
)
const
;
virtual
longlong
val_int
(
Hybrid_type
*
val
,
bool
unsigned_flag
)
const
;
virtual
double
val_real
(
Hybrid_type
*
val
)
const
;
virtual
my_decimal
*
val_decimal
(
Hybrid_type
*
val
,
my_decimal
*
buf
)
const
{
return
&
val
->
dec_buf
[
val
->
used_dec_buf_no
];
}
virtual
String
*
val_str
(
Hybrid_type
*
val
,
String
*
buf
,
uint8
decimals
)
const
;
static
const
Hybrid_type_traits_decimal
*
instance
();
Hybrid_type_traits_decimal
()
{};
};
struct
Hybrid_type_traits_integer
:
public
Hybrid_type_traits
{
virtual
Item_result
type
()
const
{
return
INT_RESULT
;
}
virtual
void
fix_length_and_dec
(
Item
*
arg
,
Item
*
item
)
const
;
/* Hybrid_type operations. */
virtual
void
set_zero
(
Hybrid_type
*
val
)
const
{
val
->
integer
=
0
;
}
virtual
void
add
(
Hybrid_type
*
val
,
Field
*
f
)
const
{
val
->
integer
+=
f
->
val_int
();
}
virtual
void
div
(
Hybrid_type
*
val
,
ulonglong
u
)
const
{
val
->
integer
/=
(
longlong
)
u
;
}
virtual
longlong
val_int
(
Hybrid_type
*
val
,
bool
unsigned_flag
)
const
{
return
val
->
integer
;
}
virtual
double
val_real
(
Hybrid_type
*
val
)
const
{
return
(
double
)
val
->
integer
;
}
virtual
my_decimal
*
val_decimal
(
Hybrid_type
*
val
,
my_decimal
*
buf
)
const
{
int2my_decimal
(
E_DEC_FATAL_ERROR
,
val
->
integer
,
0
,
&
val
->
dec_buf
[
2
]);
return
&
val
->
dec_buf
[
2
];
}
virtual
String
*
val_str
(
Hybrid_type
*
val
,
String
*
buf
,
uint8
decimals
)
const
{
buf
->
set
(
val
->
integer
,
&
my_charset_bin
);
return
buf
;}
static
const
Hybrid_type_traits_integer
*
instance
();
Hybrid_type_traits_integer
()
{};
};
void
dummy_error_processor
(
THD
*
thd
,
void
*
data
);
...
...
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