Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum column in binary protocol #34690

Closed
ChenPeng2013 opened this issue May 16, 2022 · 0 comments · Fixed by #34709
Closed

enum column in binary protocol #34690

ChenPeng2013 opened this issue May 16, 2022 · 0 comments · Fixed by #34709
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 epic/plan-cache severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

ChenPeng2013 commented May 16, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

prepared-plan-cache.enabled = true

package main

import (
	"context"
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

var (
	dsn ="root:@tcp(172.16.4.181:17000)/test"
)

func mustExec(c *sql.Conn, query string) {
	_, err := c.ExecContext(context.Background(), query)
	if err != nil {
		panic(err)
	}
}

func main() {
	db, err := sql.Open("mysql", dsn)
	if err != nil {
		panic(err)
	}
	defer db.Close()

	c, err := db.Conn(context.Background())
	if err != nil {
		panic(err)
	}
	defer c.Close()

	mustExec(c, "drop table if exists IDT_MULTI15842STROBJSTROBJ;")
	mustExec(c, "CREATE TABLE IDT_MULTI15842STROBJSTROBJ (COL1 enum('aa', 'bb') DEFAULT NULL,  COL2 smallint(41) DEFAULT NULL, COL3 datetime DEFAULT NULL, KEY U_M_COL4 (COL1,COL2), KEY U_M_COL5 (COL3,COL2)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;")
	mustExec(c, `insert into IDT_MULTI15842STROBJSTROBJ values("aa", 10107, "0871-07-11 22:22:40");`)
	stmt, err := db.Prepare("select col2 from IDT_MULTI15842STROBJSTROBJ where col2 between ? and ? and col1 in (?, ?, ?)")
	if err != nil {
		panic(err)
	}

	ss := [][]interface{}{
		[]interface{}{-286425994142, 539889691716, "none", "none", "none"},
		[]interface{}{-879193018085, 32676, "aa", "aa", "aa"},
	}
	for _, v := range ss {
		rows, err := stmt.Query(v...)
		if err != nil {
			panic(err)
		}

		count := 0
		for rows.Next() {
			var str1 string

			rows.Scan(&str1)
			//fmt.Printf("%s\n", str1)
			count++
		}
		rows.Close()
		fmt.Printf("%v\n", count)
	}
	
	c.ExecContext(context.Background(), "prepare stmt from 'select col2 from IDT_MULTI15842STROBJSTROBJ where col2 between ? and ? and col1 in (?, ?, ?)'")
	c.ExecContext(context.Background(), "set @a=-879193018085, @b=32676, @c='aa', @d='aa', @e='aa'")


	rows, err := c.QueryContext(context.Background(), "execute stmt using @a, @b, @c, @c, @d")
	count := 0
	for rows.Next() {
		var str3 []byte
		rows.Scan(&str3)
		count++
	}
	rows.Close()
	fmt.Printf("%v\n", count)
}

2. What did you expect to see? (Required)

0
1
1

3. What did you see instead (Required)

0
0
1

4. What is your TiDB version? (Required)

master

@ChenPeng2013 ChenPeng2013 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner epic/plan-cache labels May 16, 2022
@qw4990 qw4990 added affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 severity/major labels May 16, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. labels May 16, 2022
@qw4990 qw4990 removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels May 16, 2022
ti-chi-bot pushed a commit that referenced this issue May 17, 2022
ti-chi-bot pushed a commit that referenced this issue Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 epic/plan-cache severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
3 participants