Re: use of SPI by postgresImportForeignStatistics - Mailing list pgsql-hackers

From jian he
Subject Re: use of SPI by postgresImportForeignStatistics
Date
Msg-id CACJufxEoNOAOqomVzo7KukvxqLoknvh47-3=bmcj_hEvgyC8iA@mail.gmail.com
Whole thread
In response to Re: use of SPI by postgresImportForeignStatistics  (Corey Huinker <corey.huinker@gmail.com>)
List pgsql-hackers
On Tue, Jun 23, 2026 at 3:08 AM Corey Huinker <corey.huinker@gmail.com> wrote:
>
> To that end, here's a new and rebased patch set:
>
> 0001 - exactly the same as before

+/*
+ * Convenience routine to parse float values, and emit a warning on parse
+ * errors.
+ *
+ * Returns -1.0 if the value is NULL or invalid.
+ */
+static float
+str_to_float(const char *s)
+{
+ const float default_value = -1.0;
+
+ float result;
+
+ ErrorSaveContext escontext = {T_ErrorSaveContext};
+
+ if (!s)
+ return default_value;
+
+ result = float4in_internal((char *) s, NULL, "float", s, (Node *) &escontext);
+
+ if (escontext.error_occurred)
+ {
+ escontext.error_data->elevel = WARNING;
+ ThrowErrorData(escontext.error_data);
+ FreeErrorData(escontext.error_data);
+ return default_value;
+ }
+
+ return result;
+}
+

Just a quick thought: the above can be replaced by InputFunctionCallSafe?



--
jian
https://www.enterprisedb.com/



pgsql-hackers by date:

Previous
From: solai v
Date:
Subject: Re: Support EXCEPT for ALL SEQUENCES publications
Next
From: Ajin Cherian
Date:
Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade