On Tue, Jul 29, 2025 at 5:35 AM Jelte Fennema-Nio <postg...@jeltef.nl> wrote: > On Wed Jul 23, 2025 at 7:12 PM CEST, Artem Gavrilov wrote: > > 1) I noticed that pg_dump changes weren't covered with tests. > > > > 2) I assume these error messages may be confusing, especially first one: > > Attached is an updated version that addresses these issues.
I generally like the direction that this is going but there are places where the new stuff looks too much like it was bolted onto whatever was there already. It's important to go back and edit things so that they look natural, as if the new feature had been present all along. - relocated. The named schema must already exist. + relocated. The named schema must already exist, unless + <literal>owned_schema</literal> is set to <literal>true</literal> in + the control file, then the schema must not exist. This reads awkwardly, at least to me. The smallest possible edit that would make it passable for me is to replace "the" with "in which case," but possibly the whole sentence should be rephrased somehow. + * If the user is giving us the schema name, it must exist already if + * the extension does not want to own the schema This could be made clearer. + errmsg("schema \"%s\" already exists but the extension needs to create it", + schemaName), I don't really find this an improvement over: ERROR: schema "test_ext_owned_schema" already exists. + else if (control->owned_schema) + { + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_SCHEMA), + errmsg("schema \"%s\" already exists but the extension needs to create it", + schemaName), + errhint("Drop schema \"%s\" or specify another schema using CREATE EXTENSION ... SCHEMA ...", schemaName))); + } + } - else if (!OidIsValid(schemaOid)) + else if (control->owned_schema) + { + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_SCHEMA), + errmsg("no schema has been selected to create in"))); + } + else It certainly seems worth asking whether this if-nest should be rephrased in some way to make it clearer. But even if it's best to keep it as it is, I find the absence of comments hard to justify. Who is going to read the bit that emits "no schema has been selected to create in" and find that self-explanatory? I would like to see some improvements in AlterExtensionNamespace. In the context of the patch, it's possible to puzzle out what is happening, but I think the picture is not going to be clear to later readers. It seems to me that this either needs some restructuring to make the logical flow clearer, or a few well-written comments. -- Robert Haas EDB: http://www.enterprisedb.com