-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E-Maj Could use a Makefile #54
Comments
Thank You very much, David, for your proposal. I think it would be great if the next version could allow pgxn to install, load, unload and uninstall the extension. And this needs a proper Makefile to be created. I already tried to do this in the past, but unsuccessfully (I am not a system expert). That's the reason for I finally described the installation as currently stated in the documentation. There are several specificities for the E-Maj project:
The approach I currently have in mind could:
Regarding the load and unload functions, I presume that pgxn should be able to handle them (once an uninstall_emaj.sql link will be created, pointing towards emaj_uninstall.sql). Regarding the install and uninstall functions, my current feeling is that PGXS would not really help and I should rather try to write a Makefile without it. Please, feel free to comment. |
Here is a first Makefile draft:
|
Shouldn't |
I think ideally it would be installed in
I think it's reasonable that they'd live with the other scripts in PG_SHAREDIR. To keep them all in a subdirectory, set
If it's an extension using a control file, then
You can include SQL scripts to cover all versions, then the user just has to make sure they have the same release installed (that is,
This should at least be configurable, and ideally use PostgreSQL SHAREDIR. I don't think you need the version in the directory name.
I don't think that will work. Postgres requires that its SQL files be in its SHAREDIR. Maybe the
Postgres extension docs ideally should go into the cluster's docs or man directories. If you set
Is there something about
The PGXN client currently expects everything to use either PGXS-based
I think that's true if you have requirements for file system locations that PGXS isn't aware of, but I encourage using the Postgres standard locations for everything to do with an extension (and not the other stuff you have in this repo, which I assume is not included in the zip file released on PGXN). It keeps things much more predictable for DBAs. Hope that's helpful! |
Thanks a lot for your comments. It's very helpful :-) Regarding the files location, it's good to know where the DBAs use to find components.
E-Maj goal is to capture changes on tables. And this is done using triggers created on application tables. When dropping the extension, we have to be sure that no such triggers are left on these tables. The uninstall SQL script checks this and refuses to drop the extension if it's not the case. I am not aware of a parameter in the control file or any other trick that would allow to avoid a SQL script.
In fact, it's possible to use a full path, as stated in the documentation. And I use this in my tests environments that uses all PG versions from 11 to 16. I will try to write another Makefile taking into account your advice. |
To be more precise about the emaj_uninstall.sql script:
The same script processes emaj installed as an EXTENSION and installed with a psql script (for cloud environments). |
Hi David, Right now, I am facing 3 issues. The first concerns PGXS, more precisely the uninstall target. I reported it yesterday in the pgsql-general mailing list. (https://www.postgresql.org/message-id/f2645de1-b3b0-43b2-b467-bc3e83bb4898%40free.fr) While issuing the load command, I get a message saying that required extensions are missing. It looks like the pgxn client doesn't use the CASCADE clause of the CREATE EXTENSION statement. This is not a big deal as once the required extensions are created, the command works fine. I have not found any parameter asking for the CASCADE clause. Could you confirm that I have not missed something and that it is the expected behavior ? The last issue deals with the unload command. I have not been able to let the pgxn client use an uninstall script instead of the regular DROP EXTENSION statement. I tried to copy the uninstall script into the $PGSHARE/$MODULEDIR directory or directly into the $PGSHARE/extension directory but unsuccessfully. May be I misread the documentation. It says in particular:
Actually, I don't understand where this Thanks by advance for your help. |
Yes, most extensions that let the use add and remove objects can leave detritus. It's not mutually-exclusive to
Yeah, PGXS does not remove those files, it just leaves them. They're mostly harmless though.
I don't thin you've missed anything; I don't see it in the source. Might be worth opening a feature request issue in the client project.
Yeah that's not a supported pattern of
I didn't know about that! It's specific to the
I don't know either. I would assume it would need to be installed with all of your SQL scripts, so should be included in the |
I have created 2 issues in the pgxn client project:
|
The commit b367d0a adds a Makefile. |
Looks good, although I think the SQL files need to go into |
Thanks for the feedback.
FYI, I am currently working on the move of the uninstall script towards a SQL function, to help the user dropping the extension, as you suggested in an earlier message. This is a good idea and ... it seems to work fine. |
Oh I see, I forget it doesn't go into the I think documentation is the only way to encourage people to run an uninstall procedure before actually uninstalling, alas. Nice to have it in the database, though, will be more convenient, I think — as long as no one calls it accidentally. :-) |
To support automated installers like the pgxn client, add a Makefile that uses PGXS to install the extension. Something like this has bits to automate various things, but even just something as simple as this would help:
This would allow one to do
The text was updated successfully, but these errors were encountered: