From 1c073505e8e4fa8a03312fea714da25ab83cb5fa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 20 Feb 2017 10:27:48 -0500 Subject: [PATCH] Improve error message for misuse of TZ, tz, OF formatting patterns. Be specific about which pattern is being complained of, and avoid saying "it's not supported in to_date", which is just confusing if the error is actually coming out of to_timestamp. We can phrase it as "is only supported in to_char", instead. Also, use the term "formatting field" not "format pattern", because other error messages in the same file prefer that terminology. (This isn't terribly consistent with the documentation, so maybe we should change all these error messages?) --- src/backend/utils/adt/formatting.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 4f3d8a1189..247234564e 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -3031,7 +3031,9 @@ DCH_from_char(FormatNode *node, char *in, TmFromChar *out) case DCH_OF: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("\"TZ\"/\"tz\"/\"OF\" format patterns are not supported in to_date"))); + errmsg("formatting field \"%s\" is only supported in to_char", + n->key->name))); + break; case DCH_A_D: case DCH_B_C: case DCH_a_d: