You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-1170 Fix ANALYZE to not error (#2682)
Analyze needs to be completed differently than a normal query. In server, when an ANALYZE is seen, it calls init_scan() immediatly followed by end_scan(). This leaves the sqlfrontendsession (ExeMgr) in a state where it expects to return rows. This patch fixes end_scan to clean this up via reads and writes to get everything back in synch. ANALYZE should display the number of rows to be displayed if the query were run normally. We have that information available, but no way to return it. A modification to server side to ask for that in the handler is required. This patch also includes a beautification of sqlfrontsessionthread.cpp since it looked bad. The important change is at line 774 if (!swallowRows) which short circuits the actual return of data
This commit is contained in:
@ -420,6 +420,11 @@ void SQLFrontSessionThread::operator()()
|
||||
analyzeTableHandleStats(bs);
|
||||
continue;
|
||||
}
|
||||
else if (qb == 0)
|
||||
{
|
||||
// 0 => Nothing left to do. Sent by rnd_end() just to be sure.
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gDebug)
|
||||
@ -765,62 +770,64 @@ void SQLFrontSessionThread::operator()()
|
||||
bs << errInfo->errorMsg(jl->status());
|
||||
}
|
||||
|
||||
try // @bug2244: try/catch around fIos.write() calls projecting rows
|
||||
if (!swallowRows)
|
||||
{
|
||||
if (csep.traceFlags() & execplan::CalpontSelectExecutionPlan::TRACE_NO_ROWS3)
|
||||
try // @bug2244: try/catch around fIos.write() calls projecting rows
|
||||
{
|
||||
// Skip the write to the front end until the last empty band. Used to time queries
|
||||
// through without any front end waiting.
|
||||
if (tableOID < 3000 || rowCount == 0)
|
||||
if (csep.traceFlags() & execplan::CalpontSelectExecutionPlan::TRACE_NO_ROWS3)
|
||||
{
|
||||
// Skip the write to the front end until the last empty band. Used to time queries
|
||||
// through without any front end waiting.
|
||||
if (tableOID < 3000 || rowCount == 0)
|
||||
fIos.write(bs);
|
||||
}
|
||||
else
|
||||
{
|
||||
fIos.write(bs);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
fIos.write(bs);
|
||||
msgHandler.stop();
|
||||
std::ostringstream errMsg;
|
||||
errMsg << "ExeMgr: error projecting rows "
|
||||
"for tableOID: "
|
||||
<< tableOID << "; rowCnt: " << rowCount << "; prevTotRowCnt: " << totalRowCount << "; "
|
||||
<< ex.what();
|
||||
jl->abort();
|
||||
|
||||
while (rowCount)
|
||||
rowCount = jl->projectTable(tableOID, bs);
|
||||
|
||||
if (tableOID == 100 && msgHandler.aborted())
|
||||
{
|
||||
/* TODO: modularize the cleanup code, as well as
|
||||
* the rest of this fcn */
|
||||
|
||||
decThreadCntPerSession(csep.sessionID() | 0x80000000);
|
||||
statementsRunningCount->decr(stmtCounted);
|
||||
fIos.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// std::cout << "connection drop\n";
|
||||
throw std::runtime_error(errMsg.str());
|
||||
}
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
msgHandler.stop();
|
||||
std::ostringstream errMsg;
|
||||
errMsg << "ExeMgr: error projecting rows "
|
||||
"for tableOID: "
|
||||
<< tableOID << "; rowCnt: " << rowCount << "; prevTotRowCnt: " << totalRowCount << "; "
|
||||
<< ex.what();
|
||||
jl->abort();
|
||||
|
||||
while (rowCount)
|
||||
rowCount = jl->projectTable(tableOID, bs);
|
||||
|
||||
if (tableOID == 100 && msgHandler.aborted())
|
||||
catch (...)
|
||||
{
|
||||
/* TODO: modularize the cleanup code, as well as
|
||||
* the rest of this fcn */
|
||||
std::ostringstream errMsg;
|
||||
msgHandler.stop();
|
||||
errMsg << "ExeMgr: unknown error projecting rows "
|
||||
"for tableOID: "
|
||||
<< tableOID << "; rowCnt: " << rowCount << "; prevTotRowCnt: " << totalRowCount;
|
||||
jl->abort();
|
||||
|
||||
decThreadCntPerSession(csep.sessionID() | 0x80000000);
|
||||
statementsRunningCount->decr(stmtCounted);
|
||||
fIos.close();
|
||||
return;
|
||||
while (rowCount)
|
||||
rowCount = jl->projectTable(tableOID, bs);
|
||||
|
||||
throw std::runtime_error(errMsg.str());
|
||||
}
|
||||
|
||||
// std::cout << "connection drop\n";
|
||||
throw std::runtime_error(errMsg.str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::ostringstream errMsg;
|
||||
msgHandler.stop();
|
||||
errMsg << "ExeMgr: unknown error projecting rows "
|
||||
"for tableOID: "
|
||||
<< tableOID << "; rowCnt: " << rowCount << "; prevTotRowCnt: " << totalRowCount;
|
||||
jl->abort();
|
||||
|
||||
while (rowCount)
|
||||
rowCount = jl->projectTable(tableOID, bs);
|
||||
|
||||
throw std::runtime_error(errMsg.str());
|
||||
}
|
||||
|
||||
totalRowCount += rowCount;
|
||||
totalBytesSent += bs.length();
|
||||
|
||||
|
Reference in New Issue
Block a user