diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2018-05-13 13:52:52 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-14 20:20:48 +0200 |
commit | 78cddc366251909c34cddbd777630260fc38d2b2 (patch) | |
tree | f9eb454df7a97f73b32b90125e46ad0e4430ed8d /server/sonar-db-core | |
parent | 32cb4c1a0efd63772e2f7da940704aef6f7d97e9 (diff) | |
download | sonarqube-78cddc366251909c34cddbd777630260fc38d2b2.tar.gz sonarqube-78cddc366251909c34cddbd777630260fc38d2b2.zip |
Speed-up DatabaseUtils.tableExists() on Oracle
Signed-off-by: Simon Brandhof <simon.brandhof@sonarsource.com>
Diffstat (limited to 'server/sonar-db-core')
-rw-r--r-- | server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java index 9b850e40f65..0e9c5d1169e 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java @@ -38,6 +38,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.function.Consumer; import java.util.function.IntFunction; @@ -309,8 +310,15 @@ public class DatabaseUtils { * @throws SQLException */ public static boolean tableExists(String table, Connection connection) { + return doTableExists(table, connection) || + doTableExists(table.toLowerCase(Locale.ENGLISH), connection) || + doTableExists(table.toUpperCase(Locale.ENGLISH), connection); + + } + + private static boolean doTableExists(String table, Connection connection) { // table type is used to speed-up Oracle by removing introspection of system tables and aliases. - try (ResultSet rs = connection.getMetaData().getTables(null, null, null, TABLE_TYPE)) { + try (ResultSet rs = connection.getMetaData().getTables(null, null, table, TABLE_TYPE)) { while (rs.next()) { String name = rs.getString("TABLE_NAME"); if (table.equalsIgnoreCase(name)) { |