From 38633cf89151e24b461ebfe09800bf183de8f8c2 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 4 Oct 2001 17:52:24 +0000
Subject: [PATCH] Make the world safe for atttypmod=0 ... this didn't use to
 mean anything, but timestamp now wants it to mean something.

---
 src/backend/parser/parse_coerce.c   |  7 +++----
 src/backend/utils/adt/format_type.c | 10 +++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index e038a087251..e1e218f27ec 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.62 2001/10/03 05:29:12 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.63 2001/10/04 17:52:24 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -284,10 +284,9 @@ coerce_type_typmod(ParseState *pstate, Node *node,
 	Oid			oid_array[FUNC_MAX_ARGS];
 
 	/*
-	 * We assume that only typmod values greater than 0 indicate a forced
-	 * conversion is necessary.
+	 * A negative typmod is assumed to mean that no coercion is wanted.
 	 */
-	if ((atttypmod <= 0) || (atttypmod == exprTypmod(node)))
+	if (atttypmod < 0 || atttypmod == exprTypmod(node))
 		return node;
 
 	funcname = typeidTypeName(targetTypeId);
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 0e189d72461..faa0c9f6bb6 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.17 2001/10/03 18:32:42 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.18 2001/10/04 17:52:24 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -201,7 +201,7 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
 			break;
 
 		case TIMEOID:
-			if (with_typemod && typemod > 0)
+			if (with_typemod)
 				buf = psnprintf(50, "time(%d) without time zone",
 								typemod);
 			else
@@ -209,7 +209,7 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
 			break;
 
 		case TIMETZOID:
-			if (with_typemod && typemod > 0)
+			if (with_typemod)
 				buf = psnprintf(50, "time(%d) with time zone",
 								typemod);
 			else
@@ -217,7 +217,7 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
 			break;
 
 		case TIMESTAMPOID:
-			if (with_typemod && typemod > 0)
+			if (with_typemod)
 				buf = psnprintf(50, "timestamp(%d) without time zone",
 								typemod);
 			else
@@ -225,7 +225,7 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
 			break;
 
 		case TIMESTAMPTZOID:
-			if (with_typemod && typemod > 0)
+			if (with_typemod)
 				buf = psnprintf(50, "timestamp(%d) with time zone",
 								typemod);
 			else
-- 
GitLab