Upgrade scripts should use CREATE OR REPLACE and the like
Opened this issue · 4 comments
I was testing 1.4.0 in a database here before it was it was 1.4.0. When I went to upgrade that database to 1.4.1, I got
ERROR: function "spoly" already exists with same argument types
My solution was to change all the "CREATE FUNCTION" statements in the upgrade script to "CREATE OR REPLACE FUNCTION". The upgrade then worked fine. I feel this should be the standard practice for all upgrade scripts, past and future.
I'm surprised that using create or replace in the upgrade script worked to fix the problem because it actually shouldn't: postgres/postgres@b9b21ac
I'm surprised that using
create or replacein the upgrade script worked to fix the problem because it actually shouldn't: postgres/postgres@b9b21ac
Are we reading the same commit message? It says, "Hence, forbid CREATE OR REPLACE of an existing object unless it already belongs to the extension." (Emphasis mine.) So why shouldn't it work?
Ah right, I had assumed you had created an spoly function outside of pg_sphere and then the upgrade complained it's already there, but it was a function from inside pg_sphere. That explains why it worked, thanks.