Buggy code:
public class JdbcDatabaseSnapshot extends DatabaseSnapshot { private JdbcDatabaseSnapshot . CachingDatabaseMetaData cachingDatabaseMetaData ; public JdbcDatabaseSnapshot ( DatabaseObject [ ] examples , Database database , SnapshotControl snapshotControl ) throws DatabaseException , InvalidExampleException { } public JdbcDatabaseSnapshot ( DatabaseObject [ ] examples , Database database ) throws DatabaseException , InvalidExampleException { } public JdbcDatabaseSnapshot . CachingDatabaseMetaData getMetaData ( ) throws SQLException { } public class CachingDatabaseMetaData { private DatabaseMetaData databaseMetaData ; private Database database ; public CachingDatabaseMetaData ( Database database , DatabaseMetaData metaData ) { } public DatabaseMetaData getDatabaseMetaData ( ) { } public List < CachedRow > getForeignKeys ( final String catalogName , final String schemaName , final String tableName , final String fkName ) throws DatabaseException { return getResultSetCache ( "getImportedKeys" ) . get ( new ResultSetCache . UnionResultSetExtractor ( database ) { @ Override public RowData rowKeyParameters ( CachedRow row ) { return new ResultSetCache . RowData ( row . getString ( "FKTABLE_CAT" ) , row . getString ( "FKTABLE_SCHEM" ) , database , row . getString ( "FKTABLE_NAME" ) , row . getString ( "FK_NAME" ) ) ; } @ Override public RowData wantedKeyParameters ( ) { return new ResultSetCache . RowData ( catalogName , schemaName , database , tableName , fkName ) ; } @ Override public List < CachedRow > fastFetch ( ) throws SQLException , DatabaseException { CatalogAndSchema catalogAndSchema = new CatalogAndSchema ( catalogName , schemaName ) . customize ( database ) ; List < CachedRow > returnList = new ArrayList < CachedRow > ( ) ; List < String > tables = new ArrayList < String > ( ) ; String jdbcCatalogName = ( ( AbstractJdbcDatabase ) ( database ) ) . getJdbcCatalogName ( catalogAndSchema ) ; String jdbcSchemaName = ( ( AbstractJdbcDatabase ) ( database ) ) . getJdbcSchemaName ( catalogAndSchema ) ; if ( ( database ) instanceof DB2Database ) { String sql = getDB2Sql ( jdbcSchemaName ) ; if ( tableName != null ) { sql = sql . replace ( "<seq2seq4repair_space>ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>" , ( ( "<seq2seq4repair_space>AND<seq2seq4repair_space>fk_col.tabname='" + tableName ) + "'<seq2seq4repair_space>ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>" ) ) ; } return executeAndExtract ( sql , database ) ; } else { if ( tableName == null ) { for ( CachedRow row : getTables ( jdbcCatalogName , jdbcSchemaName , null ) ) { tables . add ( row . getString ( "TABLE_NAME" ) ) ; } } else { tables . add ( tableName ) ; } for ( String foundTable : tables ) { if ( ( database ) instanceof OracleDatabase ) { throw new RuntimeException ( "Should<seq2seq4repair_space>have<seq2seq4repair_space>bulk<seq2seq4repair_space>selected" ) ; } else { returnList . addAll ( extract ( databaseMetaData . getImportedKeys ( jdbcCatalogName , jdbcSchemaName , foundTable ) ) ) ; } } return returnList ; } } @ Override public List < CachedRow > bulkFetch ( ) throws SQLException , DatabaseException { if ( ( database ) instanceof OracleDatabase ) { CatalogAndSchema catalogAndSchema = new CatalogAndSchema ( catalogName , schemaName ) . customize ( database ) ; String jdbcSchemaName = ( ( AbstractJdbcDatabase ) ( database ) ) . getJdbcSchemaName ( catalogAndSchema ) ; <START_BUG> String sql = ( ( ( ( ( "SELECT<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<seq2seq4repair_space>NULL<seq2seq4repair_space>AS<seq2seq4repair_space>pktable_cat,<seq2seq4repair_space>" + "<seq2seq4repair_space>p.owner<seq2seq4repair_space>as<seq2seq4repair_space>pktable_schem,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>p.table_name<seq2seq4repair_space>as<seq2seq4repair_space>pktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>pc.column_name<seq2seq4repair_space>as<seq2seq4repair_space>pkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>NULL<seq2seq4repair_space>as<seq2seq4repair_space>fktable_cat,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.owner<seq2seq4repair_space>as<seq2seq4repair_space>fktable_schem,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.table_name<seq2seq4repair_space>as<seq2seq4repair_space>fktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fc.column_name<seq2seq4repair_space>as<seq2seq4repair_space>fkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fc.position<seq2seq4repair_space>as<seq2seq4repair_space>key_seq,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>NULL<seq2seq4repair_space>as<seq2seq4repair_space>update_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode<seq2seq4repair_space>(f.delete_rule,<seq2seq4repair_space>'CASCADE',<seq2seq4repair_space>0,<seq2seq4repair_space>'SET<seq2seq4repair_space>NULL',<seq2seq4repair_space>2,<seq2seq4repair_space>1)<seq2seq4repair_space>as<seq2seq4repair_space>delete_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.constraint_name<seq2seq4repair_space>as<seq2seq4repair_space>fk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>p.constraint_name<seq2seq4repair_space>as<seq2seq4repair_space>pk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode(f.deferrable,<seq2seq4repair_space>'DEFERRABLE',<seq2seq4repair_space>5,<seq2seq4repair_space>'NOT<seq2seq4repair_space>DEFERRABLE',<seq2seq4repair_space>7,<seq2seq4repair_space>'DEFERRED',<seq2seq4repair_space>6)<seq2seq4repair_space>deferrability<seq2seq4repair_space>" ) + "FROM<seq2seq4repair_space>" ) + "all_cons_columns<seq2seq4repair_space>pc<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_constraints<seq2seq4repair_space>p<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>pc.owner<seq2seq4repair_space>=<seq2seq4repair_space>p.owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>pc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>p.constraint_name<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_constraints<seq2seq4repair_space>f<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>pc.owner<seq2seq4repair_space>=<seq2seq4repair_space>f.r_owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>pc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>f.r_constraint_name<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_cons_columns<seq2seq4repair_space>fc<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>fc.owner<seq2seq4repair_space>=<seq2seq4repair_space>f.owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>fc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>f.constraint_name<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>fc.position<seq2seq4repair_space>=<seq2seq4repair_space>pc.position<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>p.owner<seq2seq4repair_space>=<seq2seq4repair_space>'" ) ) + jdbcSchemaName ) + "'<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>p.constraint_type<seq2seq4repair_space>in<seq2seq4repair_space>('P',<seq2seq4repair_space>'U')<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>f.constraint_type<seq2seq4repair_space>=<seq2seq4repair_space>'R'" ) + "ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>fktable_schem,<seq2seq4repair_space>fktable_name,<seq2seq4repair_space>key_seq" ; <END_BUG> return executeAndExtract ( sql , database ) ; } else if ( ( database ) instanceof DB2Database ) { CatalogAndSchema catalogAndSchema = new CatalogAndSchema ( catalogName , schemaName ) . customize ( database ) ; String jdbcSchemaName = ( ( AbstractJdbcDatabase ) ( database ) ) . getJdbcSchemaName ( catalogAndSchema ) ; String sql = getDB2Sql ( jdbcSchemaName ) ; return executeAndExtract ( sql , database ) ; } else { throw new RuntimeException ( "Cannot<seq2seq4repair_space>bulk<seq2seq4repair_space>select" ) ; } } protected String getDB2Sql ( String jdbcSchemaName ) { return ( ( ( ( "SELECT<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<seq2seq4repair_space>pk_col.tabschema<seq2seq4repair_space>AS<seq2seq4repair_space>pktable_cat,<seq2seq4repair_space>" + "<seq2seq4repair_space>pk_col.tabname<seq2seq4repair_space>as<seq2seq4repair_space>pktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>pk_col.colname<seq2seq4repair_space>as<seq2seq4repair_space>pkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fk_col.tabschema<seq2seq4repair_space>as<seq2seq4repair_space>fktable_cat,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fk_col.tabname<seq2seq4repair_space>as<seq2seq4repair_space>fktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fk_col.colname<seq2seq4repair_space>as<seq2seq4repair_space>fkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fk_col.colseq<seq2seq4repair_space>as<seq2seq4repair_space>key_seq,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode<seq2seq4repair_space>(ref.updaterule,<seq2seq4repair_space>'A',<seq2seq4repair_space>3,<seq2seq4repair_space>'R',<seq2seq4repair_space>1,<seq2seq4repair_space>1)<seq2seq4repair_space>as<seq2seq4repair_space>update_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode<seq2seq4repair_space>(ref.deleterule,<seq2seq4repair_space>'A',<seq2seq4repair_space>3,<seq2seq4repair_space>'C',<seq2seq4repair_space>0,<seq2seq4repair_space>'N',<seq2seq4repair_space>2,<seq2seq4repair_space>'R',<seq2seq4repair_space>1,<seq2seq4repair_space>1)<seq2seq4repair_space>as<seq2seq4repair_space>delete_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>ref.constname<seq2seq4repair_space>as<seq2seq4repair_space>fk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>ref.refkeyname<seq2seq4repair_space>as<seq2seq4repair_space>pk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>7<seq2seq4repair_space>as<seq2seq4repair_space>deferrability<seq2seq4repair_space>" ) + "FROM<seq2seq4repair_space>" ) + "syscat.references<seq2seq4repair_space>ref<seq2seq4repair_space>" ) + "join<seq2seq4repair_space>syscat.keycoluse<seq2seq4repair_space>fk_col<seq2seq4repair_space>on<seq2seq4repair_space>ref.constname=fk_col.constname<seq2seq4repair_space>and<seq2seq4repair_space>ref.tabschema=fk_col.tabschema<seq2seq4repair_space>and<seq2seq4repair_space>ref.tabname=fk_col.tabname<seq2seq4repair_space>" ) + "join<seq2seq4repair_space>syscat.keycoluse<seq2seq4repair_space>pk_col<seq2seq4repair_space>on<seq2seq4repair_space>ref.refkeyname=pk_col.constname<seq2seq4repair_space>and<seq2seq4repair_space>ref.reftabschema=pk_col.tabschema<seq2seq4repair_space>and<seq2seq4repair_space>ref.reftabname=pk_col.tabname<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>ref.tabschema<seq2seq4repair_space>=<seq2seq4repair_space>'" ) ) + jdbcSchemaName ) + "'<seq2seq4repair_space>" ) + "and<seq2seq4repair_space>pk_col.colseq=fk_col.colseq<seq2seq4repair_space>" ) + "ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>fk_col.colseq" ; } @ Override boolean shouldBulkSelect ( String schemaKey , ResultSetCache resultSetCache ) { if ( ( database ) instanceof DB2Database ) { return super . shouldBulkSelect ( schemaKey , resultSetCache ) ; } else { return ( database ) instanceof OracleDatabase ; } } } ) ; } public List < CachedRow > getIndexInfo ( final String catalogName , final String schemaName , final String tableName , final String indexName ) throws DatabaseException { } public List < CachedRow > getColumns ( final String catalogName , final String schemaName , final String tableName , final String columnName ) throws SQLException , DatabaseException { } public List < CachedRow > getTables ( final String catalogName , final String schemaName , final String table ) throws SQLException , DatabaseException { } public List < CachedRow > getViews ( final String catalogName , final String schemaName , final String view ) throws SQLException , DatabaseException { } public List < CachedRow > getPrimaryKeys ( final String catalogName , final String schemaName , final String table ) throws SQLException , DatabaseException { }

Fix:
String sql = ( ( ( ( ( "SELECT<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<seq2seq4repair_space>NULL<seq2seq4repair_space>AS<seq2seq4repair_space>pktable_cat,<seq2seq4repair_space>" + "<seq2seq4repair_space>p.owner<seq2seq4repair_space>as<seq2seq4repair_space>pktable_schem,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>p.table_name<seq2seq4repair_space>as<seq2seq4repair_space>pktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>pc.column_name<seq2seq4repair_space>as<seq2seq4repair_space>pkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>NULL<seq2seq4repair_space>as<seq2seq4repair_space>fktable_cat,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.owner<seq2seq4repair_space>as<seq2seq4repair_space>fktable_schem,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.table_name<seq2seq4repair_space>as<seq2seq4repair_space>fktable_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fc.column_name<seq2seq4repair_space>as<seq2seq4repair_space>fkcolumn_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>fc.position<seq2seq4repair_space>as<seq2seq4repair_space>key_seq,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>NULL<seq2seq4repair_space>as<seq2seq4repair_space>update_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode<seq2seq4repair_space>(f.delete_rule,<seq2seq4repair_space>'CASCADE',<seq2seq4repair_space>0,<seq2seq4repair_space>'SET<seq2seq4repair_space>NULL',<seq2seq4repair_space>2,<seq2seq4repair_space>1)<seq2seq4repair_space>as<seq2seq4repair_space>delete_rule,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>f.constraint_name<seq2seq4repair_space>as<seq2seq4repair_space>fk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>p.constraint_name<seq2seq4repair_space>as<seq2seq4repair_space>pk_name,<seq2seq4repair_space>" ) + "<seq2seq4repair_space>decode(f.deferrable,<seq2seq4repair_space>'DEFERRABLE',<seq2seq4repair_space>5,<seq2seq4repair_space>'NOT<seq2seq4repair_space>DEFERRABLE',<seq2seq4repair_space>7,<seq2seq4repair_space>'DEFERRED',<seq2seq4repair_space>6)<seq2seq4repair_space>deferrability<seq2seq4repair_space>" ) + "FROM<seq2seq4repair_space>" ) + "all_cons_columns<seq2seq4repair_space>pc<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_constraints<seq2seq4repair_space>p<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>pc.owner<seq2seq4repair_space>=<seq2seq4repair_space>p.owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>pc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>p.constraint_name<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_constraints<seq2seq4repair_space>f<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>pc.owner<seq2seq4repair_space>=<seq2seq4repair_space>f.r_owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>pc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>f.r_constraint_name<seq2seq4repair_space>" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>all_cons_columns<seq2seq4repair_space>fc<seq2seq4repair_space>" ) + "ON<seq2seq4repair_space>fc.owner<seq2seq4repair_space>=<seq2seq4repair_space>f.owner<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>fc.constraint_name<seq2seq4repair_space>=<seq2seq4repair_space>f.constraint_name<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>fc.position<seq2seq4repair_space>=<seq2seq4repair_space>pc.position<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>f.owner<seq2seq4repair_space>=<seq2seq4repair_space>'" ) ) + jdbcSchemaName ) + "'<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>p.constraint_type<seq2seq4repair_space>in<seq2seq4repair_space>('P',<seq2seq4repair_space>'U')<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>f.constraint_type<seq2seq4repair_space>=<seq2seq4repair_space>'R'" ) + "ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>fktable_schem,<seq2seq4repair_space>fktable_name,<seq2seq4repair_space>key_seq" ;