Skip to content

Commit

Permalink
0001518: rebuild of trigger hist fails on some platforms (postgres, f…
Browse files Browse the repository at this point in the history
…irebird, oracle) when upgrading from 3.1 to 3.5
  • Loading branch information
chenson42 committed Jan 8, 2014
1 parent f02da2e commit 3e17217
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Expand Up @@ -93,12 +93,12 @@ public FirebirdDdlBuilder() {
protected void createTable(Table table, StringBuilder ddl, boolean temporary, boolean recreate) {
super.createTable(table, ddl, temporary, recreate);

if (!temporary && !recreate) {
if (!temporary) {
// creating generator and trigger for auto-increment
Column[] columns = table.getAutoIncrementColumns();

for (int idx = 0; idx < columns.length; idx++) {
writeAutoIncrementCreateStmts(table, columns[idx], ddl);
writeAutoIncrementCreateStmts(table, columns[idx], ddl, recreate);
}
}
}
Expand All @@ -120,10 +120,12 @@ protected void dropTable(Table table, StringBuilder ddl, boolean temporary, bool
* Writes the creation statements to make the given column an auto-increment
* column.
*/
private void writeAutoIncrementCreateStmts(Table table, Column column, StringBuilder ddl) {
ddl.append("CREATE GENERATOR ");
printIdentifier(getGeneratorName(table, column), ddl);
printEndOfStatement(ddl);
private void writeAutoIncrementCreateStmts(Table table, Column column, StringBuilder ddl, boolean recreate) {
if (!recreate) {
ddl.append("CREATE GENERATOR ");
printIdentifier(getGeneratorName(table, column), ddl);
printEndOfStatement(ddl);
}

ddl.append("CREATE TRIGGER ");
printIdentifier(getTriggerName(table, column), ddl);
Expand Down Expand Up @@ -370,7 +372,7 @@ protected void processChange(Database currentModel, Database desiredModel,
printEndOfStatement(ddl);
}
if (change.getNewColumn().isAutoIncrement()) {
writeAutoIncrementCreateStmts(curTable, change.getNewColumn(), ddl);
writeAutoIncrementCreateStmts(curTable, change.getNewColumn(), ddl, false);
}
change.apply(currentModel, delimitedIdentifierModeOn);
}
Expand Down
Expand Up @@ -110,15 +110,15 @@ protected void createTable(Table table, StringBuilder ddl, boolean temporary, bo
// lets create any sequences
Column[] columns = table.getAutoIncrementColumns();

if (!temporary) {
if (!temporary && !recreate) {
for (int idx = 0; idx < columns.length; idx++) {
createAutoIncrementSequence(table, columns[idx], ddl);
}
}

super.createTable(table, ddl, temporary, recreate);

if (!temporary && !recreate) {
if (!temporary) {
for (int idx = 0; idx < columns.length; idx++) {
createAutoIncrementTrigger(table, columns[idx], ddl);
}
Expand Down

0 comments on commit 3e17217

Please sign in to comment.