From d3c980425321005ba4a7b5d9064ba799ea9952ed Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 17 Sep 2020 15:02:22 +0200 Subject: [PATCH] IDEMPIERE-4454 Implement filter for SQL debug - unify oracle and postgresql variable (#252) --- .../src/org/compiere/db/DB_Oracle.java | 9 +++++++-- .../src/org/compiere/dbPort/Convert_Oracle.java | 9 +++++++-- .../src/org/compiere/db/DB_PostgreSQL.java | 9 +++++++-- .../src/org/compiere/dbPort/Convert_PostgreSQL.java | 13 ++++++++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index 1a200851c5..11c43a986f 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -371,8 +371,13 @@ public class DB_Oracle implements AdempiereDatabase public String convertStatement (String oraStatement) { Convert.logMigrationScript(oraStatement, null); - if ("true".equals(System.getProperty("org.idempiere.db.oracle.debug"))) { - log.warning("Oracle -> " + oraStatement); + if ("true".equals(System.getProperty("org.idempiere.db.debug"))) { + String filterOrDebug = System.getProperty("org.idempiere.db.debug.filter"); + boolean print = true; + if (filterOrDebug != null) + print = oraStatement.matches(filterOrDebug); + if (print) + log.warning("Oracle -> " + oraStatement); } return oraStatement; } // convertStatement diff --git a/org.compiere.db.oracle.provider/src/org/compiere/dbPort/Convert_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/dbPort/Convert_Oracle.java index d1ad7bcca5..2e220ca7f3 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/dbPort/Convert_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/dbPort/Convert_Oracle.java @@ -15,8 +15,13 @@ public class Convert_Oracle extends Convert { protected ArrayList convertStatement(String sqlStatement) { ArrayList result = new ArrayList(); result.add(sqlStatement); - if ("true".equals(System.getProperty("org.idempiere.db.oracle.debug"))) { - log.warning("Oracle -> " + sqlStatement); + if ("true".equals(System.getProperty("org.idempiere.db.debug"))) { + String filterOrDebug = System.getProperty("org.idempiere.db.debug.filter"); + boolean print = true; + if (filterOrDebug != null) + print = sqlStatement.matches(filterOrDebug); + if (print) + log.warning("Oracle -> " + sqlStatement); } return result; } diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index e87a276024..f0d8dfc6c9 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -355,9 +355,14 @@ public class DB_PostgreSQL implements AdempiereDatabase String cache = convertCache.get(oraStatement); if (cache != null) { Convert.logMigrationScript(oraStatement, cache); - if ("true".equals(System.getProperty("org.idempiere.db.postgresql.debug"))) { + if ("true".equals(System.getProperty("org.idempiere.db.debug"))) { + String filterPgDebug = System.getProperty("org.idempiere.db.debug.filter"); + boolean print = true; + if (filterPgDebug != null) + print = cache.matches(filterPgDebug); // log.warning("Oracle -> " + oraStatement); - log.warning("Pgsql -> " + cache); + if (print) + log.warning("Pgsql -> " + cache); } return cache; } diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/Convert_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/Convert_PostgreSQL.java index 869fdffbb2..21581a6482 100644 --- a/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/Convert_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/Convert_PostgreSQL.java @@ -127,9 +127,16 @@ public class Convert_PostgreSQL extends Convert_SQL92 { statement = recoverQuotedStrings(statement, retVars); result.add(statement); - if ("true".equals(System.getProperty("org.idempiere.db.postgresql.debug"))) { - log.warning("Oracle -> " + sqlStatement); - log.warning("PgSQL -> " + statement); + if ("true".equals(System.getProperty("org.idempiere.db.debug"))) { + String filterPgDebug = System.getProperty("org.idempiere.db.debug.filter"); + boolean print = true; + if (filterPgDebug != null) + print = statement.matches(filterPgDebug); + // log.warning("Oracle -> " + oraStatement); + if (print) { + log.warning("Oracle -> " + sqlStatement); + log.warning("PgSQL -> " + statement); + } } return result; } // convertStatement