Skip to content

Commit 909a2f5

Browse files
committed
readme, null terminator modified and 2GB spported
1 parent 64e65fd commit 909a2f5

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

column.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ func (l *BufferLen) GetData(h api.SQLHSTMT, idx int, ctype api.SQLSMALLINT, buf
2828
}
2929

3030
func (l *BufferLen) Bind(h api.SQLHSTMT, idx int, ctype api.SQLSMALLINT, buf []byte) api.SQLRETURN {
31+
if len(buf) <= 2147483647 {
32+
return api.SQLBindCol(h, api.SQLUSMALLINT(idx+1), ctype,
33+
buf, api.SQLLEN(len(buf)),
34+
(*api.SQLLEN)(l))
35+
}
3136
return api.SQLBindCol(h, api.SQLUSMALLINT(idx+1), ctype,
32-
buf, api.SQLLEN(len(buf)),
37+
buf, api.SQLLEN(len(buf)-1),
3338
(*api.SQLLEN)(l))
3439
}
3540

@@ -235,10 +240,10 @@ func NewVariableWidthColumn(b *BaseColumn, ctype api.SQLSMALLINT, colWidth api.S
235240
l := int(colWidth)
236241
switch ctype {
237242
case api.SQL_C_WCHAR, api.SQL_C_DBCHAR:
238-
//l += 1 // room for null-termination character
243+
l++ // room for null-termination character
239244
l *= 2 // wchars take 2 bytes each
240245
case api.SQL_C_CHAR:
241-
//l += 1 // room for null-termination character
246+
l++ // room for null-termination character
242247
case api.SQL_C_BINARY:
243248
// nothing to do
244249
default:

installer/setup.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ func linux_untar(clidriver string, targetDirectory string) error {
7979
func main() {
8080
var target, cliFileName string
8181
var unpackageType int
82-
_, errDir := os.LookupEnv("IBM_DB_DIR")
83-
_, errHome := os.LookupEnv("IBM_DB_HOME")
84-
_, errLib := os.LookupEnv("IBM_DB_LIB")
85-
86-
if errDir || errHome || errLib {
87-
fmt.Printf("Failed to fetch environment variables.")
88-
os.Exit(1)
82+
value, errDir := os.LookupEnv("DB2HOME")
83+
if errDir {
84+
if runtime.GOOS == "windows" {
85+
fmt.Println("clidriver is already present in this path ", value)
86+
fmt.Println("Please add this path to PATH environment variable")
87+
os.Exit(1)
88+
} else {
89+
fmt.Println("clidriver is already present in this path ", value)
90+
fmt.Println("Please set CGO_CFLAGS, CGO_LDFLAGS and LD_LIBRARY_PATH or DYLD_LIBRARY_PATH environment variables")
91+
os.Exit(1)
92+
}
8993
}
9094
if len(os.Args) == 2 {
9195
target = os.Args[1]

0 commit comments

Comments
 (0)