From ecc6824a8cf1a600f27bf2932469bc4cc2137da8 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 24 Apr 2017 11:36:22 -0400 Subject: [PATCH] INT-4262-4.3: Fix SQL scripts for `IF EXISTS` JIRA: https://jira.spring.io/browse/INT-4262 Since `IF EXISTS` doesn't exist for `DROP INDEX` command and even more this command isn't necessary when we fully drop the table, we don't need it as a separate command. `DROP TABLE IF EXISTS` is fully sufficient for schema recreation requirements * Add `NODROPINDEX` variable for VPP engine to let it do not add `DROP INDEX` command * Fix `channel/schema-mysql.sql` for proper INDEX names --- .../springframework/integration/jdbc/schema-drop-db2.sql | 4 ++-- .../springframework/integration/jdbc/schema-drop-derby.sql | 4 ++-- .../org/springframework/integration/jdbc/schema-drop-h2.sql | 4 ++-- .../springframework/integration/jdbc/schema-drop-hsqldb.sql | 4 ++-- .../integration/jdbc/schema-drop-mysql-5_6_4.sql | 6 +++--- .../springframework/integration/jdbc/schema-drop-mysql.sql | 6 +++--- .../integration/jdbc/schema-drop-oracle10g.sql | 4 ++-- .../integration/jdbc/schema-drop-postgresql.sql | 4 ++-- .../integration/jdbc/schema-drop-sqlserver.sql | 4 ++-- .../springframework/integration/jdbc/schema-drop-sybase.sql | 4 ++-- .../integration/jdbc/store/channel/schema-mysql.sql | 4 ++-- spring-integration-jdbc/src/main/sql/destroy.sql.vpp | 3 ++- spring-integration-jdbc/src/main/sql/mysql-5_6_4.properties | 1 + spring-integration-jdbc/src/main/sql/mysql.properties | 1 + .../jdbc/DelayerHandlerRescheduleIntegrationTests.java | 1 + 15 files changed, 29 insertions(+), 25 deletions(-) diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-db2.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-db2.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-db2.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-db2.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-derby.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-derby.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-derby.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-derby.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-h2.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-h2.sql index c51aaafa05..5d4a93c998 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-h2.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-h2.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE IF EXISTS; DROP TABLE INT_MESSAGE_GROUP IF EXISTS; DROP TABLE INT_GROUP_TO_MESSAGE IF EXISTS; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-hsqldb.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-hsqldb.sql index c51aaafa05..5d4a93c998 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-hsqldb.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-hsqldb.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE IF EXISTS; DROP TABLE INT_MESSAGE_GROUP IF EXISTS; DROP TABLE INT_GROUP_TO_MESSAGE IF EXISTS; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql-5_6_4.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql-5_6_4.sql index badab9b282..ba8573e2ec 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql-5_6_4.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql-5_6_4.sql @@ -1,7 +1,7 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE IF EXISTS INT_MESSAGE ; DROP TABLE IF EXISTS INT_MESSAGE_GROUP ; DROP TABLE IF EXISTS INT_GROUP_TO_MESSAGE ; DROP TABLE IF EXISTS INT_LOCK ; -DROP INDEX IF EXISTS INT_MESSAGE_IX1 ; + diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql.sql index badab9b282..ba8573e2ec 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-mysql.sql @@ -1,7 +1,7 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE IF EXISTS INT_MESSAGE ; DROP TABLE IF EXISTS INT_MESSAGE_GROUP ; DROP TABLE IF EXISTS INT_GROUP_TO_MESSAGE ; DROP TABLE IF EXISTS INT_LOCK ; -DROP INDEX IF EXISTS INT_MESSAGE_IX1 ; + diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-oracle10g.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-oracle10g.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-oracle10g.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-oracle10g.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-postgresql.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-postgresql.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-postgresql.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-postgresql.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sqlserver.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sqlserver.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sqlserver.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sqlserver.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sybase.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sybase.sql index cfb68b5bc4..188f9cd242 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sybase.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-drop-sybase.sql @@ -1,5 +1,5 @@ --- Autogenerated: do not edit this file - +-- Autogenerated: do not edit this file + DROP TABLE INT_MESSAGE ; DROP TABLE INT_MESSAGE_GROUP ; DROP TABLE INT_GROUP_TO_MESSAGE ; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/store/channel/schema-mysql.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/store/channel/schema-mysql.sql index 1989e4872c..c5ada2e54f 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/store/channel/schema-mysql.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/store/channel/schema-mysql.sql @@ -10,7 +10,7 @@ CREATE TABLE INT_CHANNEL_MESSAGE ( ) ENGINE=InnoDB; ALTER TABLE INT_CHANNEL_MESSAGE -ADD INDEX MSG_INDEX_DATE_IDX USING BTREE (CREATED_DATE, MESSAGE_SEQUENCE); +ADD INDEX INT_CHANNEL_MSG_DATE_IDX USING BTREE (CREATED_DATE, MESSAGE_SEQUENCE); ALTER TABLE INT_CHANNEL_MESSAGE -ADD INDEX MSG_INDEX_PRIORITY_IDX USING BTREE (MESSAGE_PRIORITY DESC, CREATED_DATE, MESSAGE_SEQUENCE); +ADD INDEX INT_CHANNEL_MSG_PRIORITY_IDX USING BTREE (MESSAGE_PRIORITY DESC, CREATED_DATE, MESSAGE_SEQUENCE); diff --git a/spring-integration-jdbc/src/main/sql/destroy.sql.vpp b/spring-integration-jdbc/src/main/sql/destroy.sql.vpp index ab382a93a9..95257ce5ff 100644 --- a/spring-integration-jdbc/src/main/sql/destroy.sql.vpp +++ b/spring-integration-jdbc/src/main/sql/destroy.sql.vpp @@ -2,4 +2,5 @@ DROP TABLE $!{IFEXISTSBEFORE} INT_MESSAGE $!{IFEXISTS}; DROP TABLE $!{IFEXISTSBEFORE} INT_MESSAGE_GROUP $!{IFEXISTS}; DROP TABLE $!{IFEXISTSBEFORE} INT_GROUP_TO_MESSAGE $!{IFEXISTS}; DROP TABLE $!{IFEXISTSBEFORE} INT_LOCK $!{IFEXISTS}; -DROP INDEX $!{IFEXISTSBEFORE} INT_MESSAGE_IX1 $!{IFEXISTS}; +#if(!${NODROPINDEX})DROP INDEX $!{IFEXISTSBEFORE} INT_MESSAGE_IX1 $!{IFEXISTS};#end + diff --git a/spring-integration-jdbc/src/main/sql/mysql-5_6_4.properties b/spring-integration-jdbc/src/main/sql/mysql-5_6_4.properties index 1a5c2c4046..fb79a0bd34 100644 --- a/spring-integration-jdbc/src/main/sql/mysql-5_6_4.properties +++ b/spring-integration-jdbc/src/main/sql/mysql-5_6_4.properties @@ -12,3 +12,4 @@ TIMESTAMP = DATETIME(6) VARCHAR = VARCHAR # for generating drop statements... SEQUENCE = TABLE +NODROPINDEX = true \ No newline at end of file diff --git a/spring-integration-jdbc/src/main/sql/mysql.properties b/spring-integration-jdbc/src/main/sql/mysql.properties index 470ca6bc1d..3537e7bb07 100644 --- a/spring-integration-jdbc/src/main/sql/mysql.properties +++ b/spring-integration-jdbc/src/main/sql/mysql.properties @@ -12,3 +12,4 @@ TIMESTAMP = DATETIME VARCHAR = VARCHAR # for generating drop statements... SEQUENCE = TABLE +NODROPINDEX = true \ No newline at end of file diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java index ae6c41771b..eae6887170 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java @@ -72,6 +72,7 @@ public class DelayerHandlerRescheduleIntegrationTests { public static void init() { dataSource = new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) + .addScript("classpath:/org/springframework/integration/jdbc/schema-drop-h2.sql") .addScript("classpath:/org/springframework/integration/jdbc/schema-h2.sql") .build(); }