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 1vpNT1-006wMD-08 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 09:22:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpNSz-009rw2-18 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 09:22:01 +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 1vpNSz-009rvu-0D for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 09:22:00 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpNSw-00000001FfN-1UkP for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 09:21:59 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-c551edc745eso1586881a12.2 for ; Mon, 09 Feb 2026 01:21:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770628917; x=1771233717; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=2SoK02n9GmLNuhn20PkSX0iZ9qNLKwKOd8RTZI1io10=; b=BSQMpUMe15v7T91FG6nu7fTlOI6uIvQkLi2A3sDtHwhAbEN3/Zj31JRX1RJh+WjNYI H/3pGSa13FGv2k029Etl2zXQyuu1wqRweVAARxQrVCTTfM2/MRFxrRTifMPhT5kHLh8F XHHGt5VVtPWu3qpmRRhKhRhV6f+f0l6apUQ43P5BVjc9uGH8/nSY3OqpiAa34MThlAUh jvEPsBuZyu5V411EyujXGqY/kST3bF46TUM30iosIqTIZn6ffo6duhDdTYmD4E8Yb786 WmYHlA9B0Oym0d9JBg/GIhu7ppg0PANsZViYB3EzaSSPcQoEuVpG/VNaPrl1ceCMcdwX 17PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770628917; x=1771233717; h=to:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2SoK02n9GmLNuhn20PkSX0iZ9qNLKwKOd8RTZI1io10=; b=wNuf2mlCT6lb3fQ9r5pa42kT33qQy5A/DLJDuduXex/+dLaiiKPLYGwsL93nncEqJx by0SeNGl+u55Bkn4/dvVbOuSlk3y4tZoNqcApXdTbCn3/FIKysRkC6XVnghbzAQEA4+k RV1rth+E43fgOVWEEml2oUUU/wd/7bLG2fZ5ribydDTzlwbh80yNANpymt8qJBmHBjHc Z8kXtCJf5iRuMYYmgsxYcLhV2+n93Yw0wekLKId7FdgCKGpY2s6ZLikTxKRNBgpdlJ3+ 9HdwGllEstJrs/xoNilkF9CUys4xrPYttSh1JY4b45ZG7cuq+VfdQmTB6k79LwcvN8hu SBQA== X-Gm-Message-State: AOJu0YxoClXP5YTmNjIL0XOJ93KfVTzETtJ5OuVAX6X2thNvj71eCkiX U762DwKCRW9u1aShPVY+KCTO4wgo82ByzDn+n8u7vT9yxjgKuIpDhoHCfLRWtLW6xT5J8g== X-Gm-Gg: AZuq6aL2aKMVzkWxREmPjpkF9OII1feQrP1ifSksOZOf64LJL66WkDWA1eJCIsQ+vFC hpNv6sVzIT9qeFMNYoBRXvYWguvm8Y/N8kMdqeVp5aJ0ajEe5Rd5VyIKzBbSRqSERrRIFExmGt6 cCUBw7PPZz86Xma7nbXYwEOf4c+CGCVCZToXuTu2+UmRFwnsCt649t870dwUkcDblQqBAK3cNrK c9j66Ug0JliD+Eckw/3hSkIF4CB2d2uefW6Hmwefy/Yz73k9zqK3Ws3AZCslGWmx1BVJa9IVGqc pMHo2g4y3AEp5cfOVUkSSlcZMXulA1TnGPXorBjEah6vv8hDuYrdAqDxdjcHeOEdMZarRw0fAPK sKUx5BraR1YnXRNp6mejA9A1PykK7JwYfzXNE0mRcR5qZrFuoY04dOk2QWNzn3yWHMxNEi5mGSe uEjS8t76zraei+Sngp5vqwHmAOBtILXA== X-Received: by 2002:a17:903:3d07:b0:2aa:e415:589c with SMTP id d9443c01a7336-2aae4155993mr36432965ad.55.1770628916550; Mon, 09 Feb 2026 01:21:56 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82441695f50sm9143834b3a.22.2026.02.09.01.21.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Feb 2026 01:21:55 -0800 (PST) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_8CF70173-CC3C-4AEA-9F13-48F4E9AACF27" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Fix a bug in extension_file_exists() Message-Id: <362EA9B3-589B-475A-A16E-F10C30426E28@gmail.com> Date: Mon, 9 Feb 2026 17:21:17 +0800 To: Postgres hackers 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 --Apple-Mail=_8CF70173-CC3C-4AEA-9F13-48F4E9AACF27 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, 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. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_8CF70173-CC3C-4AEA-9F13-48F4E9AACF27 Content-Disposition: attachment; filename=v1-0001-Fix-incorrect-iteration-type-in-extension_file_ex.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-Fix-incorrect-iteration-type-in-extension_file_ex.patch" Content-Transfer-Encoding: quoted-printable =46rom=204a69b519a1b077fc617a2f968bb1dbb2ce2c6806=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Mon,=209=20Feb=202026=2017:05:57=20+0800=0ASubject:=20[PATCH=20= v1]=20Fix=20incorrect=20iteration=20type=20in=20extension_file_exists()=0A= =0AAuthor:=20Chao=20Li=20=0AReviewed-by:=0ADiscussion:=20= https://postgr.es/m/=0A---=0A=20src/backend/commands/extension.c=20|=206=20= +++---=0A=201=20file=20changed,=203=20insertions(+),=203=20deletions(-)=0A= =0Adiff=20--git=20a/src/backend/commands/extension.c=20= b/src/backend/commands/extension.c=0Aindex=20596105ee078..f82a7f104c7=20= 100644=0A---=20a/src/backend/commands/extension.c=0A+++=20= b/src/backend/commands/extension.c=0A@@=20-2557,9=20+2557,9=20@@=20= extension_file_exists(const=20char=20*extensionName)=0A=20=0A=20=09= locations=20=3D=20get_extension_control_directories();=0A=20=0A-=09= foreach_ptr(char,=20location,=20locations)=0A+=09= foreach_ptr(ExtensionLocation,=20location,=20locations)=0A=20=09{=0A-=09=09= dir=20=3D=20AllocateDir(location);=0A+=09=09dir=20=3D=20= AllocateDir(location->loc);=0A=20=0A=20=09=09/*=0A=20=09=09=20*=20If=20= the=20control=20directory=20doesn't=20exist,=20we=20want=20to=20silently=20= return=0A@@=20-2571,7=20+2571,7=20@@=20extension_file_exists(const=20= char=20*extensionName)=0A=20=09=09}=0A=20=09=09else=0A=20=09=09{=0A-=09=09= =09while=20((de=20=3D=20ReadDir(dir,=20location))=20!=3D=20NULL)=0A+=09=09= =09while=20((de=20=3D=20ReadDir(dir,=20location->loc))=20!=3D=20NULL)=0A=20= =09=09=09{=0A=20=09=09=09=09char=09=20=20=20*extname;=0A=20=0A--=20=0A= 2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_8CF70173-CC3C-4AEA-9F13-48F4E9AACF27--