diff --git a/query_classifier/query_classifier.cc b/query_classifier/query_classifier.cc index 7a4bcba40..b249206d0 100644 --- a/query_classifier/query_classifier.cc +++ b/query_classifier/query_classifier.cc @@ -512,7 +512,15 @@ static skygw_query_type_t resolve_query_type( } else if (lex->option_type == OPT_SESSION) { - type |= QUERY_TYPE_SESSION_WRITE; + /** SHOW commands are all reads to one backend */ + if (lex->sql_command == SQLCOM_SHOW_VARIABLES) + { + type |= QUERY_TYPE_SESSION_READ; + } + else + { + type |= QUERY_TYPE_SESSION_WRITE; + } goto return_qtype; } /** @@ -531,10 +539,11 @@ static skygw_query_type_t resolve_query_type( force_data_modify_op_replication) { type |= QUERY_TYPE_SESSION_WRITE; - } else { + } + else + { type |= QUERY_TYPE_WRITE; } - goto return_qtype; } diff --git a/query_classifier/query_classifier.h b/query_classifier/query_classifier.h index 325087910..8284650f4 100644 --- a/query_classifier/query_classifier.h +++ b/query_classifier/query_classifier.h @@ -44,7 +44,8 @@ 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_SESSION_READ = 0x2000 /*< Read session data (from master 31.8.14) */ } skygw_query_type_t; diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 210feaac2..5f9f4715f 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -1451,7 +1451,7 @@ static int routeQuery( if (succp) /*< Have DCB of the target backend */ { - if ((ret = target_dcb->func.write(target_dcb, querybuf)) == 1) + if ((ret = target_dcb->func.write(target_dcb, gwbuf_clone(querybuf))) == 1) { backend_ref_t* bref;