1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
diff --git a/load.sql.sh b/load.sql.sh
index add962a..3ec6c12 100644
--- a/load.sql.sh
+++ b/load.sql.sh
@@ -10,11 +10,21 @@ if_enable() {
}
create_agg_function() {
- echo "CREATE AGGREGATE FUNCTION $1 RETURNS $2 SONAME 'udf_infusion.so';"
+ case $2 in
+ string) ret=0;;
+ real) ret=1;;
+ integer) ret=2;;
+ esac
+ echo "INSERT INTO mysql.func (name, ret, dl, type) VALUES ('$1', $ret, 'udf_infusion.so', 'aggregate');"
}
create_function() {
- echo "CREATE FUNCTION $1 RETURNS $2 SONAME 'udf_infusion.so';"
+ case $2 in
+ string) ret=0;;
+ real) ret=1;;
+ integer) ret=2;;
+ esac
+ echo "INSERT INTO mysql.func (name, ret, dl, type) VALUES ('$1', $ret, 'udf_infusion.so', 'function');"
}
sh unload.sql.sh
diff --git a/unload.sql.sh b/unload.sql.sh
index 25fd264..9d5cfd5 100644
--- a/unload.sql.sh
+++ b/unload.sql.sh
@@ -1,48 +1,3 @@
-[ $# -eq 0 ] && enable_all=1
-enable_functions="$@"
-
-if_enable() {
- [ "$enable_all" = 1 ] && return 0
- for func in $enable_functions; do
- [ "$func" = "$1" ] && return 0
- done
- return 1
-}
-
-drop_function() {
- echo "DROP FUNCTION IF EXISTS $1;"
-}
-
-if_enable "bound" && drop_function "bound"
-if_enable "bround" && drop_function "bround"
-if_enable "corr" && drop_function "corr"
-if_enable "covariance" && drop_function "covariance"
-if_enable "cut" && drop_function "cut"
-if_enable "fnv" && drop_function "fnv"
-if_enable "getint" && drop_function "getint"
-if_enable "group_first" && drop_function "group_first"
-if_enable "group_last" && drop_function "group_last"
-if_enable "invbit" && drop_function "invbit"
-if_enable "isbit" && drop_function "isbit"
-if_enable "kurtosis" && drop_function "kurtosis"
-if_enable "lessavg" && drop_function "lessavg"
-if_enable "lesspartpct" && drop_function "lesspartpct"
-if_enable "lesspart" && drop_function "lesspart"
-if_enable "median" && drop_function "median"
-if_enable "stats_mode" && drop_function "stats_mode"
-if_enable "ngram" && drop_function "ngram"
-if_enable "noverk" && drop_function "noverk"
-if_enable "percentile_cont" && drop_function "percentile_cont"
-if_enable "percentile_disc" && drop_function "percentile_disc"
-if_enable "rotbit" && drop_function "rotbit"
-if_enable "rotint" && drop_function "rotint"
-if_enable "row_number" && drop_function "row_number"
-if_enable "rsumd" && drop_function "rsumd"
-if_enable "rsumi" && drop_function "rsumi"
-if_enable "setbit" && drop_function "setbit"
-if_enable "setint" && drop_function "setint"
-if_enable "skewness" && drop_function "skewness"
-if_enable "slug" && drop_function "slug"
-if_enable "xround" && drop_function "xround"
+echo "DELETE FROM mysql.func WHERE dl = 'udf_infusion.so';"
true
|