Coder Social home page Coder Social logo

Comments (2)

sangshuduo avatar sangshuduo commented on September 16, 2024

请提供复现代码

from driver-go.

fengtongxue avatar fengtongxue commented on September 16, 2024

golang client driver

version:

  • github.com/taosdata/driver-go/v3 v3.5.0

varchar 字段能存,但是 client driver 不能读,driver panic, int16 越界长度报错


  • 复现方式:
    td sql

     `sql CREATE STABLE `super_for_test` (`ts` TIMESTAMP, `json_value` VARCHAR(40000)) TAGS (`dev_id` VARCHAR(50));`
    
    INSERT INTO 'super_for_test_123' USING 'super_for_test'
    TAGS ('123')
    ('ts', 'json_value')
        VALUES (1704881588040,
    {{字符串len > int16}}
    );
    
  • golang clinet

func TestTDPanic(t *testing.T) {
    type Tmp struct {
        Ts      time.Time `json:"ts" db:"ts"` 
        JsonStr string    `json:"json_str" db:"json_value"`
    }
    rows, err := Ddata.td.Query("select ts, json_value from super_for_test")
    require.NoError(t, err)
    for rows.Next() {
        r := &Tmp{}
        var ts time.Time
        err = rows.Scan(&ts, &r.JsonStr)
        if err != nil {
            require.NoError(t, err)
        }
        fmt.Println(r)
    }

    //--- FAIL: TestTDPanic (0.07s)
    //panic: runtime error: makeslice: len out of range [recovered]
    // panic: runtime error: makeslice: len out of range
}
  • panic 位置

github.com/taosdata/driver-go/[email protected]/common/parser/block.go:200

func rawConvertBinary(pHeader, pStart uintptr, row int) driver.Value {
	offset := *((*int32)(unsafe.Pointer(pHeader + uintptr(row*4))))
	if offset == -1 {
		return nil
	}
	currentRow := unsafe.Pointer(pStart + uintptr(offset))
	clen := *((*int16)(currentRow))
	currentRow = unsafe.Pointer(uintptr(currentRow) + 2)
	println("**********: %v", clen)
	binaryVal := make([]byte, clen)

	for index := int16(0); index < clen; index++ {
		binaryVal[index] = *((*byte)(unsafe.Pointer(uintptr(currentRow) + uintptr(index))))
	}
	return string(binaryVal[:])
}

output:
**********: %v -32767

@sangshuduo

from driver-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.