details: /erp/devel/dbsm-main/rev/299ccedf6b44
changeset: 273:299ccedf6b44
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Mon Mar 01 18:24:54 2010 +0100
summary: Fixed issue 12514. A DROP statement will not be executed. Instead, a
CREATE OR REPLACE will be executed when a function has been changed.
diffstat:
src/org/apache/ddlutils/alteration/ModelComparator.java | 20
+++++++--
src/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java | 2 +-
2 files changed, 16 insertions(+), 6 deletions(-)
diffs (44 lines):
diff -r 3587c8c3d0a1 -r 299ccedf6b44
src/org/apache/ddlutils/alteration/ModelComparator.java
--- a/src/org/apache/ddlutils/alteration/ModelComparator.java Fri Feb 26
12:21:45 2010 +0100
+++ b/src/org/apache/ddlutils/alteration/ModelComparator.java Mon Mar 01
18:24:54 2010 +0100
@@ -219,13 +219,23 @@
for (int fnIdx = 0; fnIdx < sourceModel.getFunctionCount(); fnIdx++) {
Function sourceFunction = sourceModel.getFunction(fnIdx);
Function targetFunction = findCorrespondingFunction(targetModel,
sourceFunction);
-
if (targetFunction == null) {
- if (_log.isDebugEnabled()) {
- _log.debug("Processing Function " + sourceFunction + " (removed from
database "
- + sourceModel.getName() + ")");
+ boolean foundFunctionWithSameName = false;
+ int i = 0;
+ while (i < targetModel.getFunctionCount() &&
!foundFunctionWithSameName) {
+ if
(targetModel.getFunction(i).getName().equalsIgnoreCase(sourceFunction.getName()))
+ foundFunctionWithSameName = true;
+ i++;
}
- changes.add(new RemoveFunctionChange(sourceFunction));
+ if (!foundFunctionWithSameName) // We will only generate a drop
function statement if the
+ // view will not be recreated
+ {
+ if (_log.isDebugEnabled()) {
+ _log.debug("Processing Function " + sourceFunction + " (removed
from database "
+ + sourceModel.getName() + ")");
+ }
+ changes.add(new RemoveFunctionChange(sourceFunction));
+ }
}
}
diff -r 3587c8c3d0a1 -r 299ccedf6b44
src/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
--- a/src/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
Fri Feb 26 12:21:45 2010 +0100
+++ b/src/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
Mon Mar 01 18:24:54 2010 +0100
@@ -386,7 +386,7 @@
*/
@Override
protected void writeCreateFunctionStmt(Function function) throws IOException
{
- print("CREATE FUNCTION ");
+ print("CREATE OR REPLACE FUNCTION ");
printIdentifier(getStructureObjectName(function));
}
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits