Skip to content

Commit

Permalink
fix: bug in not scalable case for drop table and export
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Dec 1, 2023
1 parent be7587d commit bc3a919
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,19 @@ public void dropTable(String clientTable) {
}

public void dropTable(int connectionIndex, String clientTable) {
if (StringUtils.isBlank(clientTable)) {
return;
}
UtilitaireDao.get(connectionIndex).dropTable(connection, clientTable);
}

public void dropTable(TableToRetrieve table) {

dropTable(table.getTableName());

if (table.getNod().equals(ArcDatabase.EXECUTOR)) {
int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods();
for (int executorConnectionId = ArcDatabase.EXECUTOR.getIndex(); executorConnectionId < ArcDatabase.EXECUTOR
.getIndex() + numberOfExecutorNods; executorConnectionId++) {
dropTable(executorConnectionId, table.getTableName());
}
} else {
dropTable(0, table.getTableName());
}

}
Expand Down Expand Up @@ -553,10 +550,6 @@ public void deleteFromTrackTable(String tableName) throws ArcException {
UtilitaireDao.get(0).executeImmediate(connection, query);
}

public void setConnection(Connection connection) {
this.connection = connection;
}

public long getTimestamp() {
return timestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
public class ServiceDao {

public static void execQueryExportDataToResponse(OutputStream os, TableToRetrieve table, boolean csvExportFormat) throws ArcException {


int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods();

if (csvExportFormat)
{
try(GZIPOutputStream goz=new GZIPOutputStream(os);)
{
if (table.getNod().equals(ArcDatabase.EXECUTOR))

if (table.getNod().equals(ArcDatabase.EXECUTOR) && numberOfExecutorNods>0)
{
int numberOfExecutorNods = ArcDatabase.numberOfExecutorNods();
for (int executorConnectionId = ArcDatabase.EXECUTOR.getIndex(); executorConnectionId < ArcDatabase.EXECUTOR
.getIndex() + numberOfExecutorNods; executorConnectionId++) {
UtilitaireDao.get(executorConnectionId).exporting(null, table.getTableName(), goz, csvExportFormat);
Expand All @@ -36,7 +38,8 @@ public static void execQueryExportDataToResponse(OutputStream os, TableToRetriev
}
else
{
if (table.getNod().equals(ArcDatabase.EXECUTOR))
// binary transfer cannot be scaled
if (numberOfExecutorNods>0)
{
throw new ArcException(ArcExceptionMessage.WS_RETRIEVE_DATA_SCALABLE_TABLE_MUST_BE_EXPORT_IN_CSV);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import fr.insee.arc.core.dataobjects.ArcDatabase;
import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder;
import fr.insee.arc.core.dataobjects.ViewEnum;
import fr.insee.arc.utils.dao.SQL;
import fr.insee.arc.utils.dao.UtilitaireDao;
import fr.insee.arc.utils.exception.ArcException;
Expand Down

0 comments on commit bc3a919

Please sign in to comment.