X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=dak%2Fdakdb%2Fupdate23.py;h=5fa8a64358be455ae63fc84307f6c3df82b9e4be;hb=1cc079eee7fce279ec6e9701d82f69a1567955cd;hp=9d97172b9352059672ff1624be9caf90602eb049;hpb=3b50b545815298b77b8eb68930acb6fde01ea4d4;p=dak.git diff --git a/dak/dakdb/update23.py b/dak/dakdb/update23.py index 9d97172b..5fa8a643 100644 --- a/dak/dakdb/update23.py +++ b/dak/dakdb/update23.py @@ -92,8 +92,7 @@ def do_update(self): package text, binary_id integer, arch integer, - suite integer, - component text)""" ) + suite integer)""" ) c.execute("""CREATE TABLE udeb_contents ( filename text, @@ -101,8 +100,7 @@ def do_update(self): package text, binary_id integer, suite integer, - arch integer, - component text )""" ) + arch integer)""" ) c.execute("""ALTER TABLE ONLY deb_contents ADD CONSTRAINT deb_contents_arch_fkey @@ -171,24 +169,19 @@ def do_update(self): if event == "INSERT" or event == "UPDATE": content_data = plpy.execute(plpy.prepare( - """SELECT s.section, b.package, b.architecture, c.name, ot.type + """SELECT s.section, b.package, b.architecture, ot.type FROM override o JOIN override_type ot on o.type=ot.id JOIN binaries b on b.package=o.package JOIN files f on b.file=f.id JOIN location l on l.id=f.location JOIN section s on s.id=o.section - JOIN component c on c.id=l.component WHERE b.id=$1 AND o.suite=$2 """, ["int", "int"]), [TD["new"]["bin"], TD["new"]["suite"]])[0] - component_str = ""; - if not content_data["name"] === "main": - component_str=content_data["name"]+"/" - filenames = plpy.execute(plpy.prepare( "SELECT bc.file FROM bin_contents bc where bc.binary_id=$1", ["int"]), @@ -197,16 +190,15 @@ def do_update(self): for filename in filenames: plpy.execute(plpy.prepare( """INSERT INTO deb_contents - (file,section,package,binary_id,arch,suite,component) - VALUES($1,$2,$3,$4,$5,$6,$7)""", - ["text","text","text","int","int","int","text"]), - [filename["filename"], + (filename,section,package,binary_id,arch,suite) + VALUES($1,$2,$3,$4,$5,$6)""", + ["text","text","text","int","int","int"]), + [filename["file"], content_data["section"], content_data["package"], TD["new"]["bin"], content_data["architecture"], - TD["new"]["suite"], - component_str]) + TD["new"]["suite"]] ) $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; """) @@ -215,12 +207,16 @@ $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; event = TD["event"] if event == "UPDATE": - otype = plpy.execute(plpy.prepare("SELECT type from override_type where id=$1",["int"]),TD["new"]["type"] )[0]; + otype = plpy.execute(plpy.prepare("SELECT type from override_type where id=$1",["int"]),[TD["new"]["type"]] )[0]; if otype["type"].endswith("deb"): + section = plpy.execute(plpy.prepare("SELECT section from section where id=$1",["int"]),[TD["new"]["section"]] )[0]; + table_name = "%s_contents" % otype["type"] - plpy.execute(plpy.prepare("UPDATE %s set sections=$1" % table_name - ["text"]), - [TD["new"]["section"]]) + plpy.execute(plpy.prepare("UPDATE %s set section=$1 where package=$2 and suite=$3" % table_name, + ["text","text","int"]), + [section["section"], + TD["new"]["package"], + TD["new"]["suite"]]) $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; """) @@ -231,6 +227,10 @@ $$ LANGUAGE plpythonu VOLATILE SECURITY DEFINER; AFTER UPDATE ON override FOR EACH ROW EXECUTE PROCEDURE update_contents_for_override();""") + + c.execute( "CREATE INDEX ind_deb_contents_name ON deb_contents(package);"); + c.execute( "CREATE INDEX ind_udeb_contents_name ON udeb_contents(package);"); + self.db.commit() except psycopg2.ProgrammingError, msg: