1let $SERVER_NAME=
2  `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '-', 2), '-', -1)`;
3let $SERVER_MAJOR_VERSION=
4  `SELECT SUBSTRING_INDEX(version(), '.', 1)`;
5let $SERVER_MINOR_VERSION=
6  `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '.', 2), '.', -1)`;
7let $PLUGIN_VERSION=
8  `SELECT SUBSTRING_INDEX(plugin_version, '.', 1)
9     FROM information_schema.plugins
10    WHERE plugin_name = 'SPIDER'`;
11if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
12{
13  let $HAS_REWRITE=
14    `SELECT IF (STRCMP('$SERVER_NAME', 'MariaDB') = 0,
15                IF ($SERVER_MAJOR_VERSION = 10,
16                    IF ($SERVER_MINOR_VERSION < 4,  0, 1),
17                    IF ($SERVER_MAJOR_VERSION < 10, 0, 1)),
18                0)`;
19  let $HAS_REWRITE= 0;
20  if ($HAS_REWRITE)
21  {
22    DROP FUNCTION spider_flush_rewrite_cache;
23    UNINSTALL PLUGIN spider_rewrite;
24    DROP TABLE IF EXISTS mysql.spider_rewrite_tables;
25    DROP TABLE IF EXISTS mysql.spider_rewrite_table_tables;
26    DROP TABLE IF EXISTS mysql.spider_rewrite_table_partitions;
27    DROP TABLE IF EXISTS mysql.spider_rewrite_table_subpartitions;
28    DROP TABLE IF EXISTS mysql.spider_rewritten_tables;
29  }
30}
31DROP FUNCTION spider_flush_table_mon_cache;
32DROP FUNCTION spider_copy_tables;
33DROP FUNCTION spider_ping_table;
34DROP FUNCTION spider_bg_direct_sql;
35DROP FUNCTION spider_direct_sql;
36UNINSTALL PLUGIN spider_wrapper_protocols;
37UNINSTALL PLUGIN spider_alloc_mem;
38UNINSTALL PLUGIN spider;
39DROP TABLE IF EXISTS mysql.spider_xa;
40DROP TABLE IF EXISTS mysql.spider_xa_member;
41DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
42DROP TABLE IF EXISTS mysql.spider_tables;
43DROP TABLE IF EXISTS mysql.spider_link_mon_servers;
44DROP TABLE IF EXISTS mysql.spider_link_failed_log;
45DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
46DROP TABLE IF EXISTS mysql.spider_table_sts;
47DROP TABLE IF EXISTS mysql.spider_table_crd;
48if ($VERSION_COMPILE_OS_WIN)
49{
50  if ($MASTER_1_MYPORT)
51  {
52    DROP SERVER s_1;
53  }
54  if ($CHILD2_1_MYPORT)
55  {
56    DROP SERVER s_2_1;
57  }
58  if ($CHILD2_2_MYPORT)
59  {
60    DROP SERVER s_2_2;
61  }
62  if ($CHILD2_3_MYPORT)
63  {
64    DROP SERVER s_2_3;
65  }
66  if ($CHILD3_1_MYPORT)
67  {
68    DROP SERVER s_3_1;
69  }
70  if ($CHILD3_2_MYPORT)
71  {
72    DROP SERVER s_3_2;
73  }
74  if ($CHILD2_3_MYPORT)
75  {
76    DROP SERVER s_3_3;
77  }
78}
79if (!$VERSION_COMPILE_OS_WIN)
80{
81  if ($MASTER_1_MYSOCK)
82  {
83    DROP SERVER s_1;
84  }
85  if ($CHILD2_1_MYSOCK)
86  {
87    DROP SERVER s_2_1;
88  }
89  if ($CHILD2_2_MYSOCK)
90  {
91    DROP SERVER s_2_2;
92  }
93  if ($CHILD2_3_MYSOCK)
94  {
95    DROP SERVER s_2_3;
96  }
97  if ($CHILD3_1_MYSOCK)
98  {
99    DROP SERVER s_3_1;
100  }
101  if ($CHILD3_2_MYSOCK)
102  {
103    DROP SERVER s_3_2;
104  }
105  if ($CHILD3_3_MYSOCK)
106  {
107    DROP SERVER s_3_3;
108  }
109}
110