On 08.02.22 13:55, Julien Rouhaud wrote:
I'm just saying that without such a lock you can easily trigger the "cache
lookup" error, and that's something that's supposed to happen with normal
usage I think.  So it should be a better message saying that the database has
been concurrently dropped, or actually simply does not exist like it's done in
AlterDatabaseOwner() for the same pattern:

[...]
        tuple = systable_getnext(scan);
        if (!HeapTupleIsValid(tuple))
                ereport(ERROR,
                                (errcode(ERRCODE_UNDEFINED_DATABASE),
                                 errmsg("database \"%s\" does not exist", 
dbname)));
[...]

In my code, the existence of the database is checked by

    dboid = get_database_oid(stmt->dbname, false);

This also issues an appropriate user-facing error message if the database does not exist.

The flow in AlterDatabaseOwner() is a bit different, it looks up the pg_database tuple directly from the name. I think both are correct. My code has been copied from the analogous code in AlterCollation().


Reply via email to