Author: nunofsantos
Date: 2008-12-08 14:33:25 -0500 (Mon, 08 Dec 2008)
New Revision: 2950
Modified:
mgmt/trunk/mint/python/mint/schemaparser.py
mgmt/trunk/mint/sql/triggers.sql
Log:
add conditional 'CREATE LANGUAGE plpgsql' to schema creation
Modified: mgmt/trunk/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/trunk/mint/python/mint/schemaparser.py 2008-12-08 18:15:49 UTC (rev 2949)
+++ mgmt/trunk/mint/python/mint/schemaparser.py 2008-12-08 19:33:25 UTC (rev 2950)
@@ -216,6 +216,23 @@
# TODO: optimize getting the id to the parent table from new.parent_table_id
self.sqlTriggersOutput += """
+CREATE OR REPLACE FUNCTION create_plpgsql() RETURNS TEXT AS '
+ CREATE LANGUAGE plpgsql;
+ SELECT ''plpgsql language created''::TEXT;
+' LANGUAGE sql;
+
+SELECT CASE WHEN
+ (SELECT true
+ FROM pg_language
+ WHERE lanname='plpgsql')
+ THEN
+ (SELECT 'plpgsql language already installed'::TEXT)
+ ELSE
+ (SELECT create_plpgsql())
+END;
+
+DROP FUNCTION create_plpgsql();
+
CREATE OR REPLACE FUNCTION update_stats() RETURNS trigger AS '
DECLARE
parent_table varchar;
Modified: mgmt/trunk/mint/sql/triggers.sql
===================================================================
--- mgmt/trunk/mint/sql/triggers.sql 2008-12-08 18:15:49 UTC (rev 2949)
+++ mgmt/trunk/mint/sql/triggers.sql 2008-12-08 19:33:25 UTC (rev 2950)
@@ -1,4 +1,21 @@
+CREATE OR REPLACE FUNCTION create_plpgsql() RETURNS TEXT AS '
+ CREATE LANGUAGE plpgsql;
+ SELECT ''plpgsql language created''::TEXT;
+' LANGUAGE sql;
+
+SELECT CASE WHEN
+ (SELECT true
+ FROM pg_language
+ WHERE lanname='plpgsql')
+ THEN
+ (SELECT 'plpgsql language already installed'::TEXT)
+ ELSE
+ (SELECT create_plpgsql())
+END;
+
+DROP FUNCTION create_plpgsql();
+
CREATE OR REPLACE FUNCTION update_stats() RETURNS trigger AS '
DECLARE
parent_table varchar;
Show replies by date