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@svana.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.
pgpXT06S5bKJY.pgp
Description: PGP signature