Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eb990a2

Browse files
committed
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.
1 parent 531e60a commit eb990a2

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,7 +4337,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
43374337
int tzoff;
43384338
struct pg_tm tm;
43394339
fsec_t fsec;
4340-
char *tzn;
4340+
const char *tzn;
43414341
Interval *resInterval;
43424342
struct pg_tm itm;
43434343

src/backend/utils/adt/formatting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ typedef struct TmToChar
459459
{
460460
struct pg_tm tm; /* classic 'tm' struct */
461461
fsec_t fsec; /* fractional seconds */
462-
char *tzn; /* timezone */
462+
const char *tzn; /* timezone */
463463
} TmToChar;
464464

465465
#define tmtcTm(_X) (&(_X)->tm)

src/backend/utils/adt/timestamp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ timestamptz_out(PG_FUNCTION_ARGS)
494494
struct pg_tm tt,
495495
*tm = &tt;
496496
fsec_t fsec;
497-
char *tzn;
497+
const char *tzn;
498498
char buf[MAXDATELEN + 1];
499499

500500
if (TIMESTAMP_NOT_FINITE(dt))
@@ -1415,7 +1415,7 @@ timestamptz_to_str(TimestampTz t)
14151415
struct pg_tm tt,
14161416
*tm = &tt;
14171417
fsec_t fsec;
1418-
char *tzn;
1418+
const char *tzn;
14191419

14201420
if (TIMESTAMP_NOT_FINITE(t))
14211421
EncodeSpecialTimestamp(t, buf);
@@ -1466,7 +1466,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
14661466
* timezone) will be used.
14671467
*/
14681468
int
1469-
timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn, pg_tz *attimezone)
1469+
timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
14701470
{
14711471
Timestamp date;
14721472
Timestamp time;
@@ -1602,7 +1602,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn
16021602
tm->tm_zone = tx->tm_zone;
16031603
*tzp = -tm->tm_gmtoff;
16041604
if (tzn != NULL)
1605-
*tzn = (char *) tm->tm_zone;
1605+
*tzn = tm->tm_zone;
16061606
}
16071607
else
16081608
{

src/backend/utils/adt/xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings)
20132013
struct pg_tm tm;
20142014
int tz;
20152015
fsec_t fsec;
2016-
char *tzn = NULL;
2016+
const char *tzn = NULL;
20172017
char buf[MAXDATELEN + 1];
20182018

20192019
timestamp = DatumGetTimestamp(value);

src/include/utils/timestamp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ extern const char *timestamptz_to_str(TimestampTz t);
222222

223223
extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
224224
extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm,
225-
fsec_t *fsec, char **tzn, pg_tz *attimezone);
225+
fsec_t *fsec, const char **tzn, pg_tz *attimezone);
226226
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);
227227

228228
extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec);

src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ SetEpochTimestamp(void)
119119
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
120120
*/
121121
static int
122-
timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
122+
timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, const char **tzn)
123123
{
124124
#ifdef HAVE_INT64_TIMESTAMP
125125
int64 dDate,
@@ -224,7 +224,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
224224

225225
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
226226
if (tzn != NULL)
227-
*tzn = (char *) tm->tm_zone;
227+
*tzn = tm->tm_zone;
228228
#elif defined(HAVE_INT_TIMEZONE)
229229
*tzp = (tm->tm_isdst > 0) ? TIMEZONE_GLOBAL - SECS_PER_HOUR : TIMEZONE_GLOBAL;
230230
if (tzn != NULL)

0 commit comments

Comments
 (0)