0001-Try-to-fix-array_eq-without-providing-FmgrInfo-issue.patch

application/octet-stream

Filename: 0001-Try-to-fix-array_eq-without-providing-FmgrInfo-issue.patch
Type: application/octet-stream
Part: 0
Message: Re: BUG #18692: Segmentation fault when extending a varchar column with a gist index with custom signal length

Patch

Format: format-patch
Series: patch 0001
Subject: Try to fix array_eq without providing FmgrInfo issue.
File+
src/backend/commands/indexcmds.c 4 1
From 0c725f3b912c79fcd4cd54e49a3d97278351fb09 Mon Sep 17 00:00:00 2001
From: Tender Wang <tndrwang@gmail.com>
Date: Thu, 7 Nov 2024 14:34:04 +0800
Subject: [PATCH] Try to fix array_eq without providing FmgrInfo issue.

---
 src/backend/commands/indexcmds.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 2f652463e3..8e61929ab9 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -29,6 +29,7 @@
 #include "catalog/namespace.h"
 #include "catalog/pg_am.h"
 #include "catalog/pg_authid.h"
+#include "catalog/pg_collation.h"
 #include "catalog/pg_constraint.h"
 #include "catalog/pg_database.h"
 #include "catalog/pg_inherits.h"
@@ -362,10 +363,12 @@ static bool
 CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts)
 {
 	int			i;
+	FmgrInfo	fm;
 
 	if (!opts1 && !opts2)
 		return true;
 
+	fmgr_info(F_ARRAY_EQ, &fm);
 	for (i = 0; i < natts; i++)
 	{
 		Datum		opt1 = opts1 ? opts1[i] : (Datum) 0;
@@ -382,7 +385,7 @@ CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts)
 			return false;
 
 		/* Compare non-NULL text[] datums. */
-		if (!DatumGetBool(DirectFunctionCall2(array_eq, opt1, opt2)))
+		if (!DatumGetBool(FunctionCall2Coll(&fm, DEFAULT_COLLATION_OID, opt1, opt2)))
 			return false;
 	}
 
-- 
2.25.1