aboutsummaryrefslogtreecommitdiffstats
path: root/sql/date.c
diff options
context:
space:
mode:
Diffstat (limited to 'sql/date.c')
-rw-r--r--sql/date.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/sql/date.c b/sql/date.c
index e86d7f75..4f0f80ee 100644
--- a/sql/date.c
+++ b/sql/date.c
@@ -57,9 +57,9 @@ static inline TDate TDate_from_DateADT(DateADT d) {
}
static inline const char* cal_from_currency(const char* curr) {
- const char default_cal[] = "NONE";
- const char us_cal[] = "/usr/share/cds/US";
- if (strcmp(currency, "USD") == 0) {
+ static const char default_cal[] = "NONE";
+ static const char us_cal[] = "/usr/share/cds/US";
+ if (strcmp(curr, "USD") == 0) {
return us_cal;
} else {
return default_cal;
@@ -68,8 +68,6 @@ static inline const char* cal_from_currency(const char* curr) {
PG_FUNCTION_INFO_V1(cds_accrued);
Datum cds_accrued(PG_FUNCTION_ARGS) {
- const char default_cal[] = "NONE";
- const char us_cal[] = "/usr/share/cds/US";
DateADT d = PG_GETARG_DATEADT(0);
float8 coupon = PG_GETARG_FLOAT8(1);
bool include_cashflow = PG_GETARG_BOOL(2);
@@ -77,9 +75,9 @@ Datum cds_accrued(PG_FUNCTION_ARGS) {
const char* cal = cal_from_currency(currency);
TDate date = TDate_from_DateADT(d) + 1;
TDate date1 = next_business_day(date, JPMCDS_BAD_DAY_PREVIOUS, cal);
- if (date1 == -1) {
- elog(ERROR, "Please set up the US calendar in /usr/share/cds/US");
- }
+ if (date1 == -1)
+ elog(ERROR, "Please set up the US calendar in /usr/share/cds/US");
+
TDate date_prev = _previous_twentieth(date1, true, cal);
if ((date_prev == date) && include_cashflow) {