Skip to content

Commit 5a6ed17

Browse files
committed
Bug #28047970 - WARNINGS NOT BEING VISIBLE AS THEY SHOULD BE
When warnings are accessed, complete server reply is processed and results are stored in the cache.
1 parent 02c36db commit 5a6ed17

File tree

5 files changed

+48
-36
lines changed

5 files changed

+48
-36
lines changed

common/result.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ inline
11371137
unsigned Result_impl::get_warning_count() const
11381138
{
11391139
auto self = const_cast<Result_impl*>(this);
1140+
self->store_all_results();
11401141
return self->entry_count(cdk::api::Severity::WARNING);
11411142
}
11421143

devapi/result.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ auto Result_detail::get_warning(size_t pos) -> Warning
542542
if (!common::check_num_limits<unsigned>(pos))
543543
throw std::out_of_range("No diagnostic entry at position ...");
544544

545+
get_warning_count();
545546
auto &impl = get_impl();
546547
auto &it = impl.get_entries(cdk::api::Severity::WARNING);
547548
size_t curr = SIZE_MAX;

devapi/tests/first-t.cc

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -565,56 +565,68 @@ TEST_F(First, warnings_multi_rset)
565565

566566
mysqlx::Session &sess = get_sess();
567567

568-
sess.createSchema("test", true);
568+
get_sess().createSchema("test", true);
569569

570-
sess.sql("DROP PROCEDURE IF EXISTS test.Get").execute();
570+
sql("DROP PROCEDURE IF EXISTS test.p");
571571

572-
sess.sql("CREATE PROCEDURE test.Get()"\
573-
"BEGIN"\
574-
" SELECT 1/0;"\
575-
" SELECT 1/0;"\
576-
"END"
577-
)
578-
.execute();
572+
sql(
573+
"CREATE PROCEDURE test.p()"
574+
"BEGIN"
575+
" SELECT 1;"
576+
" SELECT 1/0;"
577+
" SELECT 2/'a';"
578+
"END"
579+
);
579580

581+
{
582+
SqlResult res = sql("call test.p()");
580583

581-
SqlResult res = sess.sql("call test.Get()").execute();
584+
std::vector<Row> rows = res.fetchAll();
582585

583-
std::vector<Row> rows = res.fetchAll();
586+
/*
587+
We are in the middle of processing query result (only
588+
1st rset has been consumed).
589+
*/
584590

585-
/*
586-
We are in the middle of processing query result (only
587-
1st rset has been consumed. Thus getWarnings() might not
588-
report all the warnings yet. The protocol does not specify
589-
when during result transfer the warnings will be reported.
590-
*/
591+
EXPECT_EQ(2, res.getWarningsCount());
591592

592-
EXPECT_NO_THROW(res.getWarningsCount());
593-
EXPECT_NO_THROW(res.getWarnings());
593+
std::vector<Warning> warnings = res.getWarnings();
594+
EXPECT_EQ(2, warnings.size());
594595

595-
res.nextResult();
596+
for(auto warn : warnings)
597+
{
598+
std::cout << warn << std::endl;
599+
}
600+
}
596601

597-
rows = res.fetchAll();
602+
{
603+
// getWarnings() without getWarningsCount()
598604

599-
/*
600-
We have consumed whole query results so all warnings
601-
should be available now.
602-
*/
605+
SqlResult res = sql("call test.p()");
603606

604-
std::vector<Warning> warnings = res.getWarnings();
607+
unsigned cnt = 0;
608+
for (Warning warn : res.getWarnings())
609+
{
610+
std::cout << warn << std::endl;
611+
cnt++;
612+
}
613+
EXPECT_EQ(2, cnt);
605614

606-
// Bug #28047970
607-
SKIP_TEST("Bug #28047970");
615+
// Check that results are still available.
608616

609-
EXPECT_EQ(1, warnings.size());
610-
EXPECT_EQ(1, res.getWarningsCount());
617+
EXPECT_EQ(1, res.fetchOne()[0].get<int>());
618+
}
611619

612-
for(auto warn : warnings)
613620
{
614-
std::cout << warn << std::endl;
621+
// getWarning() without getWarningsCount()
622+
623+
SqlResult res = sql("call test.p()");
624+
625+
EXPECT_NE(0, res.getWarning(0).getCode());
615626
}
616627
}
617628

629+
618630
TEST_F(First, parser_xplugin)
619631
{
620632

include/mysqlx/devapi/detail/result.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class PUBLIC_API Result_detail
160160

161161
WarningList get_warnings()
162162
{
163-
assert(m_impl);
163+
get_warning_count();
164164
return { *this };
165165
}
166166

xapi/tests/xapi-t.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ TEST_F(xapi, compression_test_doc)
221221
mysqlx_session_close(sess);
222222
}
223223

224+
224225
TEST_F(xapi, free_test)
225226
{
226227
SKIP_IF_NO_XPLUGIN
@@ -656,9 +657,6 @@ TEST_F(xapi, warnings_test)
656657
/* All rows have to be read before getting warnings */
657658
mysqlx_store_result(res, NULL);
658659

659-
// Bug #28047970
660-
SKIP_TEST("Bug #28047970");
661-
662660
EXPECT_EQ(7, mysqlx_result_warning_count(res));
663661
warn_count = 0;
664662
while ((warn = mysqlx_result_next_warning(res)) != NULL)

0 commit comments

Comments
 (0)