Re: Support for CREATE MODULE?

Joel Jacobson <joel@compiler.org>

From: "Joel Jacobson" <joel@compiler.org>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-06-02T15:22:11Z
Lists: pgsql-hackers
On Wed, Jun 2, 2021, at 16:43, Jim Mlodgenski wrote:
> On Wed, Jun 2, 2021 at 9:58 AM Tom Lane <tgl@sss.pgh.pa.us <mailto:tgl%40sss.pgh.pa.us>> wrote:
> > I wonder whether it'd be better to consider modules as a kind of
> > extension, or at least things with the same sort of ownership relations
> > as extensions have.
> 
> That would solve the problem of associating objects which is the larger
> problem for users today. The objects can all live in their respective
> schemas with the module tying them all together.

I like the idea of somehow using extensions.

Right now, extensions can only be added from the command-line, via `make install`.

But maybe a new extension could be packaged from the SQL prompt, out of existing database objects that are not already part of an extension?

Maybe the interface could be:

init_new_extension(extension_name text) function, to register a new empty extension.
add_object_to_extension(extension_name text, type text, object_names text[], object_args text[])

Then, if dropping the extension, all objects would be dropped, and if creating the extension, all objects would be restored.

I don't have an idea on how to handle update scripts, but since it's not mandatory to provide extension update scripts, maybe that's not a problem.

/Joel