details:   https://code.openbravo.com/erp/devel/pi/rev/15559dddfaad
changeset: 33434:15559dddfaad
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Wed Feb 14 13:35:37 2018 +0100
summary:   Fixes issue 36226: No error is shown on install.source if role does 
not exist

Now if the role/user does not exist in postgresql/oracle when invoking 
install.source, no error message will be shown:
- In postgresql, the role is only dropped if exists
- Oracle does not have the IF EXISTS clause, so the dba_users table is queried 
to check if a user with the given name exists.

diffstat:

 src-db/database/build-create.xml |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (48 lines):

diff -r d0a6cc5b94d5 -r 15559dddfaad src-db/database/build-create.xml
--- a/src-db/database/build-create.xml  Wed Feb 14 10:37:25 2018 +0100
+++ b/src-db/database/build-create.xml  Wed Feb 14 13:35:37 2018 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2018 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -58,7 +58,7 @@
 
 
   <target name="clean.database.ORACLE">
-    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" 
password="${bbdd.systemPassword}" onerror="continue">
+    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" 
password="${bbdd.systemPassword}" onerror="continue" delimiter="/">
       <classpath>
         <fileset dir="${base.lib}">
           <include name="**/*.jar">
@@ -66,7 +66,16 @@
         </fileset>
       </classpath>
       <transaction>
-        DROP USER ${bbdd.user} CASCADE;
+        -- DROP USER IF EXISTS
+        DECLARE
+          v_count NUMBER;
+        BEGIN
+          SELECT COUNT(*) INTO v_count FROM dba_users WHERE UPPER(username) = 
UPPER('${bbdd.user}');
+          IF (v_count > 0) THEN
+            EXECUTE IMMEDIATE 'DROP USER ${bbdd.user} CASCADE';
+          END IF;
+        END;
+        /
       </transaction>
     </sql>
   </target>
@@ -91,7 +100,7 @@
         </fileset>
       </classpath>
       <transaction>
-        DROP ROLE ${bbdd.user};
+        DROP ROLE IF EXISTS ${bbdd.user};
       </transaction>
     </sql>
   </target>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to