1let $VERSION_COMPILE_OS_WIN= 2 `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`; 3if ($VERSION_COMPILE_OS_WIN) 4{ 5 INSTALL PLUGIN spider SONAME 'ha_spider.dll'; 6 CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.dll'; 7 CREATE AGGREGATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.dll'; 8 CREATE FUNCTION spider_ping_table RETURNS INT SONAME 'ha_spider.dll'; 9 CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.dll'; 10 CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.dll'; 11 eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( 12 HOST 'localhost', 13 DATABASE 'auto_test_remote', 14 USER 'root', 15 PASSWORD '', 16 PORT $CHILD2_1_MYPORT 17 ); 18 eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER mysql OPTIONS ( 19 HOST 'localhost', 20 DATABASE 'auto_test_remote2', 21 USER 'root', 22 PASSWORD '', 23 PORT $CHILD2_2_MYPORT 24 ); 25 eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER mysql OPTIONS ( 26 HOST 'localhost', 27 DATABASE 'auto_test_remote3', 28 USER 'root', 29 PASSWORD '', 30 PORT $CHILD2_3_MYPORT 31 ); 32 eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( 33 HOST 'localhost', 34 DATABASE 'auto_test_local', 35 USER 'root', 36 PASSWORD '', 37 PORT $CHILD3_1_MYPORT 38 ); 39 eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( 40 HOST 'localhost', 41 DATABASE 'auto_test_local', 42 USER 'root', 43 PASSWORD '', 44 PORT $CHILD3_2_MYPORT 45 ); 46 eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( 47 HOST 'localhost', 48 DATABASE 'auto_test_local', 49 USER 'root', 50 PASSWORD '', 51 PORT $CHILD2_3_MYPORT 52 ); 53} 54if (!$VERSION_COMPILE_OS_WIN) 55{ 56 INSTALL PLUGIN spider SONAME 'ha_spider.so'; 57 CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; 58 CREATE AGGREGATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; 59 CREATE FUNCTION spider_ping_table RETURNS INT SONAME 'ha_spider.so'; 60 CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; 61 CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; 62 eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( 63 HOST 'localhost', 64 DATABASE 'auto_test_remote', 65 USER 'root', 66 PASSWORD '', 67 SOCKET '$CHILD2_1_MYSOCK' 68 ); 69 eval CREATE SERVER s_2_2 FOREIGN DATA WRAPPER mysql OPTIONS ( 70 HOST 'localhost', 71 DATABASE 'auto_test_remote2', 72 USER 'root', 73 PASSWORD '', 74 SOCKET '$CHILD2_2_MYSOCK' 75 ); 76 eval CREATE SERVER s_2_3 FOREIGN DATA WRAPPER mysql OPTIONS ( 77 HOST 'localhost', 78 DATABASE 'auto_test_remote3', 79 USER 'root', 80 PASSWORD '', 81 SOCKET '$CHILD2_3_MYSOCK' 82 ); 83 eval CREATE SERVER s_3_1 FOREIGN DATA WRAPPER mysql OPTIONS ( 84 HOST 'localhost', 85 DATABASE 'auto_test_local', 86 USER 'root', 87 PASSWORD '', 88 SOCKET '$CHILD3_1_MYSOCK' 89 ); 90 eval CREATE SERVER s_3_2 FOREIGN DATA WRAPPER mysql OPTIONS ( 91 HOST 'localhost', 92 DATABASE 'auto_test_local', 93 USER 'root', 94 PASSWORD '', 95 SOCKET '$CHILD3_2_MYSOCK' 96 ); 97 eval CREATE SERVER s_3_3 FOREIGN DATA WRAPPER mysql OPTIONS ( 98 HOST 'localhost', 99 DATABASE 'auto_test_local', 100 USER 'root', 101 PASSWORD '', 102 SOCKET '$CHILD3_3_MYSOCK' 103 ); 104} 105 106let $SERVER_NAME= 107 `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '-', 2), '-', -1)`; 108let $SERVER_MAJOR_VERSION= 109 `SELECT SUBSTRING_INDEX(version(), '.', 1)`; 110let $SERVER_MINOR_VERSION= 111 `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '.', 2), '.', -1)`; 112let $PLUGIN_VERSION= 113 `SELECT SUBSTRING_INDEX(plugin_version, '.', 1) 114 FROM information_schema.plugins 115 WHERE plugin_name = 'SPIDER'`; 116 117if (`SELECT IF($PLUGIN_VERSION = 1, 1, 0)`) 118{ 119 DROP TABLE IF EXISTS mysql.spider_xa; 120 CREATE TABLE mysql.spider_xa( 121 format_id int not null default 0, 122 gtrid_length int not null default 0, 123 bqual_length int not null default 0, 124 data char(128) charset binary not null default '', 125 status char(8) not null default '', 126 PRIMARY KEY (data, format_id, gtrid_length), 127 KEY idx1 (status) 128 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 129 DROP TABLE IF EXISTS mysql.spider_xa_member; 130 CREATE TABLE mysql.spider_xa_member( 131 format_id int not null default 0, 132 gtrid_length int not null default 0, 133 bqual_length int not null default 0, 134 data char(128) charset binary not null default '', 135 scheme char(64) not null default '', 136 host char(64) not null default '', 137 port char(5) not null default '', 138 socket char(64) not null default '', 139 username char(64) not null default '', 140 password char(64) not null default '', 141 PRIMARY KEY (data, format_id, gtrid_length, host, port, socket) 142 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 143 DROP TABLE IF EXISTS mysql.spider_tables; 144 CREATE TABLE mysql.spider_tables( 145 db_name char(64) not null default '', 146 table_name char(64) not null default '', 147 priority bigint not null default 0, 148 server char(64) default null, 149 scheme char(64) default null, 150 host char(64) default null, 151 port char(5) default null, 152 socket char(64) default null, 153 username char(64) default null, 154 password char(64) default null, 155 tgt_db_name char(64) default null, 156 tgt_table_name char(64) default null, 157 PRIMARY KEY (db_name, table_name), 158 KEY idx1 (priority) 159 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 160} 161if (`SELECT IF($PLUGIN_VERSION = 2, 1, 0)`) 162{ 163 DROP TABLE IF EXISTS mysql.spider_xa; 164 CREATE TABLE mysql.spider_xa( 165 format_id int not null default 0, 166 gtrid_length int not null default 0, 167 bqual_length int not null default 0, 168 data char(128) charset binary not null default '', 169 status char(8) not null default '', 170 PRIMARY KEY (data, format_id, gtrid_length), 171 KEY idx1 (status) 172 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 173 DROP TABLE IF EXISTS mysql.spider_xa_member; 174 CREATE TABLE mysql.spider_xa_member( 175 format_id int not null default 0, 176 gtrid_length int not null default 0, 177 bqual_length int not null default 0, 178 data char(128) charset binary not null default '', 179 scheme char(64) not null default '', 180 host char(64) not null default '', 181 port char(5) not null default '', 182 socket char(64) not null default '', 183 username char(64) not null default '', 184 password char(64) not null default '', 185 ssl_ca char(64) default null, 186 ssl_capath char(64) default null, 187 ssl_cert char(64) default null, 188 ssl_cipher char(64) default null, 189 ssl_key char(64) default null, 190 ssl_verify_server_cert tinyint not null default 0, 191 default_file char(64) default null, 192 default_group char(64) default null, 193 PRIMARY KEY (data, format_id, gtrid_length, host, port, socket) 194 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 195 DROP TABLE IF EXISTS mysql.spider_tables; 196 CREATE TABLE mysql.spider_tables( 197 db_name char(64) not null default '', 198 table_name char(64) not null default '', 199 link_id int not null default 0, 200 priority bigint not null default 0, 201 server char(64) default null, 202 scheme char(64) default null, 203 host char(64) default null, 204 port char(5) default null, 205 socket char(64) default null, 206 username char(64) default null, 207 password char(64) default null, 208 ssl_ca char(64) default null, 209 ssl_capath char(64) default null, 210 ssl_cert char(64) default null, 211 ssl_cipher char(64) default null, 212 ssl_key char(64) default null, 213 ssl_verify_server_cert tinyint not null default 0, 214 default_file char(64) default null, 215 default_group char(64) default null, 216 tgt_db_name char(64) default null, 217 tgt_table_name char(64) default null, 218 link_status tinyint not null default 1, 219 PRIMARY KEY (db_name, table_name, link_id), 220 KEY idx1 (priority) 221 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 222 DROP TABLE IF EXISTS mysql.spider_link_mon_servers; 223 CREATE TABLE mysql.spider_link_mon_servers( 224 db_name char(64) not null default '', 225 table_name char(64) not null default '', 226 link_id char(5) not null default '', 227 sid int not null default 0, 228 server char(64) default null, 229 scheme char(64) default null, 230 host char(64) default null, 231 port char(5) default null, 232 socket char(64) default null, 233 username char(64) default null, 234 password char(64) default null, 235 ssl_ca char(64) default null, 236 ssl_capath char(64) default null, 237 ssl_cert char(64) default null, 238 ssl_cipher char(64) default null, 239 ssl_key char(64) default null, 240 ssl_verify_server_cert tinyint not null default 0, 241 default_file char(64) default null, 242 default_group char(64) default null, 243 PRIMARY KEY (db_name, table_name, link_id, sid) 244 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 245 DROP TABLE IF EXISTS mysql.spider_link_failed_log; 246 CREATE TABLE mysql.spider_link_failed_log( 247 db_name char(64) not null default '', 248 table_name char(64) not null default '', 249 link_id int not null default 0, 250 failed_time timestamp not null default current_timestamp 251 ) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 252} 253if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) 254{ 255 let $ENGINE_NAME= 256 `SELECT IF (STRCMP('$SERVER_NAME', 'MariaDB') = 0, 257 IF ($SERVER_MAJOR_VERSION = 10, 258 IF ($SERVER_MINOR_VERSION < 4, 'MyISAM', 259 'Aria transactional=1'), 260 IF ($SERVER_MAJOR_VERSION < 10, 'MyISAM', 261 'Aria transactional=1')), 262 'MyISAM')`; 263 DROP TABLE IF EXISTS mysql.spider_xa; 264 eval 265 CREATE TABLE mysql.spider_xa( 266 format_id int not null default 0, 267 gtrid_length int not null default 0, 268 bqual_length int not null default 0, 269 data binary(128) not null default '', 270 status char(8) not null default '', 271 PRIMARY KEY (data, format_id, gtrid_length), 272 KEY idx1 (status) 273 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 274 DROP TABLE IF EXISTS mysql.spider_xa_member; 275 eval 276 CREATE TABLE mysql.spider_xa_member( 277 format_id int not null default 0, 278 gtrid_length int not null default 0, 279 bqual_length int not null default 0, 280 data binary(128) not null default '', 281 scheme char(64) not null default '', 282 host char(64) not null default '', 283 port char(5) not null default '', 284 socket text not null default '', 285 username char(64) not null default '', 286 password char(64) not null default '', 287 ssl_ca text default null, 288 ssl_capath text default null, 289 ssl_cert text default null, 290 ssl_cipher char(64) default null, 291 ssl_key text default null, 292 ssl_verify_server_cert tinyint not null default 0, 293 default_file text default null, 294 default_group char(64) default null, 295 KEY idx1 (data, format_id, gtrid_length, host) 296 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 297 DROP TABLE IF EXISTS mysql.spider_xa_failed_log; 298 eval 299 CREATE TABLE mysql.spider_xa_failed_log( 300 format_id int not null default 0, 301 gtrid_length int not null default 0, 302 bqual_length int not null default 0, 303 data binary(128) not null default '', 304 scheme char(64) not null default '', 305 host char(64) not null default '', 306 port char(5) not null default '', 307 socket text not null, 308 username char(64) not null default '', 309 password char(64) not null default '', 310 ssl_ca text, 311 ssl_capath text, 312 ssl_cert text, 313 ssl_cipher char(64) default null, 314 ssl_key text, 315 ssl_verify_server_cert tinyint not null default 0, 316 default_file text, 317 default_group char(64) default null, 318 thread_id int default null, 319 status char(8) not null default '', 320 failed_time timestamp not null default current_timestamp, 321 key idx1 (data, format_id, gtrid_length, host) 322 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 323 DROP TABLE IF EXISTS mysql.spider_tables; 324 eval 325 CREATE TABLE mysql.spider_tables( 326 db_name char(64) not null default '', 327 table_name char(199) not null default '', 328 link_id int not null default 0, 329 priority bigint not null default 0, 330 server char(64) default null, 331 scheme char(64) default null, 332 host char(64) default null, 333 port char(5) default null, 334 socket text default null, 335 username char(64) default null, 336 password char(64) default null, 337 ssl_ca text default null, 338 ssl_capath text default null, 339 ssl_cert text default null, 340 ssl_cipher char(64) default null, 341 ssl_key text default null, 342 ssl_verify_server_cert tinyint not null default 0, 343 monitoring_binlog_pos_at_failing tinyint not null default 0, 344 default_file text default null, 345 default_group char(64) default null, 346 tgt_db_name char(64) default null, 347 tgt_table_name char(64) default null, 348 link_status tinyint not null default 1, 349 block_status tinyint not null default 0, 350 static_link_id char(64) default null, 351 PRIMARY KEY (db_name, table_name, link_id), 352 KEY idx1 (priority), 353 UNIQUE KEY uidx1 (db_name, table_name, static_link_id) 354 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 355 DROP TABLE IF EXISTS mysql.spider_link_mon_servers; 356 eval 357 CREATE TABLE mysql.spider_link_mon_servers( 358 db_name char(64) not null default '', 359 table_name char(199) not null default '', 360 link_id char(64) not null default '', 361 sid int unsigned not null default 0, 362 server char(64) default null, 363 scheme char(64) default null, 364 host char(64) default null, 365 port char(5) default null, 366 socket text default null, 367 username char(64) default null, 368 password char(64) default null, 369 ssl_ca text default null, 370 ssl_capath text default null, 371 ssl_cert text default null, 372 ssl_cipher char(64) default null, 373 ssl_key text default null, 374 ssl_verify_server_cert tinyint not null default 0, 375 default_file text default null, 376 default_group char(64) default null, 377 PRIMARY KEY (db_name, table_name, link_id, sid) 378 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 379 DROP TABLE IF EXISTS mysql.spider_link_failed_log; 380 eval 381 CREATE TABLE mysql.spider_link_failed_log( 382 db_name char(64) not null default '', 383 table_name char(199) not null default '', 384 link_id char(64) not null default '', 385 failed_time timestamp not null default current_timestamp 386 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 387 DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery; 388 eval 389 CREATE TABLE mysql.spider_table_position_for_recovery( 390 db_name char(64) not null default '', 391 table_name char(199) not null default '', 392 failed_link_id int not null default 0, 393 source_link_id int not null default 0, 394 file text, 395 position text, 396 gtid text, 397 primary key (db_name, table_name, failed_link_id, source_link_id) 398 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 399 DROP TABLE IF EXISTS mysql.spider_table_sts; 400 eval 401 CREATE TABLE mysql.spider_table_sts( 402 db_name char(64) not null default '', 403 table_name char(199) not null default '', 404 data_file_length bigint unsigned not null default 0, 405 max_data_file_length bigint unsigned not null default 0, 406 index_file_length bigint unsigned not null default 0, 407 records bigint unsigned not null default 0, 408 mean_rec_length bigint unsigned not null default 0, 409 check_time datetime not null default '0000-00-00 00:00:00', 410 create_time datetime not null default '0000-00-00 00:00:00', 411 update_time datetime not null default '0000-00-00 00:00:00', 412 primary key (db_name, table_name) 413 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 414 DROP TABLE IF EXISTS mysql.spider_table_crd; 415 eval 416 CREATE TABLE mysql.spider_table_crd( 417 db_name char(64) not null default '', 418 table_name char(199) not null default '', 419 key_seq int unsigned not null default 0, 420 cardinality bigint not null default 0, 421 primary key (db_name, table_name, key_seq) 422 ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 423} 424 425SET spider_internal_sql_log_off= 0; 426