v4-0004-Mop-up-a-few-other-error-message-style-violations.patch
text/x-diff
Filename: v4-0004-Mop-up-a-few-other-error-message-style-violations.patch
Type: text/x-diff
Part: 3
Patch
Format: format-patch
Series: patch v4-0004
Subject: Mop up a few other error message style violations.
| File | + | − |
|---|---|---|
| doc/src/sgml/sources.sgml | 4 | 3 |
| doc/src/sgml/typeconv.sgml | 3 | 3 |
| src/backend/parser/parse_func.c | 4 | 4 |
| src/backend/parser/parse_oper.c | 2 | 2 |
| src/test/regress/expected/polymorphism.out | 10 | 5 |
| src/test/regress/expected/time.out | 2 | 1 |
From 177b5d3819d4f013bc201d99c37b127f2d3484a1 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sun, 24 Aug 2025 14:15:06 -0400
Subject: [PATCH v4 4/4] Mop up a few other error message style violations.
Fix a few related messages that likewise were failing to
separate errdetail from errhint.
Reported-by: Dominique Devienne <ddevienne@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1756041.1754616558@sss.pgh.pa.us
---
doc/src/sgml/sources.sgml | 7 ++++---
doc/src/sgml/typeconv.sgml | 6 +++---
src/backend/parser/parse_func.c | 8 ++++----
src/backend/parser/parse_oper.c | 4 ++--
src/test/regress/expected/polymorphism.out | 15 ++++++++++-----
src/test/regress/expected/time.out | 3 ++-
6 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/doc/src/sgml/sources.sgml b/doc/src/sgml/sources.sgml
index fa68d4d024a..5759c6f7426 100644
--- a/doc/src/sgml/sources.sgml
+++ b/doc/src/sgml/sources.sgml
@@ -153,11 +153,12 @@ ereport(ERROR,
errmsg("function %s is not unique",
func_signature_string(funcname, nargs,
NIL, actual_arg_types)),
- errhint("Unable to choose a best candidate function. "
- "You might need to add explicit typecasts."));
+ errdetail("Could not choose a best candidate function."),
+ errhint("You might need to add explicit type casts."));
</programlisting>
This illustrates the use of format codes to embed run-time values into
- a message text. Also, an optional <quote>hint</quote> message is provided.
+ a message text. Also, optional <quote>detail</quote>
+ and <quote>hint</quote> messages are provided.
The auxiliary function calls can be written in any order, but
conventionally <function>errcode</function>
and <function>errmsg</function> appear first.
diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml
index 44aaf284da4..1707bd884dc 100644
--- a/doc/src/sgml/typeconv.sgml
+++ b/doc/src/sgml/typeconv.sgml
@@ -465,9 +465,9 @@ try a similar case with <literal>~</literal>, we get:
<screen>
SELECT ~ '20' AS "negation";
-ERROR: operator is not unique: ~ "unknown"
-HINT: Could not choose a best candidate operator. You might need to add
-explicit type casts.
+ERROR: operator is not unique: ~ unknown
+DETAIL: Could not choose a best candidate operator.
+HINT: You might need to add explicit type casts.
</screen>
This happens because the system cannot decide which of the several
possible <literal>~</literal> operators should be preferred. We can help
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index a772de6b76e..c43020a769d 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -567,8 +567,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
errmsg("procedure %s is not unique",
func_signature_string(funcname, nargs, argnames,
actual_arg_types)),
- errhint("Could not choose a best candidate procedure. "
- "You might need to add explicit type casts."),
+ errdetail("Could not choose a best candidate procedure."),
+ errhint("You might need to add explicit type casts."),
parser_errposition(pstate, location)));
else
ereport(ERROR,
@@ -576,8 +576,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
errmsg("function %s is not unique",
func_signature_string(funcname, nargs, argnames,
actual_arg_types)),
- errhint("Could not choose a best candidate function. "
- "You might need to add explicit type casts."),
+ errdetail("Could not choose a best candidate function."),
+ errhint("You might need to add explicit type casts."),
parser_errposition(pstate, location)));
}
else
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index fafdf0a80a3..7bd7a336fd6 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -633,8 +633,8 @@ op_error(ParseState *pstate, List *op,
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("operator is not unique: %s",
op_signature_string(op, arg1, arg2)),
- errhint("Could not choose a best candidate operator. "
- "You might need to add explicit type casts."),
+ errdetail("Could not choose a best candidate operator."),
+ errhint("You might need to add explicit type casts."),
parser_errposition(pstate, location)));
else
ereport(ERROR,
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index dd38d950d81..3cd99a92aa5 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1210,7 +1210,8 @@ select dfunc(); -- fail: which dfunc should be called? int or text
ERROR: function dfunc() is not unique
LINE 1: select dfunc();
^
-HINT: Could not choose a best candidate function. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate function.
+HINT: You might need to add explicit type casts.
select dfunc('Hi'); -- ok
dfunc
-----------
@@ -1249,17 +1250,20 @@ select dfunc(); -- fail
ERROR: function dfunc() is not unique
LINE 1: select dfunc();
^
-HINT: Could not choose a best candidate function. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate function.
+HINT: You might need to add explicit type casts.
select dfunc(1); -- fail
ERROR: function dfunc(integer) is not unique
LINE 1: select dfunc(1);
^
-HINT: Could not choose a best candidate function. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate function.
+HINT: You might need to add explicit type casts.
select dfunc(1, 2); -- fail
ERROR: function dfunc(integer, integer) is not unique
LINE 1: select dfunc(1, 2);
^
-HINT: Could not choose a best candidate function. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate function.
+HINT: You might need to add explicit type casts.
select dfunc(1, 2, 3); -- ok
dfunc
-------
@@ -1378,7 +1382,8 @@ select dfunc(1); -- fail
ERROR: function dfunc(integer) is not unique
LINE 1: select dfunc(1);
^
-HINT: Could not choose a best candidate function. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate function.
+HINT: You might need to add explicit type casts.
-- but this works since the ambiguous functions aren't preferred anyway
select dfunc('Hi');
dfunc
diff --git a/src/test/regress/expected/time.out b/src/test/regress/expected/time.out
index 4247fae9412..765adeb6e51 100644
--- a/src/test/regress/expected/time.out
+++ b/src/test/regress/expected/time.out
@@ -157,7 +157,8 @@ SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
ERROR: operator is not unique: time without time zone + time without time zone
LINE 1: SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
^
-HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
+DETAIL: Could not choose a best candidate operator.
+HINT: You might need to add explicit type casts.
--
-- test EXTRACT
--
--
2.43.7