modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java | 23
+++++++++-
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 5 +-
2 files changed, 26 insertions(+), 2 deletions(-)
New commits:
commit 638de1b71e5eb15b137ca2deda01299a30f5482c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 15 13:18:32 2011 -0500
[Bug 768031 - Pin template failure on upgraded dbs]
Set RHQ_DRIFT_CHANGE_SET.DRIFT_DEFINITION_ID nullable in the db upgrade.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9e3bbd6..24c536d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3826,7 +3826,10 @@
<schemaSpec version="2.117">
<!-- Remove an obsolete drift table that may be hanging around -->
- <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" />
+ <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" />
+
+ <!-- Remove an unwanted null consraint -->
+ <schema-alterColumn table="RHQ_DRIFT_CHANGE_SET"
column="DRIFT_DEFINITION_ID" nullable="TRUE" />
</schemaSpec>
</dbupgrade>
commit 4da6f3724d6492ae449ea76100aac8d9948f6303
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 15 13:16:59 2011 -0500
Supporting check-in for [Bug 768031 - Pin template failure on upgraded dbs]
- Fix a long standing issue in dbupgrade due to Oracle throwing exceptions
when trying to set nullable to the current value. In other words, the
upgrade would fail on oracle if you tried to set nullable false on a
column that was already nullable false. (same for nullable true). This
caused issues when you can't guarantee the current state, you just know
what you need it to be. Now, catch the relevant exceptions and toss
them as needed.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
index b4ea5e9..9dcbb89 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
@@ -25,6 +25,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import mazz.i18n.Logger;
+
/**
* Superclass of all versions of the Oracle database.
*
@@ -32,6 +34,8 @@ import java.util.List;
*
*/
public abstract class OracleDatabaseType extends DatabaseType {
+ private static final Logger LOG =
DbUtilsI18NFactory.getLogger(OracleDatabaseType.class);
+
/**
* The vendor name for all Oracle databases.
*/
@@ -150,7 +154,24 @@ public abstract class OracleDatabaseType extends DatabaseType {
sql += ")";
- executeSql(conn, sql);
+ try {
+ executeSql(conn, sql);
+ } catch (SQLException e) {
+ // Oracle throws an exception if you try to set nullable to its current
setting. Ignore errors
+ // generated when a nullable setting is already the way we want it to be.
+ // ORA-01442: column to be modified to NOT NULL is already NOT NULL
+ // ORA-01451: column to be modified to NULL cannot be modified to NULL
+ if (nullable != null) {
+ String msg = e.getMessage();
+ if (msg.contains("ORA-01442") ||
msg.contains("ORA-01451")) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring exception, column already set to
nullable=" + nullable, e);
+ }
+ } else {
+ throw e;
+ }
+ }
+ }
if ((reindex != null) && reindex.booleanValue()) {
reindexTable(conn, table);
Show replies by date