Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpO60-007BB0-11 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 10:02:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpO5z-00A1U9-1B for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 10:02:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpO5y-00A1Tz-32 for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 10:02:18 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vpO5w-00000001Fwm-1L00 for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 10:02:17 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4f8gGW5CJGz49Pvj; Mon, 09 Feb 2026 12:02:11 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1770631332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EKQ5K7wzTWXBoHu2AtO7qeRILakvxN2XOaJ3JY66fr4=; b=TMW6TwBl86tr3AdfixVvk7am751lb/VZSNVoLUW7dJqWDh8MvbEQDt6wxfgmT5ZKHC2P4b 5dpQ/5RN12KTCQMxtCu/Aqfq311iPJ9U/QdspoXaBW7Nmz8BInjyzkfvyejsLHYqsyUndx EZdOOWw1QpbvGeUQ5dBPVoSU9RG19eM0O4F7woGqOCFpGzPlaBBN2fdnQOALZPxPhdDgd6 ge0fvCt8BkPbg+33tLvlhGlcZTWR7cbUG25+QjRnJwOcW1rGJTwymJB1BAgxXq143njH++ w8XsxChUPi1T1yuq6QrEaOw9XUFe92a2r5euPapeLO9cjD+S9tjvjr7pSK/jow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1770631332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EKQ5K7wzTWXBoHu2AtO7qeRILakvxN2XOaJ3JY66fr4=; b=GZ3zrOrk1QMn2sUwQkUzvc2e78lSM9SiNRHNuNbjeNAlsmzbt5LUCRklr6AmKs54BM3BP9 u5YrdM3mz+c+IvzDuFDFnY/1KRYxcm3BuMlHy3q+HT+ySRm0j4ChhN4oJoZT1mXnF/R7L3 kmoksA2QMozC+BTZJcfkUGH3OzDQHy4SYvYlm09Mek/VakMNoPhmONzUi47ClrCBWyl6pi gfMutjM52ATBf9xVeBCVRh1xMXMvkHX3sdF/csHihDe7aJQE8HXGuEXmZai8t0F0gcc/Wq UzYa0nlIofh4ZqhKbHvpP45D92yAKlYHXU8Rh8WmHwVV8/i4FCRWnY8lsDGfdQ== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1770631332; b=Xib34SAZs2RQ+WryBRKa/5i11GPUkBkQCNO+8UhEGXziZKKCMQSKu6CvHcPE7Z71/kjnfU Ek3mGTUpb0CCJk1ltCsn9u8lq0tgOQvM3JX9FUdSIujff2Y/oDPh/ayfHopzZAAvzXVhf0 a4F6FXwONBg9/d7WVl/GpHdecgi2DGi+HIfxyM93eGJZZx7h5EWm3AIKd51oSSVKylXrsm avXUjHAbyFta2y1JFMU7X/VX/6HgoSz/D9Oc0Sx1ZE/Xujqk0BkniQ5CVU2KMPLYL1VvoK iKVp0Q3W71TvTAmgrki8WGy41O6fYNmDRqXC9D+aGVxVTGhl9zIeB2awJaVMDA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <6ccbe513-a815-4d2c-a746-abe5de2da86b@iki.fi> Date: Mon, 9 Feb 2026 12:02:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix a bug in extension_file_exists() To: Chao Li , Postgres hackers References: <362EA9B3-589B-475A-A16E-F10C30426E28@gmail.com> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <362EA9B3-589B-475A-A16E-F10C30426E28@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 09/02/2026 11:21, Chao Li wrote: > I just noticed a bug in extension_file_exists(): > > ``` > bool > extension_file_exists(const char *extensionName) > { > bool result = false; > List *locations; > DIR *dir; > struct dirent *de; > > locations = get_extension_control_directories(); > > foreach_ptr(char, location, locations) // <== Here type char is wrong > { > dir = AllocateDir(location); > ``` > > get_extension_control_directories() returns a list of ExtensionLocation, but the loop iterates it as if it contained char *, which is incorrect. As a result, AllocateDir() and ReadDir() are called with the wrong type. > > This bug is only triggered on an error path, when PostgreSQL is deciding whether to emit a hint. For example: > ``` > evantest=# create function f() returns int LANGUAGE plpython3u as $$return 1$$; > ERROR: language "plpython3u" does not exist > ``` > No hint is printed. > > With this patch applied: > ``` > evantest=# create function f() returns int LANGUAGE plpython3u as $$return 1$$; > ERROR: language "plpython3u" does not exist > HINT: Use CREATE EXTENSION to load the language into the database. > ``` > So the hint is shown as intended. > > Attached is a patch fixing the iteration to use ExtensionLocation and location->loc consistently. Yep, good catch. This went wrong in commit f3c9e341cd, which changed the type of objects in the list from "char *" to "ExtensionLocation *". So this is master only, stable branches are not affected. I will push the fix shortly, thanks! - Heikki