query_classifier.cc: added detection for CREATE TEMPORARY TABLE and setting a new query type QUERY_TYPE_CREATE_TMP_TABLE for it.
query_classifier.h: added QUERY_TYPE_CREATE_TMP_TABLE and QUERY_TYPE_READ_TMP_TABLE for use of temporary table support. hashtable.c:Added variant of hashtable which is 'flat', that is, stored to existing memory instead of allocating memory as a part of the call. Existing function declarations don't change but added hashtable_alloc_flat for the purpose. Both hashtable_alloc and hashtable_alloc_flat now call the real allocation function, hashtable_alloc_real. hashtable_free only frees memory which is allocated in hashtable_alloc_real. hashtable.h: added a flag to HASHTABLE struct to indicate whether hashtable owns its memory or not. readwritesplit.h: Added RSES_PROP_TYPE_TMPTABLES property type to be used for keeping the hashtable for tablenames. readwritesplit.c: Added comments about temporary table support implementation.
This commit is contained in:
@ -494,8 +494,15 @@ static skygw_query_type_t resolve_query_type(
|
||||
force_data_modify_op_replication)
|
||||
{
|
||||
type |= QUERY_TYPE_SESSION_WRITE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
type |= QUERY_TYPE_WRITE;
|
||||
|
||||
if (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)
|
||||
{
|
||||
type |= QUERY_TYPE_CREATE_TMP_TABLE;
|
||||
}
|
||||
}
|
||||
|
||||
goto return_qtype;
|
||||
@ -692,6 +699,17 @@ static skygw_query_type_t resolve_query_type(
|
||||
break;
|
||||
}
|
||||
} /**< for */
|
||||
#if defined(TEMPORARY_TABLES)
|
||||
if ((skygw_query_type_t)type == QUERY_TYPE_READ)
|
||||
{
|
||||
/**
|
||||
* Find out the database name and all tables the query
|
||||
* uses. Create a hashvalue from each and if any of the
|
||||
* values can be found from property's hashtable, set
|
||||
* query type to QUERY_TYPE_READ_TMP_TABLE.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
} /**< if */
|
||||
return_qtype:
|
||||
qtype = (skygw_query_type_t)type;
|
||||
@ -816,3 +834,25 @@ char* skygw_query_classifier_get_stmtname(
|
||||
return ((THD *)(mysql->thd))->lex->prepared_stmt_name.str;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the head of the list of tables affected by the current select statement.
|
||||
* @param thd Pointer to a valid thread descriptor structure
|
||||
* @return Head of the TABLE_LIST chain or NULL in case of an error
|
||||
*/
|
||||
void* skygw_get_affected_tables(void* thdp)
|
||||
{
|
||||
THD* thd = (THD*)thdp;
|
||||
|
||||
if(thd == NULL ||
|
||||
thd->lex == NULL ||
|
||||
thd->lex->current_select == NULL)
|
||||
{
|
||||
ss_dassert(thd != NULL &&
|
||||
thd->lex != NULL &&
|
||||
thd->lex->current_select != NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*)thd->lex->current_select->table_list.first;
|
||||
}
|
@ -43,7 +43,9 @@ typedef enum {
|
||||
QUERY_TYPE_COMMIT = 0x0200, /*< COMMIT */
|
||||
QUERY_TYPE_PREPARE_NAMED_STMT = 0x0400, /*< Prepared stmt with name from user */
|
||||
QUERY_TYPE_PREPARE_STMT = 0x0800, /*< Prepared stmt with id provided by server */
|
||||
QUERY_TYPE_EXEC_STMT = 0x1000 /*< Execute prepared statement */
|
||||
QUERY_TYPE_EXEC_STMT = 0x1000, /*< Execute prepared statement */
|
||||
QUERY_TYPE_CREATE_TMP_TABLE = 0x2000, /*< Create temporary table */
|
||||
QUERY_TYPE_READ_TMP_TABLE = 0x4000 /*< Read temporary table */
|
||||
} skygw_query_type_t;
|
||||
|
||||
#define QUERY_IS_TYPE(mask,type) ((mask & type) == type)
|
||||
@ -60,6 +62,8 @@ skygw_query_type_t skygw_query_classifier_get_type(
|
||||
/** Free THD context and close MYSQL */
|
||||
void skygw_query_classifier_free(MYSQL* mysql);
|
||||
char* skygw_query_classifier_get_stmtname(MYSQL* mysql);
|
||||
void* skygw_get_affected_tables(void* thdp);
|
||||
|
||||
|
||||
EXTERN_C_BLOCK_END
|
||||
|
||||
|
Reference in New Issue
Block a user