X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate3.py;h=5a5562fbedfe2659c5c2990f7ba125b3a25ac00c;hb=e92bd768962e2d6145907ccc01962c36934975b7;hp=c91ecf56eadba987c11339109ea371a71cfa65a4;hpb=65eca3359b965e53f16a8132ba62eaa8462716f8;p=dak.git diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py index c91ecf56..5a5562fb 100755 --- a/dak/dakdb/update3.py +++ b/dak/dakdb/update3.py @@ -36,7 +36,15 @@ def do_update(self): try: c = self.db.cursor() - c.execute("DROP FUNCTION versioncmp(text, text);") + # The reason we try and check to see if it exists is that + # psycopg2 might leave the cursor invalid if the drop fails + c.execute("SELECT proname from pg_catalog.pg_proc WHERE proname = 'versioncmp'") + rows = c.fetchall() + if rows: + c.execute("DROP FUNCTION versioncmp(text, text);") + else: + print "function already does not exist" + c.execute("UPDATE config SET value = '3' WHERE name = 'db_revision'") self.db.commit()