PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/MySqlBackup.NET/MySqlBackup/MySqlObjects/MySqlFunction.cs

http://mysqlbackupnet.codeplex.com
C# | 36 lines | 28 code | 8 blank | 0 comment | 0 complexity | 4e032a456368bb396f3bf0fd8a6cb5a1 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace MySql.Data.MySqlClient
  5. {
  6. public class MySqlFunction
  7. {
  8. string _name;
  9. string _createFunctionSQL = "";
  10. string _createFunctionSqlWithoutDefiner = "";
  11. public string Name { get { return _name; } }
  12. public string CreateFunctionSQL { get { return _createFunctionSQL; } }
  13. public string CreateFunctionSQLWithoutDefiner { get { return _createFunctionSqlWithoutDefiner; } }
  14. public MySqlFunction(MySqlCommand cmd, string functionName, string definer)
  15. {
  16. _name = functionName;
  17. string sql = string.Format("SHOW CREATE FUNCTION `{0}`;", functionName);
  18. _createFunctionSQL = QueryExpress.ExecuteScalarStr(cmd, sql, 2);
  19. _createFunctionSQL = _createFunctionSQL.Replace("\r\n", "^~~~~~~~~~~~~~~^");
  20. _createFunctionSQL = _createFunctionSQL.Replace("\n", "^~~~~~~~~~~~~~~^");
  21. _createFunctionSQL = _createFunctionSQL.Replace("\r", "^~~~~~~~~~~~~~~^");
  22. _createFunctionSQL = _createFunctionSQL.Replace("^~~~~~~~~~~~~~~^", "\r\n");
  23. string[] sa = definer.Split('@');
  24. definer = string.Format(" DEFINER=`{0}`@`{1}`", sa[0], sa[1]);
  25. _createFunctionSqlWithoutDefiner = _createFunctionSQL.Replace(definer, string.Empty);
  26. }
  27. }
  28. }