From 8951aa4e11623aa67fee4f02c21b1323961f6863 Mon Sep 17 00:00:00 2001 From: Gil Moskowitz Date: Fri, 26 Sep 2014 13:53:41 -0400 Subject: [PATCH] let administrators modify package contents even if they are not marked as such to simplify upgrade processing --- .../public/trigger_functions/pkgcmd.sql | 2 +- .../public/trigger_functions/pkgcmdarg.sql | 2 +- .../public/trigger_functions/pkgimage.sql | 2 +- .../public/trigger_functions/pkgmetasql.sql | 7 +---- .../public/trigger_functions/pkgpriv.sql | 2 +- .../public/trigger_functions/pkgreport.sql | 2 +- .../public/trigger_functions/pkgscript.sql | 2 +- .../public/trigger_functions/pkguiform.sql | 2 +- scripts/lib/util/convert_specialized.js | 30 ++++--------------- 9 files changed, 14 insertions(+), 37 deletions(-) diff --git a/foundation-database/public/trigger_functions/pkgcmd.sql b/foundation-database/public/trigger_functions/pkgcmd.sql index 3905379e5..be407b8d3 100644 --- a/foundation-database/public/trigger_functions/pkgcmd.sql +++ b/foundation-database/public/trigger_functions/pkgcmd.sql @@ -45,7 +45,7 @@ CREATE OR REPLACE FUNCTION _pkgcmdalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgcmdarg.sql b/foundation-database/public/trigger_functions/pkgcmdarg.sql index 8eb9cb742..09eaa6190 100644 --- a/foundation-database/public/trigger_functions/pkgcmdarg.sql +++ b/foundation-database/public/trigger_functions/pkgcmdarg.sql @@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkgcmdargalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgimage.sql b/foundation-database/public/trigger_functions/pkgimage.sql index 1d51cb1c2..0f8ae1dd0 100644 --- a/foundation-database/public/trigger_functions/pkgimage.sql +++ b/foundation-database/public/trigger_functions/pkgimage.sql @@ -43,7 +43,7 @@ CREATE OR REPLACE FUNCTION _pkgimagealterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgmetasql.sql b/foundation-database/public/trigger_functions/pkgmetasql.sql index 10f7f078a..3f9f3c396 100644 --- a/foundation-database/public/trigger_functions/pkgmetasql.sql +++ b/foundation-database/public/trigger_functions/pkgmetasql.sql @@ -52,13 +52,8 @@ $$ LANGUAGE 'plpgsql'; CREATE OR REPLACE FUNCTION _pkgmetasqlalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -DECLARE - _isdba BOOLEAN := false; - BEGIN - SELECT rolsuper INTO _isdba FROM pg_roles WHERE (rolname=getEffectiveXtUser()); - - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgpriv.sql b/foundation-database/public/trigger_functions/pkgpriv.sql index edb8f638d..b3af0037c 100644 --- a/foundation-database/public/trigger_functions/pkgpriv.sql +++ b/foundation-database/public/trigger_functions/pkgpriv.sql @@ -47,7 +47,7 @@ CREATE OR REPLACE FUNCTION _pkgprivalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgreport.sql b/foundation-database/public/trigger_functions/pkgreport.sql index 94f9c4b0c..d32f4f01d 100644 --- a/foundation-database/public/trigger_functions/pkgreport.sql +++ b/foundation-database/public/trigger_functions/pkgreport.sql @@ -50,7 +50,7 @@ CREATE OR REPLACE FUNCTION _pkgreportalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkgscript.sql b/foundation-database/public/trigger_functions/pkgscript.sql index 954418c49..40e2fb4a3 100644 --- a/foundation-database/public/trigger_functions/pkgscript.sql +++ b/foundation-database/public/trigger_functions/pkgscript.sql @@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkgscriptalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/foundation-database/public/trigger_functions/pkguiform.sql b/foundation-database/public/trigger_functions/pkguiform.sql index a5f1a923e..dc0e307a2 100644 --- a/foundation-database/public/trigger_functions/pkguiform.sql +++ b/foundation-database/public/trigger_functions/pkguiform.sql @@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkguiformalterTrigger() RETURNS TRIGGER AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN - IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN + IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE diff --git a/scripts/lib/util/convert_specialized.js b/scripts/lib/util/convert_specialized.js index 95b8d5234..3b89903ef 100644 --- a/scripts/lib/util/convert_specialized.js +++ b/scripts/lib/util/convert_specialized.js @@ -50,10 +50,8 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ grade = "0", tableName = defaultSchema ? defaultSchema + ".pkgreport" : "report", description, - disableSql, updateSql, - insertSql, - enableSql; + insertSql; if (lines[3].indexOf(" ") !== 0 || lines[4].indexOf(" ") !== 0) { @@ -68,8 +66,6 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ grade = grade.substring(0, grade.indexOf("<")); } - disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;"; - insertSql = "insert into " + tableName + " (report_name, report_descrip, " + "report_source, report_loaddate, report_grade) select " + "'" + name + "'," + @@ -87,21 +83,15 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ "where report_name = '" + name + "' and report_grade = " + grade + ";"; - enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;"; - - return disableSql + insertSql + updateSql + enableSql; + return insertSql + updateSql; }; var convertFromScript = function (content, filename, defaultSchema) { var name = path.basename(filename, '.js'), tableName = defaultSchema ? defaultSchema + ".pkgscript" : "unknown", notes = "", //"xtMfg package", - disableSql, insertSql, - updateSql, - enableSql; - - disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;"; + updateSql; insertSql = "insert into " + tableName + " (script_name, script_order, script_enabled, " + "script_source, script_notes) select " + @@ -117,21 +107,15 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ "$$, script_notes = '" + notes + "' " + "where script_name = '" + name + "';"; - enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;"; - - return disableSql + insertSql + updateSql + enableSql; + return insertSql + updateSql; }; var convertFromUiform = function (content, filename, defaultSchema) { var name = path.basename(filename, '.ui'), tableName = defaultSchema ? defaultSchema + ".pkguiform" : "unknown", notes = "", //"xtMfg package", - disableSql, insertSql, - updateSql, - enableSql; - - disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;"; + updateSql; insertSql = "insert into " + tableName + " (uiform_name, uiform_order, uiform_enabled, " + "uiform_source, uiform_notes) select " + @@ -146,9 +130,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ "uiform_source = $$" + content + "$$, uiform_notes = '" + notes + "' " + "where uiform_name = '" + name + "';"; - enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;"; - - return disableSql + insertSql + updateSql + enableSql; + return insertSql + updateSql; }; exports.conversionMap = { -- 2.39.2