Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0040264Openbravo ERPY. DBSourceManagerpublic2019-02-25 10:352019-05-30 04:01
AugustoMauch 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
3.0PR19Q33.0PR19Q3 
caristu
Core
No
0040264: update.database task fails with no proper error message when a wrong function is defined in db but not excluded
There are some functions that are not defined as part of Openbravo model and that they must be excluded from being loaded by adding them to the exclude filter.

Whe one of those functions is not added to the exclude filter, the update.database function will fail, and the error message will not be clear enough:

 [java] 67129 INFO - Updating database model...
     [java] 67335 ERROR -
     [java] java.lang.NullPointerException
     [java] at org.apache.ddlutils.model.Parameter.getName(Parameter.java:53)
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlBuilder.writeParameter(PostgreSqlBuilder.java:529)
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlBuilder.writeDropFunctionStmt(PostgreSqlBuilder.java:346)
     [java] at org.apache.ddlutils.platform.SqlBuilder.dropFunction(SqlBuilder.java:4276)
     [java] at org.apache.ddlutils.platform.postgresql.PostgreSqlBuilder.dropFunction(PostgreSqlBuilder.java:519)
     [java] at org.apache.ddlutils.platform.SqlBuilder.processChange(SqlBuilder.java:1543)
     [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java] at java.lang.reflect.Method.invoke(Method.java:498)
     [java] at org.apache.ddlutils.util.CallbackClosure.execute(CallbackClosure.java:151)
     [java] at org.apache.ddlutils.platform.SqlBuilder$1.evaluate(SqlBuilder.java:1024)
     [java] at org.apache.commons.collections.CollectionUtils.filter(CollectionUtils.java:406)
     [java] at org.apache.ddlutils.platform.SqlBuilder.applyForSelectedChanges(SqlBuilder.java:1021)

Even if the dbsourcemanager log is set to debug, it still does not what was the function that caused the error while being loaded from the database. The cause of the error is that Openbravo does not support to load functions with unnamed parameters.
Create this function directly in the database:

CREATE FUNCTION bad_function(integer, integer) RETURNS integer
    AS 'select $1 + $2;'
    LANGUAGE SQL
    IMMUTABLE
    RETURNS NULL ON NULL INPUT;

Run ant update.database -Dforce=yes

The process will fail and it will throw the error mentioned in the description
It would be better to:
- Fail like now, but mentioning in the error message the function that was being loaded and telling that update.database will not work until that function is added to exclude filter / removed from database
- When a function with unnamed parameters is loaded, just ignore and show a warning message.
No tags attached.
Issue History
2019-02-25 10:35AugustoMauchNew Issue
2019-02-25 10:35AugustoMauchAssigned To => platform
2019-02-25 10:35AugustoMauchModules => Core
2019-02-25 10:35AugustoMauchTriggers an Emergency Pack => No
2019-05-09 07:35alostaleTarget Version => 3.0PR19Q3
2019-05-13 10:55AugustoMauchAssigned Toplatform => AugustoMauch
2019-05-28 11:11AugustoMauchReview Assigned To => caristu
2019-05-28 11:12hgbotCheckin
2019-05-28 11:12hgbotNote Added: 0112198
2019-05-28 11:12hgbotStatusnew => resolved
2019-05-28 11:12hgbotResolutionopen => fixed
2019-05-28 11:12hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/dbsm-main/rev/fd7db9cfa66d4320300b4bcade0bb2a7d5bd4963 [^]
2019-05-28 11:14hgbotCheckin
2019-05-28 11:14hgbotNote Added: 0112199
2019-05-28 11:14hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/dbsm-main/rev/fd7db9cfa66d4320300b4bcade0bb2a7d5bd4963 [^] => http://code.openbravo.com/erp/devel/pi/rev/30d087840b5502ada2a775de7f2c6bf68673883c [^]
2019-05-28 11:15AugustoMauchNote Added: 0112200
2019-05-28 20:14hudsonbotCheckin
2019-05-28 20:14hudsonbotNote Added: 0112215
2019-05-29 13:29caristuNote Added: 0112224
2019-05-29 13:29caristuStatusresolved => new
2019-05-29 13:29caristuResolutionfixed => open
2019-05-29 13:56hgbotCheckin
2019-05-29 13:56hgbotNote Added: 0112226
2019-05-29 16:12hgbotCheckin
2019-05-29 16:12hgbotNote Added: 0112229
2019-05-29 16:24hgbotCheckin
2019-05-29 16:24hgbotNote Added: 0112230
2019-05-29 16:28hgbotCheckin
2019-05-29 16:28hgbotNote Added: 0112232
2019-05-29 16:30hgbotCheckin
2019-05-29 16:30hgbotNote Added: 0112233
2019-05-29 17:01hgbotCheckin
2019-05-29 17:01hgbotNote Added: 0112234
2019-05-29 17:02caristuStatusnew => scheduled
2019-05-29 17:02caristuStatusscheduled => resolved
2019-05-29 17:02caristuResolutionopen => fixed
2019-05-29 17:02caristuNote Added: 0112235
2019-05-29 17:02caristuStatusresolved => closed
2019-05-29 17:02caristuFixed in Version => 3.0PR19Q3
2019-05-29 20:49hudsonbotCheckin
2019-05-29 20:49hudsonbotNote Added: 0112245
2019-05-30 04:01hudsonbotCheckin
2019-05-30 04:01hudsonbotNote Added: 0112248

Notes
(0112198)
hgbot   
2019-05-28 11:12   
Repository: erp/devel/dbsm-main
Changeset: fd7db9cfa66d4320300b4bcade0bb2a7d5bd4963
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue May 28 11:05:45 2019 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/fd7db9cfa66d4320300b4bcade0bb2a7d5bd4963 [^]

Fixes issue 40264: Ignore some invalid functions when loading the database model

Openbravo does not support the definition of functions with anonymous parameters. Before this
changeset, loading from the model one of those functions resulted in a NullPointerException.

Now these functions will be ignored when loading the model from the database. This means that
export.database will not export them, and update.database will not overwrite them.

To be able to ignore a row within RowConstructor.getRow a new exception called SkipRowException has
been defined.

---
M src-test/src/org/openbravo/dbsm/test/model/Functions.java
M src/org/apache/ddlutils/platform/ModelLoaderBase.java
M src/org/apache/ddlutils/platform/RowConstructor.java
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java
---
(0112199)
hgbot   
2019-05-28 11:14   
Repository: erp/devel/pi
Changeset: 30d087840b5502ada2a775de7f2c6bf68673883c
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue May 28 11:13:47 2019 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/30d087840b5502ada2a775de7f2c6bf68673883c [^]

Fixes issue 40264: Ignore some invalid functions when loading the database model

Openbravo does not support the definition of functions with anonymous parameters. Before this
changeset, loading from the model one of those functions resulted in a NullPointerException.

Now these functions will be ignored when loading the model from the database. This means that
export.database will not export them, and update.database will not overwrite them.

To be able to ignore a row within RowConstructor.getRow a new exception called SkipRowException has
been defined.

---
M src-db/database/lib/dbsourcemanager.jar
---
(0112200)
AugustoMauch   
2019-05-28 11:15   
There is no need to make changes in OracleModelLoader, because Oracle does not support functions with anonymous parameters.

That's also why the new test added to Functions.java is only executed when using postgres.
(0112215)
hudsonbot   
2019-05-28 20:14   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/d51097bed845 [^]
Maturity status: Test
(0112224)
caristu   
2019-05-29 13:29   
SkipRowException class is missing
(0112226)
hgbot   
2019-05-29 13:56   
Repository: erp/devel/dbsm-main
Changeset: f766e3ee8a15c2f7339c4002af68cf6cbc0a0fdb
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed May 29 13:55:51 2019 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/f766e3ee8a15c2f7339c4002af68cf6cbc0a0fdb [^]

Related with issue 40264: Adds missing class, renames it to InvalidRowException

---
M src/org/apache/ddlutils/platform/ModelLoaderBase.java
M src/org/apache/ddlutils/platform/RowConstructor.java
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java
A src/org/apache/ddlutils/platform/InvalidRowException.java
---
(0112229)
hgbot   
2019-05-29 16:12   
Repository: erp/devel/pi
Changeset: 1d550d6c5cc6672fb804a5127ba5d34acc4dcca4
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed May 29 16:11:55 2019 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1d550d6c5cc6672fb804a5127ba5d34acc4dcca4 [^]

Related with issue 40264: Adds missing class, renames it to InvalidRowException

---
M src-db/database/lib/dbsourcemanager.jar
---
(0112230)
hgbot   
2019-05-29 16:24   
Repository: erp/devel/dbsm-main
Changeset: 0ef16af7a112232e452a585ae5a7dc3a76598f76
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed May 29 16:23:52 2019 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/0ef16af7a112232e452a585ae5a7dc3a76598f76 [^]

related to issue 40264: fix javadoc

---
M src-test/src/org/openbravo/dbsm/test/model/Functions.java
---
(0112232)
hgbot   
2019-05-29 16:28   
Repository: erp/devel/dbsm-main
Changeset: ff253fd0e2debe8c92ef780dcc6cd690b48e8d58
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed May 29 16:28:38 2019 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/ff253fd0e2debe8c92ef780dcc6cd690b48e8d58 [^]

Related with issue 40264: Include function name in warning message

---
M src-test/src/org/openbravo/dbsm/test/model/Functions.java
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java
---
(0112233)
hgbot   
2019-05-29 16:30   
Repository: erp/devel/pi
Changeset: 1924cce570cd55319491551e737c2cae4dab4f0a
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed May 29 16:29:58 2019 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1924cce570cd55319491551e737c2cae4dab4f0a [^]

Related with issue 40264: Include function name in warning message

---
M src-db/database/lib/dbsourcemanager.jar
---
(0112234)
hgbot   
2019-05-29 17:01   
Repository: erp/devel/dbsm-main
Changeset: b5d75690ddba3ebf58121e80550737300c3696b3
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed May 29 16:59:29 2019 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/b5d75690ddba3ebf58121e80550737300c3696b3 [^]

related to issue 40264: update copyright year

---
M src-test/src/org/openbravo/dbsm/test/model/Functions.java
M src/org/apache/ddlutils/platform/RowConstructor.java
---
(0112235)
caristu   
2019-05-29 17:02   
Reviewed + tested OK.
(0112245)
hudsonbot   
2019-05-29 20:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/0705db562021 [^]
Maturity status: Test
(0112248)
hudsonbot   
2019-05-30 04:01   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/2785551137d4 [^]
Maturity status: Test