From e9b7d6abd03e2a08f4de5f069a96a3db83351374 Mon Sep 17 00:00:00 2001
From: Nikhil Benesch <nikhil.benesch@gmail.com>
Date: Sun, 2 Jan 2022 21:59:29 -0500
Subject: [PATCH] Remove inconsistent quotes from date_part error

Calling EXTRACT/date_part on a time or timetz value with invalid units
produces an error message that includes quotation marks around "time" or
"timestamp with time zone". These quotation marks are not present in the
error message when date_part is invoked with a timestamp, timestamptz,
or interval value. So this commit removes the quotes from time and
timetz error messages; this seems more in line with how type names are
generally displayed in error messages.
---
 src/backend/utils/adt/date.c         | 8 ++++----
 src/test/regress/expected/time.out   | 6 +++---
 src/test/regress/expected/timetz.out | 4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 9e8baeaa9c..188795eae4 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -2203,7 +2203,7 @@ time_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 			default:
 				ereport(ERROR,
 						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-						 errmsg("\"time\" units \"%s\" not recognized",
+						 errmsg("time units \"%s\" not recognized",
 								lowunits)));
 				intresult = 0;
 		}
@@ -2219,7 +2219,7 @@ time_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 	{
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-				 errmsg("\"time\" units \"%s\" not recognized",
+				 errmsg("time units \"%s\" not recognized",
 						lowunits)));
 		intresult = 0;
 	}
@@ -2981,7 +2981,7 @@ timetz_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 			default:
 				ereport(ERROR,
 						(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-						 errmsg("\"time with time zone\" units \"%s\" not recognized",
+						 errmsg("time with time zone units \"%s\" not recognized",
 								lowunits)));
 				intresult = 0;
 		}
@@ -3001,7 +3001,7 @@ timetz_part_common(PG_FUNCTION_ARGS, bool retnumeric)
 	{
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-				 errmsg("\"time with time zone\" units \"%s\" not recognized",
+				 errmsg("time with time zone units \"%s\" not recognized",
 						lowunits)));
 		intresult = 0;
 	}
diff --git a/src/test/regress/expected/time.out b/src/test/regress/expected/time.out
index 39b409feca..e1161ba761 100644
--- a/src/test/regress/expected/time.out
+++ b/src/test/regress/expected/time.out
@@ -161,11 +161,11 @@ SELECT EXTRACT(HOUR        FROM TIME '2020-05-26 13:30:25.575401');
 (1 row)
 
 SELECT EXTRACT(DAY         FROM TIME '2020-05-26 13:30:25.575401');  -- error
-ERROR:  "time" units "day" not recognized
+ERROR:  time units "day" not recognized
 SELECT EXTRACT(FORTNIGHT   FROM TIME '2020-05-26 13:30:25.575401');  -- error
-ERROR:  "time" units "fortnight" not recognized
+ERROR:  time units "fortnight" not recognized
 SELECT EXTRACT(TIMEZONE    FROM TIME '2020-05-26 13:30:25.575401');  -- error
-ERROR:  "time" units "timezone" not recognized
+ERROR:  time units "timezone" not recognized
 SELECT EXTRACT(EPOCH       FROM TIME '2020-05-26 13:30:25.575401');
    extract    
 --------------
diff --git a/src/test/regress/expected/timetz.out b/src/test/regress/expected/timetz.out
index f4960c0166..2d0d55546a 100644
--- a/src/test/regress/expected/timetz.out
+++ b/src/test/regress/expected/timetz.out
@@ -178,9 +178,9 @@ SELECT EXTRACT(HOUR        FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-
 (1 row)
 
 SELECT EXTRACT(DAY         FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');  -- error
-ERROR:  "time with time zone" units "day" not recognized
+ERROR:  time with time zone units "day" not recognized
 SELECT EXTRACT(FORTNIGHT   FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');  -- error
-ERROR:  "time with time zone" units "fortnight" not recognized
+ERROR:  time with time zone units "fortnight" not recognized
 SELECT EXTRACT(TIMEZONE    FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30');
  extract 
 ---------
-- 
2.25.1

