mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-05-28 13:01:26 +03:00
MCOL-153 Add UDF function calgetsqlcount() which will display the number of sql statements active and the number waiting.
This commit is contained in:
parent
6694bc3d16
commit
0368dd487a
@ -20,6 +20,7 @@
|
||||
* $Id: ha_calpont_impl.cpp 9642 2013-06-24 14:57:42Z rdempsey $
|
||||
*/
|
||||
|
||||
//#define DEBUG_WALK_COND
|
||||
#include <my_config.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
@ -2294,6 +2295,70 @@ void calgetversion_deinit(UDF_INIT* initid)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
const char* calgetsqlcount(UDF_INIT* initid, UDF_ARGS* args,
|
||||
char* result, unsigned long* length,
|
||||
char* is_null, char* error)
|
||||
{
|
||||
sm::cpsm_conhdl_t* hndl;
|
||||
THD* thd = current_thd;
|
||||
if (!thd->infinidb_vtable.cal_conn_info)
|
||||
thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info());
|
||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(thd->infinidb_vtable.cal_conn_info);
|
||||
idbassert(ci != 0);
|
||||
|
||||
MessageQueueClient* mqc = 0;
|
||||
mqc = new MessageQueueClient("ExeMgr1");
|
||||
|
||||
ByteStream msg;
|
||||
ByteStream::quadbyte runningSql, waitingSql;
|
||||
ByteStream::quadbyte qb = 5;
|
||||
msg << qb;
|
||||
mqc->write(msg);
|
||||
|
||||
//get ExeMgr response
|
||||
msg.restart();
|
||||
msg = mqc->read();
|
||||
if (msg.length() == 0)
|
||||
{
|
||||
memcpy(result, "Lost connection to ExeMgr", *length);
|
||||
return result;
|
||||
}
|
||||
msg >> runningSql;
|
||||
msg >> waitingSql;
|
||||
delete mqc;
|
||||
|
||||
char ans[128];
|
||||
sprintf(ans, "Running SQL statements %d, Waiting SQL statments %d", runningSql, waitingSql);
|
||||
*length = strlen(ans);
|
||||
memcpy(result, ans, *length);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
my_bool calgetsqlcount_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
|
||||
{
|
||||
if (args->arg_count != 0)
|
||||
{
|
||||
strcpy(message,"CALGETSQLCOUNT() takes no arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void calgetsqlcount_deinit(UDF_INIT* initid)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} //extern "C"
|
||||
|
||||
int ha_calpont_impl_open(const char *name, int mode, uint32_t test_if_locked)
|
||||
|
@ -69,6 +69,7 @@ CREATE FUNCTION caldroppartitionsbyvalue RETURNS STRING SONAME 'libcalmysql.so';
|
||||
CREATE FUNCTION caldisablepartitionsbyvalue RETURNS STRING SONAME 'libcalmysql.so';
|
||||
CREATE FUNCTION calenablepartitionsbyvalue RETURNS STRING SONAME 'libcalmysql.so';
|
||||
CREATE FUNCTION calshowpartitionsbyvalue RETURNS STRING SONAME 'libcalmysql.so';
|
||||
CREATE FUNCTION calgetsqlcount RETURNS STRING SONAME 'libcalmysql.so';
|
||||
CREATE FUNCTION idbpm RETURNS INTEGER soname 'libcalmysql.so';
|
||||
CREATE FUNCTION idbdbroot RETURNS INTEGER soname 'libcalmysql.so';
|
||||
CREATE FUNCTION idbsegment RETURNS INTEGER soname 'libcalmysql.so';
|
||||
|
@ -8,6 +8,7 @@ CREATE FUNCTION calgetversion RETURNS STRING SONAME 'libcalmysql.dll';
|
||||
CREATE FUNCTION calonlinealter RETURNS INTEGER SONAME 'libcalmysql.dll';
|
||||
CREATE FUNCTION calviewtablelock RETURNS STRING SONAME 'libcalmysql.dll';
|
||||
CREATE FUNCTION calcleartablelock RETURNS STRING SONAME 'libcalmysql.dll';
|
||||
CREATE FUNCTION calgetsqlcount RETURNS STRING SONAME 'libcalmysql.dll';
|
||||
|
||||
create database if not exists calpontsys;
|
||||
use calpontsys;
|
||||
|
Loading…
x
Reference in New Issue
Block a user