activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1049122 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc: Statements.java adapter/PostgresqlJDBCAdapter.java
Date Tue, 14 Dec 2010 15:18:03 GMT
Author: gtully
Date: Tue Dec 14 15:18:01 2010
New Revision: 1049122

URL: http://svn.apache.org/viewvc?rev=1049122&view=rev
Log:
resolve https://issues.apache.org/jira/browse/AMQ-3075 - a constraint name needs to be provided
for postgres but this is not the general case. extracted the end of the alter statement to
allow the postgress adapter to override and provided accessor for the constraint name in case
of auto generation issues

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/PostgresqlJDBCAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java?rev=1049122&r1=1049121&r2=1049122&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
Tue Dec 14 15:18:01 2010
@@ -76,6 +76,7 @@ public class Statements {
     private String updateDurableLastAckStatement;
     private String deleteOldMessagesStatementWithPriority;
     private String durableSubscriberMessageCountStatementWithPriority;
+    private String dropAckPKAlterStatementEnd;
 
     public String[] getCreateSchemaStatements() {
         if (createSchemaStatements == null) {
@@ -100,13 +101,24 @@ public class Statements {
                 "ALTER TABLE " + getFullMessageTableName() + " ADD PRIORITY " + sequenceDataType,
                 "CREATE INDEX " + getFullMessageTableName() + "_PIDX ON " + getFullMessageTableName()
+ " (PRIORITY)",
                 "ALTER TABLE " + getFullAckTableName() + " ADD PRIORITY " + sequenceDataType
 + " DEFAULT 5 NOT NULL",
-                "ALTER TABLE " + getFullAckTableName() + " DROP PRIMARY KEY",
+                "ALTER TABLE " + getFullAckTableName() + " " + getDropAckPKAlterStatementEnd(),
                 "ALTER TABLE " + getFullAckTableName() + " ADD PRIMARY KEY (CONTAINER, CLIENT_ID,
SUB_NAME, PRIORITY)",
             };
         }
         return createSchemaStatements;
     }
 
+    public String getDropAckPKAlterStatementEnd() {
+        if (dropAckPKAlterStatementEnd == null) {
+            dropAckPKAlterStatementEnd = "DROP PRIMARY KEY";
+        }
+        return dropAckPKAlterStatementEnd;
+    }
+
+    public void setDropAckPKAlterStatementEnd(String dropAckPKAlterStatementEnd) {
+        this.dropAckPKAlterStatementEnd = dropAckPKAlterStatementEnd;
+    }
+
     public String[] getDropSchemaStatements() {
         if (dropSchemaStatements == null) {
             dropSchemaStatements = new String[] {"DROP TABLE " + getFullAckTableName() +
"",

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/PostgresqlJDBCAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/PostgresqlJDBCAdapter.java?rev=1049122&r1=1049121&r2=1049122&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/PostgresqlJDBCAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/PostgresqlJDBCAdapter.java
Tue Dec 14 15:18:01 2010
@@ -38,10 +38,19 @@ import org.apache.activemq.store.jdbc.St
  * @version $Revision: 1.1 $
  */
 public class PostgresqlJDBCAdapter extends BytesJDBCAdapter {
+    public String acksPkName = "activemq_acks_pkey";
 
     public void setStatements(Statements statements) {
         statements.setBinaryDataType("BYTEA");
+        statements.setDropAckPKAlterStatementEnd("DROP CONSTRAINT \"" + getAcksPkName() +
"\"");
         super.setStatements(statements);
     }
 
+    private String getAcksPkName() {
+        return acksPkName;
+    }
+
+    public void setAcksPkName(String acksPkName) {
+        this.acksPkName = acksPkName;
+    }
 }



Mime
View raw message