Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions src/test/java/net/snowflake/client/jdbc/MultiStatementIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import net.snowflake.client.annotations.DontRunOnGithubActions;
import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.SFSession;
import net.snowflake.common.core.SqlState;
Expand Down Expand Up @@ -372,64 +371,4 @@ public void testMultiStmtLarge() throws SQLException {
}
}
}

@Test
public void testMultiStmtCountNotMatch() throws SQLException {
try (Statement statement = connection.createStatement()) {
SQLException e =
assertThrows(SQLException.class, () -> statement.execute("select 1; select 2; select 3"));
assertThat(e.getErrorCode(), is(8));

statement.unwrap(SnowflakeStatement.class).setParameter("MULTI_STATEMENT_COUNT", 3);
e = assertThrows(SQLException.class, () -> statement.execute("select 1"));
assertThat(e.getErrorCode(), is(8));

// 0 means any number of statement can be executed
statement.unwrap(SnowflakeStatement.class).setParameter("MULTI_STATEMENT_COUNT", 0);
statement.execute("select 1; select 2; select 3");
}
}

@Test
@DontRunOnGithubActions
public void testInvalidParameterCount() throws SQLException {
String userName = null;
String accountName = null;
try (Statement statement = connection.createStatement()) {

try (ResultSet rs = statement.executeQuery("select current_account_locator()")) {
assertTrue(rs.next());
accountName = rs.getString(1);
}

try (ResultSet rs = statement.executeQuery("select current_user()")) {
assertTrue(rs.next());
userName = rs.getString(1);
}

String[] testSuites = new String[5];
testSuites[0] =
String.format("alter account %s set " + "multi_statement_count = 20", accountName);
testSuites[1] =
String.format("alter account %s set " + "multi_statement_count = -1", accountName);
testSuites[2] = String.format("alter user %s set " + "multi_statement_count = 20", userName);
testSuites[3] = String.format("alter user %s set " + "multi_statement_count = -1", userName);
testSuites[4] = "alter session set " + "multi_statement_count = -1";

int[] expectedErrorCodes = new int[5];
expectedErrorCodes[0] = 1008;
expectedErrorCodes[1] = 1008;
expectedErrorCodes[2] = 1006;
expectedErrorCodes[3] = 1006;
expectedErrorCodes[4] = 1008;

statement.execute("use role accountadmin");
for (int i = 0; i < testSuites.length; i++) {
int finalI = i;
SQLException e =
assertThrows(SQLException.class, () -> statement.execute(testSuites[finalI]));
assertThat(e.getErrorCode(), is(expectedErrorCodes[i]));
}
}
}
}