aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-12-09 16:07:49 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-12-09 16:07:49 -0500
commitc60488b4748b4316f1c92d62457671046e5c8994 (patch)
tree3868154eb7b042e1fa6bca2e0f581b5c8e28b5b6 /src/backend/utils/adt/formatting.c
parent2661469d862239ea8b9e3a1cf5352d833f6f0fec (diff)
downloadpostgresql-c60488b4748b4316f1c92d62457671046e5c8994.tar.gz
postgresql-c60488b4748b4316f1c92d62457671046e5c8994.zip
Convert datetime input functions to use "soft" error reporting.
This patch converts the input functions for date, time, timetz, timestamp, timestamptz, and interval to the new soft-error style. There's some related stuff in formatting.c that remains to be cleaned up, but that seems like a separable project. Discussion: https://postgr.es/m/3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 0d065d8e418..eba981abd85 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -4251,7 +4251,7 @@ to_timestamp(PG_FUNCTION_ARGS)
if (dterr)
DateTimeParseError(dterr, &extra, text_to_cstring(date_txt),
- "timestamptz");
+ "timestamptz", NULL);
}
else
tz = DetermineTimeZoneOffset(&tm, session_timezone);
@@ -4263,7 +4263,7 @@ to_timestamp(PG_FUNCTION_ARGS)
/* Use the specified fractional precision, if any. */
if (fprec)
- AdjustTimestampForTypmod(&result, fprec);
+ AdjustTimestampForTypmod(&result, fprec, NULL);
PG_RETURN_TIMESTAMP(result);
}
@@ -4351,7 +4351,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
if (dterr)
DateTimeParseError(dterr, &extra,
text_to_cstring(date_txt),
- "timestamptz");
+ "timestamptz", NULL);
}
else
{
@@ -4372,7 +4372,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamptz out of range"))));
- AdjustTimestampForTypmod(&result, *typmod);
+ AdjustTimestampForTypmod(&result, *typmod, NULL); /* XXX */
*typid = TIMESTAMPTZOID;
return TimestampTzGetDatum(result);
@@ -4386,7 +4386,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range"))));
- AdjustTimestampForTypmod(&result, *typmod);
+ AdjustTimestampForTypmod(&result, *typmod, NULL); /* XXX */
*typid = TIMESTAMPOID;
return TimestampGetDatum(result);
@@ -4440,7 +4440,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
if (dterr)
RETURN_ERROR(DateTimeParseError(dterr, &extra,
text_to_cstring(date_txt),
- "timetz"));
+ "timetz", NULL));
}
else
{
@@ -4789,7 +4789,8 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std,
* said DTERR_MD_FIELD_OVERFLOW, because we don't want to print an
* irrelevant hint about datestyle.
*/
- RETURN_ERROR(DateTimeParseError(DTERR_FIELD_OVERFLOW, NULL, date_str, "timestamp"));
+ RETURN_ERROR(DateTimeParseError(DTERR_FIELD_OVERFLOW, NULL,
+ date_str, "timestamp", NULL));
}
}
@@ -4799,7 +4800,8 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std,
tm->tm_sec < 0 || tm->tm_sec >= SECS_PER_MINUTE ||
*fsec < INT64CONST(0) || *fsec >= USECS_PER_SEC)
{
- RETURN_ERROR(DateTimeParseError(DTERR_FIELD_OVERFLOW, NULL, date_str, "timestamp"));
+ RETURN_ERROR(DateTimeParseError(DTERR_FIELD_OVERFLOW, NULL,
+ date_str, "timestamp", NULL));
}
/* Save parsed time-zone into tm->tm_zone if it was specified */
@@ -4810,7 +4812,8 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std,
if (tmfc.tzh < 0 || tmfc.tzh > MAX_TZDISP_HOUR ||
tmfc.tzm < 0 || tmfc.tzm >= MINS_PER_HOUR)
{
- RETURN_ERROR(DateTimeParseError(DTERR_TZDISP_OVERFLOW, NULL, date_str, "timestamp"));
+ RETURN_ERROR(DateTimeParseError(DTERR_TZDISP_OVERFLOW, NULL,
+ date_str, "timestamp", NULL));
}
tz = psprintf("%c%02d:%02d",