Skip to content

Commit d8b3b51

Browse files
committed
CONCPP-167 Changing of auto_increment_increment with crashed the driver
This could happen only if rewriteBatchedStatements on - only in this case auto_increment_increment was tracked. If that actually happened, the bug in the session tracking processing caused unhandled exception that aborted the program. The test has been added.
1 parent 10dccad commit d8b3b51

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/protocol/capi/QueryProtocol.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,8 @@ namespace capi
15321532
case StateChange::SESSION_TRACK_SYSTEM_VARIABLES:
15331533
if (str.compare("auto_increment_increment") == 0)
15341534
{
1535+
mysql_session_track_get_next(connection, static_cast<enum capi::enum_session_state_type>(type), &value, &len);
1536+
str.assign(value, len);
15351537
autoIncrementIncrement= std::stoi(str);
15361538
results->setAutoIncrement(autoIncrementIncrement);
15371539
}

test/unit/classes/connection.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,6 +3553,29 @@ void connection::concpp163()
35533553
}
35543554

35553555

3556+
/* CONCPP-167 Changing of the session's auto_increment_increment causes unhandled exception */
3557+
void connection::concpp167()
3558+
{
3559+
sql::ConnectOptionsMap opts;
3560+
3561+
/* The connector asks the server to track the changes of the auto_increment_increment system
3562+
variable if the rewriteBatchedStatements option is on. Thus testing both kinds of connections */
3563+
for (auto rewriteBatchedStatements : {"false", "true"}) {
3564+
opts["rewriteBatchedStatements"]= rewriteBatchedStatements;
3565+
3566+
Connection c(getConnection(&opts));
3567+
Statement s(c->createStatement());
3568+
3569+
s->execute("SET SESSION auto_increment_increment=3");
3570+
3571+
/* The connection has to be usable, and the new value in effect */
3572+
ResultSet r(s->executeQuery("SELECT @@session.auto_increment_increment"));
3573+
ASSERT(r->next());
3574+
ASSERT_EQUALS(3, r->getInt(1));
3575+
}
3576+
}
3577+
3578+
35563579
void connection::setUp()
35573580
{
35583581
super::setUp();

test/unit/classes/connectiontest.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class connection : public unit_fixture
9595
TEST_CASE(concpp105_conn_concurrency);
9696
TEST_CASE(concpp112_connection_attributes);
9797
TEST_CASE(concpp163);
98+
TEST_CASE(concpp167);
9899
}
99100

100101
/**
@@ -293,6 +294,9 @@ class connection : public unit_fixture
293294
/* allowMultiQueries option, and other client capabilities controlled by connection options */
294295
void concpp163();
295296

297+
/* Changing of the session's auto_increment_increment */
298+
void concpp167();
299+
296300
void setUp();
297301
};
298302

0 commit comments

Comments
 (0)