From: Mark Hymers Date: Wed, 23 Mar 2011 14:37:09 +0000 (+0000) Subject: Merge remote branch 'mhy/master' into merge X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=d7b90c4606e6f4fe32965d3c77d8f5f7428b7168;hp=ca92aad2e0267a71fc089db42bb3eb802065fb13;p=dak.git Merge remote branch 'mhy/master' into merge Signed-off-by: Mark Hymers --- diff --git a/config/backports/dinstall.functions b/config/backports/dinstall.functions index 27854f8b..0dfe19ec 100644 --- a/config/backports/dinstall.functions +++ b/config/backports/dinstall.functions @@ -322,7 +322,7 @@ function mkfilesindices() { ARCHLIST=$(tempfile) - log "Querying $PGDATABASE..." + log "Querying postgres..." echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql -At | sed 's/|//;s,^/srv/ftp-master.debian.org/ftp,.,' | sort >$ARCHLIST includedirs () { diff --git a/config/debian-security/dak.conf b/config/debian-security/dak.conf index 58f77c11..b03e0f89 100644 --- a/config/debian-security/dak.conf +++ b/config/debian-security/dak.conf @@ -262,10 +262,13 @@ Dir DB { - Name "obscurity"; - Host ""; - Port -1; - + Service "obscurity"; + // PoolSize should be at least ThreadCount + 1 + PoolSize 5; + // MaxOverflow shouldn't exceed postgresql.conf's max_connections - PoolSize + MaxOverflow 13; + // should be false for encoding == SQL_ASCII + Unicode "false" }; Architectures diff --git a/config/debian/dinstall.functions b/config/debian/dinstall.functions index e4de479e..cac7c7c5 100644 --- a/config/debian/dinstall.functions +++ b/config/debian/dinstall.functions @@ -295,7 +295,7 @@ function mkfilesindices() { ARCHLIST=$(tempfile) - log "Querying $PGDATABASE..." + log "Querying postgres" echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql -At | sed 's/|//;s,^/srv/ftp-master.debian.org/ftp,.,' | sort >$ARCHLIST includedirs () { diff --git a/dak/dakdb/update48.py b/dak/dakdb/update48.py new file mode 100755 index 00000000..67ea8c5b --- /dev/null +++ b/dak/dakdb/update48.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# coding=utf8 + +""" +Suite.version can be null + +@contact: Debian FTP Master +@copyright: 2011 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + +import psycopg2 +from daklib.dak_exceptions import DBUpdateError +from socket import gethostname; + +################################################################################ +def do_update(self): + """ + Add table for source contents. + """ + print __doc__ + try: + c = self.db.cursor() + + c.execute("ALTER TABLE suite ALTER COLUMN version DROP NOT NULL") + c.execute("UPDATE suite SET version=NULL WHERE version='-'") + + c.execute("UPDATE config SET value = '48' WHERE name = 'db_revision'") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, 'Unable to apply sick update 48, rollback issued. Error message : %s' % (str(msg)) diff --git a/dak/update_db.py b/dak/update_db.py index b58996b1..3effa477 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -46,7 +46,7 @@ from daklib.daklog import Logger ################################################################################ Cnf = None -required_database_schema = 47 +required_database_schema = 48 ################################################################################ diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 25fd9c6e..6782c081 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2992,7 +2992,7 @@ class DBConn(object): backref=backref('binaries', lazy='dynamic')), extra_sources = relation(DBSource, secondary=self.tbl_extra_src_references, backref=backref('extra_binary_references', lazy='dynamic')), - key = relation(BinaryMetadata, + key = relation(BinaryMetadata, cascade='all', collection_class=attribute_mapped_collection('key'))), extension = validator) @@ -3164,7 +3164,7 @@ class DBConn(object): suites = relation(Suite, secondary=self.tbl_src_associations, backref=backref('sources', lazy='dynamic')), srcuploaders = relation(SrcUploader), - key = relation(SourceMetadata, + key = relation(SourceMetadata, cascade='all', collection_class=attribute_mapped_collection('key'))), extension = validator) diff --git a/tests/dbtest_metadata.py b/tests/dbtest_metadata.py index dff1b05f..1b698b85 100755 --- a/tests/dbtest_metadata.py +++ b/tests/dbtest_metadata.py @@ -76,5 +76,18 @@ class MetadataTestCase(DBDakTestCase): self.assertEqual('http://debian.org', self.src_hello.metadata[self.homepage]) self.assertTrue(self.depends not in self.src_hello.metadata) + def test_delete(self): + ''' + Tests the delete / cascading behaviour. + ''' + self.setup_metadata() + self.session.delete(self.bin_hello) + # Remove associated binaries because we have no cascading rule for + # them. + for binary in self.src_hello.binaries: + self.session.delete(binary) + self.session.delete(self.src_hello) + self.session.flush() + if __name__ == '__main__': unittest.main()