Merge lp:~edwin-grubbs/launchpad/bug-663861-product-series-timeout-part1 into lp:launchpad/db-devel

Proposed by Edwin Grubbs
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 9939
Proposed branch: lp:~edwin-grubbs/launchpad/bug-663861-product-series-timeout-part1
Merge into: lp:launchpad/db-devel
Diff against target: 52 lines (+29/-0)
3 files modified
database/schema/patch-2208-26-0.sql (+9/-0)
database/schema/security.cfg (+1/-0)
database/schema/trusted.sql (+19/-0)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-663861-product-series-timeout-part1
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Stuart Bishop db Pending
Review via email: mp+39118@code.launchpad.net

Description of the change

This branch adds an index to the ProductSeries table to allow efficient batching. I deleted the last merge proposal since I had erroneously made changes on top of devel instead of db-devel.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

So, a few things here.
Patch #2208-26-0

I thought we had a function for this in the DB already? Could you have a look for it and preferentially use it?

If we don't have one, this seems fine - but I think you should follow this patch up with a test that you get the sort order you expect.

review: Approve
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

> So, a few things here.
> Patch #2208-26-0

Done.

> I thought we had a function for this in the DB already? Could you have a look
> for it and preferentially use it?

I can't find another one that will work properly. I added the milestone_sort_key() recently, but that takes a date field in addition to the version number.

> If we don't have one, this seems fine - but I think you should follow this
> patch up with a test that you get the sort order you expect.

I'll definitely add a test for that in the next branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2208-26-0.sql'
2--- database/schema/patch-2208-26-0.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2208-26-0.sql 2010-10-28 16:17:49 +0000
4@@ -0,0 +1,9 @@
5+-- Copyright 2010 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+SET client_min_messages=ERROR;
8+
9+CREATE INDEX productseries_name_sort
10+ON ProductSeries
11+USING btree (version_sort_key(name));
12+
13+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 26, 0);
14
15=== modified file 'database/schema/security.cfg'
16--- database/schema/security.cfg 2010-10-26 12:53:04 +0000
17+++ database/schema/security.cfg 2010-10-28 16:17:49 +0000
18@@ -18,6 +18,7 @@
19 public.calculate_bug_heat(integer) = EXECUTE
20 public.debversion_sort_key(text) = EXECUTE
21 public.milestone_sort_key(timestamp without time zone, text) = EXECUTE
22+public.version_sort_key(text) = EXECUTE
23 public.null_count(anyarray) = EXECUTE
24 public.valid_name(text) = EXECUTE
25 public.valid_bug_name(text) = EXECUTE
26
27=== modified file 'database/schema/trusted.sql'
28--- database/schema/trusted.sql 2010-10-05 12:05:50 +0000
29+++ database/schema/trusted.sql 2010-10-28 16:17:49 +0000
30@@ -1814,3 +1814,22 @@
31
32 COMMENT ON FUNCTION milestone_sort_key(timestamp, text) IS
33 'Sort by the Milestone dateexpected and name. If the dateexpected is NULL, then it is converted to a date far in the future, so it will be sorted as a milestone in the future.';
34+
35+
36+CREATE OR REPLACE FUNCTION version_sort_key(version text) RETURNS text
37+LANGUAGE plpythonu IMMUTABLE RETURNS NULL ON NULL INPUT AS
38+$$
39+ # If this method is altered, then any functional indexes using it
40+ # need to be rebuilt.
41+ import re
42+
43+ [version] = args
44+
45+ def substitute_filled_numbers(match):
46+ return match.group(0).zfill(5)
47+
48+ return re.sub(u'\d+', substitute_filled_numbers, version)
49+$$;
50+
51+COMMENT ON FUNCTION version_sort_key(text) IS
52+'Sort a field as version numbers that do not necessarily conform to debian package versions (For example, when "2-2" should be considered greater than "1:1"). debversion_sort_key() should be used for debian versions.';

Subscribers

People subscribed via source and target branches

to status/vote changes: