Suggestion to simplify installation of external modules

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Suggestion to simplify installation of external modules
Date: 2005-09-08 20:54:17
Message-ID: 20050908205412.GD4045@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There's been some discussion about loading of external modules and
getting the right function definitions. I was wondering if it would be
an idea to have the install scripts inside the module itself. Create a
command called:

INSTALL word | 'full path'

Would search for $libdir/{word}.so (or full path if specified) or
whatever is appropriate for the platform. The module would then be
queried for the installation script.

I made a little script sql2install.pl [1] which takes an SQL file and
turns it into a C file that exports a single function,
__PG_INSTALL_FUNCTION. This returns a list of strings which are the
commands in the SQL file. Just link this into the final module.

While this does simplify installation, there are other benefits:

- There could be a maintained list of "installed" modules, for
frontends.

- If the process created dependancies between the module and the
functions created, pg_dump could avoid outputting those functions and
types and instead emit "INSTALL blah" in the dump. This makes upgrades
much easier because the definitions are no longer in the dump.

- Dumps become more portable across architectures, because the library
name is not stored directly.

- Saner error messages.

I guess in the specific case of languages, the proposed table would be
redundant as the CREATE LANGUAGE definition would neither be hardcoded
in the backend, nor in the dump, but in the module that implements it.

Note, it would be just as easy to return a structure with author name,
copyright info, version, CATVERSION, etc. Ideally, the module author
would provide a properly formatted file and the pgxs scripts would take
care of the conversion to C and linking.

Note: I also though of UNINSTALL but that would seem to be a great
shoot-in-foot capability.

Thoughts?

[1] http://svana.org/kleptog/pgsql/sql2install.pl
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Browse pgsql-hackers by date

  From Date Subject
Next Message James William Pye 2005-09-08 21:27:58 Re: PQ versions request message
Previous Message Tom Lane 2005-09-08 20:38:50 Re: Rendezvous/Bonjour broken in 8.1 beta