Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f6943f

Browse files
committed
Improve error message for missing extension.
If we get ENOENT while trying to read an extension control file, report that as a missing extension (with a HINT to install it) rather than as a filesystem access problem. The message wording was extensively bikeshedded in hopes of pointing people to the idea that they need to do a software installation before they can install the extension into the current database. Nathan Bossart, with review/wording suggestions from Daniel Gustafsson, Chapman Flack, and myself Discussion: https://postgr.es/m/[email protected]
1 parent 98e93a1 commit 6f6943f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/backend/commands/extension.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,22 @@ parse_extension_control_file(ExtensionControlFile *control,
487487

488488
if ((file = AllocateFile(filename, "r")) == NULL)
489489
{
490-
if (version && errno == ENOENT)
490+
if (errno == ENOENT)
491491
{
492-
/* no auxiliary file for this version */
493-
pfree(filename);
494-
return;
492+
/* no complaint for missing auxiliary file */
493+
if (version)
494+
{
495+
pfree(filename);
496+
return;
497+
}
498+
499+
/* missing control file indicates extension is not installed */
500+
ereport(ERROR,
501+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
502+
errmsg("extension \"%s\" is not available", control->name),
503+
errdetail("Could not open extension control file \"%s\": %m.",
504+
filename),
505+
errhint("The extension must first be installed on the system where PostgreSQL is running.")));
495506
}
496507
ereport(ERROR,
497508
(errcode_for_file_access(),

0 commit comments

Comments
 (0)