Skip to content

using hex string as bindvar for decimal type column in prepared statement causes panic #4989

@jennifersp

Description

@jennifersp

Repro enginetest:

{
	Name: "simple decimal type insert",
	SetUpScript: []string{
		"CREATE TABLE test(id int primary key auto_increment, decimal_col DECIMAL(9,2))",
	},
	Assertions: []queries.ScriptTestAssertion{
		{
			Query: "INSERT INTO test(decimal_col) VALUES (?)",
			Bindings: map[string]sql.Expression{
				"v1": expression.NewLiteral([]byte("X'10'"), sql.MustCreateString(sqltypes.VarBinary, 4, sql.Collation_binary)),
			},
			Expected: []sql.Row{
				{sql.OkResult{RowsAffected: 1, InsertID: 1}},
			},
		},
	},
},

Using Literal of X'10' with VarBinary type is because most types are handled as VarBinary in https://github.com/dolthub/vitess/blob/main/go/mysql/query.go#L842 when we get parse the bindvars, so the hex string is handled the same way as any other string values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpanic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions