PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include "pgtypes_error.h"
#include "pgtypes_numeric.h"
#include "pgtypeslib_extern.h"
Go to the source code of this file.
Macros | |
#define | Max(x, y) ((x) > (y) ? (x) : (y)) |
#define | Min(x, y) ((x) < (y) ? (x) : (y)) |
#define | init_var(v) memset(v,0,sizeof(numeric)) |
#define | digitbuf_alloc(size) ((NumericDigit *) pgtypes_alloc(size)) |
#define | digitbuf_free(buf) free(buf) |
#define digitbuf_alloc | ( | size | ) | ((NumericDigit *) pgtypes_alloc(size)) |
Definition at line 465 of file numeric.c.
References numeric::buf, digitbuf_alloc, digitbuf_free, numeric::digits, numeric::dscale, i, Max, numeric::ndigits, numeric::rscale, and numeric::weight.
Referenced by PGTYPESnumeric_add(), and PGTYPESnumeric_sub().
|
static |
Definition at line 29 of file numeric.c.
References numeric::buf, digitbuf_alloc, digitbuf_free, numeric::digits, and numeric::ndigits.
Referenced by PGTYPESnumeric_copy(), PGTYPESnumeric_from_decimal(), PGTYPESnumeric_from_long(), PGTYPESnumeric_new(), and set_var_from_str().
Definition at line 407 of file numeric.c.
References numeric::digits, stat, and numeric::weight.
Referenced by PGTYPESnumeric_add(), PGTYPESnumeric_cmp(), PGTYPESnumeric_div(), and PGTYPESnumeric_sub().
|
static |
Definition at line 226 of file numeric.c.
References numeric::digits, i, Max, Min, numeric::ndigits, NUMERIC_NAN, NUMERIC_NEG, pgtypes_alloc(), numeric::sign, sprintf, str, and numeric::weight.
Referenced by numericvar_to_double(), and PGTYPESnumeric_to_asc().
|
static |
Definition at line 1432 of file numeric.c.
References numeric::dscale, free, get_str_from_var(), PGTYPES_NUM_BAD_NUMERIC, PGTYPES_NUM_OVERFLOW, PGTYPES_NUM_UNDERFLOW, PGTYPESnumeric_copy(), PGTYPESnumeric_free(), PGTYPESnumeric_new(), and val.
Referenced by PGTYPESnumeric_to_double().
void PGTYPESdecimal_free | ( | decimal * | var | ) |
decimal* PGTYPESdecimal_new | ( | void | ) |
Definition at line 59 of file numeric.c.
References pgtypes_alloc().
Referenced by main().
Definition at line 637 of file numeric.c.
References add_abs(), cmp_abs(), numeric::dscale, Max, NUMERIC_NEG, NUMERIC_POS, numeric::rscale, numeric::sign, sub_abs(), and zero_var().
Definition at line 1281 of file numeric.c.
References cmp_abs(), NUMERIC_NEG, NUMERIC_POS, PGTYPES_NUM_BAD_NUMERIC, and numeric::sign.
Definition at line 1388 of file numeric.c.
References alloc_var(), numeric::digits, numeric::dscale, i, numeric::ndigits, numeric::rscale, numeric::sign, numeric::weight, and zero_var().
Referenced by ecpg_get_data(), ecpg_store_input(), main(), numericvar_to_double(), PGTYPESnumeric_from_double(), and PGTYPESnumeric_to_asc().
Definition at line 1053 of file numeric.c.
References buf, numeric::buf, cmp_abs(), digitbuf_alloc, digitbuf_free, digits, numeric::digits, numeric::dscale, err(), i, init_var, numeric::ndigits, NUMERIC_NEG, NUMERIC_POS, PGTYPES_NUM_DIVIDE_ZERO, numeric::rscale, select_div_scale(), numeric::sign, sub_abs(), numeric::weight, and zero_var().
void PGTYPESnumeric_free | ( | numeric * | var | ) |
Definition at line 385 of file numeric.c.
References numeric::buf, digitbuf_free, and free.
Referenced by deccall2(), deccall3(), deccvasc(), deccvdbl(), deccvint(), deccvlong(), dectoasc(), dectodbl(), dectoint(), dectolong(), ecpg_get_data(), ecpg_set_compat_sqlda(), ecpg_set_native_sqlda(), ecpg_store_input(), main(), numericvar_to_double(), PGTYPESnumeric_from_asc(), PGTYPESnumeric_from_double(), PGTYPESnumeric_to_asc(), and sqlda_common_total_size().
numeric* PGTYPESnumeric_from_asc | ( | char * | str, |
char ** | endptr | ||
) |
Definition at line 321 of file numeric.c.
References pgtypes_alloc(), PGTYPESnumeric_free(), set_var_from_str(), str, and value.
Referenced by deccvasc(), ecpg_get_data(), ecpg_set_compat_sqlda(), ecpg_set_native_sqlda(), main(), PGTYPESnumeric_from_double(), and sqlda_common_total_size().
Definition at line 1570 of file numeric.c.
References alloc_var(), numeric::digits, decimal::digits, numeric::dscale, decimal::dscale, i, decimal::ndigits, numeric::rscale, decimal::rscale, numeric::sign, decimal::sign, numeric::weight, decimal::weight, and zero_var().
Referenced by deccall2(), deccall3(), dectoasc(), dectodbl(), dectoint(), dectolong(), ecpg_store_input(), and main().
int PGTYPESnumeric_from_double | ( | double | d, |
numeric * | dst | ||
) |
Definition at line 1411 of file numeric.c.
References i, PGTYPESnumeric_copy(), PGTYPESnumeric_free(), PGTYPESnumeric_from_asc(), and sprintf.
Referenced by deccvdbl().
int PGTYPESnumeric_from_int | ( | signed int | int_val, |
numeric * | var | ||
) |
Definition at line 1309 of file numeric.c.
References PGTYPESnumeric_from_long().
Referenced by deccvint(), and main().
int PGTYPESnumeric_from_long | ( | signed long int | long_val, |
numeric * | var | ||
) |
Definition at line 1318 of file numeric.c.
References alloc_var(), numeric::digits, numeric::dscale, i, NUMERIC_NEG, NUMERIC_POS, numeric::rscale, numeric::sign, size, and numeric::weight.
Referenced by deccvlong(), main(), and PGTYPESnumeric_from_int().
Definition at line 896 of file numeric.c.
References numeric::buf, digitbuf_alloc, digitbuf_free, numeric::digits, numeric::dscale, i, numeric::ndigits, NUMERIC_NEG, NUMERIC_POS, numeric::rscale, numeric::sign, and numeric::weight.
numeric* PGTYPESnumeric_new | ( | void | ) |
Definition at line 42 of file numeric.c.
References alloc_var(), free, and pgtypes_alloc().
Referenced by deccall2(), deccall3(), deccvdbl(), deccvint(), deccvlong(), dectoasc(), dectodbl(), dectoint(), dectolong(), ecpg_get_data(), ecpg_store_input(), main(), numericvar_to_double(), and PGTYPESnumeric_to_asc().
Definition at line 765 of file numeric.c.
References add_abs(), cmp_abs(), numeric::dscale, Max, NUMERIC_NEG, NUMERIC_POS, numeric::rscale, numeric::sign, sub_abs(), and zero_var().
char* PGTYPESnumeric_to_asc | ( | numeric * | num, |
int | dscale | ||
) |
Definition at line 343 of file numeric.c.
References numeric::dscale, get_str_from_var(), PGTYPESnumeric_copy(), PGTYPESnumeric_free(), and PGTYPESnumeric_new().
Referenced by dectoasc(), dump_sqlda(), ecpg_store_input(), main(), and PGTYPESnumeric_to_long().
Definition at line 1547 of file numeric.c.
References DECSIZE, numeric::digits, decimal::digits, numeric::dscale, decimal::dscale, i, numeric::ndigits, decimal::ndigits, PGTYPES_NUM_OVERFLOW, numeric::rscale, decimal::rscale, numeric::sign, decimal::sign, numeric::weight, and decimal::weight.
Referenced by deccall3(), deccvasc(), deccvdbl(), deccvint(), deccvlong(), ecpg_get_data(), and main().
int PGTYPESnumeric_to_double | ( | numeric * | nv, |
double * | dp | ||
) |
Definition at line 1483 of file numeric.c.
References numericvar_to_double().
Referenced by dectodbl(), and main().
int PGTYPESnumeric_to_int | ( | numeric * | nv, |
int * | ip | ||
) |
Definition at line 1494 of file numeric.c.
References i, PGTYPES_NUM_OVERFLOW, and PGTYPESnumeric_to_long().
Referenced by dectoint(), and main().
int PGTYPESnumeric_to_long | ( | numeric * | nv, |
long * | lp | ||
) |
Definition at line 1518 of file numeric.c.
References free, PGTYPES_NUM_OVERFLOW, PGTYPES_NUM_UNDERFLOW, and PGTYPESnumeric_to_asc().
Referenced by dectolong(), main(), and PGTYPESnumeric_to_int().
Definition at line 987 of file numeric.c.
References numeric::digits, numeric::dscale, i, Max, Min, numeric::ndigits, NUMERIC_MAX_DISPLAY_SCALE, NUMERIC_MIN_DISPLAY_SCALE, NUMERIC_MIN_SIG_DIGITS, and numeric::weight.
Referenced by PGTYPESnumeric_div().
|
static |
Definition at line 78 of file numeric.c.
References alloc_var(), generate_unaccent_rules::dest, i, NUMERIC_NAN, NUMERIC_NEG, NUMERIC_POS, pg_strncasecmp(), PGTYPES_NUM_BAD_NUMERIC, and str.
Referenced by PGTYPESnumeric_from_asc().
Definition at line 553 of file numeric.c.
References numeric::buf, digitbuf_alloc, digitbuf_free, numeric::digits, numeric::dscale, i, Max, numeric::ndigits, numeric::rscale, and numeric::weight.
Referenced by PGTYPESnumeric_add(), PGTYPESnumeric_div(), and PGTYPESnumeric_sub().
|
static |
Definition at line 374 of file numeric.c.
References numeric::buf, digitbuf_free, numeric::digits, numeric::ndigits, NUMERIC_POS, numeric::sign, and numeric::weight.
Referenced by PGTYPESnumeric_add(), PGTYPESnumeric_copy(), PGTYPESnumeric_div(), PGTYPESnumeric_from_decimal(), and PGTYPESnumeric_sub().