to_timestamp报错信息修复

This commit is contained in:
luo_zihao5524
2022-08-02 11:34:48 +08:00
committed by luozihao
parent fc5f028b22
commit 9aa4caff4f
3 changed files with 8 additions and 2 deletions

View File

@ -5865,7 +5865,8 @@ Datum float8_timestamptz(PG_FUNCTION_ARGS)
/* Out of range? */
if (seconds < (float8) SECS_PER_DAY * (DATETIME_MIN_JULIAN - UNIX_EPOCH_JDATE) ||
seconds >= (float8) SECS_PER_DAY * (TIMESTAMP_END_JULIAN - UNIX_EPOCH_JDATE)) {
ereport(ERROR, (errmsg("timestamp out of range: \"%g\"", seconds)));
ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range: \"%g\"", seconds)));
}
/* Convert UNIX epoch to Postgres epoch */
@ -5876,7 +5877,8 @@ Datum float8_timestamptz(PG_FUNCTION_ARGS)
/* Recheck in case roundoff produces something just out of range */
if (!IS_VALID_TIMESTAMP(result)) {
ereport(ERROR, (errmsg("timestamp out of range: \"%g\"", PG_GETARG_FLOAT8(0))));
ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range: \"%g\"", PG_GETARG_FLOAT8(0))));
}
}

View File

@ -1035,3 +1035,6 @@ SELECT to_timestamp('-Infinity'::float);
SELECT to_timestamp('NaN'::float);
ERROR: timestamp cannot be NaN
CONTEXT: referenced column: to_timestamp
SELECT to_timestamp(-999888762478);
ERROR: timestamp out of range: "-9.99889e+11"
CONTEXT: referenced column: to_timestamp

View File

@ -269,3 +269,4 @@ end;
SELECT to_timestamp(' Infinity'::float);
SELECT to_timestamp('-Infinity'::float);
SELECT to_timestamp('NaN'::float);
SELECT to_timestamp(-999888762478);