Comments (22)
@NateMoeller @liuljun I have made the changes now CLOB supports 2GB.
Thanks,
Akhil
from go_ibm_db.
Hi @liuljun
I will try to remove that null terminator but only if all the functionalities are working fine. Last time when I tried to remove it VARBIR was failing so let me check again. I have found other drivers(which are not native) also uses a null terminator.
Thanks,
Akhil
from go_ibm_db.
@NateMoeller In golang, if you declare the variable type as time.Time it is declared as TimeStamp.
time package has many functions you can parse it as you want. If we return time then it will be invalid has user-declared variable has time.Time which is TIMESTAMP.
I have given a small example of extracting time from time stamp.
package main
import (
"fmt"
"time"
)
func main() {
var b time.Time
fmt.Println(b.Format("15:04:05"))
//THIS WILL GIVE YOU THE TIME
}
Thanks,
Akhil
from go_ibm_db.
@akhilravuri1 Thanks so much. We'll pull the code and test it out.
from go_ibm_db.
Can someone know if any other data type is not supported like CLOB
and TIME
? And what's the plan to fix this issue?
from go_ibm_db.
Hi,
create a sample program of how you are reading the clob and time datatype and share the program.
Thanks,
Akhil
from go_ibm_db.
@akhilravuri1 From @NateMoeller's description, it sounds the error happened when executed db.Query(queryString)
.
from go_ibm_db.
@liuljun CLOB and TIME are supported I just want to know how @NateMoeller is are trying to read the data.
ex for clob:-
package main
import (
"database/sql"
"fmt"
_ "github.com/ibmdb/go_ibm_db"
)
func main() {
con := "HOSTNAME=localhost;PORT=50000;DATABASE=go;UID=**;PWD=***"
db, err := sql.Open("go_ibm_db", con)
if err != nil {
fmt.Println(err)
}
defer db.Close()
db.Exec("drop table clob_main")
_, err = db.Exec("create table clob_main(name clob)")
if err != nil {
fmt.Println(err)
}
st, err := db.Prepare("Insert into clob_main values(?)")
if err != nil {
fmt.Println(err)
}
clob := "akhilfjlewqiufhewqjfewygqiufdbewfewhfibewhjfgkjrehfkbrechrejbfu"
st.Query(clob)
//st.Query()
var a string
err = db.QueryRow("select name from clob_main").Scan(&a)
fmt.Println(a)
}
from go_ibm_db.
@akhilravuri1 Got it. Here are sample code he is using:
for rows.Next() {
for i := 0; i < len(columns); i++ {
valuePtrs[i] = &values[i]
}
rows.Scan(valuePtrs...)
for i := range values {
val := values[i]
v := getValue(val)
}
}
func getValue(val interface{}) interface{} {
var v interface{}
b, hasBytes := val.([]byte)
if hasBytes {
if !utf8.Valid(b) {
v = hex.EncodeToString(b)
} else {
v = string(b)
}
} else {
v = val
}
return v
}
Is it because the getValue function? This function is used to fix another issue on the non-utf8 encoding.
from go_ibm_db.
@liuljun I have tried this ..
st1,err := db.Prepare("select name from clob_main");
rows,err := st1.Query();
for rows.Next(){
var a interface{}
rows.Scan(&a);
var ak = a.([]byte)
fmt.Println(string(ak))
}
I was able to retrieve the data
from go_ibm_db.
@akhilravuri1 @liuljun The query is failing before we even try to read the data:
rows, err := db.Query(queryString)
if err != nil {
log.Error(err.Error())
return err
}
defer rows.Close()
<read data if query succeeds>
The function never attempts to read the data because db.Query
is throwing an error.
from go_ibm_db.
Hi
Can you specify your platform and go version which you are working on.
Thanks,
Akhil
from go_ibm_db.
output of go version
:
go version go1.12.7 darwin/amd64
from go_ibm_db.
@akhilravuri1 , I got a test this afternoon, the data source are Db2, BigSQL and DV(inside DV is a BigSQL).
test case 1: create the clob_main(name clob)
table and select name from clob_main
.
All the 3 data source works fine. and the clob column can be selected properly.
test case2: with data source DV, select a remote table, rather then DV itself,
sql like,
//rows, err := db.Query("SELECT C_INT, C_TM, C_TS FROM "QPLEX"."GAIANDB"."MSSQL_DVSANITY_TEST1" FETCH FIRST 10 ROW ONLY")
Got error message like,
unsupported column type 92
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4abd46]
goroutine 1 [running]:
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0x1, 0x1)
/opt/go/src/database/sql/sql.go:2972 +0x33
panic(0x4d79a0, 0x7acab0)
/opt/go/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).Next(0x0, 0x4fead0)
/opt/go/src/database/sql/sql.go:2657 +0x30
main.main()
/opt/gospace/src/hellp/hello.go:55 +0x242
exit status 2
test case 3: create table create table time_test(C_INT integer, C_TM time)
in 3 data sources, and run sql like, //rows, err := db.Query("SELECT C_INT, C_TM FROM time_test")
It is strange, all got error message(not sure what is the difference between clob and time, in test case 1, clob all got works, but time column got error in test case 3.),
unsupported column type 92
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4abd46]
goroutine 1 [running]:
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0x1, 0x1)
/opt/go/src/database/sql/sql.go:2972 +0x33
panic(0x4d79a0, 0x7acab0)
/opt/go/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).Next(0x0, 0x4fea90)
/opt/go/src/database/sql/sql.go:2657 +0x30
main.main()
/opt/gospace/src/hellp/hello.go:55 +0x242
exit status 2
Hope it is helpful for the investigation. Thank you.
Test code FYR,
func main() {
//3 data sources
//con := "HOSTNAME=9.30.250.67;PORT=32051;DATABASE=bigsql;UID=***;PWD=***"
//con := "HOSTNAME=9.30.167.138;PORT=50000;DATABASE=TPCDS;UID=***;PWD=***"
con := "HOSTNAME=mdv1202-master-1.fyre.ibm.com;PORT=30973;DATABASE=bigsql;UID=***;PWD=***"
db, err := sql.Open("go_ibm_db", con)
if err != nil {
fmt.Println(err)
}
defer db.Close()
//Table clob_main
// db.Exec("drop table clob_main")
// _, err = db.Exec("create table clob_main(name clob)")
// if err != nil {
// fmt.Println(err)
// }
// st, err := db.Prepare("Insert into clob_main values(?)")
// if err != nil {
// fmt.Println(err)
// }
// clob := "akhilfjlewqiufhewqjfewygqiufdbewfewhfibewhjfgkjrehfkbrechrejbfu"
// st.Query(clob)
//Table time_test
// db.Exec("drop table time_test")
// _, err = db.Exec("create table time_test(C_INT integer, C_TM time)")
// if err != nil {
// fmt.Println(err)
// }
// _, err = db.Exec("Insert into clob_main values(10,'07:12:12')")
// if err != nil {
// fmt.Println(err)
// }
//Select sqls
var a string
var b string
var c string
//rows, err := db.Query("select name from clob_main")
//rows, err := db.Query("SELECT C_INT, C_TM, C_TS FROM \"QPLEX\".\"GAIANDB\".\"MSSQL_DVSANITY_TEST1\" FETCH FIRST 10 ROW ONLY")
rows, err := db.Query("SELECT C_INT, C_TM FROM time_test")
//rows, err := db.Query("SELECT C_INT, C_TM FROM USER999.MSSQL_DVSANITY_TEST1")
if err != nil {
fmt.Println(err.Error())
}
defer rows.Close()
for rows.Next() {
rows.Scan(&a, &b)
}
fmt.Println(a)
fmt.Println(b)
fmt.Println(c)
}
from go_ibm_db.
It is strange, all got error message(not sure what is the difference between clob and time, in test case 1, clob all got works, but time column got error in test case 3.),
Thanks, @maxatcn for your information.
from go_ibm_db.
As for CLOB type, one of failure case is:
Not sure if the length is too long?
from go_ibm_db.
Hi @liuljun
CLOB type can have up to 2GB. I guess it is fine.
CLOB should be working fine But I will create a column with the same size and I will try to reproduce the issue. From @maxatcn comment, I think when there is time involved it is creating error I will reproduce it and fix this.
Thanks,
Akhil
from go_ibm_db.
Hi @NateMoeller and @liuljun
I have some changes can you pull the latest code and try it.
If it shows {HY090} [IBM][CLI Driver] CLI0131E Invalid string or buffer length.
Can you change the size to 2147483646 and try it?
If you face any issues please let me know.
Thanks,
Akhil
from go_ibm_db.
@akhilravuri1 We test CLOB(2147483647) and it reported {HY090} [IBM][CLI Driver] CLI0131E Invalid string or buffer length.
If changed to CLOB(2147483646) , it's fine. However, we are unable to change it as the table definition is from customer database.
from go_ibm_db.
@akhilravuri1 Still running into an issue with TIME
values. It looks like we can read the value, but when converting to json I am seeing this error:
json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
This is happening because the value that is read is: -0001-11-30T19:12:12+08:00
, which is actually invalid because the year is -0001. We also don't want to be showing the year/day/month when the type is TIME
.
I think the value will need to be formatted to omit the date part of the value.
from go_ibm_db.
@akhilravuri1 When can we have conclusion on the CLOB(2GB) support?
from go_ibm_db.
@akhilravuri1 We test the code and it works now. Thanks for help.
from go_ibm_db.
Related Issues (20)
- Inconsistent GSKIT Error 2 HOT 12
- fatal error: invalid pointer found on stack HOT 6
- [help]how to debug the cost breakdown HOT 2
- The gbk encoded Chinese field may be truncated when read in the utf8 operating environment HOT 1
- SQL_DECIMAL type uses comma as separator, not period, so it can't convert to float64 HOT 5
- [CRITICAL] - double byte characters are truncated for CHAR columns HOT 1
- Driver support sql.Named or not? HOT 2
- DECIMAL Precision is lost by binding variables by inserting string HOT 4
- Get Clob CLI0131E Invalid string or buffer lengt HOT 2
- Does go_ibm_db support informix HOT 1
- Support go_ibm_db driver with UBI 9 and openssl 3.0 HOT 6
- Adding Dynamic Cursor Functionalities HOT 1
- Add env var to override cli driver download url
- DB2 Connection TCP/IP Error HOT 13
- fatal error: 'sqlcli1.h' file not found on macOS HOT 1
- fatal error: 'sqlcli1.h' file not found on macOS HOT 2
- Dockerfile issue HOT 14
- Golang DB2 driver issue HOT 1
- The go_ibm_db driver cannot be registered sql: unknown driver "go_ibm_db" (forgotten import?) HOT 7
- Decimal value by instering as string BUG HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go_ibm_db.