On 03.03.25 19:45, Matheus Alcantara wrote:
Hi, attached a new v5 with some minor improvements on TAP tests:- Add a proper test name for all test cases - Add CREATE EXTENSION command execution - Change the assert on pg_available_extensions and pg_available_extension_versions to validate the row content Also rebased with master
This looks very good to me. I have one issue to point out: The logic in get_extension_control_directories() needs to be a little bit more careful to align with the rules in find_in_path(). For example, it should use first_path_var_separator() to get the platform-specific path separator, and probably also substitute_path_macro() and canonicalize_path() etc., to keep everything consistent. (Maybe it would be ok to move the function to dfmgr.c to avoid having to export too many things from there.)
Independent of that, attached is a small patch that suggests to use the newer foreach_ptr() macro in some places.
From 35c2106558095e74359cec58b9631fa19ed937b3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pe...@eisentraut.org> Date: Thu, 6 Mar 2025 14:28:08 +0100 Subject: [PATCH] Use foreach_ptr --- src/backend/commands/extension.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 7e8a28e4064..4bdb20aaf54 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -51,10 +51,10 @@ #include "commands/defrem.h" #include "commands/extension.h" #include "commands/schemacmds.h" -#include "nodes/pg_list.h" #include "funcapi.h" #include "mb/pg_wchar.h" #include "miscadmin.h" +#include "nodes/pg_list.h" #include "nodes/queryjumble.h" #include "storage/fd.h" #include "tcop/utility.h" @@ -2183,20 +2183,17 @@ Datum pg_available_extensions(PG_FUNCTION_ARGS) { ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + List *locations; DIR *dir; struct dirent *de; - List *locations; - ListCell *cell; /* Build tuplestore to hold the result rows */ InitMaterializedSRF(fcinfo, 0); locations = get_extension_control_directories(); - foreach(cell, locations) + foreach_ptr(char, location, locations) { - char *location = (char *) lfirst(cell); - dir = AllocateDir(location); /* @@ -2271,7 +2268,6 @@ pg_available_extension_versions(PG_FUNCTION_ARGS) { ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; List *locations; - ListCell *cell; DIR *dir; struct dirent *de; @@ -2279,10 +2275,9 @@ pg_available_extension_versions(PG_FUNCTION_ARGS) InitMaterializedSRF(fcinfo, 0); locations = get_extension_control_directories(); - foreach(cell, locations) - { - char *location = (char *) lfirst(cell); + foreach_ptr(char, location, locations) + { dir = AllocateDir(location); /* @@ -2449,16 +2444,13 @@ extension_file_exists(const char *extensionName) { bool result = false; List *locations; - ListCell *cell; DIR *dir; struct dirent *de; locations = get_extension_control_directories(); - foreach(cell, locations) + foreach_ptr(char, location, locations) { - char *location = (char *) lfirst(cell); - dir = AllocateDir(location); /* -- 2.48.1