Skip to content

Commit

Permalink
0001460: On postgres, when sync triggers is run from symadmin tool th…
Browse files Browse the repository at this point in the history
…e generated triggers put null into the transaction id field
  • Loading branch information
chenson42 committed Oct 30, 2013
1 parent 17a4413 commit 0416b19
Showing 1 changed file with 16 additions and 22 deletions.
Expand Up @@ -50,9 +50,7 @@ public class PostgreSqlSymmetricDialect extends AbstractSymmetricDialect impleme
" select count(*) from information_schema.routines " +
" where routine_name = '$(functionName)' and specific_schema = '$(defaultSchema)'" ;

private boolean supportsTransactionId = false;

private String transactionIdExpression = "null";
private Boolean supportsTransactionId = null;

public PostgreSqlSymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
Expand All @@ -61,13 +59,6 @@ public PostgreSqlSymmetricDialect(IParameterService parameterService, IDatabaseP

@Override
public void createRequiredDatabaseObjects() {

if (transactionIdSupported()) {
supportsTransactionId = true;
transactionIdExpression = TRANSACTION_ID_EXPRESSION;
} else {
log.warn("Capturing of transaction identifiers is not supported in this version of postgres");
}

ISqlTransaction transaction = null;
try {
Expand Down Expand Up @@ -154,17 +145,6 @@ public void dropRequiredDatabaseObjects() {

}

private boolean transactionIdSupported() {

boolean transactionIdSupported = false;

if (platform.getSqlTemplate().queryForInt("select count(*) from information_schema.routines where routine_name='txid_current'") > 0) {
transactionIdSupported = true;
}

return transactionIdSupported;
}

@Override
public boolean requiresAutoCommitFalseToSetFetchSize() {
return true;
Expand Down Expand Up @@ -226,11 +206,25 @@ public String getSyncTriggersExpression() {

@Override
public String getTransactionTriggerExpression(String defaultCatalog, String defaultSchema, Trigger trigger) {
return transactionIdExpression;
if (supportsTransactionId()) {
return TRANSACTION_ID_EXPRESSION;
} else {
return "null";
}
}

@Override
public boolean supportsTransactionId() {
if (supportsTransactionId == null) {
if (platform
.getSqlTemplate()
.queryForInt(
"select count(*) from information_schema.routines where routine_name='txid_current'") > 0) {
supportsTransactionId = true;
} else {
supportsTransactionId = false;
}
}
return supportsTransactionId;
}

Expand Down

0 comments on commit 0416b19

Please sign in to comment.