MySQL 8.0.39
Source Code Documentation
|
#include "sql/my_decimal.h"
#include "my_config.h"
#include <stdio.h>
#include <sys/time.h>
#include "decimal.h"
#include "m_ctype.h"
#include "my_dbug.h"
#include "my_sys.h"
#include "my_time.h"
#include "mysql_time.h"
#include "mysqld_error.h"
#include "sql/current_thd.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
Macros | |
#define | DIG_PER_DEC1 9 |
#define | ROUND_UP(X) (((X) + DIG_PER_DEC1 - 1) / DIG_PER_DEC1) |
Functions | |
int | my_decimal2string (uint mask, const my_decimal *d, uint fixed_prec, uint fixed_dec, String *str) |
Converting decimal to string. More... | |
bool | str_set_decimal (uint mask, const my_decimal *val, String *str, const CHARSET_INFO *cs, uint decimals) |
Converting decimal to string with character set conversion. More... | |
int | my_decimal2binary (uint mask, const my_decimal *d, uchar *bin, int prec, int scale) |
int | str2my_decimal (uint mask, const char *from, size_t length, const CHARSET_INFO *charset, my_decimal *decimal_value) |
static my_decimal * | lldiv_t2my_decimal (const lldiv_t *lld, bool neg, my_decimal *dec) |
Convert lldiv_t value to my_decimal value. More... | |
my_decimal * | date2my_decimal (const MYSQL_TIME *ltime, my_decimal *dec) |
Convert datetime value to my_decimal in format YYYYMMDDhhmmss.ffffff. More... | |
my_decimal * | time2my_decimal (const MYSQL_TIME *ltime, my_decimal *dec) |
Convert time value to my_decimal in format hhmmss.ffffff. More... | |
my_decimal * | timeval2my_decimal (const my_timeval *tm, my_decimal *dec) |
Convert timeval value to my_decimal. More... | |
void | my_decimal_trim (ulong *precision, uint *scale) |
void | print_decimal (const my_decimal *dec) |
void | print_decimal_buff (const my_decimal *dec, const uchar *ptr, int length) |
const char * | dbug_decimal_as_string (char *buff, const my_decimal *val) |
#define DIG_PER_DEC1 9 |
#define ROUND_UP | ( | X | ) | (((X) + DIG_PER_DEC1 - 1) / DIG_PER_DEC1) |
my_decimal * date2my_decimal | ( | const MYSQL_TIME * | ltime, |
my_decimal * | dec | ||
) |
Convert datetime value to my_decimal in format YYYYMMDDhhmmss.ffffff.
ltime | Date value to convert from. |
dec | Decimal value to convert to. |
const char * dbug_decimal_as_string | ( | char * | buff, |
const my_decimal * | val | ||
) |
|
static |
Convert lldiv_t value to my_decimal value.
Integer part of the result is set to lld->quot. Fractional part of the result is set to lld->rem divided to 1000000000.
lld | The lldiv_t variable to convert from. | |
neg | Sign flag (negative, 0 positive). | |
[out] | dec | Decimal number to convert to. |
int my_decimal2binary | ( | uint | mask, |
const my_decimal * | d, | ||
uchar * | bin, | ||
int | prec, | ||
int | scale | ||
) |
int my_decimal2string | ( | uint | mask, |
const my_decimal * | d, | ||
uint | fixed_prec, | ||
uint | fixed_dec, | ||
String * | str | ||
) |
Converting decimal to string.
Convert given my_decimal to String; allocate buffer as needed.
[in] | mask | what problems to warn on (mask of E_DEC_* values) |
[in] | d | the decimal to print |
[in] | fixed_prec | overall number of digits if ZEROFILL, 0 otherwise |
[in] | fixed_dec | number of decimal places (if fixed_prec != 0) |
[out] | str | where to store the resulting string |
E_DEC_OK | |
E_DEC_TRUNCATED | |
E_DEC_OVERFLOW | |
E_DEC_OOM |
void my_decimal_trim | ( | ulong * | precision, |
uint * | scale | ||
) |
void print_decimal | ( | const my_decimal * | dec | ) |
void print_decimal_buff | ( | const my_decimal * | dec, |
const uchar * | ptr, | ||
int | length | ||
) |
int str2my_decimal | ( | uint | mask, |
const char * | from, | ||
size_t | length, | ||
const CHARSET_INFO * | charset, | ||
my_decimal * | decimal_value | ||
) |
bool str_set_decimal | ( | uint | mask, |
const my_decimal * | val, | ||
String * | str, | ||
const CHARSET_INFO * | cs, | ||
uint | decimals | ||
) |
Converting decimal to string with character set conversion.
Convert given my_decimal to String; allocate buffer as needed.
[in] | mask | what problems to warn on (mask of E_DEC_* values) |
[in] | val | the decimal to print |
[out] | str | where to store the resulting string |
[in] | cs | character set |
[in] | decimals | round to desired number of decimals |
E_DEC_OK | |
E_DEC_TRUNCATED | |
E_DEC_OVERFLOW | |
E_DEC_OOM |
Would be great to make it a method of the String class, but this would need to include my_decimal.h from sql_string.h and sql_string.cc, which is not desirable.
my_decimal * time2my_decimal | ( | const MYSQL_TIME * | ltime, |
my_decimal * | dec | ||
) |
Convert time value to my_decimal in format hhmmss.ffffff.
ltime | Date value to convert from. |
dec | Decimal value to convert to. |
my_decimal * timeval2my_decimal | ( | const my_timeval * | tm, |
my_decimal * | dec | ||
) |
Convert timeval value to my_decimal.