Merge branch '2.1' into develop

This commit is contained in:
Markus Mäkelä
2017-07-31 15:57:05 +03:00
27 changed files with 389 additions and 58 deletions

View File

@ -606,7 +606,8 @@ static bool extract_insert_target(GWBUF *buffer, char* target, int len)
{
bool rval = false;
if (qc_get_operation(buffer) == QUERY_OP_INSERT &&
if (MYSQL_GET_COMMAND(GWBUF_DATA(buffer)) == MYSQL_COM_QUERY &&
qc_get_operation(buffer) == QUERY_OP_INSERT &&
only_implicit_values(buffer))
{
int n_tables = 0;

View File

@ -85,7 +85,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{"disable_master_failback", MXS_MODULE_PARAM_BOOL, "false"},
{"available_when_donor", MXS_MODULE_PARAM_BOOL, "false"},
{"disable_master_role_setting", MXS_MODULE_PARAM_BOOL, "false"},
{"root_node_as_master", MXS_MODULE_PARAM_BOOL, "true"},
{"root_node_as_master", MXS_MODULE_PARAM_BOOL, "false"},
{"use_priority", MXS_MODULE_PARAM_BOOL, "false"},
{
"script",

View File

@ -15,11 +15,11 @@ import (
"database/sql"
"encoding/json"
"flag"
"fmt"
"log"
"os"
"regexp"
"strconv"
"fmt"
)
import _ "github.com/go-sql-driver/mysql"
@ -45,8 +45,10 @@ The "user" and "password" flags are required.
// Avro field
type Field struct {
Name string `json:"name"`
Type string `json:"type"`
Name string `json:"name"`
Type string `json:"type"`
RealType string `json:"real_type"`
Length int `json:"length"`
}
// Avro schema
@ -68,13 +70,20 @@ func LogObject(obj interface{}) {
}
var field_re *regexp.Regexp
var length_re *regexp.Regexp
// Convert the SQL type to the appropriate Avro type
func (f *Field) ToAvroType() {
orig := f.Type
f.Type = field_re.ReplaceAllString(f.Type, "")
f.Length = -1
f.RealType = f.Type
switch f.Type {
case "date", "datetime", "time", "timestamp", "year", "tinytext", "text",
"mediumtext", "longtext", "char", "varchar", "enum", "set":
"mediumtext", "longtext", "char", "varchar":
f.Type = "string"
f.Length, _ = strconv.Atoi(length_re.ReplaceAllString(orig, "$1"))
case "enum", "set":
f.Type = "string"
case "tinyblob", "blob", "mediumblob", "longblob", "binary", "varbinary":
f.Type = "bytes"
@ -127,11 +136,18 @@ func StoreSchema(db *sql.DB, schema, table string) {
func main() {
var err error
field_re, err = regexp.Compile("[(].*")
if err != nil {
log.Fatal("Error: ", err)
}
flag.Usage = PrintUsage;
length_re, err = regexp.Compile(".*[(](.*)[)].*")
if err != nil {
log.Fatal("Error: ", err)
}
flag.Usage = PrintUsage
flag.Parse()
if len(*user) == 0 || len(*passwd) == 0 {

View File

@ -401,8 +401,7 @@ static bool handle_error_new_connection(RWSplit *inst,
* to the client.
*/
GWBUF *stored = NULL;
const SERVER *target;
const SERVER *target = NULL;
if (!session_take_stmt(backend_dcb->session, &stored, &target) ||
target != backend->backend()->server ||
!reroute_stored_statement(*rses, backend, stored))