00001 /* 00002 * src/include/utils/cash.h 00003 * 00004 * 00005 * cash.h 00006 * Written by D'Arcy J.M. Cain 00007 * 00008 * Functions to allow input and output of money normally but store 00009 * and handle it as 64 bit integer. 00010 */ 00011 00012 #ifndef CASH_H 00013 #define CASH_H 00014 00015 #include "fmgr.h" 00016 00017 typedef int64 Cash; 00018 00019 /* Cash is pass-by-reference if and only if int64 is */ 00020 #define DatumGetCash(X) ((Cash) DatumGetInt64(X)) 00021 #define CashGetDatum(X) Int64GetDatum(X) 00022 #define PG_GETARG_CASH(n) DatumGetCash(PG_GETARG_DATUM(n)) 00023 #define PG_RETURN_CASH(x) return CashGetDatum(x) 00024 00025 extern Datum cash_in(PG_FUNCTION_ARGS); 00026 extern Datum cash_out(PG_FUNCTION_ARGS); 00027 extern Datum cash_recv(PG_FUNCTION_ARGS); 00028 extern Datum cash_send(PG_FUNCTION_ARGS); 00029 00030 extern Datum cash_eq(PG_FUNCTION_ARGS); 00031 extern Datum cash_ne(PG_FUNCTION_ARGS); 00032 extern Datum cash_lt(PG_FUNCTION_ARGS); 00033 extern Datum cash_le(PG_FUNCTION_ARGS); 00034 extern Datum cash_gt(PG_FUNCTION_ARGS); 00035 extern Datum cash_ge(PG_FUNCTION_ARGS); 00036 extern Datum cash_cmp(PG_FUNCTION_ARGS); 00037 00038 extern Datum cash_pl(PG_FUNCTION_ARGS); 00039 extern Datum cash_mi(PG_FUNCTION_ARGS); 00040 extern Datum cash_div_cash(PG_FUNCTION_ARGS); 00041 00042 extern Datum cash_mul_flt8(PG_FUNCTION_ARGS); 00043 extern Datum flt8_mul_cash(PG_FUNCTION_ARGS); 00044 extern Datum cash_div_flt8(PG_FUNCTION_ARGS); 00045 00046 extern Datum cash_mul_flt4(PG_FUNCTION_ARGS); 00047 extern Datum flt4_mul_cash(PG_FUNCTION_ARGS); 00048 extern Datum cash_div_flt4(PG_FUNCTION_ARGS); 00049 00050 extern Datum cash_mul_int8(PG_FUNCTION_ARGS); 00051 extern Datum int8_mul_cash(PG_FUNCTION_ARGS); 00052 extern Datum cash_div_int8(PG_FUNCTION_ARGS); 00053 00054 extern Datum cash_mul_int4(PG_FUNCTION_ARGS); 00055 extern Datum int4_mul_cash(PG_FUNCTION_ARGS); 00056 extern Datum cash_div_int4(PG_FUNCTION_ARGS); 00057 00058 extern Datum cash_mul_int2(PG_FUNCTION_ARGS); 00059 extern Datum int2_mul_cash(PG_FUNCTION_ARGS); 00060 extern Datum cash_div_int2(PG_FUNCTION_ARGS); 00061 00062 extern Datum cashlarger(PG_FUNCTION_ARGS); 00063 extern Datum cashsmaller(PG_FUNCTION_ARGS); 00064 00065 extern Datum cash_words(PG_FUNCTION_ARGS); 00066 00067 extern Datum cash_numeric(PG_FUNCTION_ARGS); 00068 extern Datum numeric_cash(PG_FUNCTION_ARGS); 00069 00070 extern Datum int4_cash(PG_FUNCTION_ARGS); 00071 extern Datum int8_cash(PG_FUNCTION_ARGS); 00072 00073 #endif /* CASH_H */