Commit eb990a2b authored by Peter Eisentraut's avatar Peter Eisentraut

Add const qualifier to tzn returned by timestamp2tm()

The tzn value might come from tm->tm_zone, which libc declares as
const, so it's prudent that the upper layers know about this as well.
parent 531e60ae
...@@ -4337,7 +4337,7 @@ pg_timezone_names(PG_FUNCTION_ARGS) ...@@ -4337,7 +4337,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
int tzoff; int tzoff;
struct pg_tm tm; struct pg_tm tm;
fsec_t fsec; fsec_t fsec;
char *tzn; const char *tzn;
Interval *resInterval; Interval *resInterval;
struct pg_tm itm; struct pg_tm itm;
......
...@@ -459,7 +459,7 @@ typedef struct TmToChar ...@@ -459,7 +459,7 @@ typedef struct TmToChar
{ {
struct pg_tm tm; /* classic 'tm' struct */ struct pg_tm tm; /* classic 'tm' struct */
fsec_t fsec; /* fractional seconds */ fsec_t fsec; /* fractional seconds */
char *tzn; /* timezone */ const char *tzn; /* timezone */
} TmToChar; } TmToChar;
#define tmtcTm(_X) (&(_X)->tm) #define tmtcTm(_X) (&(_X)->tm)
......
...@@ -494,7 +494,7 @@ timestamptz_out(PG_FUNCTION_ARGS) ...@@ -494,7 +494,7 @@ timestamptz_out(PG_FUNCTION_ARGS)
struct pg_tm tt, struct pg_tm tt,
*tm = &tt; *tm = &tt;
fsec_t fsec; fsec_t fsec;
char *tzn; const char *tzn;
char buf[MAXDATELEN + 1]; char buf[MAXDATELEN + 1];
if (TIMESTAMP_NOT_FINITE(dt)) if (TIMESTAMP_NOT_FINITE(dt))
...@@ -1415,7 +1415,7 @@ timestamptz_to_str(TimestampTz t) ...@@ -1415,7 +1415,7 @@ timestamptz_to_str(TimestampTz t)
struct pg_tm tt, struct pg_tm tt,
*tm = &tt; *tm = &tt;
fsec_t fsec; fsec_t fsec;
char *tzn; const char *tzn;
if (TIMESTAMP_NOT_FINITE(t)) if (TIMESTAMP_NOT_FINITE(t))
EncodeSpecialTimestamp(t, buf); EncodeSpecialTimestamp(t, buf);
...@@ -1466,7 +1466,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) ...@@ -1466,7 +1466,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
* timezone) will be used. * timezone) will be used.
*/ */
int int
timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn, pg_tz *attimezone) timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
{ {
Timestamp date; Timestamp date;
Timestamp time; Timestamp time;
...@@ -1602,7 +1602,7 @@ recalc_t: ...@@ -1602,7 +1602,7 @@ recalc_t:
tm->tm_zone = tx->tm_zone; tm->tm_zone = tx->tm_zone;
*tzp = -tm->tm_gmtoff; *tzp = -tm->tm_gmtoff;
if (tzn != NULL) if (tzn != NULL)
*tzn = (char *) tm->tm_zone; *tzn = tm->tm_zone;
} }
else else
{ {
......
...@@ -2013,7 +2013,7 @@ map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings) ...@@ -2013,7 +2013,7 @@ map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings)
struct pg_tm tm; struct pg_tm tm;
int tz; int tz;
fsec_t fsec; fsec_t fsec;
char *tzn = NULL; const char *tzn = NULL;
char buf[MAXDATELEN + 1]; char buf[MAXDATELEN + 1];
timestamp = DatumGetTimestamp(value); timestamp = DatumGetTimestamp(value);
......
...@@ -222,7 +222,7 @@ extern const char *timestamptz_to_str(TimestampTz t); ...@@ -222,7 +222,7 @@ extern const char *timestamptz_to_str(TimestampTz t);
extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt); extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm,
fsec_t *fsec, char **tzn, pg_tz *attimezone); fsec_t *fsec, const char **tzn, pg_tz *attimezone);
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec); extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);
extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec); extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec);
......
...@@ -119,7 +119,7 @@ SetEpochTimestamp(void) ...@@ -119,7 +119,7 @@ SetEpochTimestamp(void)
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27 * local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/ */
static int static int
timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn) timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, const char **tzn)
{ {
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
int64 dDate, int64 dDate,
...@@ -224,7 +224,7 @@ recalc_t: ...@@ -224,7 +224,7 @@ recalc_t:
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
if (tzn != NULL) if (tzn != NULL)
*tzn = (char *) tm->tm_zone; *tzn = tm->tm_zone;
#elif defined(HAVE_INT_TIMEZONE) #elif defined(HAVE_INT_TIMEZONE)
*tzp = (tm->tm_isdst > 0) ? TIMEZONE_GLOBAL - SECS_PER_HOUR : TIMEZONE_GLOBAL; *tzp = (tm->tm_isdst > 0) ? TIMEZONE_GLOBAL - SECS_PER_HOUR : TIMEZONE_GLOBAL;
if (tzn != NULL) if (tzn != NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment