1""" 

2src_associations_full view 

3 

4@contact: Debian FTP Master <ftpmaster@debian.org> 

5@copyright: 2013, Ansgar Burchardt <ansgar@debian.org> 

6@license: GNU General Public License version 2 or later 

7""" 

8 

9# This program is free software; you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation; either version 2 of the License, or 

12# (at your option) any later version. 

13 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18 

19# You should have received a copy of the GNU General Public License 

20# along with this program; if not, write to the Free Software 

21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 

22 

23################################################################################ 

24 

25import psycopg2 

26 

27from daklib.dak_exceptions import DBUpdateError 

28 

29statements = [ 

30 """ 

31CREATE OR REPLACE VIEW src_associations_full AS 

32SELECT 

33 suite, 

34 source, 

35 BOOL_AND(extra_source) AS extra_source 

36FROM 

37 (SELECT sa.suite AS suite, sa.source AS source, FALSE AS extra_source 

38 FROM src_associations sa 

39 UNION 

40 SELECT ba.suite AS suite, esr.src_id AS source_id, TRUE AS extra_source 

41 FROM extra_src_references esr 

42 JOIN bin_associations ba ON esr.bin_id = ba.bin) 

43 AS tmp 

44GROUP BY suite, source 

45""", 

46 """ 

47COMMENT ON VIEW src_associations_full IS 

48 'view including all source packages for a suite, including those referenced by Built-Using' 

49""", 

50] 

51 

52################################################################################ 

53 

54 

55def do_update(self): 

56 print(__doc__) 

57 try: 

58 c = self.db.cursor() 

59 

60 for stmt in statements: 

61 c.execute(stmt) 

62 

63 c.execute("UPDATE config SET value = '94' WHERE name = 'db_revision'") 

64 self.db.commit() 

65 

66 except psycopg2.ProgrammingError as msg: 

67 self.db.rollback() 

68 raise DBUpdateError( 

69 "Unable to apply sick update 94, rollback issued. Error message: {0}".format( 

70 msg 

71 ) 

72 )