]> granicus.if.org Git - postgresql/commitdiff
Improve error message for misuse of TZ, tz, OF formatting patterns.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 20 Feb 2017 15:27:48 +0000 (10:27 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 20 Feb 2017 15:27:48 +0000 (10:27 -0500)
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

index 4f3d8a118949f0a84510bfc32f417cd8cefeac24..247234564e31acb25e5f25f1251ab6b9adf8e210 100644 (file)
@@ -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: