Skip to content

Commit c9ab3e6

Browse files
vmathur12Vikas Mathur
andauthored
Code alignment (#244)
* Updated code alignment --------- Co-authored-by: Vikas Mathur <[email protected]>
1 parent 30028d8 commit c9ab3e6

23 files changed

+502
-425
lines changed

api/api.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type (
5959
// UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
6060
// with a terminating NUL removed.
6161
func UTF16ToString(s []uint16) string {
62-
trc.Trace1("api/api.go UTF16ToString() - ENTRY")
62+
trc.Trace1("api/api.go UTF16ToString() - ENTRY")
6363
for i, v := range s {
6464
if v == 0 {
6565
s = s[0:i]
@@ -74,9 +74,9 @@ func UTF16ToString(s []uint16) string {
7474
// with a terminating NUL added.
7575
//func StringToUTF16(s string) []uint16 { return utf16.Encode([]rune(s + "\u0000")) }
7676
func StringToUTF16(s string) []uint16 {
77-
trc.Trace1("api/api.go StringToUTF16()")
77+
trc.Trace1("api/api.go StringToUTF16()")
7878
trc.Trace1(fmt.Sprintf("api/api.go StringToUTF16() - s = %s", s))
79-
79+
8080
if runtime.GOOS == "zos"{
8181
return utf16.Encode([]rune(s))
8282
}else {
@@ -91,26 +91,26 @@ func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
9191

9292
// ExtractUTF16Str uses unsafe package to copy UTF16 string to a byte slice.
9393
func ExtractUTF16Str(s []uint16) []byte {
94-
trc.Trace1("api/api.go ExtractUTF16Str() - ENTRY")
95-
94+
trc.Trace1("api/api.go ExtractUTF16Str() - ENTRY")
95+
9696
var out []byte
9797
for i := range s {
9898
b := Extract(unsafe.Pointer(&s[i]), unsafe.Sizeof(s[i]))
9999
out = append(out, b...)
100100
}
101-
101+
102102
trc.Trace1("api/api.go ExtractUTF16Str() - EXIT")
103103
return out
104104
}
105105

106106
func Extract(ptr unsafe.Pointer, size uintptr) []byte {
107107
trc.Trace1("api/api.go Extract() - ENTRY")
108-
108+
109109
out := make([]byte, size)
110110
for i := range out {
111111
out[i] = *((*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(i))))
112112
}
113-
113+
114114
trc.Trace1("api/api.go Extract() - EXIT")
115115
return out
116116
}

api/api_unix.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
package api
1010

1111
import (
12-
trc "github.com/ibmdb/go_ibm_db/log2"
12+
trc "github.com/ibmdb/go_ibm_db/log2"
1313
"fmt"
1414
)
1515

@@ -177,23 +177,23 @@ type (
177177
)
178178

179179
func SQLSetEnvUIntPtrAttr(environmentHandle SQLHENV, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
180-
trc.Trace1("api/api_unix.go SQLSetEnvUIntPtrAttr() - ENTRY)
180+
trc.Trace1("api/api_unix.go SQLSetEnvUIntPtrAttr() - ENTRY")
181181
trc.Trace1(fmt.Sprintf("attribute=%d, valuePtr=0x%x, stringLength=%d", attribute, valuePtr, stringLength))
182182

183183
r := C.sqlSetEnvUIntPtrAttr(C.SQLHENV(environmentHandle), C.SQLINTEGER(attribute), C.uintptr_t(valuePtr), C.SQLINTEGER(stringLength))
184-
184+
185185
trc.Trace1(fmt.Sprintf("r = %d", r))
186-
trc.Trace1("api/api_unix.go SQLSetEnvUIntPtrAttr() - EXIT)
186+
trc.Trace1("api/api_unix.go SQLSetEnvUIntPtrAttr() - EXIT")
187187
return SQLRETURN(r)
188188
}
189189

190190
func SQLSetConnectUIntPtrAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
191-
trc.Trace1("api/api_unix.go SQLSetConnectUIntPtrAttr() - ENTRY)
191+
trc.Trace1("api/api_unix.go SQLSetConnectUIntPtrAttr() - ENTRY")
192192
trc.Trace1(fmt.Sprintf("attribute=%d, valuePtr=%x, stringLength=%d", attribute, valuePtr, stringLength))
193-
193+
194194
r := C.sqlSetConnectUIntPtrAttr(C.SQLHDBC(connectionHandle), C.SQLINTEGER(attribute), C.uintptr_t(valuePtr), C.SQLINTEGER(stringLength))
195-
195+
196196
trc.Trace1(fmt.Sprintf("r = %d", r))
197-
trc.Trace1("api/api_unix.go SQLSetConnectUIntPtrAttr() - EXIT)
197+
trc.Trace1("api/api_unix.go SQLSetConnectUIntPtrAttr() - EXIT")
198198
return SQLRETURN(r)
199199
}

api/api_windows.go

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package api
66

77
import (
88
"syscall"
9-
trc "github.com/ibmdb/go_ibm_db/log2"
9+
trc "github.com/ibmdb/go_ibm_db/log2"
1010
"fmt"
1111
)
1212

@@ -112,10 +112,51 @@ const (
112112
SQL_AUTOCOMMIT_ON = 1
113113
SQL_AUTOCOMMIT_DEFAULT = SQL_AUTOCOMMIT_ON
114114
SQL_ATTR_PARAMSET_SIZE = 22
115+
// Statement attributes
116+
SQL_ROW_NUMBER = 14
117+
118+
// Statement attributes for ODBC 3.0
119+
SQL_ATTR_CURSOR_TYPE = 6
120+
//SQL_ATTR_PARAMSET_SIZE = 22
121+
SQL_ATTR_ROW_NUMBER = SQL_ROW_NUMBER
122+
SQL_ATTR_ROW_ARRAY_SIZE = 27
123+
SQL_ATTR_ROW_STATUS_PTR = 25
124+
SQL_ATTR_ROWS_FETCHED_PTR = 26
125+
126+
// SQL_CURSOR_TYPE options
127+
SQL_CURSOR_FORWARD_ONLY = 0
128+
SQL_CURSOR_KEYSET_DRIVEN = 1
129+
SQL_CURSOR_DYNAMIC = 2
130+
SQL_CURSOR_STATIC = 3
131+
SQL_CURSOR_TYPE_DEFAULT = SQL_CURSOR_FORWARD_ONLY
132+
133+
// Operations in SQLSetPos
134+
SQL_POSITION = 0
135+
SQL_REFRESH = 1
136+
SQL_UPDATE = 2
137+
SQL_DELETE = 3
138+
139+
// Operations in SQLBulkOperations
140+
SQL_ADD = 4
141+
SQL_SETPOS_MAX_OPTION_VALUE = SQL_ADD
142+
SQL_UPDATE_BY_BOOKMARK = 5 // Check if to be removed
143+
SQL_DELETE_BY_BOOKMARK = 6
144+
SQL_FETCH_BY_BOOKMARK = 7
145+
146+
// Lock options in SQLSetPos
147+
SQL_LOCK_NO_CHANGE = 0
115148

116149
SQL_IS_UINTEGER = -5
117150
SQL_IS_INTEGER = -6
118151

152+
// Fetch Orientation in SQLFetchScroll
153+
SQL_FETCH_NEXT = 1
154+
SQL_FETCH_FIRST = 2
155+
SQL_FETCH_LAST = 3
156+
SQL_FETCH_PRIOR = 4
157+
SQL_FETCH_ABSOLUTE = 5
158+
SQL_FETCH_RELATIVE = 6
159+
119160
//Connection pooling
120161
SQL_ATTR_CONNECTION_POOLING = 201
121162
SQL_ATTR_CP_MATCH = 202
@@ -145,14 +186,15 @@ type (
145186
SQLHSTMT SQLHANDLE
146187
SQLHWND uintptr
147188

148-
SQLWCHAR uint16
149-
SQLSCHAR int8
150-
SQLSMALLINT int16
151-
SQLUSMALLINT uint16
152-
SQLINTEGER int32
153-
SQLUINTEGER uint32
154-
SQLPOINTER uintptr
155-
SQLRETURN SQLSMALLINT
189+
SQLWCHAR uint16
190+
SQLSCHAR int8
191+
SQLSMALLINT int16
192+
SQLUSMALLINT uint16
193+
SQLINTEGER int32
194+
SQLUINTEGER uint32
195+
SQLPOINTER uintptr
196+
SQLRETURN SQLSMALLINT
197+
SQLSETPOSIROW SQLUSMALLINT
156198

157199
SQLGUID struct {
158200
Data1 uint32
@@ -163,24 +205,24 @@ type (
163205
)
164206

165207
func SQLSetEnvUIntPtrAttr(environmentHandle SQLHENV, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
166-
trc.Trace1("api/api_windows.go SQLSetEnvUIntPtrAttr() - ENTRY")
208+
trc.Trace1("api/api_windows.go SQLSetEnvUIntPtrAttr() - ENTRY")
167209
trc.Trace1(fmt.Sprintf("attribute=%d, valuePtr=0x%x, stringLength=%d", attribute, valuePtr, stringLength))
168-
210+
169211
r0, _, _ := syscall.Syscall6(procSQLSetEnvAttr.Addr(), 4, uintptr(environmentHandle), uintptr(attribute), uintptr(valuePtr), uintptr(stringLength), 0, 0)
170212
ret = SQLRETURN(r0)
171213

172-
trc.Trace1(fmt.Sprintf("ret = %d", ret))
214+
trc.Trace1(fmt.Sprintf("ret = %d", ret))
173215
trc.Trace1("api/api_windows.go SQLSetEnvUIntPtrAttr() - EXIT")
174216
return
175217
}
176218

177219
func SQLSetConnectUIntPtrAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
178-
trc.Trace1("api/api_windows.go SQLSetConnectUIntPtrAttr() - ENTRY")
220+
trc.Trace1("api/api_windows.go SQLSetConnectUIntPtrAttr() - ENTRY")
179221
trc.Trace1(fmt.Sprintf("attribute=%d, valuePtr=%x, stringLength=%d", attribute, valuePtr, stringLength))
180-
222+
181223
r0, _, _ := syscall.Syscall6(procSQLSetConnectAttrW.Addr(), 4, uintptr(connectionHandle), uintptr(attribute), uintptr(valuePtr), uintptr(stringLength), 0, 0)
182224
ret = SQLRETURN(r0)
183-
225+
184226
trc.Trace1(fmt.Sprintf("ret = %d", ret))
185227
trc.Trace1("api/api_windows.go SQLSetConnectUIntPtrAttr() - EXIT")
186228
return

api/api_zos.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"log"
1111
"runtime"
1212
"unsafe"
13-
1413
"github.com/ibmruntimes/go-recordio/v2/utils"
1514
trc "github.com/ibmdb/go_ibm_db/log2"
1615
"fmt"
@@ -166,21 +165,21 @@ type (
166165
)
167166

168167
func SQLSetEnvUIntPtrAttr(environmentHandle SQLHENV, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
169-
trc.Trace1("api/api_zos.go SQLSetEnvUIntPtrAttr() - ENTRY")
170-
168+
trc.Trace1("api/api_zos.go SQLSetEnvUIntPtrAttr() - ENTRY")
169+
171170
r := utils.CfuncEbcdic(getFunc(&dll, "SQLSetEnvAttr"), uintptr(environmentHandle), uintptr(attribute), uintptr(valuePtr), uintptr(stringLength))
172-
171+
173172
trc.Trace1(fmt.Sprintf("r = %d", r))
174173
trc.Trace1("api/api_zos.go SQLSetEnvUIntPtrAttr() - EXIT")
175174
return SQLRETURN(r)
176175
}
177176

178177
func SQLSetConnectUIntPtrAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
179-
trc.Trace1("api/api_zos.go SQLSetConnectUIntPtrAttr() - ENTRY")
178+
trc.Trace1("api/api_zos.go SQLSetConnectUIntPtrAttr() - ENTRY")
180179

181180
r := utils.CfuncEbcdic(getFunc(&dll, "SQLSetConnectAttr"), uintptr(connectionHandle), uintptr(attribute), uintptr(valuePtr), uintptr(stringLength))
182-
181+
183182
trc.Trace1(fmt.Sprintf("r = %d", r))
184183
trc.Trace1("api/api_zos.go SQLSetConnectUIntPtrAttr() - EXIT")
185184
return SQLRETURN(r)
186-
}
185+
}

0 commit comments

Comments
 (0)