Repository navigation
Closed
Description
- os Version: macOS 11.2
- cli-driver Version: 11.5
- Db2 Server Version: v11.5.4.0
- go Version:
go env Output:
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/travel/Library/Caches/go-build" GOENV="/Users/travel/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/travel/Documents/Code/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/travel/Documents/Code/go" GOPRIVATE="" GOPROXY="https://goproxy.cn" GOROOT="/usr/local/Cellar/go/1.15.2/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.15.2/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/travel/Documents/Code/Enmotech/cloudAssistant/mtk/go.mod" CGO_CFLAGS="-I/Users/travel/Oracle_tools/db2client/include" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-L/Users/travel/Oracle_tools/db2client/lib" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k1/vqmqkz_s4gg5c0775rlv4g000000gn/T/go-build488589789=/tmp/go-build -gno-record-gcc-switches -fno-common"
Steps to Reproduce:
- install gbk charset and create gbk database
docker run -itd --name db2_11 --privileged=true -p 50000:50000 \
-e LICENSE=accept -e DB2INST1_PASSWORD=db2@123 \
-e SAMPLEDB=true \
-e DBNAME=testdb \
ibmcom/db2
docker exec -it db2_11 bash
-- install gdk charset
yum install -y kde-l10n-Chinese
localedef -c -f GBK -i zh_CN zh_CN.GBK
locale -a | grep CN
-- create gbb database
su - db2inst1
db2 create database testdb1 using codeset GBK territory cn
db2 get db cfg for testdb1 |grep code
Database code page = 1386
Database code set = GBK
Database country/region code = 86
- create table
create table t_char(name char(20)) ;
insert into t_char values('中国');
- test
rows, err := db.Query("select name from db2inst1.t_char")
if err != nil {
t.Error(err)
}
for rows.Next() {
var (
a1 []byte
)
if err := rows.Scan(&a1); err != nil {
t.Error(err)
return
}
fmt.Printf("%s\n", a1)
}
if err := rows.Err(); err != nil {
t.Error(err)
}
- error
panic: runtime error: slice bounds out of range [:22] with capacity 21 [recovered]
panic: runtime error: slice bounds out of range [:22] with capacity 21
goroutine 20 [running]:
testing.tRunner.func1.1(0x4447b80, 0xc000150ba0)
/usr/local/Cellar/go/1.15.2/libexec/src/testing/testing.go:1076 +0x30d
testing.tRunner.func1(0xc00010ea80)
/usr/local/Cellar/go/1.15.2/libexec/src/testing/testing.go:1079 +0x41a
panic(0x4447b80, 0xc000150ba0)
/usr/local/Cellar/go/1.15.2/libexec/src/runtime/panic.go:969 +0x175
github.com/ibmdb/go_ibm_db.(*BindableColumn).Value(0xc00011f140, 0xc000010001, 0x0, 0xc000209db8, 0x405028c, 0x10, 0x440be00)
/Users/travel/Documents/Code/go/pkg/mod/github.com/ibmdb/go_ibm_db@v0.4.0/column.go:286 +0x2b5
github.com/ibmdb/go_ibm_db.(*Rows).Next(0xc00010a118, 0xc000101f00, 0x1, 0x1, 0x0, 0xc000184360)
/Users/travel/Documents/Code/go/pkg/mod/github.com/ibmdb/go_ibm_db@v0.4.0/rows.go:116 +0xcc
utf8 database no issue
Metadata
Metadata
Assignees
Labels
No labels
Activity
akhilravuri1 commentedon Mar 23, 2021
Hi @travelliu
You are able to insert data into the database but while retrieving the data you are facing this issue right?
Thanks,
Akhil
travelliu commentedon Mar 23, 2021
YES.
i will modify code
akhilravuri1 commentedon Mar 23, 2021
Can you declare variable a1 as string and try?
Thanks,
Akhil
travelliu commentedon Mar 23, 2021
bytes and string some issue. panic: runtime error: slice bounds out of range.
akhilravuri1 commentedon Mar 25, 2021
Hi @travelliu
I will run some test cases and I will make the changes. Thanks for the input.
-Akhil
#126 fix
akhilravuri1 commentedon May 28, 2021
Hi @travelliu
Sorry for the late response.
I have pushed your changes.
Thanks for the contribution.
-Akhil
travelliu commentedon Jun 16, 2021
Publish a new version?v0.4.1 not include this
0.4.2
feat: 升级db2等依赖库用于解决db2的问题https://github.com/ibmdb/go_ibm_db/issues/12…