From dd0f7ec5e776c25cbb0b6715bf62d52a9965f9b1 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Fri, 25 Dec 2015 19:59:45 +0200
Subject: Support version release

---
 brep/package-extra.sql | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'brep/package-extra.sql')

diff --git a/brep/package-extra.sql b/brep/package-extra.sql
index 6859173..acf1489 100644
--- a/brep/package-extra.sql
+++ b/brep/package-extra.sql
@@ -20,7 +20,9 @@ RETURNS SETOF package AS $$
      p1.version_epoch = p2.version_epoch AND
      (p1.version_canonical_upstream < p2.version_canonical_upstream OR
       p1.version_canonical_upstream = p2.version_canonical_upstream AND
-      p1.version_revision < p2.version_revision)))
+      (p1.version_canonical_release < p2.version_canonical_release OR
+       p1.version_canonical_release = p2.version_canonical_release AND
+       p1.version_revision < p2.version_revision))))
   WHERE
     p1.internal_repository IS NOT NULL AND p2.name IS NULL;
 $$ LANGUAGE SQL STABLE;
@@ -33,9 +35,11 @@ CREATE FUNCTION
 latest_package(INOUT name TEXT,
                OUT version_epoch SMALLINT,
                OUT version_canonical_upstream TEXT,
+               OUT version_canonical_release TEXT,
                OUT version_revision SMALLINT)
 RETURNS SETOF record AS $$
-  SELECT name, version_epoch, version_canonical_upstream, version_revision
+  SELECT name, version_epoch, version_canonical_upstream,
+         version_canonical_release, version_revision
   FROM latest_packages()
   WHERE name = latest_package.name;
 $$ LANGUAGE SQL STABLE;
@@ -50,10 +54,12 @@ search_latest_packages(IN query tsquery,
                        OUT name TEXT,
                        OUT version_epoch SMALLINT,
                        OUT version_canonical_upstream TEXT,
+                       OUT version_canonical_release TEXT,
                        OUT version_revision SMALLINT,
                        OUT rank real)
 RETURNS SETOF record AS $$
-  SELECT name, version_epoch, version_canonical_upstream, version_revision,
+  SELECT name, version_epoch, version_canonical_upstream,
+         version_canonical_release, version_revision,
          CASE
 	   WHEN query IS NULL THEN 0
 -- Weight mapping:           D     C    B    A
@@ -72,10 +78,12 @@ search_packages(IN query tsquery,
                 INOUT name TEXT,
                 OUT version_epoch SMALLINT,
                 OUT version_canonical_upstream TEXT,
+                OUT version_canonical_release TEXT,
                 OUT version_revision SMALLINT,
                 OUT rank real)
 RETURNS SETOF record AS $$
-  SELECT name, version_epoch, version_canonical_upstream, version_revision,
+  SELECT name, version_epoch, version_canonical_upstream,
+         version_canonical_release, version_revision,
          CASE
 	   WHEN query IS NULL THEN 0
 -- Weight mapping:           D     C    B    A
-- 
cgit v1.1

