2

Suppose we have a hypothetical extension named as xyz with version 1.0. It has xyz--1.0.sql and xyz.c file. I have declared function named fun() in xyz--1.0.sql file and its definition in xyz.c file.

Now I wanted to drop this function in the next upgrade i.e xyz--1.0--1.1 so I will use DROP FUNCTION fun(); in it and remove the definition from xyz.c file.

Here my doubt is wouldn't xyz--1.0 will complain about missing definition of fun() and if yes how can I clean up my function definition in xyz.c file?

3
  • DROP FUNCTION IF EXISTS fun(); (Untested, but certainly suppresses complaints.) Feb 13 at 2:29
  • Hi Erwin, I guess you didn't get my question, my concern is, if I will remove the function fun from next update still it will be present in earlier version which will demand some C definition. Now if I will remove that C definition as I have dropped the fun() in new version wouldn't there would be errors? Feb 13 at 18:30
  • I would have to look into extension upgrade dynamics myself ... Feb 13 at 20:26

1 Answer 1

1

You have to leave the function in the xyz.c file forever, otherwise people who choose not to update the extension will have a problem.

You could be rude and ship version 2 without the function and without xyz--1.0.sql (so that you can no longer install version 1.0, only upgrade from it), but you had better make clear to the users that they need to

ALTER EXTENSION xyz UPDATE;

otherwise they will be facing ugly errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.