Skip to content

Commit

Permalink
0004874: SQL Server and Sybase dialects should make sure that SET
Browse files Browse the repository at this point in the history
NOCOUNT OFF is set on each database connection
  • Loading branch information
catherinequamme committed Nov 7, 2022
1 parent d497bb0 commit 91f7e61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -39,6 +39,7 @@
import org.jumpmind.db.sql.JdbcSqlTransaction;
import org.jumpmind.db.sql.SqlException;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.SymmetricException;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.TableConstants;
import org.jumpmind.symmetric.db.AbstractSymmetricDialect;
Expand All @@ -57,7 +58,9 @@ public class AseSymmetricDialect extends AbstractSymmetricDialect implements ISy
static final String SQL_DROP_FUNCTION = "drop function dbo.$(functionName)";
static final String SQL_FUNCTION_INSTALLED = "select count(object_name(object_id('$(functionName)')))";
static final String SQL_PAGE_SIZE = "select @@maxpagesize";
static final String SQL_NOCOUNT = "select @@OPTIONS & 512";
private int pageSize = 2048;
private int noCount = 0;

public AseSymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
Expand All @@ -72,6 +75,15 @@ public AseSymmetricDialect(IParameterService parameterService, IDatabasePlatform
} catch (Exception e) {
log.debug("Unable to query page size", e);
}
try {
noCount = platform.getSqlTemplate().queryForInt(SQL_NOCOUNT);
} catch (Exception se) {
log.warn("Unable to query nocount", se);
}
if (noCount != 0) {
throw new SymmetricException("Incompatible setting for nocount detected. Add the following to your\r\n"
+ "engine properties file: db.init.sql=set nocount off");
}
}

@Override
Expand Down
Expand Up @@ -77,7 +77,7 @@ public MsSqlSymmetricDialect(IParameterService parameterService, IDatabasePlatfo
}
if (noCount != 0) {
throw new SymmetricException("Incompatible setting for nocount detected. Add the following to your\r\n"
+ "engine properties file: db.init.sql=set no count off");
+ "engine properties file: db.init.sql=set nocount off");
}
}

Expand Down

0 comments on commit 91f7e61

Please sign in to comment.