Convert maxscale/query_classifier.h to .hh

The header was not merged with queryclassifier.hh since the latter
does not include the former.
This commit is contained in:
Esa Korhonen 2019-01-15 18:05:49 +02:00
parent 45bfbbdd9e
commit d4674faa7d
43 changed files with 70 additions and 74 deletions

View File

@ -46,7 +46,7 @@
#include <maxscale/modulecmd.hh>
#include <maxscale/modutil.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/router.hh>
// #define DEBUG_RRROUTER

View File

@ -28,7 +28,7 @@
#include <maxbase/jansson.h>
#include <maxscale/modinfo.h>
#include <maxscale/pcre2.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/server.hh>
class SERVICE;

View File

@ -12,38 +12,36 @@
*/
#pragma once
#include <maxscale/cdefs.h>
#include <maxscale/ccdefs.hh>
#include <maxbase/jansson.h>
#include <maxscale/buffer.h>
MXS_BEGIN_DECLS
#include <maxscale/buffer.hh>
#define MXS_QUERY_CLASSIFIER_VERSION {3, 0, 0}
/**
* qc_init_kind_t specifies what kind of initialization should be performed.
*/
typedef enum qc_init_kind
enum qc_init_kind_t
{
QC_INIT_SELF = 0x01, /*< Initialize/finalize the query classifier itself. */
QC_INIT_PLUGIN = 0x02, /*< Initialize/finalize the plugin. */
QC_INIT_BOTH = 0x03
} qc_init_kind_t;
};
/**
* qc_sql_mode_t specifies what should be assumed of the statements
* that will be parsed.
*/
typedef enum qc_sql_mode
enum qc_sql_mode_t
{
QC_SQL_MODE_DEFAULT, /*< Assume the statements are MariaDB SQL. */
QC_SQL_MODE_ORACLE /*< Assume the statements are PL/SQL. */
} qc_sql_mode_t;
};
/**
* @c qc_collect_info_t specifies what information should be collected during parsing.
*/
typedef enum qc_collect_info
enum qc_collect_info_t
{
QC_COLLECT_ESSENTIALS = 0x00, /*< Collect only the base minimum. */
QC_COLLECT_TABLES = 0x01, /*< Collect table names. */
@ -52,14 +50,14 @@ typedef enum qc_collect_info
QC_COLLECT_FUNCTIONS = 0x08, /*< Collect function information. */
QC_COLLECT_ALL = (QC_COLLECT_TABLES | QC_COLLECT_DATABASES | QC_COLLECT_FIELDS | QC_COLLECT_FUNCTIONS)
} qc_collect_info_t;
};
/**
* qc_query_type_t defines bits that provide information about a
* particular statement.
*
* Note that more than one bit may be set for a single statement.
*/
typedef enum qc_query_type
enum qc_query_type_t
{
QUERY_TYPE_UNKNOWN = 0x000000, /*< Initial value, can't be tested bitwisely */
QUERY_TYPE_LOCAL_READ = 0x000001, /*< Read non-database data, execute in MaxScale:any */
@ -87,12 +85,12 @@ typedef enum qc_query_type
QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */
QUERY_TYPE_SHOW_TABLES = 0x400000, /*< Show list of tables */
QUERY_TYPE_DEALLOC_PREPARE = 0x1000000 /*< Dealloc named prepare stmt:all */
} qc_query_type_t;
};
/**
* qc_query_op_t defines the operations a particular statement can perform.
*/
typedef enum qc_query_op
enum qc_query_op_t
{
QUERY_OP_UNDEFINED = 0,
@ -113,56 +111,56 @@ typedef enum qc_query_op
QUERY_OP_SHOW,
QUERY_OP_TRUNCATE,
QUERY_OP_UPDATE,
} qc_query_op_t;
};
/**
* qc_parse_result_t defines the possible outcomes when a statement is parsed.
*/
typedef enum qc_parse_result
enum qc_parse_result_t
{
QC_QUERY_INVALID = 0, /*< The query was not recognized or could not be parsed. */
QC_QUERY_TOKENIZED = 1, /*< The query was classified based on tokens; incompletely classified. */
QC_QUERY_PARTIALLY_PARSED = 2, /*< The query was only partially parsed; incompletely classified. */
QC_QUERY_PARSED = 3 /*< The query was fully parsed; completely classified. */
} qc_parse_result_t;
};
/**
* QC_FIELD_INFO contains information about a field used in a statement.
*/
typedef struct qc_field_info
struct QC_FIELD_INFO
{
char* database; /** Present if the field is of the form "a.b.c", NULL otherwise. */
char* table; /** Present if the field is of the form "a.b", NULL otherwise. */
char* column; /** Always present. */
} QC_FIELD_INFO;
};
/**
* QC_FUNCTION_INFO contains information about a function used in a statement.
*/
typedef struct qc_function_info
struct QC_FUNCTION_INFO
{
char* name; /** Name of function. */
QC_FIELD_INFO* fields; /** What fields the function accesses. */
uint32_t n_fields;/** The number of fields in @c fields. */
} QC_FUNCTION_INFO;
};
/**
* Each API function returns @c QC_RESULT_OK if the actual parsing process
* succeeded, and some error code otherwise.
*/
typedef enum qc_result
enum qc_result_t
{
QC_RESULT_OK,
QC_RESULT_ERROR
} qc_result_t;
};
/**
* QC_STMT_INFO is an opaque type where the query classifier stores
* information about a statement.
*/
typedef struct qc_stmt_info
struct QC_STMT_INFO
{
} QC_STMT_INFO;
};
/**
* QUERY_CLASSIFIER defines the object a query classifier plugin must
@ -171,7 +169,7 @@ typedef struct qc_stmt_info
* To a user of the query classifier functionality, it can in general
* be ignored.
*/
typedef struct query_classifier
struct QUERY_CLASSIFIER
{
/**
* Called once to setup the query classifier
@ -431,27 +429,27 @@ typedef struct query_classifier
* @param info The info to be closed.
*/
void (* qc_info_close)(QC_STMT_INFO* info);
} QUERY_CLASSIFIER;
};
/**
* QC_CACHE_PROPERTIES specifies the limits of the query classification cache.
*/
typedef struct QC_CACHE_PROPERTIES
struct QC_CACHE_PROPERTIES
{
int64_t max_size; /** The maximum size of the cache. */
} QC_CACHE_PROPERTIES;
};
/**
* QC_CACHE_STATS provides statistics of the cache.
*/
typedef struct QC_CACHE_STATS
struct QC_CACHE_STATS
{
int64_t size; /** The current size of the cache. */
int64_t inserts; /** The number of inserts. */
int64_t hits; /** The number of hits. */
int64_t misses; /** The number of misses. */
int64_t evictions; /** The number of evictions. */
} QC_CACHE_STATS;
};
/**
* Loads and sets up the default query classifier.
@ -941,5 +939,3 @@ json_t* qc_get_cache_stats_as_json();
* @return The corresponding string.
*/
const char* qc_result_to_string(qc_parse_result_t result);
MXS_END_DECLS

View File

@ -25,7 +25,7 @@
#include <maxbase/worker.hh>
#include <maxbase/stopwatch.hh>
#include <maxscale/poll.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/session.hh>
MXS_BEGIN_DECLS

View File

@ -62,7 +62,7 @@
#include <maxbase/assert.h>
#include <maxscale/log.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/paths.h>
#include <maxscale/utils.h>

View File

@ -32,7 +32,7 @@
#include <maxscale/modinfo.h>
#include <maxscale/modutil.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/utils.h>
#include "builtin_functions.h"

View File

@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/buffer.h>
#include <mysql.h>
#include <unistd.h>

View File

@ -24,7 +24,7 @@
#include <maxscale/paths.h>
#include <maxscale/log.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "../../server/modules/protocol/MySQL/mariadbclient/setsqlmodeparser.hh"
#include "testreader.hh"
using std::cerr;

View File

@ -15,7 +15,7 @@
#include <maxbase/maxbase.hh>
#include <maxscale/buffer.h>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#define MYSQL_HEADER_LEN 4

View File

@ -16,7 +16,7 @@
#include <iostream>
#include <maxscale/log.hh>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/protocol/mysql.hh>
using namespace std;

View File

@ -14,7 +14,7 @@
#include <iostream>
#include <maxscale/log.hh>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/server.hh>
#include <maxscale/protocol/mysql.hh>

View File

@ -55,7 +55,7 @@
#include <maxscale/maxscale.h>
#include <maxscale/mysql_utils.hh>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/server.hh>
#include <maxscale/sqlite3.h>
#include <maxscale/session.hh>

View File

@ -26,7 +26,7 @@
#include <maxscale/config.hh>
#include <maxscale/housekeeper.h>
#include <maxscale/json_api.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
/**
* @file housekeeper.cc Provide a mechanism to run periodic tasks

View File

@ -13,7 +13,7 @@
#pragma once
#include <maxscale/ccdefs.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/jansson.hh>
MXS_BEGIN_DECLS

View File

@ -15,7 +15,7 @@
#include <maxscale/ccdefs.hh>
#include <ctype.h>
#include <maxscale/customparser.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
namespace maxscale
{

View File

@ -35,7 +35,7 @@
#include <maxscale/filter.hh>
#include <maxscale/authenticator.hh>
#include <maxscale/monitor.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "internal/modules.hh"
#include "internal/config.hh"

View File

@ -1473,7 +1473,7 @@ std::unique_ptr<json_t> qc_classify_as_json(const char* zHost, const std::string
std::unique_ptr<GWBUF> sBuffer(modutil_create_query(statement.c_str()));
GWBUF* pBuffer = sBuffer.get();
qc_parse_result result = qc_parse(pBuffer, QC_COLLECT_ALL);
qc_parse_result_t result = qc_parse(pBuffer, QC_COLLECT_ALL);
json_object_set_new(pParams, CN_PARSE_RESULT, json_string(qc_result_to_string(result)));

View File

@ -15,7 +15,7 @@
#include <unordered_map>
#include <maxscale/alloc.h>
#include <maxscale/modutil.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/protocol/mysql.hh>
namespace

View File

@ -21,7 +21,7 @@
#include <iostream>
#include <string>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/buffer.hh>
#include <maxscale/paths.h>
#include <maxscale/utils.h>

View File

@ -19,7 +19,7 @@
#include <maxscale/maxscale_test.h>
#include <maxscale/log.hh>
#include <maxscale/config.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/paths.h>
#include <maxscale/alloc.h>
#include <maxscale/routingworker.hh>

View File

@ -20,7 +20,7 @@
#include <maxscale/alloc.h>
#include <maxscale/buffer.h>
#include <maxscale/modutil.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/paths.h>
#include "storagefactory.hh"
#include "storage.hh"

View File

@ -17,7 +17,7 @@
#include <maxscale/alloc.h>
#include <maxscale/modutil.hh>
#include <maxscale/mysql_utils.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "storage.hh"
namespace

View File

@ -24,7 +24,7 @@
#include <maxscale/modutil.hh>
#include <maxscale/mysql_utils.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/session.hh>
#include "cachefilter.hh"

View File

@ -15,7 +15,7 @@
#include "inmemorystorage.hh"
#include <maxscale/alloc.h>
#include <maxscale/modutil.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "inmemorystoragest.hh"
#include "inmemorystoragemt.hh"

View File

@ -17,7 +17,7 @@
#include <unordered_map>
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "storagefactory.hh"
#include "cache.hh"
#include "cache_storage_api.hh"

View File

@ -18,7 +18,7 @@
#include <maxscale/config.hh>
#include <maxscale/paths.h>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
using namespace std;

View File

@ -18,7 +18,7 @@
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/utils.h>
#include "storagefactory.hh"

View File

@ -23,7 +23,7 @@
#include <maxscale/modinfo.h>
#include <maxscale/modutil.hh>
#include <maxscale/pcre2.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
using std::string;

View File

@ -25,7 +25,7 @@
#include <vector>
#include <maxscale/filter.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "dbfwfilter.h"

View File

@ -23,7 +23,7 @@
#include <maxscale/modutil.hh>
#include <maxscale/poll.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
/**
* @file datastream.c - Streaming of bulk inserts

View File

@ -54,7 +54,7 @@ extern "C"
#include <maxscale/alloc.h>
#include <maxscale/filter.hh>
#include <maxscale/modutil.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/session.hh>
/*

View File

@ -30,7 +30,7 @@
#include <maxscale/paths.h>
#include <maxscale/poll.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER*);
static MXS_FILTER_SESSION* newSession(MXS_FILTER* instance,

View File

@ -74,7 +74,7 @@
#include <amqp_tcp_socket.h>
#include <amqp_ssl_socket.h>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/session.hh>
#include <maxscale/mainworker.hh>
#include <maxscale/alloc.h>

View File

@ -14,7 +14,7 @@
#include <maxscale/ccdefs.hh>
#include <memory>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "module.hh"
namespace maxscale

View File

@ -14,7 +14,7 @@
#include "maxscale/mock/backend.hh"
#include <algorithm>
#include <vector>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/protocol/mysql.hh>
#include <iostream>

View File

@ -16,7 +16,7 @@
#include <maxscale/ccdefs.hh>
#include <maxscale/modutil.hh>
#include <maxscale/poll.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include "throttlesession.hh"
#include "throttlefilter.hh"

View File

@ -61,7 +61,7 @@
#include <maxscale/modutil.hh>
#include <maxscale/server.hh>
#include <maxbase/atomic.h>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
/* The maximum size for query statements in a transaction (64MB) */
static size_t sql_size_limit = 64 * 1024 * 1024;

View File

@ -31,7 +31,7 @@
#include <maxscale/poll.hh>
#include <maxscale/protocol.hh>
#include <maxscale/protocol/mysql.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/router.hh>
#include <maxscale/routingworker.hh>
#include <maxscale/session.hh>

View File

@ -23,7 +23,7 @@
*/
#include "avrorouter.hh"
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <binlog_common.hh>
#include <blr_constants.hh>

View File

@ -27,7 +27,7 @@
#include <maxscale/dcb.hh>
#include <maxscale/modinfo.h>
#include <maxscale/modutil.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/router.hh>
#include <maxscale/mysql_utils.hh>
#include <maxscale/routingworker.hh>

View File

@ -20,7 +20,7 @@
#include <stdint.h>
#include <maxscale/router.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/dcb.hh>
#include <maxscale/modinfo.h>
#include <maxscale/modutil.hh>

View File

@ -25,7 +25,7 @@
#include <maxscale/modinfo.h>
#include <maxscale/modutil.hh>
#include <maxscale/poll.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/router.hh>
#include <maxscale/secrets.h>

View File

@ -21,7 +21,7 @@
#include <maxscale/alloc.h>
#include <maxscale/modutil.hh>
#include <maxscale/poll.hh>
#include <maxscale/query_classifier.h>
#include <maxscale/query_classifier.hh>
#include <maxscale/resultset.hh>
namespace schemarouter