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 1vpbxj-00C17x-1j for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Feb 2026 00:50:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpbxi-00DJrT-0m for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Feb 2026 00:50:42 +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 1vpbxh-00DJrL-30 for pgsql-hackers@lists.postgresql.org; Tue, 10 Feb 2026 00:50:41 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpbxf-00000001M8W-0esf for pgsql-hackers@lists.postgresql.org; Tue, 10 Feb 2026 00:50:40 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-c56188aef06so1978376a12.2 for ; Mon, 09 Feb 2026 16:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770684637; x=1771289437; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mqbqIkZw/BJoYg+e7wkYKAZaeK3URYdlIG4BznKP4go=; b=Zxkkl68E1kgzmvYffelNvER0uAGKqHkM3/MP26msPPIu2Pw41wtkL7tDS3Zow6V6sJ A64hQdaY2i+KaSNSQomQkPXHwaANFmI/hPgvH/i+IZz5SJ9C59w7iV/iHz3TDEz00Er2 FfKwsX/Kb/nofgAAFAc3avScub9YClXK1pKvFaQy1qWaMWnHNfh4GFq30IbLmQ8lPHdW Q5u+mq38Bbxeu8FLl1y8WMoKKXqosmhcmfFWIY/+hnuYx1XNRKELKt+3Hf6BhMcRnXdL +X43Xhb7Tsbvto2ravrYbeIIsInpaPcYE3p9LA5z/l+MHxXoEWLic2/xiOxxF5cMmjlP 7r/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770684637; x=1771289437; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mqbqIkZw/BJoYg+e7wkYKAZaeK3URYdlIG4BznKP4go=; b=geE3Kk1tZwu6H+4bv+C3yC9gNHLJnQV/JAdvcTEiB5D0bVLYOqasXivb2tnTLZT5iQ hds+0A7HNvLZ6UFG6uwoRZJ8L+UeBTTqzwMBYhGoTU80/gjjEcTG4N24PMrPzJIBuFZy bReUaFDpl4y210FtBNn2Jb3Qam6nQCFqit/OyaKqgtzYFaSh0rZZs68GK/kafeFSiiln S3L4ZBk2RIZHMekmBjzEgNjvR48wgoYw5Zb64pKUvnQXd8YQFtjp66NA+rEJnmhz6FLE jdCcURWmjmipPFglGyzhHESl4+WaRrY4dPWkUnczlENRoJqmlCo6J1ZFrAh6WgbgdGt4 UykQ== X-Gm-Message-State: AOJu0Yx/2WXSPQuXwLgciCCwOhviMufkq/6m19tecmP2OlMX3u9HVIXW EE3skFzFGQmssMXdeu0gUtLlmYtjPulN/pYzxSS+zAadVjC8QHpqOE8R X-Gm-Gg: AZuq6aLRnJLOSzBAyGUWs4OZi9+wNK3Mfz0BRhJAVGyOJdQ3JRy4IgubXDmyHIuXjHv N5uLW98+OqaK3S2NBI23q3SDRnF9qlsqwC8xvNVRRbxMzixvb7O/iXLW9TpLs1KisHpQFPNZ9pL NrPzU9wsBtJRpQm9azQAoVh2pID55YUxViDofxvlJiNPEIqsVHMQRgx21n32TLAB499tsCE5Uim Ay98z4Kzvg35x4sxfeVkcge4HlCTVnvTb7oGdPqG19oONwYKBprdzRWfxlLswYYEi2NfLbJgUTN 5JXPKvF1y9VxX3b5VPc8gbuRyq0fnhx0r/p9FbpJzqEpgC9/R2s3Tz/RWClTahKVcnKCFPALKv6 IjyA41zXyJjSPQeNQ2S5WxbJeUs5A+YEGa7nqPHmMvhEY6YFHBPIfgE1X1v9qqKw2iFaCZetRQA jUqGuwGfY9SrD2uQxPEppzFBPAMeBF6Nw= X-Received: by 2002:a17:903:3bad:b0:2aa:e0d3:cae2 with SMTP id d9443c01a7336-2ab10320efdmr4922055ad.14.1770684637240; Mon, 09 Feb 2026 16:50:37 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a9521b9bd1sm133908185ad.66.2026.02.09.16.50.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Feb 2026 16:50:36 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: Fix a bug in extension_file_exists() From: Chao Li In-Reply-To: <6ccbe513-a815-4d2c-a746-abe5de2da86b@iki.fi> Date: Tue, 10 Feb 2026 08:50:10 +0800 Cc: Postgres hackers Content-Transfer-Encoding: quoted-printable Message-Id: <5FB32F4A-C4CA-400C-9FC8-7AA32CC1020C@gmail.com> References: <362EA9B3-589B-475A-A16E-F10C30426E28@gmail.com> <6ccbe513-a815-4d2c-a746-abe5de2da86b@iki.fi> To: Heikki Linnakangas X-Mailer: Apple Mail (2.3864.300.41.1.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Feb 9, 2026, at 18:02, Heikki Linnakangas wrote: >=20 > 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 =3D false; >> List *locations; >> DIR *dir; >> struct dirent *de; >> locations =3D get_extension_control_directories(); >> foreach_ptr(char, location, locations) // <=3D=3D Here type char is = wrong >> { >> dir =3D 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=3D# 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=3D# 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. >=20 > 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. >=20 > I will push the fix shortly, thanks! >=20 > - Heikki >=20 Thanks for pushing. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/