aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2018-01-16 19:07:13 -0500
committerAndrew Dunstan <andrew@dunslane.net>2018-01-16 19:07:13 -0500
commitcc4feded0a31d2b732d4ea68613115cb720e624e (patch)
treea3e1a713c0a16cfb0dfbe02e9bf718fd56319adf /src/include
parentd91da5ecedc8f8965bd35de66b09feb79c26e5ca (diff)
downloadpostgresql-cc4feded0a31d2b732d4ea68613115cb720e624e.tar.gz
postgresql-cc4feded0a31d2b732d4ea68613115cb720e624e.zip
Centralize json and jsonb handling of datetime types
The creates a single function JsonEncodeDateTime which will format these data types in an efficient and consistent manner. This will be all the more important when we come to jsonpath so we don't have to implement yet more code doing the same thing in two more places. This also extends the code to handle time and timetz types which were not previously handled specially. This requires exposing the time2tm and timetz2tm functions. Patch from Nikita Glukhov
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/date.h4
-rw-r--r--src/include/utils/jsonapi.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/include/utils/date.h b/src/include/utils/date.h
index 274959231b4..e17cd49602e 100644
--- a/src/include/utils/date.h
+++ b/src/include/utils/date.h
@@ -17,7 +17,7 @@
#include <math.h>
#include "fmgr.h"
-
+#include "datatype/timestamp.h"
typedef int32 DateADT;
@@ -73,5 +73,7 @@ extern void EncodeSpecialDate(DateADT dt, char *str);
extern DateADT GetSQLCurrentDate(void);
extern TimeTzADT *GetSQLCurrentTime(int32 typmod);
extern TimeADT GetSQLLocalTime(int32 typmod);
+extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
+extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp);
#endif /* DATE_H */
diff --git a/src/include/utils/jsonapi.h b/src/include/utils/jsonapi.h
index d6baea5368c..e39572e00f2 100644
--- a/src/include/utils/jsonapi.h
+++ b/src/include/utils/jsonapi.h
@@ -147,4 +147,6 @@ extern Jsonb *transform_jsonb_string_values(Jsonb *jsonb, void *action_state,
extern text *transform_json_string_values(text *json, void *action_state,
JsonTransformStringValuesAction transform_action);
+extern char *JsonEncodeDateTime(char *buf, Datum value, Oid typid);
+
#endif /* JSONAPI_H */