X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate3.py;h=5a5562fbedfe2659c5c2990f7ba125b3a25ac00c;hb=f0bfd37e7286156598d79b53501ebe2000bb7924;hp=ccd463c4bef3c4866f63ade9f1c9839be0e40a7f;hpb=425e44739cd77ffa01294f23e94ae7eabd5f5ec8;p=dak.git diff --git a/dak/dakdb/update3.py b/dak/dakdb/update3.py index ccd463c4..5a5562fb 100755 --- a/dak/dakdb/update3.py +++ b/dak/dakdb/update3.py @@ -1,8 +1,13 @@ #!/usr/bin/env python -""" Database Update Script - Remove unused versioncmp """ -# Copyright (C) 2008 Michael Casadevall -# Copyright (C) 2009 Joerg Jaspert +""" +Remove unused versioncmp + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2009 Joerg Jaspert +@license: GNU General Public License version 2 or later +""" # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,12 +36,15 @@ def do_update(self): try: c = self.db.cursor() - try: - # This might not exist on a fresh install, so don't fail - # needlessly + # 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);") - except: - pass + else: + print "function already does not exist" + c.execute("UPDATE config SET value = '3' WHERE name = 'db_revision'") self.db.commit()