Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0030720Openbravo ERPA. Platformpublic2015-09-01 16:222016-07-06 12:07
shuehner 
shuehner 
normaltrivialhave not tried
closedfixed 
5
 
3.0PR15Q4 
alostale
Core
No
0030720: Cleanup unused variables in pl-functions & triggers (platform part)
There are quite a few variables declared in in pl-functions & -triggers which are never used.

Those should be cleaned up.

Note: found using static analysis using plpgsql_check

This issue is split out of 27432 and handles part of platform team.
Run plpgsql_check_function on all functions + trigger
And review output.
Delete the unused variables.
No tags attached.
related to defect 0027432 closed Sanjota Cleanup unused variables in pl-functions & triggers 
related to defect 0033422 closed Sanjota Static code analysis: triggers 
Issue History
2015-09-01 16:22shuehnerNew Issue
2015-09-01 16:22shuehnerAssigned To => shuehner
2015-09-01 16:22shuehnerModules => Core
2015-09-01 16:22shuehnerTriggers an Emergency Pack => No
2015-09-01 16:22shuehnerIssue generated from0027432
2015-09-01 16:22shuehnerRelationship addedrelated to 0027432
2015-09-02 10:05shuehnerNote Added: 0080009
2015-09-02 10:06shuehnerReview Assigned To => alostale
2015-09-02 10:07hgbotCheckin
2015-09-02 10:07hgbotNote Added: 0080011
2015-09-02 10:07hgbotStatusnew => resolved
2015-09-02 10:07hgbotResolutionopen => fixed
2015-09-02 10:07hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/f41aa6109535a38a4d9161649f2fd1de4d987390 [^]
2015-09-10 10:25alostaleNote Added: 0080311
2015-09-10 10:25alostaleStatusresolved => closed
2015-09-10 10:25alostaleFixed in Version => 3.0PR15Q4
2015-09-10 10:29alostaleNote Edited: 0080311bug_revision_view_page.php?bugnote_id=0080311#r9417
2016-07-06 12:07vmromanosRelationship addedrelated to 0033422

Notes
(0080009)
shuehner   
2015-09-02 10:05   
Notes for review:
All cases have been found by plpgsql_check static analysis tool but then also manually verified by checking the .xml source file in an editor.

And for each case search for the allegedly unused variable in all file to verify it is not used at all

That same procedure can be used to verify that the deleted variables are in fact not used.

NOTE: search must be done case-insensitive as pl does allow that when using variables.
(0080011)
hgbot   
2015-09-02 10:07   
Repository: erp/devel/pi
Changeset: f41aa6109535a38a4d9161649f2fd1de4d987390
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Tue Sep 01 16:28:36 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/f41aa6109535a38a4d9161649f2fd1de4d987390 [^]

Fixed 30720. Remove most unused variables from pl functions & triggers.

That takes care of the big bunch of those warnings keeping only the ones
having some special case to be looked at in more detail.

All found using plpgsql_check tool.

---
M modules/org.openbravo.client.application/src-db/database/model/triggers/OBUIAPP_AD_FIELD_MOD_TRG.xml
M modules/org.openbravo.client.application/src-db/database/model/triggers/OBUIAPP_MENU_PARAM_MOD_TRG.xml
M modules/org.openbravo.client.application/src-db/database/model/triggers/OBUIAPP_PARAMETER_MOD_TRG.xml
M modules/org.openbravo.client.kernel/src-db/database/model/triggers/OBCLKER_TEMPLATE_DEPEND_TRG.xml
M modules/org.openbravo.client.myob/src-db/database/model/triggers/OBKMO_WIDGET_CLASS_MOD_TRG.xml
M modules/org.openbravo.client.myob/src-db/database/model/triggers/OBKMO_WIDGET_URL_MOD_TRG.xml
M modules/org.openbravo.service.datasource/src-db/database/model/triggers/OBSERDS_DATASOURCE_FIELD_TRG.xml
M modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_SELECTOR_FLD_MOD_TRG.xml
M modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_SELECTOR_TRL_TRG.xml
M src-db/database/model/functions/AD_COLUMN_IDENTIFIER_REF_SQL.xml
M src-db/database/model/functions/AD_COLUMN_IDENTIFIER_SQL.xml
M src-db/database/model/functions/AD_GETTAB_FROM_TABLE.xml
M src-db/database/model/functions/AD_GET_NODE_TREE_BYLEVEL.xml
M src-db/database/model/functions/AD_ORG_READY.xml
M src-db/database/model/functions/AD_TABLE_IMPORT.xml
M src-db/database/model/functions/AD_TAB_COPY.xml
M src-db/database/model/functions/AD_TAB_IMPORT.xml
M src-db/database/model/prescript-PostgreSql.sql
M src-db/database/model/triggers/AD_EP_PROCEDURES_MOD_TRG.xml
M src-db/database/model/triggers/AD_EXTENSION_POINT_MOD_TRG.xml
M src-db/database/model/triggers/AD_MENU_TRG.xml
M src-db/database/model/triggers/AD_MODULE_TRG.xml
M src-db/database/model/triggers/AD_MODULE_TRG2.xml
M src-db/database/model/triggers/AD_ORG_TRG.xml
---
(0080311)
alostale   
2015-09-10 10:25   
(edited on: 2015-09-10 10:29)
code reviewed

additional test was performed:

1. In an Oracle instance invoke: call dba_recompile(null)
2. Check dbsm output -> "All valid" message is shown
3. Check all objects are in valid status

In case any used variable would have been deleted this would have been the result of the test:

* dbsm output would have informed about the invalid object
* an error like "Error(42,34): PLS-00201: identifier 'V_DATENULL' must be declared" would be seen for those objects