From 60f4ab928e2b50c831f97f585520950a8f3ddeef Mon Sep 17 00:00:00 2001
From: Timur Magomedov <t.magomedov@postgrespro.ru>
Date: Fri, 30 May 2025 18:41:10 +0300
Subject: [PATCH 1/4] Removed unnecessary preload libraries checks

---
 contrib/vci/vci.conf   |  1 -
 contrib/vci/vci_main.c | 69 ------------------------------------------
 2 files changed, 70 deletions(-)

diff --git a/contrib/vci/vci.conf b/contrib/vci/vci.conf
index 776dd7b5cc6..017c481c68f 100644
--- a/contrib/vci/vci.conf
+++ b/contrib/vci/vci.conf
@@ -1,5 +1,4 @@
 shared_preload_libraries = 'vci'
-session_preload_libraries = 'vci'
 max_worker_processes = 20
 vci.table_rows_threshold = 0
 vci.cost_threshold = 0
diff --git a/contrib/vci/vci_main.c b/contrib/vci/vci_main.c
index 10624e1d3f0..0919ecfe10f 100644
--- a/contrib/vci/vci_main.c
+++ b/contrib/vci/vci_main.c
@@ -59,60 +59,6 @@ ProcessUtility_hook_type process_utility_prev = NULL;
 static shmem_request_hook_type prev_shmem_request_hook = NULL;
 static void vci_shmem_request(void);
 
-/*
- * @description check whether 'vci' is contained in the specified guc.
- *
- * This function is written based on load_libraries
- * in src/backend/utils/init/miscinit.c
- *
- * @param[in] str specified string by guc.
- * @param[in] guc parameter.
- * @return true is 'vci' is contained in the parameter specified by guc.
- */
-static bool
-has_vci_lib_str(const char *str_)
-{
-	char	   *rawstring;
-	List	   *elemlist;
-	ListCell   *l;
-	bool		result = false;
-
-	if (str_ == NULL || str_[0] == '\0')
-		return result;			/* nothing to do */
-
-	/* Need a modifiable copy of string */
-	rawstring = pstrdup(str_);
-
-	/* Parse string into list of identifiers */
-	if (!SplitIdentifierString(rawstring, ',', &elemlist))
-	{
-		/* syntax error in list */
-		pfree(rawstring);
-		list_free(elemlist);
-		return result;
-	}
-
-#ifdef WIN32					/* WIN32 */
-	foreach(l, elemlist)
-#else							/* WIN32 */
-	foreach(l, elemlist)
-#endif
-	{
-		char	   *tok = (char *) lfirst(l);
-
-		if (!strcmp(VCI_STRING, tok))
-		{
-			result = true;
-			break;
-		}
-	}
-
-	pfree(rawstring);
-	list_free(elemlist);
-
-	return result;
-}
-
 /**
  * _PG_init: Entry point of this module.
  * It is called when the module is loaded.
@@ -120,7 +66,6 @@ has_vci_lib_str(const char *str_)
 void
 _PG_init(void)
 {
-
 	pg_bindtextdomain(TEXTDOMAIN);
 
 	if (!process_shared_preload_libraries_in_progress)
@@ -131,20 +76,6 @@ _PG_init(void)
 		return;					/* LCOV_EXCL_LINE */
 	}
 
-	/*
-	 * Check if both shared_preload_libraries and session_preload_libraries
-	 * have the string "vci".
-	 */
-	if ((!has_vci_lib_str(shared_preload_libraries_string)) ||
-		(!has_vci_lib_str(session_preload_libraries_string)))
-	{
-		ereport(ERROR,
-				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-				 errmsg("\"%s\" must be registered in shared_preload_libraries and session_preload_libraries",
-						VCI_STRING)));
-		return;					/* LCOV_EXCL_LINE */
-	}
-
 	vci_read_guc_variables();
 
 	if (!IsPostmasterEnvironment)
-- 
2.43.0

