LCOV - differential code coverage report
Current view: top level - src/include/utils - numeric.h (source / functions) Coverage Total Hit GNC ECB DCB
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 6 6 6 5 1
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 3 3 3 2 1
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (180,240] days: 100.0 % 6 6 6
Legend: Lines: hit not hit Function coverage date bins:
(180,240] days: 100.0 % 3 3 3
(240..) days: 0.0 % 2 0 2

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  * numeric.h
                                  4                 :  *    Definitions for the exact numeric data type of Postgres
                                  5                 :  *
                                  6                 :  * Original coding 1998, Jan Wieck.  Heavily revised 2003, Tom Lane.
                                  7                 :  *
                                  8                 :  * Copyright (c) 1998-2023, PostgreSQL Global Development Group
                                  9                 :  *
                                 10                 :  * src/include/utils/numeric.h
                                 11                 :  *
                                 12                 :  *-------------------------------------------------------------------------
                                 13                 :  */
                                 14                 : #ifndef _PG_NUMERIC_H_
                                 15                 : #define _PG_NUMERIC_H_
                                 16                 : 
                                 17                 : #include "fmgr.h"
                                 18                 : 
                                 19                 : /*
                                 20                 :  * Limits on the precision and scale specifiable in a NUMERIC typmod.  The
                                 21                 :  * precision is strictly positive, but the scale may be positive or negative.
                                 22                 :  * A negative scale implies rounding before the decimal point.
                                 23                 :  *
                                 24                 :  * Note that the minimum display scale defined below is zero --- we always
                                 25                 :  * display all digits before the decimal point, even when the scale is
                                 26                 :  * negative.
                                 27                 :  *
                                 28                 :  * Note that the implementation limits on the precision and display scale of a
                                 29                 :  * numeric value are much larger --- beware of what you use these for!
                                 30                 :  */
                                 31                 : #define NUMERIC_MAX_PRECISION       1000
                                 32                 : 
                                 33                 : #define NUMERIC_MIN_SCALE           (-1000)
                                 34                 : #define NUMERIC_MAX_SCALE           1000
                                 35                 : 
                                 36                 : /*
                                 37                 :  * Internal limits on the scales chosen for calculation results
                                 38                 :  */
                                 39                 : #define NUMERIC_MAX_DISPLAY_SCALE   NUMERIC_MAX_PRECISION
                                 40                 : #define NUMERIC_MIN_DISPLAY_SCALE   0
                                 41                 : 
                                 42                 : #define NUMERIC_MAX_RESULT_SCALE    (NUMERIC_MAX_PRECISION * 2)
                                 43                 : 
                                 44                 : /*
                                 45                 :  * For inherently inexact calculations such as division and square root,
                                 46                 :  * we try to get at least this many significant digits; the idea is to
                                 47                 :  * deliver a result no worse than float8 would.
                                 48                 :  */
                                 49                 : #define NUMERIC_MIN_SIG_DIGITS      16
                                 50                 : 
                                 51                 : /* The actual contents of Numeric are private to numeric.c */
                                 52                 : struct NumericData;
                                 53                 : typedef struct NumericData *Numeric;
                                 54                 : 
                                 55                 : /*
                                 56                 :  * fmgr interface macros
                                 57                 :  */
                                 58                 : 
                                 59                 : static inline Numeric
  194 peter                      60 GNC     9367488 : DatumGetNumeric(Datum X)
                                 61                 : {
                                 62         9367488 :     return (Numeric) PG_DETOAST_DATUM(X);
                                 63                 : }
                                 64                 : 
                                 65                 : static inline Numeric
                                 66               9 : DatumGetNumericCopy(Datum X)
                                 67                 : {
                                 68               9 :     return (Numeric) PG_DETOAST_DATUM_COPY(X);
                                 69                 : }
                                 70                 : 
                                 71                 : static inline Datum
                                 72         1746197 : NumericGetDatum(Numeric X)
                                 73                 : {
                                 74         1746197 :     return PointerGetDatum(X);
                                 75                 : }
                                 76                 : 
 8053 bruce                      77 ECB             : #define PG_GETARG_NUMERIC(n)      DatumGetNumeric(PG_GETARG_DATUM(n))
                                 78                 : #define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
                                 79                 : #define PG_RETURN_NUMERIC(x)      return NumericGetDatum(x)
                                 80                 : 
 4990 tgl                        81                 : /*
                                 82                 :  * Utility functions in numeric.c
                                 83                 :  */
                                 84                 : extern bool numeric_is_nan(Numeric num);
                                 85                 : extern bool numeric_is_inf(Numeric num);
                                 86                 : extern int32 numeric_maximum_size(int32 typmod);
                                 87                 : extern char *numeric_out_sci(Numeric num, int scale);
                                 88                 : extern char *numeric_normalize(Numeric num);
                                 89                 : 
                                 90                 : extern Numeric int64_to_numeric(int64 val);
                                 91                 : extern Numeric int64_div_fast_to_numeric(int64 val1, int log10val2);
                                 92                 : 
                                 93                 : extern Numeric numeric_add_opt_error(Numeric num1, Numeric num2,
                                 94                 :                                      bool *have_error);
                                 95                 : extern Numeric numeric_sub_opt_error(Numeric num1, Numeric num2,
                                 96                 :                                      bool *have_error);
                                 97                 : extern Numeric numeric_mul_opt_error(Numeric num1, Numeric num2,
                                 98                 :                                      bool *have_error);
                                 99                 : extern Numeric numeric_div_opt_error(Numeric num1, Numeric num2,
                                100                 :                                      bool *have_error);
                                101                 : extern Numeric numeric_mod_opt_error(Numeric num1, Numeric num2,
                                102                 :                                      bool *have_error);
                                103                 : extern int32 numeric_int4_opt_error(Numeric num, bool *have_error);
                                104                 : 
                                105                 : #endif                          /* _PG_NUMERIC_H_ */
        

Generated by: LCOV version v1.16-55-g56c0a2a