Skip to content

Commit 15a3a84

Browse files
committed
Bug#35000027 X DevAPI Don't clone Executable unless
needed If Executable object is copied onto itself, it will not be cloned. Change-Id: Id417714a9d5834d1f839733e5fcbbca2da553e4a
1 parent 2da9977 commit 15a3a84

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

devapi/tests/bugs-t.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,3 +948,19 @@ TEST_F(Bugs, Bug33352469)
948948
remove.bind("id", "2").execute();
949949
EXPECT_EQ(0U, coll.find().execute().count());
950950
}
951+
952+
TEST_F(Bugs, Bug35000027)
953+
{
954+
auto coll = get_sess().getSchema("test").createCollection("coll", true);
955+
coll.remove("true").execute();
956+
size_t nr_docs = 10000;
957+
DbDoc doc(R"({"name":"foo", "bar": "baz" })");
958+
auto add_task = coll.add(doc);
959+
auto add_tast_2 = add_task.add(doc);
960+
for (size_t i = 2; i < nr_docs; ++i) {
961+
add_task = add_task.add(doc);
962+
add_tast_2 = add_tast_2.add(doc);
963+
}
964+
EXPECT_EQ(nr_docs, add_task.execute().getAffectedItemsCount());
965+
EXPECT_EQ(nr_docs, add_tast_2.execute().getAffectedItemsCount());
966+
}

include/mysqlx/devapi/executable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Executable
8989

9090
void reset(const Executable &other)
9191
{
92-
m_impl.reset(other.m_impl->clone());
92+
if (m_impl.get() != other.m_impl.get()) m_impl.reset(other.m_impl->clone());
9393
}
9494

9595
void reset(const Executable &&other)

0 commit comments

Comments
 (0)