aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/serenitas.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/serenitas.c b/sql/serenitas.c
index 82843c9c..1a68f957 100644
--- a/sql/serenitas.c
+++ b/sql/serenitas.c
@@ -85,6 +85,8 @@ static inline const int16 curvetype_from_currency(const char* curr) {
return 530;
} else if (strcmp(curr, "JPY") == 0) {
return 532;
+ } else {
+ elog(ERROR, "unknown currency");
}
}
@@ -113,7 +115,7 @@ Datum cds_accrued(PG_FUNCTION_ARGS) {
PG_RETURN_FLOAT8((date - date_prev) / 360. * coupon);
}
-static inline int get_TCurve(const char* buf, uint32_t length, TCurve* curve) {
+static inline void get_TCurve(const char* buf, uint32_t length, TCurve* curve) {
if (LZ4_decompress_safe(buf, (char*)curve, length, 512) < 0) {
elog(ERROR, "error during decompression");
}
@@ -166,7 +168,10 @@ double calc(TDate today, TDate start_date, TDate end_date, double recovery, doub
false, // pay accrued at start
&result);
}
- return result;
+ if (success == 0)
+ return result;
+ else
+ elog(ERROR, "something went wrong");
}
@@ -260,7 +265,6 @@ update_attach(PG_FUNCTION_ARGS)
{
TriggerData *trigdata = (TriggerData *) fcinfo->context;
Trigger *trigger; /* to get trigger name */
- int nargs; /* # of arguments */
char *relname; /* triggered relation name */
Relation rel; /* triggered relation */
HeapTuple rettuple = NULL;
@@ -303,8 +307,7 @@ update_attach(PG_FUNCTION_ARGS)
char* sql_query = "SELECT indexfactor/100, cumulativeloss "
"FROM index_factors "
"WHERE redindexcode=$1";
- uint64 proc;
- nargs = 1;
+ int nargs = 1;
Oid argtypes[1] = {TEXTOID};
char nulls[1] = " ";
Datum values[1];
@@ -315,7 +318,6 @@ update_attach(PG_FUNCTION_ARGS)
elog(ERROR, "something wrong happened");
}
ret = SPI_execute_with_args(sql_query, nargs, argtypes, values, nulls, true, 1);
- proc = SPI_processed;
double factor, cumloss;
if (ret == SPI_OK_SELECT && SPI_tuptable != NULL) {
SPITupleTable *tuptable = SPI_tuptable;