From f28f327cbe86b24d234e6b5df901ee2ebc338e9c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 10 Aug 2012 16:54:44 -0500 Subject: [PATCH] IDEMPIERE-384 Problem with insertTranslations in multilanguage env caused by Generate_UUID --- .../postgresql/functions/Generate_UUID.sql | 6 +++--- .../360lts-release/oracle/874_IDEMPIERE-384.sql | 10 ++++++++++ .../postgresql/874_IDEMPIERE-384.sql | 13 +++++++++++++ org.adempiere.base/src/org/compiere/util/DB.java | 16 +++++++++++----- 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 migration/360lts-release/oracle/874_IDEMPIERE-384.sql create mode 100644 migration/360lts-release/postgresql/874_IDEMPIERE-384.sql diff --git a/db/ddlutils/postgresql/functions/Generate_UUID.sql b/db/ddlutils/postgresql/functions/Generate_UUID.sql index 9d0329028f..05f94fb252 100644 --- a/db/ddlutils/postgresql/functions/Generate_UUID.sql +++ b/db/ddlutils/postgresql/functions/Generate_UUID.sql @@ -1,6 +1,6 @@ /* -*This file is part of Adempiere ERP Bazaar -*http://www.adempiere.org +*This file is part of iDempiere ERP +*http://www.idempiere.org * *This program is free software; you can redistribute it and/or *modify it under the terms of the GNU General Public License @@ -22,5 +22,5 @@ RETURNS char(36) AS $$ BEGIN return uuid_generate_v4()::char(36); END; -$$ LANGUAGE plpgsql IMMUTABLE STRICT; +$$ LANGUAGE plpgsql; diff --git a/migration/360lts-release/oracle/874_IDEMPIERE-384.sql b/migration/360lts-release/oracle/874_IDEMPIERE-384.sql new file mode 100644 index 0000000000..a145325781 --- /dev/null +++ b/migration/360lts-release/oracle/874_IDEMPIERE-384.sql @@ -0,0 +1,10 @@ +-- IDEMPIERE-384 Problem with insertTranslations in multilanguage env caused by Generate_UUID +-- just for postgresql + + + +UPDATE AD_System + SET LastMigrationScriptApplied='874_IDEMPIERE-384.sql' +WHERE LastMigrationScriptApplied<'874_IDEMPIERE-384.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/migration/360lts-release/postgresql/874_IDEMPIERE-384.sql b/migration/360lts-release/postgresql/874_IDEMPIERE-384.sql new file mode 100644 index 0000000000..63bc32326b --- /dev/null +++ b/migration/360lts-release/postgresql/874_IDEMPIERE-384.sql @@ -0,0 +1,13 @@ +-- IDEMPIERE-384 Problem with insertTranslations in multilanguage env caused by Generate_UUID +CREATE OR REPLACE FUNCTION generate_uuid() +RETURNS char(36) AS $$ +BEGIN + return uuid_generate_v4()::char(36); +END; +$$ LANGUAGE plpgsql; + +UPDATE AD_System + SET LastMigrationScriptApplied='874_IDEMPIERE-384.sql' +WHERE LastMigrationScriptApplied<'874_IDEMPIERE-384.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index 8250810883..24a27f4b07 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -2358,16 +2358,22 @@ public final class DB } } + private static boolean m_isUUIDVerified = false; + private static boolean m_isUUIDSupported = false; /*** * @return true if current db have working generate_uuid function. generate_uuid doesn't work on 64 bit postgresql * on windows yet. */ public static boolean isGenerateUUIDSupported() { - String uuidTest = null; - try { - uuidTest = getSQLValueStringEx(null, "SELECT Generate_UUID() FROM Dual"); - } catch (Exception e) {} - return uuidTest != null && uuidTest.trim().length() == 36; + if (! m_isUUIDVerified) { + String uuidTest = null; + try { + uuidTest = getSQLValueStringEx(null, "SELECT Generate_UUID() FROM Dual"); + } catch (Exception e) {} + m_isUUIDSupported = uuidTest != null && uuidTest.trim().length() == 36; + m_isUUIDVerified = true; + } + return m_isUUIDSupported; } private static void verifyTrx(String trxName, String sql) {