]> git.decadent.org.uk Git - dak.git/commitdiff
triggers now work
authorMike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
Sat, 31 Oct 2009 12:31:59 +0000 (12:31 +0000)
committerMike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
Sat, 31 Oct 2009 12:31:59 +0000 (12:31 +0000)
Signed-off-by: Mike O'Connor <stew@dhcp-101.dfw1.kickstart.lan>
dak/dakdb/update23.py

index 9d97172b9352059672ff1624be9caf90602eb049..708011cf5257f2b496a3be74541df96d105d75e1 100644 (file)
@@ -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;
 """)