Merge lp:~stub/launchpad/db-cleanups into lp:launchpad/db-devel

Proposed by Stuart Bishop
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 10804
Proposed branch: lp:~stub/launchpad/db-cleanups
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~stub/launchpad/pending-db-changes
Diff against target: 93 lines (+20/-32)
5 files modified
database/schema/Makefile (+0/-1)
database/schema/patch-2208-76-3.sql (+15/-0)
database/schema/security.cfg (+0/-1)
database/schema/testfuncs.sql (+0/-29)
lib/lp/testing/pgsql.py (+5/-1)
To merge this branch: bzr merge lp:~stub/launchpad/db-cleanups
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+68658@code.launchpad.net

Commit message

[r=stub][bug=813761] Remove production crud to silence security.py warnings.

Description of the change

= Summary =

Running security.py on production and staging generates warnings.

== Proposed fix ==

Fix the stuff it is warning about.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/Makefile'
2--- database/schema/Makefile 2011-01-31 11:10:39 +0000
3+++ database/schema/Makefile 2011-07-21 11:09:44 +0000
4@@ -128,7 +128,6 @@
5 @ psql -d ${EMPTY_DBNAME} -q -c "CREATE SCHEMA todrop;"
6 @ echo "* Creating functions"
7 @ psql -d ${EMPTY_DBNAME} -f trusted.sql | grep : | cat
8- @ psql -d ${EMPTY_DBNAME} -f testfuncs.sql | grep : | cat
9 @ echo "* Installing tsearch2 into ts2 schema"
10 @ ${PYTHON} fti.py -q --setup-only -d ${EMPTY_DBNAME}
11 @ echo "* Loading base database schema"
12
13=== added file 'database/schema/patch-2208-76-3.sql'
14--- database/schema/patch-2208-76-3.sql 1970-01-01 00:00:00 +0000
15+++ database/schema/patch-2208-76-3.sql 2011-07-21 11:09:44 +0000
16@@ -0,0 +1,15 @@
17+-- Copyright 2011 Canonical Ltd. This software is licensed under the
18+-- GNU Affero General Public License version 3 (see the file LICENSE).
19+
20+SET client_min_messages = ERROR;
21+
22+-- Drop old unused functions still lurking on production.
23+DROP FUNCTION IF EXISTS is_blacklisted_name(text);
24+DROP FUNCTION IF EXISTS name_blacklist_match(text);
25+DROP FUNCTION IF EXISTS reverse(text);
26+DROP FUNCTION IF EXISTS bug_summary_temp_journal_clean_row(bugsummary);
27+DROP FUNCTION IF EXISTS valid_version(text);
28+DROP FUNCTION IF EXISTS decendantrevision(integer);
29+DROP FUNCTION IF EXISTS sleep_for_testing(float);
30+
31+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 76, 3);
32
33=== modified file 'database/schema/security.cfg'
34--- database/schema/security.cfg 2011-07-15 15:35:03 +0000
35+++ database/schema/security.cfg 2011-07-21 11:09:44 +0000
36@@ -11,7 +11,6 @@
37
38 [public]
39 type=group
40-public._killall_backends(text) =
41 public.activity() = EXECUTE
42 public.add_test_openid_identifier(integer) = EXECUTE
43 public.alllocks =
44
45=== removed file 'database/schema/testfuncs.sql'
46--- database/schema/testfuncs.sql 2009-06-24 21:17:33 +0000
47+++ database/schema/testfuncs.sql 1970-01-01 00:00:00 +0000
48@@ -1,29 +0,0 @@
49-/*
50-Copyright 2009 Canonical Ltd. This software is licensed under the
51-GNU Affero General Public License version 3 (see the file LICENSE).
52-
53-Stored procedures designed for use only by the test suite. These
54-will not be loaded onto the production database
55-*/
56-
57-CREATE OR REPLACE FUNCTION _killall_backends(text)
58-RETURNS Boolean AS $$
59- import os
60- from signal import SIGTERM
61-
62- plan = plpy.prepare(
63- "SELECT procpid FROM pg_stat_activity WHERE datname=$1", ['text']
64- )
65- success = True
66- for row in plpy.execute(plan, args):
67- try:
68- plpy.info("Killing %d" % row['procpid'])
69- os.kill(row['procpid'], SIGTERM)
70- except OSError:
71- success = False
72-
73- return success
74-$$ LANGUAGE plpythonu;
75-
76-COMMENT ON FUNCTION _killall_backends(text) IS 'Kill all backend processes connected to the given database. Note that this is unlikely to work if you are connected to the database you are killing, as you are likely to kill your own connection before all the others have been killed.';
77-
78
79=== modified file 'lib/lp/testing/pgsql.py'
80--- lib/lp/testing/pgsql.py 2011-07-01 07:11:27 +0000
81+++ lib/lp/testing/pgsql.py 2011-07-21 11:09:44 +0000
82@@ -399,7 +399,11 @@
83 # always having this is a problem.
84 try:
85 cur = con.cursor()
86- cur.execute('SELECT _killall_backends(%s)', [self.dbname])
87+ cur.execute("""
88+ SELECT pg_terminate_backend(procpid)
89+ FROM pg_stat_activity
90+ WHERE procpid <> pg_backend_pid() AND datname=%s
91+ """, [self.dbname])
92 except psycopg2.DatabaseError:
93 pass
94

Subscribers

People subscribed via source and target branches

to status/vote changes: