Add query classifier plugin interface.
Added a query classifier plugin interface using which plugins export their functionality. Cleaned up header slightly as well. This is the first step in the process of making the loading of the query classifier truly dynamic.
This commit is contained in:
@ -19,20 +19,11 @@ Copyright MariaDB Corporation Ab
|
||||
|
||||
*/
|
||||
|
||||
/** getpid */
|
||||
#include <my_config.h>
|
||||
#include <unistd.h>
|
||||
#include <mysql.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <buffer.h>
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
|
||||
/**
|
||||
* Query type for skygateway.
|
||||
* The meaninful difference is where operation is done and whether master data
|
||||
* is modified
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
QUERY_TYPE_UNKNOWN = 0x000000, /*< Initial value, can't be tested bitwisely */
|
||||
@ -42,11 +33,11 @@ typedef enum
|
||||
QUERY_TYPE_MASTER_READ = 0x000008, /*< Read from the master:master */
|
||||
QUERY_TYPE_SESSION_WRITE = 0x000010, /*< Session data will be modified:master or all */
|
||||
/** Not implemented yet */
|
||||
// QUERY_TYPE_USERVAR_WRITE = 0x000020, /*< Write a user variable:master or all */
|
||||
//QUERY_TYPE_USERVAR_WRITE = 0x000020, /*< Write a user variable:master or all */
|
||||
QUERY_TYPE_USERVAR_READ = 0x000040, /*< Read a user variable:master or any */
|
||||
QUERY_TYPE_SYSVAR_READ = 0x000080, /*< Read a system variable:master or any */
|
||||
/** Not implemented yet */
|
||||
// QUERY_TYPE_SYSVAR_WRITE = 0x000100, /*< Write a system variable:master or all */
|
||||
//QUERY_TYPE_SYSVAR_WRITE = 0x000100, /*< Write a system variable:master or all */
|
||||
QUERY_TYPE_GSYSVAR_READ = 0x000200, /*< Read global system variable:master or any */
|
||||
QUERY_TYPE_GSYSVAR_WRITE = 0x000400, /*< Write global system variable:master or all */
|
||||
QUERY_TYPE_BEGIN_TRX = 0x000800, /*< BEGIN or START TRANSACTION */
|
||||
@ -66,7 +57,7 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
QUERY_OP_UNDEFINED = 0,
|
||||
QUERY_OP_SELECT = 1,
|
||||
QUERY_OP_SELECT = (1 << 0),
|
||||
QUERY_OP_UPDATE = (1 << 1),
|
||||
QUERY_OP_INSERT = (1 << 2),
|
||||
QUERY_OP_DELETE = (1 << 3),
|
||||
@ -96,10 +87,6 @@ void qc_thread_end();
|
||||
qc_query_type_t qc_get_type(GWBUF* querybuf);
|
||||
qc_query_op_t qc_get_operation(GWBUF* querybuf);
|
||||
|
||||
#if defined(NOT_USED)
|
||||
char* qc_get_stmtname(GWBUF* buf);
|
||||
#endif
|
||||
|
||||
char* qc_get_created_table_name(GWBUF* querybuf);
|
||||
bool qc_is_drop_table_query(GWBUF* querybuf);
|
||||
bool qc_is_real_query(GWBUF* querybuf);
|
||||
@ -110,6 +97,30 @@ char* qc_get_qtype_str(qc_query_type_t qtype);
|
||||
char* qc_get_affected_fields(GWBUF* buf);
|
||||
char** qc_get_database_names(GWBUF* querybuf, int* size);
|
||||
|
||||
typedef struct query_classifier
|
||||
{
|
||||
bool (*qc_init)(int argc, char** argv, char** groups);
|
||||
void (*qc_end)();
|
||||
|
||||
bool (*qc_thread_init)();
|
||||
void (*qc_thread_end)();
|
||||
|
||||
qc_query_type_t (*qc_get_type)(GWBUF* querybuf);
|
||||
qc_query_op_t (*qc_get_operation)(GWBUF* querybuf);
|
||||
|
||||
char* (*qc_get_created_table_name)(GWBUF* querybuf);
|
||||
bool (*qc_is_drop_table_query)(GWBUF* querybuf);
|
||||
bool (*qc_is_real_query)(GWBUF* querybuf);
|
||||
char** (*qc_get_table_names)(GWBUF* querybuf, int* tblsize, bool fullnames);
|
||||
char* (*qc_get_canonical)(GWBUF* querybuf);
|
||||
bool (*qc_query_has_clause)(GWBUF* buf);
|
||||
char* (*qc_get_qtype_str)(qc_query_type_t qtype);
|
||||
char* (*qc_get_affected_fields)(GWBUF* buf);
|
||||
char** (*qc_get_database_names)(GWBUF* querybuf, int* size);
|
||||
} QUERY_CLASSIFIER;
|
||||
|
||||
#define QUERY_CLASSIFIER_VERSION {1, 0, 0}
|
||||
|
||||
EXTERN_C_BLOCK_END
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user