Ubuntu Pastebin

Paste from wgrant at Thu, 28 Aug 2014 08:52:09 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- Follow DSP.
EXPLAIN ANALYZE
WITH RECURSIVE location(product, distribution, sourcepackagename) AS (
    VALUES (1306::integer, NULL::integer, NULL::integer)
  UNION
    SELECT
        shared_location.to_product,
        shared_location.to_distro,
        shared_location.to_spn
    FROM
        location,
        LATERAL (
                -- Find DistributionSourcePackage from Product via Packaging.
                SELECT
                    NULL::integer AS to_product,
                    ds_from_packaging.distribution AS to_distro,
                    packaging_from_ps.sourcepackagename AS to_spn
                FROM
                    productseries AS ps_from_location
                    JOIN packaging AS packaging_from_ps
                        ON packaging_from_ps.productseries = ps_from_location.id
                    JOIN distroseries AS ds_from_packaging
                        ON ds_from_packaging.id = packaging_from_ps.distroseries
                WHERE ps_from_location.product = location.product
            UNION ALL
                -- Find Product from DistributionSourcePackage via Packaging.
                SELECT
                    ps_from_packaging.product AS to_product,
                    NULL::integer AS to_distro,
                    NULL::integer AS to_spn
                FROM
                    distroseries AS ds_from_location
                    JOIN packaging AS packaging_from_ds
                        ON packaging_from_ds.distroseries = ds_from_location.id
                    JOIN productseries AS ps_from_packaging
                        ON ps_from_packaging.id = packaging_from_ds.productseries
                WHERE
                    ds_from_location.distribution = location.distribution
                    AND packaging_from_ds.sourcepackagename = location.sourcepackagename
            UNION ALL
                -- Find DistributionSourcePackage in parent distributions.
                SELECT
                    NULL::integer AS to_product,
                    ds_from_dsp.distribution AS to_distro,
                    location.sourcepackagename AS to_spn
                FROM
                    distroseries AS ds_from_location
                    JOIN distroseriesparent
                        ON distroseriesparent.derived_series =
                            ds_from_location.id
                    JOIN distroseries AS ds_from_dsp
                        ON ds_from_dsp.id = distroseriesparent.parent_series
                WHERE
                    ds_from_location.distribution = location.distribution
            UNION ALL
                -- Find DistributionSourcePackage in child distributions.
                SELECT
                    NULL::integer AS to_product,
                    ds_from_dsp.distribution AS to_distro,
                    location.sourcepackagename AS to_spn
                FROM
                    distroseries AS ds_from_location
                    JOIN distroseriesparent
                        ON distroseriesparent.parent_series =
                            ds_from_location.id
                    JOIN distroseries AS ds_from_dsp
                        ON ds_from_dsp.id = distroseriesparent.derived_series
                WHERE
                    ds_from_location.distribution = location.distribution
            ) AS shared_location
    WHERE
        -- All rows must have a location.
        shared_location.to_product IS NOT NULL
        OR shared_location.to_distro IS NOT NULL)
SELECT * FROM location;
Download as text