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?
1 Answer 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.
DROP FUNCTION IF EXISTS fun();
(Untested, but certainly suppresses complaints.)