HHH-18232 Use change table modifier new and final consistently on DB2 and zOS
This commit is contained in:
parent
3b6c1bc7d6
commit
8100f92265
|
@ -423,11 +423,19 @@ public class DB2LegacySqlAstTranslator<T extends JdbcOperation> extends Abstract
|
||||||
appendSql( " from old table (" );
|
appendSql( " from old table (" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appendSql( " from final table (" );
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
}
|
}
|
||||||
return true;
|
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
|
@Override
|
||||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||||
|
@ -441,7 +449,9 @@ public class DB2LegacySqlAstTranslator<T extends JdbcOperation> extends Abstract
|
||||||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
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 );
|
super.visitStandardTableInsert( tableInsert );
|
||||||
appendSql( ")" );
|
appendSql( ")" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,12 @@ public class DB2zLegacySqlAstTranslator<T extends JdbcOperation> extends DB2Lega
|
||||||
renderDerivedTableReference( tableReference );
|
renderDerivedTableReference( tableReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// On DB2 zOS, `final` also sees the trigger data
|
||||||
|
return "final";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseVersion getDB2Version() {
|
public DatabaseVersion getDB2Version() {
|
||||||
return DB2_LUW_VERSION9;
|
return DB2_LUW_VERSION9;
|
||||||
|
|
|
@ -421,11 +421,19 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
|
||||||
appendSql( " from old table (" );
|
appendSql( " from old table (" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appendSql( " from final table (" );
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
}
|
}
|
||||||
return true;
|
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
|
@Override
|
||||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||||
|
@ -439,7 +447,9 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
|
||||||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
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 );
|
super.visitStandardTableInsert( tableInsert );
|
||||||
appendSql( ")" );
|
appendSql( ")" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,12 @@ public class DB2zSqlAstTranslator<T extends JdbcOperation> extends DB2SqlAstTran
|
||||||
renderDerivedTableReference( tableReference );
|
renderDerivedTableReference( tableReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// On DB2 zOS, `final` also sees the trigger data
|
||||||
|
return "final";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseVersion getDB2Version() {
|
public DatabaseVersion getDB2Version() {
|
||||||
return DB2_LUW_VERSION;
|
return DB2_LUW_VERSION;
|
||||||
|
|
Loading…
Reference in New Issue