Improve plural handling in error message
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 23 Aug 2017 17:56:59 +0000 (13:56 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 23 Aug 2017 17:56:59 +0000 (13:56 -0400)
This does not use the normal plural handling, because no numbers appear
in the actual message.

src/backend/parser/parse_oper.c
src/test/regress/expected/alter_table.out
src/test/regress/expected/create_view.out
src/test/regress/expected/geometry.out
src/test/regress/expected/horology.out
src/test/regress/expected/text.out
src/test/regress/expected/timetz.out
src/test/regress/expected/with.out

index e9bf50243f44eb1872ea0b36d502aba1a6b7492e..d7971cc3d9ffebdc73f08dea483952234c97713d 100644 (file)
@@ -723,7 +723,10 @@ op_error(ParseState *pstate, List *op, char oprkind,
                (errcode(ERRCODE_UNDEFINED_FUNCTION),
                 errmsg("operator does not exist: %s",
                        op_signature_string(op, oprkind, arg1, arg2)),
-                errhint("No operator matches the given name and argument type(s). "
+                (!arg1 || !arg2) ?
+                errhint("No operator matches the given name and argument type. "
+                        "You might need to add an explicit type cast.") :
+                errhint("No operator matches the given name and argument types. "
                         "You might need to add explicit type casts."),
                 parser_errposition(pstate, location)));
 }
index 58192d2c6afacede3560d98c58dc47575558614c..ed03cb9c630a40f04782c2cf653f156bc0b7ffc2 100644 (file)
@@ -1895,7 +1895,7 @@ alter table anothertab alter column atcol1 drop default;
 alter table anothertab alter column atcol1 type boolean
         using case when atcol1 % 2 = 0 then true else false end; -- fails
 ERROR:  operator does not exist: boolean <= integer
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 alter table anothertab drop constraint anothertab_chk;
 alter table anothertab drop constraint anothertab_chk; -- fails
 ERROR:  constraint "anothertab_chk" of relation "anothertab" does not exist
index f909a3cefeb586737af0e743b70cb877d7c017b9..4468c85d778fa42459aab580b0ce34a138466cc0 100644 (file)
@@ -1605,7 +1605,7 @@ select 'foo'::text = any((select array['abc','def','foo']::text[]));  -- fail
 ERROR:  operator does not exist: text = text[]
 LINE 1: select 'foo'::text = any((select array['abc','def','foo']::t...
                            ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 select 'foo'::text = any((select array['abc','def','foo']::text[])::text[]);
  ?column? 
 ----------
index 1271395d4ead3272c297c5480250909039c0b66e..e4c003904001622e279cb6d4152215df5dc3c855 100644 (file)
@@ -107,7 +107,7 @@ SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
 ERROR:  operator does not exist: lseg # point
 LINE 1: SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
                                            ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 -- closest point
 SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
    FROM LSEG_TBL l, POINT_TBL p;
index f9d12e0f8a3cbbdc3e2c53894a549f85b6323755..7b3d058425d6d5b4f169169959719d60b4d88b9c 100644 (file)
@@ -321,7 +321,7 @@ SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time
 ERROR:  operator does not exist: date - time with time zone
 LINE 1: SELECT date '1991-02-03' - time with time zone '04:05:06 UTC...
                                  ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 --
 -- timestamp, interval arithmetic
 --
index 829f2c224ca412b3e7b517a12194b842317c80af..d28961cf880698a629b0006a700842b71634f6c2 100644 (file)
@@ -50,7 +50,7 @@ select 3 || 4.0;
 ERROR:  operator does not exist: integer || numeric
 LINE 1: select 3 || 4.0;
                  ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 /*
  * various string functions
  */
index 43911312f9dafff1736d9fa004251fa3e0c23fcf..33ff8e18c9d53bbed1a74fb1215acdf98bd31f8e 100644 (file)
@@ -92,4 +92,4 @@ SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
 ERROR:  operator does not exist: time with time zone + time with time zone
 LINE 1: SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TI...
                   ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
index fdcc4970a130496711b31eb22920cf86babdd8eb..c32a4905806862932df9e87f5add67a011c97e91 100644 (file)
@@ -166,7 +166,7 @@ SELECT n, n IS OF (int) AS is_int FROM t;
 ERROR:  operator does not exist: text + integer
 LINE 4:     SELECT n+1 FROM t WHERE n < 10
                     ^
-HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
+HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
 --
 -- Some examples with a tree
 --