From 1dc38cf49b6c7a8b661a9cc675ded94c8ab33c36 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Mon, 18 Jan 2016 07:35:12 +0200
Subject: Implement brep-migrate utility

---
 brep/package-extra.sql | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

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

diff --git a/brep/package-extra.sql b/brep/package-extra.sql
index dc37d1f..9a847e3 100644
--- a/brep/package-extra.sql
+++ b/brep/package-extra.sql
@@ -1,12 +1,22 @@
-DROP TYPE IF EXISTS weighted_text CASCADE;
-CREATE TYPE weighted_text AS (a TEXT, b TEXT, c TEXT, d TEXT);
-
+-- This file should be parsable by the brep-migrate utility. To decrease the
+-- parser complexity, the following restrictions are placed:
+--
+-- * comments must start with -- at the beginning of the line (ignoring
+--   leading spaces)
+-- * only CREATE and DROP statements for FUNCTION and TYPE
+-- * function bodies must be defined using $$-quoted strings
+-- * strings other then function bodies must be quoted with ' or "
+-- * statements must end with ";\n"
+--
 DROP FUNCTION IF EXISTS to_tsvector(IN document weighted_text);
 DROP FUNCTION IF EXISTS search_packages(IN query tsquery, INOUT name TEXT);
 DROP FUNCTION IF EXISTS search_latest_packages(IN query tsquery);
 DROP FUNCTION IF EXISTS latest_package(INOUT name TEXT);
 DROP FUNCTION IF EXISTS latest_packages();
 
+DROP TYPE IF EXISTS weighted_text CASCADE;
+CREATE TYPE weighted_text AS (a TEXT, b TEXT, c TEXT, d TEXT);
+
 -- Return the latest versions of internal packages as a set of package rows.
 --
 CREATE FUNCTION
@@ -72,9 +82,9 @@ $$ LANGUAGE SQL STABLE;
 -- Search for packages matching the search query and having the specified name.
 -- Return a set of rows containing the package id and search rank. If query
 -- is NULL, then match all packages and return 0 rank for all rows.
--- 
+--
 CREATE FUNCTION
-search_packages(IN query tsquery,             
+search_packages(IN query tsquery,
                 INOUT name TEXT,
                 OUT version_epoch INTEGER,
                 OUT version_canonical_upstream TEXT,
-- 
cgit v1.1

