Re: [PATCH 02/12] [db] Create language "plpgsql", needed by the package_checkrel() function
On Mon, Jan 26, 2009 at 06:41:00PM +0100, Adeodato Simó wrote:
> +CREATE LANGUAGE plpgsql;
I didn't apply this patch directly, since it breaks if the template1
database already has the language installed. Instead, I've wrapped
in a function:
diff --git a/db/db.sql b/db/db.sql
index 84305d0..94de030 100644
--- a/db/db.sql
+++ b/db/db.sql
@@ -23,6 +23,25 @@ COMMENT ON DATABASE "sbuild-packages" IS 'Debian source builder package state ma
\i debversion.sql
+CREATE OR REPLACE FUNCTION create_plpgsql_language ()
+ RETURNS TEXT AS $$
+ CREATE LANGUAGE plpgsql;
+ SELECT 'language plpgsql created'::TEXT;
+$$
+LANGUAGE SQL;
+
+SELECT CASE WHEN
+ (SELECT 't'::boolean
+ FROM pg_language
+ WHERE lanname='plpgsql')
+ THEN
+ (SELECT 'language plpgsql already installed'::TEXT)
+ ELSE
+ (SELECT create_plpgsql_language())
+END;
+
+DROP FUNCTION create_plpgsql_language()
+
CREATE TABLE architectures (
name text
CONSTRAINT arch_name PRIMARY KEY
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
Reply to: