Skip to content

Commit

Permalink
0004978: Binary primary keys will not delete as part of conflict
Browse files Browse the repository at this point in the history
resolution
  • Loading branch information
joshhicks committed May 6, 2021
1 parent f7e1328 commit 359d4ba
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
Expand Up @@ -55,7 +55,7 @@ public interface IDdlReader {

public Collection<ForeignKey> getExportedKeys(Table table);

public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited);
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding);

public List<TableRow> getImportedForeignTableRows(List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding);

Expand Down
Expand Up @@ -128,7 +128,7 @@ public Collection<ForeignKey> getExportedKeys(Table table) {
}

@Override
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited) {
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding) {
return null;
}

Expand Down
Expand Up @@ -75,7 +75,7 @@ public Collection<ForeignKey> getExportedKeys(Table table) {
}

@Override
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited) {
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding) {
return null;
}

Expand Down
Expand Up @@ -72,7 +72,7 @@ public Collection<ForeignKey> getExportedKeys(Table table) {
}

@Override
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited) {
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding) {
return null;
}

Expand Down
Expand Up @@ -285,7 +285,7 @@ public Collection<ForeignKey> getExportedKeys(Table table) {
}

@Override
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited) {
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding) {
return null;
}

Expand Down
Expand Up @@ -818,7 +818,7 @@ private void deleteRandomRecord(ISqlTransaction tran, Table table) {
private void deleteForeignKeyChildren(ISqlTransaction tran, Table table, Row row) {
List<TableRow> tableRows = new ArrayList<TableRow>();
tableRows.add(new TableRow(table, row, null, null, null));
tableRows = platform.getDdlReader().getExportedForeignTableRows(tran, tableRows, new HashSet<TableRow>());
tableRows = platform.getDdlReader().getExportedForeignTableRows(tran, tableRows, new HashSet<TableRow>(), BinaryEncoding.HEX);
if (!tableRows.isEmpty()) {
Collections.reverse(tableRows);
Set<TableRow> visited = new HashSet<TableRow>();
Expand Down
Expand Up @@ -558,7 +558,7 @@ protected boolean deleteForeignKeyChildren(IDatabasePlatform platform, ISqlTempl
tableRows.add(new TableRow(targetTable, values, null, null, null));
List<TableRow> foreignTableRows = doInTransaction(platform, databaseWriter, new ITransactionCallback<List<TableRow>>() {
public List<TableRow> execute(ISqlTransaction transaction) {
return platform.getDdlReader().getExportedForeignTableRows(transaction, tableRows, new HashSet<TableRow>());
return platform.getDdlReader().getExportedForeignTableRows(transaction, tableRows, new HashSet<TableRow>(), databaseWriter.getBatch().getBinaryEncoding());
}
});

Expand Down
Expand Up @@ -1699,7 +1699,7 @@ public Collection<ForeignKey> execute(Connection connection) throws SQLException
}

@Override
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited) {
public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, List<TableRow> tableRows, Set<TableRow> visited, BinaryEncoding encoding) {
List<TableRow> fkDepList = new ArrayList<TableRow>();
for (TableRow tableRow : tableRows) {
if (!visited.contains(tableRow)) {
Expand Down Expand Up @@ -1730,7 +1730,7 @@ public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, L
DmlStatement selectSt = platform.createDmlStatement(DmlType.SELECT, foreignTable.getCatalog(),
foreignTable.getSchema(), foreignTable.getName(), keyColumns,
foreignTable.getColumns(), nullValues, null);
Object[] selectValues = platform.getObjectValues(BinaryEncoding.HEX, selectRow.toStringArray(selectRow.keySet().toArray(new String[0])),
Object[] selectValues = platform.getObjectValues(encoding, selectRow.toStringArray(selectRow.keySet().toArray(new String[0])),
keyColumns);
List<Row> rows = transaction.query(selectSt.getSql(), new RowMapper(), selectValues, selectSt.getTypes());

Expand Down Expand Up @@ -1759,7 +1759,7 @@ public List<TableRow> getExportedForeignTableRows(ISqlTransaction transaction, L
log.debug("Foreign table '{}' not found for foreign key '{}'", fk.getForeignTableName(), fk.getName());
}
if (fkDepList.size() > 0) {
fkDepList.addAll(getExportedForeignTableRows(transaction, fkDepList, visited));
fkDepList.addAll(getExportedForeignTableRows(transaction, fkDepList, visited, encoding));
}
}
}
Expand Down

0 comments on commit 359d4ba

Please sign in to comment.