0003-Use-PG_RETURN_ERROR-in-float4in.patch

text/x-patch

Filename: 0003-Use-PG_RETURN_ERROR-in-float4in.patch
Type: text/x-patch
Part: 2
Message: Re: SQL/JSON features for v15

Patch

Format: format-patch
Series: patch 0003
Subject: Use PG_RETURN_ERROR in float4in()
File+
src/backend/utils/adt/float.c 5 4
src/include/catalog/pg_proc.dat 1 1
From 4eba0bd771b85abef94125f374261d7734178657 Mon Sep 17 00:00:00 2001
From: Nikita Glukhov <n.gluhov@postgrespro.ru>
Date: Wed, 31 Aug 2022 22:28:09 +0300
Subject: [PATCH 3/5] Use PG_RETURN_ERROR in float4in()

---
 src/backend/utils/adt/float.c   | 9 +++++----
 src/include/catalog/pg_proc.dat | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index fc8f39a7a98..e3bde72b328 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -25,6 +25,7 @@
 #include "common/shortest_dec.h"
 #include "libpq/pqformat.h"
 #include "miscadmin.h"
+#include "nodes/execnodes.h"
 #include "utils/array.h"
 #include "utils/float.h"
 #include "utils/fmgrprotos.h"
@@ -183,7 +184,7 @@ float4in(PG_FUNCTION_ARGS)
 	 * strtod() on different platforms.
 	 */
 	if (*num == '\0')
-		ereport(ERROR,
+		PG_RETURN_ERROR(
 				(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
 				 errmsg("invalid input syntax for type %s: \"%s\"",
 						"real", orig_num)));
@@ -257,13 +258,13 @@ float4in(PG_FUNCTION_ARGS)
 				(val >= HUGE_VALF || val <= -HUGE_VALF)
 #endif
 				)
-				ereport(ERROR,
+				PG_RETURN_ERROR(
 						(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
 						 errmsg("\"%s\" is out of range for type real",
 								orig_num)));
 		}
 		else
-			ereport(ERROR,
+			PG_RETURN_ERROR(
 					(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
 					 errmsg("invalid input syntax for type %s: \"%s\"",
 							"real", orig_num)));
@@ -275,7 +276,7 @@ float4in(PG_FUNCTION_ARGS)
 
 	/* if there is any junk left at the end of the string, bail out */
 	if (*endptr != '\0')
-		ereport(ERROR,
+		PG_RETURN_ERROR(
 				(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
 				 errmsg("invalid input syntax for type %s: \"%s\"",
 						"real", orig_num)));
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index be47583122b..b25bfa55ab3 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -585,7 +585,7 @@
 
 { oid => '200', descr => 'I/O',
   proname => 'float4in', prorettype => 'float4', proargtypes => 'cstring',
-  prosrc => 'float4in' },
+  proissafe => 't', prosrc => 'float4in' },
 { oid => '201', descr => 'I/O',
   proname => 'float4out', prorettype => 'cstring', proargtypes => 'float4',
   prosrc => 'float4out' },
-- 
2.25.1