HHH-18232 Use change table modifier new and final consistently on DB2 and zOS
This commit is contained in:
parent
de63a8dc00
commit
a6ffa84db7
|
@ -423,11 +423,19 @@ public class DB2LegacySqlAstTranslator<T extends JdbcOperation> extends Abstract
|
|||
appendSql( " from old table (" );
|
||||
}
|
||||
else {
|
||||
appendSql( " from final table (" );
|
||||
appendSql( " from ");
|
||||
appendSql( getNewTableChangeModifier() );
|
||||
appendSql(" table (" );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getNewTableChangeModifier() {
|
||||
// Use 'from new table' to also see data from triggers
|
||||
// See https://www.ibm.com/docs/en/db2/10.5?topic=clause-table-reference#:~:text=FOR%20sequence%20reference-,FINAL%20TABLE,-Specifies%20that%20the
|
||||
return "new";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||
|
@ -441,7 +449,9 @@ public class DB2LegacySqlAstTranslator<T extends JdbcOperation> extends Abstract
|
|||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
||||
}
|
||||
|
||||
appendSql( " from new table ( " ); // 'from final table' does not seem to play well with triggers
|
||||
appendSql( " from ");
|
||||
appendSql( getNewTableChangeModifier() );
|
||||
appendSql(" table (" );
|
||||
super.visitStandardTableInsert( tableInsert );
|
||||
appendSql( ")" );
|
||||
}
|
||||
|
|
|
@ -84,6 +84,12 @@ public class DB2zLegacySqlAstTranslator<T extends JdbcOperation> extends DB2Lega
|
|||
renderDerivedTableReference( tableReference );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNewTableChangeModifier() {
|
||||
// On DB2 zOS, `final` also sees the trigger data
|
||||
return "final";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseVersion getDB2Version() {
|
||||
return DB2_LUW_VERSION9;
|
||||
|
|
|
@ -421,11 +421,19 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
|
|||
appendSql( " from old table (" );
|
||||
}
|
||||
else {
|
||||
appendSql( " from final table (" );
|
||||
appendSql( " from ");
|
||||
appendSql( getNewTableChangeModifier() );
|
||||
appendSql(" table (" );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getNewTableChangeModifier() {
|
||||
// Use 'from new table' to also see data from triggers
|
||||
// See https://www.ibm.com/docs/en/db2/10.5?topic=clause-table-reference#:~:text=FOR%20sequence%20reference-,FINAL%20TABLE,-Specifies%20that%20the
|
||||
return "new";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||
|
@ -439,7 +447,9 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
|
|||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
||||
}
|
||||
|
||||
appendSql( " from new table (" ); // 'from final table' does not seem to play well with triggers
|
||||
appendSql( " from ");
|
||||
appendSql( getNewTableChangeModifier() );
|
||||
appendSql(" table (" );
|
||||
super.visitStandardTableInsert( tableInsert );
|
||||
appendSql( ")" );
|
||||
}
|
||||
|
|
|
@ -77,6 +77,12 @@ public class DB2zSqlAstTranslator<T extends JdbcOperation> extends DB2SqlAstTran
|
|||
renderDerivedTableReference( tableReference );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNewTableChangeModifier() {
|
||||
// On DB2 zOS, `final` also sees the trigger data
|
||||
return "final";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseVersion getDB2Version() {
|
||||
return DB2_LUW_VERSION;
|
||||
|
|
Loading…
Reference in New Issue