Issue 24682: Skip validation of onCreateDefault sql's for the most common cases
authorStefan Hühner <stefan.huehner@openbravo.com>
Tue, 10 Sep 2013 11:33:22 +0200
changeset 466 c21df20ed7b1
parent 465 21dd58e127a8
child 467 3f0764688bff
Issue 24682: Skip validation of onCreateDefault sql's for the most common cases
which are known to be fine statically without executing them.
src/org/apache/ddlutils/platform/PlatformImplBase.java
--- a/src/org/apache/ddlutils/platform/PlatformImplBase.java	Tue Sep 10 08:26:32 2013 +0200
+++ b/src/org/apache/ddlutils/platform/PlatformImplBase.java	Tue Sep 10 11:33:22 2013 +0200
@@ -3438,8 +3438,12 @@
   }
 
   public boolean validateOnCreateDefault(Connection connection, String onCreateDefault, Table table) {
-    if (onCreateDefault.startsWith("'"))
+    // short-circuit the most common/simple expression to skip execution of the validation-sql
+    if (onCreateDefault.startsWith("'") || onCreateDefault.equals("get_uuid()")
+        || onCreateDefault.equals("0")) {
       return true;
+    }
+
     try {
       PreparedStatement st = connection.prepareStatement("SELECT (" + onCreateDefault + ") FROM "
           + table.getName() + limitOneRow());