Codebase list orafce / 9c9e7a7
Add upstream patch to fix to_date() crashes on 32 bit systems Martin Pitt 9 years ago
3 changed file(s) with 65 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
00 orafce (3.0.7-2) UNRELEASED; urgency=medium
11
22 * Add missing net-tools test dependency.
3 * Add upstream patch to fix to_date() crashes on 32 bit systems.
34
45 -- Martin Pitt <mpitt@debian.org> Fri, 22 Aug 2014 09:47:42 +0200
56
0 From 2c635c6214753aab952293ebebe77db0fed00205 Mon Sep 17 00:00:00 2001
1 From: Pavel Stehule <pavel.stehule@gmail.com>
2 Date: Sun, 24 Aug 2014 21:54:44 +0200
3 Subject: [PATCH] bugfix: to_date() crashes on 32 bit with certain date
4 formats #15
5
6 fix messy conversions between timestamp and datum
7 ---
8 convert.c | 4 ++--
9 datefce.c | 12 +++++++-----
10 2 files changed, 9 insertions(+), 7 deletions(-)
11
12 diff --git a/convert.c b/convert.c
13 index f7520c8..83bd020 100644
14 --- a/convert.c
15 +++ b/convert.c
16 @@ -125,14 +125,14 @@ orafce_to_char_numeric(PG_FUNCTION_ARGS)
17 Datum
18 orafce_to_char_timestamp(PG_FUNCTION_ARGS)
19 {
20 - Timestamp date_txt = PG_GETARG_TIMESTAMP(0);
21 + Timestamp ts = PG_GETARG_TIMESTAMP(0);
22 text *result = NULL;
23
24 if(nls_date_format && strlen(nls_date_format))
25 {
26 /* it will return the DATE in nls_date_format*/
27 result = DatumGetTextP(DirectFunctionCall2(timestamp_to_char,
28 - CStringGetDatum(date_txt),
29 + TimestampGetDatum(ts),
30 CStringGetDatum(cstring_to_text(nls_date_format))));
31 }
32
33 diff --git a/datefce.c b/datefce.c
34 index e228a12..1480fe0 100644
35 --- a/datefce.c
36 +++ b/datefce.c
37 @@ -590,15 +590,17 @@ _ora_date_round(DateADT day, int f)
38 Datum ora_to_date(PG_FUNCTION_ARGS)
39 {
40 text *date_txt = PG_GETARG_TEXT_P(0);
41 - Timestamp newDate, result;
42 + Timestamp result;
43
44 if(nls_date_format && strlen(nls_date_format))
45 {
46 + Datum newDate;
47 +
48 /* it will return timestamp at GMT */
49 - newDate = DatumGetTimestamp(DirectFunctionCall2(to_timestamp,
50 - CStringGetDatum(date_txt),
51 - CStringGetDatum(
52 - cstring_to_text(nls_date_format))));
53 + newDate = DirectFunctionCall2(to_timestamp,
54 + CStringGetDatum(date_txt),
55 + CStringGetDatum(cstring_to_text(nls_date_format)));
56 +
57 /* convert to local timestamp */
58 result = DatumGetTimestamp(DirectFunctionCall1(timestamptz_timestamp, newDate));
59 }
60 --
61 2.1.0
62
0 git-to_date-conversion
01 regress-no-alert