From d4d7b9c7d8260d15d90761329f660adb7766ea1b Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 30 Jan 2012 16:30:54 +0100
Subject: [PATCH] install UDFs in generic mysql recipe.

---
 slapos/recipe/generic_mysql/__init__.py                     | 6 ++++++
 .../generic_mysql/template/mysql-init-function.sql.in       | 5 +++++
 2 files changed, 11 insertions(+)
 create mode 100644 slapos/recipe/generic_mysql/template/mysql-init-function.sql.in

diff --git a/slapos/recipe/generic_mysql/__init__.py b/slapos/recipe/generic_mysql/__init__.py
index 6c36637d99..c0ef36b466 100644
--- a/slapos/recipe/generic_mysql/__init__.py
+++ b/slapos/recipe/generic_mysql/__init__.py
@@ -67,6 +67,12 @@ class Recipe(GenericBaseRecipe):
 
     mysql_script_list = []
 
+    # user defined functions
+    mysql_script_list.append(self.substituteTemplate(
+      self.getTemplateFilename('mysql-init-function.sql.in'),
+      {
+      }
+    ))
     # real database
     mysql_script_list.append(self.substituteTemplate(
       self.getTemplateFilename('initmysql.sql.in'),
diff --git a/slapos/recipe/generic_mysql/template/mysql-init-function.sql.in b/slapos/recipe/generic_mysql/template/mysql-init-function.sql.in
new file mode 100644
index 0000000000..6105ac73fe
--- /dev/null
+++ b/slapos/recipe/generic_mysql/template/mysql-init-function.sql.in
@@ -0,0 +1,5 @@
+USE mysql;
+DROP FUNCTION IF EXISTS last_insert_grn_id;
+CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';
+DROP FUNCTION IF EXISTS sphinx_snippets;
+CREATE FUNCTION sphinx_snippets RETURNS STRING SONAME 'sphinx.so';
-- 
2.30.9