Re: improve CREATE EXTENSION error message - Mailing list pgsql-hackers

From Tom Lane
Subject Re: improve CREATE EXTENSION error message
Date
Msg-id 1482885.1638223402@sss.pgh.pa.us
Whole thread Raw
In response to Re: improve CREATE EXTENSION error message  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: improve CREATE EXTENSION error message
Re: improve CREATE EXTENSION error message
List pgsql-hackers
Daniel Gustafsson <daniel@yesql.se> writes:
>> On 29 Nov 2021, at 22:47, Bossart, Nathan <bossartn@amazon.com> wrote:
>> On 11/29/21, 1:38 PM, "Chapman Flack" <chap@anastigmatix.net> wrote:
>>> Maybe a larger break with the "This means the extension something something"
>>> formulation, and more on the lines of
>>> HINT:  an extension must first be present (for example, installed with a
>>> package manager) on the system where PostgreSQL is running.

>> I like this idea.  I can do it this way in the next revision if others
>> agree.

> I think taking it in this direction has merits.

I think "The extension must ..." would read better, otherwise +1.

I don't especially like intertwining the hint choice with the existing
special case for per-version files.  Our usual style for conditional
hints can be found in places like sysv_shmem.c, and following that
would lead to a patch roughly like

    if ((file = AllocateFile(filename, "r")) == NULL)
    {
+       int ext_errno = errno;
+
        if (version && errno == ENOENT)
        {
            /* no auxiliary file for this version */
            pfree(filename);
            return;
        }
        ereport(ERROR,
                (errcode_for_file_access(),
                 errmsg("could not open extension control file \"%s\": %m",
-                       filename)));
+                       filename),
+                (ext_errno == ENOENT) ? errhint("...") : 0));
    }

            regards, tom lane



pgsql-hackers by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Lots of memory allocated when reassigning Large Objects
Next
From: "Bossart, Nathan"
Date:
Subject: Re: improve CREATE EXTENSION error message