Skip to content

Commit ecae40c

Browse files
committed
Fix when using Empty BaseResult which has m_sess = NULL (Bug #25515964 )
1 parent 17f150e commit ecae40c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

devapi/result.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,10 +1345,14 @@ void mysqlx::internal::BaseResult::init(mysqlx::internal::BaseResult &&init_)
13451345

13461346
m_sess = init_.m_sess;
13471347

1348-
// first deregister init result, since it registered itself on ctor
1349-
// otherwise it would trigger cache, and we are moving Result object
1350-
m_sess->deregister_result(&init_);
1351-
m_sess->register_result(this);
1348+
//On empty results, m_sess is NULL, so don't do anything with it!
1349+
if (m_sess)
1350+
{
1351+
// first deregister init result, since it registered itself on ctor
1352+
// otherwise it would trigger cache, and we are moving Result object
1353+
m_sess->deregister_result(&init_);
1354+
m_sess->register_result(this);
1355+
}
13521356

13531357
}
13541358

devapi/tests/crud-t.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,13 @@ TEST_F(Crud, table)
848848

849849
std::vector<string> cols = {"_id"};
850850

851+
//Inserting empty list
852+
853+
//Bug #25515964
854+
//Adding empty list shouldn't do anything
855+
std::list<Row> rList;
856+
tbl.insert(cols, "age", string("name")).rows(rList).rows(rList).execute();
857+
851858
//Using containers (vectors, const char* and string)
852859

853860
auto insert = tbl.insert(cols, "age", string("name"));

0 commit comments

Comments
 (0)