-- MySQL dump 10.13 -- -- Host: localhost Database: test -- ------------------------------------------------------ -- Server version 6.0.5-alpha-debug-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `inter1` -- DROP TABLE IF EXISTS `inter1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `inter1` ( `t1_autoinc` int(11) NOT NULL AUTO_INCREMENT, `t1_uuid` char(36) DEFAULT NULL, `t2_uuid` char(36) DEFAULT NULL, `t1_blob` mediumtext, PRIMARY KEY (`t1_autoinc`), KEY `t2_uuid` (`t2_uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `inter1` -- LOCK TABLES `inter1` WRITE; /*!40000 ALTER TABLE `inter1` DISABLE KEYS */; /*!40000 ALTER TABLE `inter1` ENABLE KEYS */; UNLOCK TABLES; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER inter1_before_insert BEFORE INSERT ON inter1 FOR EACH ROW BEGIN SET NEW.t1_uuid = UCASE(NEW.t1_uuid); INSERT INTO view1_log (uuid, verb) VALUES (NEW.t1_uuid,'insert'); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER inter1_after_insert AFTER INSERT ON inter1 FOR EACH ROW BEGIN DELETE FROM view1_log WHERE uuid = NEW.t1_uuid AND verb = 'insert'; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER inter1_before_update BEFORE UPDATE ON inter1 FOR EACH ROW BEGIN SET NEW.t1_uuid = UCASE(NEW.t1_uuid); INSERT INTO view1_log (uuid, verb) VALUES (NEW.t1_uuid,'update'); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER inter1_after_update AFTER UPDATE ON inter1 FOR EACH ROW BEGIN DELETE FROM view1_log WHERE uuid = NEW.t1_uuid AND verb = 'update'; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Table structure for table `inter1_log` -- DROP TABLE IF EXISTS `inter1_log`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `inter1_log` ( `uuid` char(36) NOT NULL, `verb` char(20) DEFAULT NULL, UNIQUE KEY `uuid` (`uuid`,`verb`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `inter1_log` -- LOCK TABLES `inter1_log` WRITE; /*!40000 ALTER TABLE `inter1_log` DISABLE KEYS */; /*!40000 ALTER TABLE `inter1_log` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `inter2` -- DROP TABLE IF EXISTS `inter2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `inter2` ( `t2_autoinc` int(11) NOT NULL AUTO_INCREMENT, `t1_uuid` char(36) DEFAULT NULL, `t2_uuid` char(36) DEFAULT NULL, `t2_date` datetime DEFAULT NULL, PRIMARY KEY (`t2_autoinc`), KEY `t1_uuid` (`t1_uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `inter2` -- LOCK TABLES `inter2` WRITE; /*!40000 ALTER TABLE `inter2` DISABLE KEYS */; /*!40000 ALTER TABLE `inter2` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `inter2_log` -- DROP TABLE IF EXISTS `inter2_log`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `inter2_log` ( `uuid` char(36) NOT NULL, `verb` char(20) DEFAULT NULL, UNIQUE KEY `uuid` (`uuid`,`verb`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `inter2_log` -- LOCK TABLES `inter2_log` WRITE; /*!40000 ALTER TABLE `inter2_log` DISABLE KEYS */; /*!40000 ALTER TABLE `inter2_log` ENABLE KEYS */; UNLOCK TABLES; -- -- Temporary table structure for view `union_view1` -- DROP TABLE IF EXISTS `union_view1`; /*!50001 DROP VIEW IF EXISTS `union_view1`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `union_view1` ( `t` int(11) ) */; SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `union_view2` -- DROP TABLE IF EXISTS `union_view2`; /*!50001 DROP VIEW IF EXISTS `union_view2`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `union_view2` ( `t` int(11) ) */; SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `view1` -- DROP TABLE IF EXISTS `view1`; /*!50001 DROP VIEW IF EXISTS `view1`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `view1` ( `t1_autoinc` int(11), `t1_uuid` char(36), `t2_uuid` char(36), `t1_blob` mediumtext ) */; SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `view1_log` -- DROP TABLE IF EXISTS `view1_log`; /*!50001 DROP VIEW IF EXISTS `view1_log`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `view1_log` ( `uuid` char(36), `verb` char(20) ) */; SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `view2` -- DROP TABLE IF EXISTS `view2`; /*!50001 DROP VIEW IF EXISTS `view2`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `view2` ( `t2_autoinc` int(11), `t1_uuid` char(36), `t2_uuid` char(36), `t2_date` datetime ) */; SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `view2_log` -- DROP TABLE IF EXISTS `view2_log`; /*!50001 DROP VIEW IF EXISTS `view2_log`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `view2_log` ( `uuid` char(36), `verb` char(20) ) */; SET character_set_client = @saved_cs_client; -- -- Dumping routines for database 'test' -- /*!50003 DROP PROCEDURE IF EXISTS `blob_insert` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `blob_insert`(IN blob3 mediumblob) BEGIN INSERT INTO blob_t1 (blob1) VALUES (blob3); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `delete_multi` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `delete_multi`(IN uuid CHAR(36)) BEGIN DELETE view1, view2 FROM view1 INNER JOIN view2 ON view1.t1_uuid = view2.t1_uuid WHERE view1.t1_uuid = @uuid; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `UUID_CLEANUP` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `UUID_CLEANUP`(IN uuid CHAR(36)) BEGIN SET @uuid = uuid; SET @uuid_plus = REPLACE(uuid, '-','+'); SET @uuid_space = REPLACE(uuid, '-', ' '); PREPARE uuid_delete1 FROM "DELETE FROM view1 WHERE t1_uuid IN (?, ?, ?)"; PREPARE uuid_delete2 FROM "DELETE FROM view2 WHERE t2_uuid IN (?, ?, ?)"; EXECUTE uuid_delete1 USING @uuid, @uuid_plus, @uuid_space; EXECUTE uuid_delete2 USING @uuid, @uuid_plus, @uuid_space; DEALLOCATE PREPARE uuid_delete1; DEALLOCATE PREPARE uuid_delete2; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `UUID_SELECT` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `UUID_SELECT`(IN uuid CHAR(36)) BEGIN SET @uuid = uuid; SET @uuid_plus = REPLACE(uuid, '-','+'); SET @uuid_space = REPLACE(uuid, '-', ' '); # # TODO - encapsulate this UNION into a VIEW # PREPARE uuid_select FROM " (SELECT *, 'eng1' FROM view1 WHERE t1_uuid IN (?, ?, ?)) UNION (SELECT *, 'eng2' FROM view2 WHERE t2_uuid IN (?, ?, ?)) "; EXECUTE uuid_select USING @uuid, @uuid_plus, @uuid_space, @uuid, @uuid_plus, @uuid_space; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Final view structure for view `union_view1` -- /*!50001 DROP TABLE `union_view1`*/; /*!50001 DROP VIEW IF EXISTS `union_view1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=TEMPTABLE */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `union_view1` AS (select `view1`.`t1_autoinc` AS `t` from `view1`) union (select `view2`.`t2_autoinc` AS `t` from `view2`) order by `t` desc limit 1 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `union_view2` -- /*!50001 DROP TABLE `union_view2`*/; /*!50001 DROP VIEW IF EXISTS `union_view2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `union_view2` AS (select `view2`.`t2_autoinc` AS `t` from `view2`) union (select `view1`.`t1_autoinc` AS `t` from `view1`) order by `t` limit 1 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `view1` -- /*!50001 DROP TABLE `view1`*/; /*!50001 DROP VIEW IF EXISTS `view1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `view1` AS select `inter1`.`t1_autoinc` AS `t1_autoinc`,`inter1`.`t1_uuid` AS `t1_uuid`,`inter1`.`t2_uuid` AS `t2_uuid`,`inter1`.`t1_blob` AS `t1_blob` from `inter1` where (isnull(`inter1`.`t1_uuid`) or (`inter1`.`t1_uuid` like _latin1'%-%')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `view1_log` -- /*!50001 DROP TABLE `view1_log`*/; /*!50001 DROP VIEW IF EXISTS `view1_log`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `view1_log` AS select `inter1_log`.`uuid` AS `uuid`,`inter1_log`.`verb` AS `verb` from `inter1_log` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `view2` -- /*!50001 DROP TABLE `view2`*/; /*!50001 DROP VIEW IF EXISTS `view2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `view2` AS select `inter2`.`t2_autoinc` AS `t2_autoinc`,`inter2`.`t1_uuid` AS `t1_uuid`,`inter2`.`t2_uuid` AS `t2_uuid`,`inter2`.`t2_date` AS `t2_date` from `inter2` where (isnull(`inter2`.`t1_uuid`) or (length(`inter2`.`t1_uuid`) = 36)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `view2_log` -- /*!50001 DROP TABLE `view2_log`*/; /*!50001 DROP VIEW IF EXISTS `view2_log`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = latin1 */; /*!50001 SET character_set_results = latin1 */; /*!50001 SET collation_connection = latin1_swedish_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `view2_log` AS select `inter2_log`.`uuid` AS `uuid`,`inter2_log`.`verb` AS `verb` from `inter2_log` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2008-02-14 23:25:51