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 1vpRAp-008RzY-1p for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 13:19:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpRAn-00AlVr-1K for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 13:19:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpRAn-00AlVj-0D for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 13:19:28 +0000 Received: from mail-dy1-x132d.google.com ([2607:f8b0:4864:20::132d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpRAk-00000001oum-1NjP for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 13:19:28 +0000 Received: by mail-dy1-x132d.google.com with SMTP id 5a478bee46e88-2b7da62b487so1304169eec.1 for ; Mon, 09 Feb 2026 05:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770643164; x=1771247964; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=ozOh0sO2dPWei0w9J9KpdCEXw7QAK0w6UYKKUgqKVTk=; b=I1uh4lNxEIuTnyxn3c89Y3WQ9GQPCpmEY6ao5gwR1iE9OpGjKrSuqvbWbo9x/Ym9/D p/FlGnPkNA0UYKl10Zor/AN3IVGOQYEOVdj4IvIiqX2bqBGlR2bRmWgI7WVV/7o2cYxS UXlWk+HtTrVAjeZaRs0okWXdKnI4xuV4u8lrSMgaS5M+J7yGUQ1S/xCosTo62QLi7TSp 6oioIWnX11A7uAdXCfOEbTdq5BMmcm5amiL5dFM8i/JQC5ED0IsM/b1fUxPsUnjz5eVF wKw+6+wRqkwjB0UFpXX81oenOlDzaC4nZ6UiNSK08RMg2KEHewNoIG3+bmXE3lFepCTE gHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770643164; x=1771247964; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ozOh0sO2dPWei0w9J9KpdCEXw7QAK0w6UYKKUgqKVTk=; b=JCmvc1B6mEZuYHGxknlv+mPhxWFiTZdR41tHkkn+gmkMaynEPahmBsokLFVHZOYott 4J1170Ywf0SWjK7VV48/uXW95dpXMKxUITZdcgCv1eWlyruj9Pnux7BIVRk7CganhP8e 8vNkrlevZKSmsZ0iHo4nDjsA6g+7rvrzLcdLq7/0um08ZuOi+aXrG6PqQ97T6ZOcsA5i juP+rUeXau1fD5JLuA/9pyL9fBuXmPlo7quDqSVqtwOc1IxteYd40Dv7EQBMt4XFsVRp yOCCANU82lSZk5tK6TEUPH6dW3JFxLFxdRyxVYJWutWASPIFIkq+ASauQcb798IR3MtC A2uw== X-Forwarded-Encrypted: i=1; AJvYcCXIh4L1LThYvENQDEjo1t9cTDK04CkQHJTBGMkqZjNlzblsGOe4Nq9Odk4ulmBwFKm4oe3XbFlmm+nuLiJP@lists.postgresql.org X-Gm-Message-State: AOJu0YzzRieGfYcZEj9jIGlQO+L6sqf4wxqJHhmdrRaaVBF5lFZrxh6U mul/juQ/7czZtWklVfvftls+YcIpLqA8vVRgZ7ICRQ1eoPDkBiOjr9h7 X-Gm-Gg: AZuq6aIXiAkDqyaGyYcX9PUAe0f6FCPdDq1hag0irVuV9T27LaQpkLlpyLoAGfJzh9h zPkS3h1ndRhNjdKs23O2LEMKXpA/M7NgiaoJnq7tzV7od5/Q9R/H1lFdrFfR96QSo7oHz+L2jnO GhuJbRqAdUNvNrpEqVnMm9q/nj3RQYpDlb0STu5wOd10WojrP9guUKpqlFBae4SvFOzoj450CsX 8dKj/Kpiw+/dIT2+rapZwBR44WUKEIaLtgZNl9qRzakBwi7dc/GuLvtRcPqHdw41rUb4uqC8Evf AdbgWxSU4uCPtidUwXXmF3C20lYkkJbdBt9cRRpvvndYVNpCqJ3HJ6JoI45LgwAwlD1T859BctR ZA68JOrtF8WQ9S76gQU0+7P2IIaO8QngFTuLc9QEqLlR2zgSK6YUJaD9reecTwrTn7jFL44F27v 5I86yQ6f4icH6Igw1SffAqRFXdVZPx50z2uRoW6xrwCA3Dac7W4tOQFxJOBgCpSQEok3rIiEcQv 74/ge9Ihw== X-Received: by 2002:a05:7300:8819:b0:2ba:67ef:535 with SMTP id 5a478bee46e88-2ba67ef11f0mr1520252eec.17.1770643164059; Mon, 09 Feb 2026 05:19:24 -0800 (PST) Received: from ?IPV6:2804:14d:328a:a59c:75c0:b9c8:6e13:3565? ([2804:14d:328a:a59c:75c0:b9c8:6e13:3565]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ba6fdb85c7sm2293959eec.5.2026.02.09.05.19.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Feb 2026 05:19:23 -0800 (PST) Message-ID: <2502db3b-558a-453e-a247-250e71e5a638@gmail.com> Date: Mon, 9 Feb 2026 10:19:20 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix a bug in extension_file_exists() To: Heikki Linnakangas , Chao Li , Postgres hackers References: <362EA9B3-589B-475A-A16E-F10C30426E28@gmail.com> <6ccbe513-a815-4d2c-a746-abe5de2da86b@iki.fi> Content-Language: en-US From: Matheus Alcantara In-Reply-To: <6ccbe513-a815-4d2c-a746-abe5de2da86b@iki.fi> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 09/02/26 07:02, Heikki Linnakangas wrote: > 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! > Sorry, I miss this change. Thanks for the patch Chao and Heikki for committing. -- Matheus Alcantara EDB: https://www.enterprisedb.com