go-sql-driver / mysql

Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
https://pkg.go.dev/github.com/go-sql-driver/mysql
Mozilla Public License 2.0
14.52k stars 2.32k forks source link

Empty result with max unsigned int value #1531

Closed shiyuhang0 closed 10 months ago

shiyuhang0 commented 10 months ago

Issue description

Empty result.

Example code

  1. Insert into mysql
CREATE DATABASE test;

CREATE TABLE test.t(
    t_int_unsigned       INT UNSIGNED
);

insert into test.t values (4294967295);

Query with go-sql-driver master. Here we use commit 0004702b931d3429afb3e16df444ed80be24d1f4

    db, err := sql.Open("mysql", "root@tcp(127.0.0.1:3306)/test")
    if err != nil {
        println(err)
        return
    }
    defer db.Close()

    rows, err := db.Query("select * from test.t")
    if err != nil {
        println(err)
        return
    }
    if !rows.Next() {
        println("no rows")
        return
    }
    var v int64
    err = rows.Scan(&v)
    if err != nil {
        println(err)
    }
    println(v)

This code output no rows

Configuration

Driver version (or git SHA): 0004702b931d3429afb3e16df444ed80be24d1f4

Go version: run go version in your console

Server version: E.g. MySQL 5.6, MariaDB 10.0.20

Server OS: E.g. Debian 8.1 (Jessie), Windows 10