diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-09 10:43:45 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-09 10:43:45 -0500 |
commit | bad5116957eea2dc360c6c233be08284bd3d5364 (patch) | |
tree | c7cf0fd40fd7e37f6e14ed4a9c883a8b129a32a3 /src | |
parent | ccff2d20ed9622815df2a7deffce8a7b14830965 (diff) | |
download | postgresql-bad5116957eea2dc360c6c233be08284bd3d5364.tar.gz postgresql-bad5116957eea2dc360c6c233be08284bd3d5364.zip |
Const-ify a couple of datetime parsing subroutines.
More could be done in this line, but I just grabbed some low-hanging
fruit. Principal objective was to remove the need for several ugly
unconstify() usages in formatting.c.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/formatting.c | 6 | ||||
-rw-r--r-- | src/include/utils/datetime.h | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 8cd10ab204a..6893c1ce09c 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -3145,7 +3145,7 @@ DecodeNumberField(int len, char *str, int fmask, * Return 0 if okay (and set *tzp), a DTERR code if not okay. */ int -DecodeTimezone(char *str, int *tzp) +DecodeTimezone(const char *str, int *tzp) { int tz; int hr, @@ -3223,7 +3223,7 @@ DecodeTimezone(char *str, int *tzp) * will be related in format. */ int -DecodeTimezoneAbbrev(int field, char *lowtoken, +DecodeTimezoneAbbrev(int field, const char *lowtoken, int *offset, pg_tz **tz) { int type; @@ -3278,7 +3278,7 @@ DecodeTimezoneAbbrev(int field, char *lowtoken, * will be related in format. */ int -DecodeSpecial(int field, char *lowtoken, int *val) +DecodeSpecial(int field, const char *lowtoken, int *val) { int type; const datetkn *tp; @@ -3985,7 +3985,7 @@ DecodeISO8601Interval(char *str, * will be related in format. */ int -DecodeUnits(int field, char *lowtoken, int *val) +DecodeUnits(int field, const char *lowtoken, int *val) { int type; const datetkn *tp; diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 26f498b5df4..311c9e748ba 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -4246,7 +4246,7 @@ to_timestamp(PG_FUNCTION_ARGS) /* Use the specified time zone, if any. */ if (tm.tm_zone) { - int dterr = DecodeTimezone(unconstify(char *, tm.tm_zone), &tz); + int dterr = DecodeTimezone(tm.tm_zone, &tz); if (dterr) DateTimeParseError(dterr, text_to_cstring(date_txt), "timestamptz"); @@ -4343,7 +4343,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict, if (tm.tm_zone) { - int dterr = DecodeTimezone(unconstify(char *, tm.tm_zone), tz); + int dterr = DecodeTimezone(tm.tm_zone, tz); if (dterr) DateTimeParseError(dterr, text_to_cstring(date_txt), "timestamptz"); @@ -4429,7 +4429,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict, if (tm.tm_zone) { - int dterr = DecodeTimezone(unconstify(char *, tm.tm_zone), tz); + int dterr = DecodeTimezone(tm.tm_zone, tz); if (dterr) RETURN_ERROR(DateTimeParseError(dterr, text_to_cstring(date_txt), "timetz")); diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index 2cae346beb0..934cb56a3a5 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -296,7 +296,7 @@ extern int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, extern int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp); -extern int DecodeTimezone(char *str, int *tzp); +extern int DecodeTimezone(const char *str, int *tzp); extern int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp); @@ -322,10 +322,10 @@ extern void EncodeSpecialTimestamp(Timestamp dt, char *str); extern int ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm); -extern int DecodeTimezoneAbbrev(int field, char *lowtoken, +extern int DecodeTimezoneAbbrev(int field, const char *lowtoken, int *offset, pg_tz **tz); -extern int DecodeSpecial(int field, char *lowtoken, int *val); -extern int DecodeUnits(int field, char *lowtoken, int *val); +extern int DecodeSpecial(int field, const char *lowtoken, int *val); +extern int DecodeUnits(int field, const char *lowtoken, int *val); extern int j2day(int date); |