Re: Request to clarify on sql_numeric datatype - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Request to clarify on sql_numeric datatype
Date
Msg-id 248.1126879914@sss.pgh.pa.us
Whole thread Raw
In response to Request to clarify on sql_numeric datatype  (Raghavendra Reddy <raghavendrar@aztec.soft.net>)
List pgsql-hackers
Raghavendra Reddy <raghavendrar@aztec.soft.net> writes:
>       While inserting numeric data type into a table can you please let me
> know how you are storing the value in the database.

From src/include/utils/numeric.h:

/** The Numeric data type stored in the database** NOTE: by convention, values in the packed form have been stripped
of*all leading and trailing zero digits (where a "digit" is of base NBASE).* In particular, if the value is zero, there
willbe no digits at all!* The weight is arbitrary in that case, but we normally set it to zero.*/
 
typedef struct NumericData
{   int32       varlen;         /* Variable size (std varlena header) */   int16       n_weight;       /* Weight of 1st
digit */   uint16      n_sign_dscale;  /* Sign + display scale */   char        n_data[1];      /* Digits (really array
ofNumericDigit) */
 
} NumericData;

See also the comments at the top of src/backend/utils/adt/numeric.c.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: New dot releases
Next
From: Peter Eisentraut
Date:
Subject: Re: inverse OR distributive law?