From f9c149b1031769516702826c6529e86159a2149a Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Mon, 29 Nov 2021 22:06:27 +0000 Subject: [PATCH v3 1/1] Improve CREATE EXTENSION error message. --- src/backend/commands/extension.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index eaa76af47b..d7713a5b3f 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -487,11 +487,21 @@ parse_extension_control_file(ExtensionControlFile *control, if ((file = AllocateFile(filename, "r")) == NULL) { - if (version && errno == ENOENT) + if (errno == ENOENT) { - /* no auxiliary file for this version */ - pfree(filename); - return; + /* auxiliary files are optional */ + if (version) + { + pfree(filename); + return; + } + + /* missing control file indicates extension is not installed */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("extension \"%s\" is not available", control->name), + errdetail("The extension must first be installed on the system where PostgreSQL is running."), + errhint("The pg_available_extensions view lists the extensions that are available for installation."))); } ereport(ERROR, (errcode_for_file_access(), -- 2.16.6