Merge branch '2.0.1' into develop
This commit is contained in:
@ -15,4 +15,5 @@ if (BUILD_QC_MYSQLEMBEDDED)
|
||||
set_target_properties(qc_mysqlembedded PROPERTIES LINK_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/qc_mysqlembedded.map)
|
||||
#set_target_properties(qc_mysqlembedded PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
||||
install_module(qc_mysqlembedded libmysqld-parser)
|
||||
install(PROGRAMS ${ERRMSG} DESTINATION ${MAXSCALE_VARDIR}/lib/maxscale)
|
||||
endif()
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <platform.h>
|
||||
#include <query_classifier.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <modutil.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include "builtin_functions.h"
|
||||
|
||||
@ -130,6 +131,7 @@ static void info_finish(QC_SQLITE_INFO* info);
|
||||
static void info_free(QC_SQLITE_INFO* info);
|
||||
static QC_SQLITE_INFO* info_init(QC_SQLITE_INFO* info);
|
||||
static bool is_submitted_query(const QC_SQLITE_INFO* info, const Parse* pParse);
|
||||
static void log_invalid_data(GWBUF* query, const char* message);
|
||||
static bool parse_query(GWBUF* query);
|
||||
static void parse_query_string(const char* query, size_t len);
|
||||
static bool query_is_parsed(GWBUF* query);
|
||||
@ -542,6 +544,33 @@ static bool is_submitted_query(const QC_SQLITE_INFO* info, const Parse* pParse)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs information about invalid data.
|
||||
*
|
||||
* @param query The query that could not be parsed.
|
||||
* @param message What is being asked for.
|
||||
*/
|
||||
static void log_invalid_data(GWBUF* query, const char* message)
|
||||
{
|
||||
// At this point the query should be contiguous, but better safe than sorry.
|
||||
|
||||
if (GWBUF_LENGTH(query) >= MYSQL_HEADER_LEN + 1)
|
||||
{
|
||||
char *sql;
|
||||
int length;
|
||||
|
||||
if (modutil_extract_SQL(query, &sql, &length))
|
||||
{
|
||||
if (length > GWBUF_LENGTH(query) - MYSQL_HEADER_LEN - 1)
|
||||
{
|
||||
length = GWBUF_LENGTH(query) - MYSQL_HEADER_LEN - 1;
|
||||
}
|
||||
|
||||
MXS_INFO("qc_sqlite: Parsing the query failed, %s: %*s", message, length, sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void append_affected_field(QC_SQLITE_INFO* info, const char* s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
@ -805,7 +834,7 @@ static void update_affected_fields_from_select(QC_SQLITE_INFO* info,
|
||||
update_affected_fields_from_exprlist(info, pSelect->pEList, NULL);
|
||||
}
|
||||
|
||||
if (pSelect->pWhere)
|
||||
if (pSelect->pWhere)
|
||||
{
|
||||
info->has_clause = true;
|
||||
update_affected_fields(info, 0, pSelect->pWhere, QC_TOKEN_MIDDLE, pSelect->pEList);
|
||||
@ -839,6 +868,7 @@ static void update_names(QC_SQLITE_INFO* info, const char* zDatabase, const char
|
||||
{
|
||||
char* zCopy = MXS_STRDUP(zTable);
|
||||
MXS_ABORT_IF_NULL(zCopy);
|
||||
// TODO: Is this call really needed. Check also sqlite3Dequote.
|
||||
exposed_sqlite3Dequote(zCopy);
|
||||
|
||||
enlarge_string_array(1, info->table_names_len, &info->table_names, &info->table_names_capacity);
|
||||
@ -1136,10 +1166,8 @@ void mxs_sqlite3DeleteFrom(Parse* pParse, SrcList* pTabList, Expr* pWhere, SrcLi
|
||||
update_affected_fields(info, 0, pWhere, QC_TOKEN_MIDDLE, 0);
|
||||
}
|
||||
|
||||
//TODO: Figure out why the following statements, causes a crash
|
||||
//TODO: long down the road.
|
||||
//TODO: exposed_sqlite3SrcListDelete(pParse->db, pTabList);
|
||||
//TODO: exposed_sqlite3ExprDelete(pParse->db, pWhere);
|
||||
exposed_sqlite3ExprDelete(pParse->db, pWhere);
|
||||
exposed_sqlite3SrcListDelete(pParse->db, pTabList);
|
||||
exposed_sqlite3SrcListDelete(pParse->db, pUsing);
|
||||
}
|
||||
|
||||
@ -2503,9 +2531,9 @@ static uint32_t qc_sqlite_get_type(GWBUF* query)
|
||||
{
|
||||
types = info->types;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report query type");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2531,9 +2559,9 @@ static qc_query_op_t qc_sqlite_get_operation(GWBUF* query)
|
||||
{
|
||||
op = info->operation;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report query operation");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2563,9 +2591,9 @@ static char* qc_sqlite_get_created_table_name(GWBUF* query)
|
||||
MXS_ABORT_IF_NULL(created_table_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report created tables");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2591,9 +2619,9 @@ static bool qc_sqlite_is_drop_table_query(GWBUF* query)
|
||||
{
|
||||
is_drop_table = info->is_drop_table;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report whether query is drop table");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2619,9 +2647,9 @@ static bool qc_sqlite_is_real_query(GWBUF* query)
|
||||
{
|
||||
is_real_query = info->is_real_query;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report whether query is a real query");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2663,9 +2691,9 @@ static char** qc_sqlite_get_table_names(GWBUF* query, int* tblsize, bool fullnam
|
||||
*tblsize = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report what tables are accessed");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2702,9 +2730,9 @@ static bool qc_sqlite_query_has_clause(GWBUF* query)
|
||||
{
|
||||
has_clause = info->has_clause;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report whether the query has a where clause");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2730,9 +2758,9 @@ static char* qc_sqlite_get_affected_fields(GWBUF* query)
|
||||
{
|
||||
affected_fields = info->affected_fields;
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report what fields are affected");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2769,9 +2797,9 @@ static char** qc_sqlite_get_database_names(GWBUF* query, int* sizep)
|
||||
database_names = copy_string_array(info->database_names, sizep);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
|
||||
{
|
||||
MXS_ERROR("qc_sqlite: The query operation was not resolved. Response not valid.");
|
||||
log_invalid_data(query, "cannot report what databases are accessed");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -219,6 +219,21 @@ int sqlite3Dequote(char *z){
|
||||
}
|
||||
for(i=1, j=0;; i++){
|
||||
assert( z[i] );
|
||||
#ifdef MAXSCALE
|
||||
if ( z[i]==0 ){
|
||||
// TODO: This is needed only because exposed_sqlite3Dequote() is called
|
||||
// TODO: in qc_sqlite.c:update_names(). That call probably is not needed
|
||||
// TODO: and should be removed, in which case this check could also be
|
||||
// TODO: removed.
|
||||
break;
|
||||
}else if ( z[i]=='\\' ){
|
||||
z[j++] = '\\';
|
||||
if ( z[i+1]==quote || z[i+1]=='\\' ){
|
||||
z[j++] = quote;
|
||||
i++;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if( z[i]==quote ){
|
||||
if( z[i+1]==quote ){
|
||||
z[j++] = quote;
|
||||
|
Reference in New Issue
Block a user