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:
@ -1989,6 +1989,7 @@ bool sendExecutionPlanToExeMgr(sm::cpsm_conhdl_t* hndl, ByteStream::quadbyte qb,
|
||||
|
||||
} // namespace
|
||||
|
||||
// Called only for ANALYZE TABLE
|
||||
int ha_mcs_impl_analyze(THD* thd, TABLE* table)
|
||||
{
|
||||
uint32_t sessionID = execplan::CalpontSystemCatalog::idb_tid2sid(thd->thread_id);
|
||||
@ -2685,6 +2686,26 @@ int ha_mcs_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
|
||||
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||
}
|
||||
|
||||
if (thd->lex->analyze_stmt && ci->cal_conn_hndl && ci->cal_conn_hndl->exeMgr)
|
||||
{
|
||||
// The ANALYZE statement leaves ExeMgr hanging. This clears it up.
|
||||
ci->cal_conn_hndl->exeMgr->read(); // Ignore the returned buffer
|
||||
ByteStream msg;
|
||||
ByteStream::quadbyte qb = 1; // Tell PrimProc front session to eat all the rows
|
||||
msg << qb;
|
||||
ci->cal_conn_hndl->exeMgr->write(msg);
|
||||
// This is the command to start sending return values. because we previously sent the swallow
|
||||
// rows command, there won't be anything useful coming back, but it needs this to flush internal queues.
|
||||
qb = 5; // Read the result data.
|
||||
msg.reset();
|
||||
msg << qb;
|
||||
ci->cal_conn_hndl->exeMgr->write(msg);
|
||||
qb = 0; // End the query
|
||||
msg.reset();
|
||||
msg << qb;
|
||||
ci->cal_conn_hndl->exeMgr->write(msg);
|
||||
}
|
||||
|
||||
if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD)
|
||||
{
|
||||
force_close_fep_conn(thd, ci);
|
||||
@ -4813,7 +4834,7 @@ int ha_mcs_impl_group_by_end(TABLE* table)
|
||||
* Execute the query and saves derived table query.
|
||||
* There is an extra handler argument so I ended up with a
|
||||
* new init function. The code is a copy of
|
||||
* ha_mcs_impl_rnd_init() mostly.
|
||||
* impl_rnd_init() mostly.
|
||||
* PARAMETERS:
|
||||
* mcs_handler_info* pnt to an envelope struct
|
||||
* TABLE* table - dest table to put the results into
|
||||
|
Reference in New Issue
Block a user