fix sqlgetdata regression in odbc (#15161)
* fix sqlgetdata import * fix db_odbc * more fixes * fix style
This commit is contained in:
parent
d9ed816b10
commit
a528382e05
2 changed files with 12 additions and 16 deletions
|
|
@ -279,7 +279,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
|
||||||
## Rows are retrieved from the server at each iteration.
|
## Rows are retrieved from the server at each iteration.
|
||||||
var
|
var
|
||||||
rowRes: Row
|
rowRes: Row
|
||||||
sz: TSqlInteger = 0
|
sz: TSqlLen = 0
|
||||||
cCnt: TSqlSmallInt = 0
|
cCnt: TSqlSmallInt = 0
|
||||||
res: TSqlSmallInt = 0
|
res: TSqlSmallInt = 0
|
||||||
res = db.prepareFetch(query, args)
|
res = db.prepareFetch(query, args)
|
||||||
|
|
@ -293,8 +293,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
cast[cstring](buf.addr), 4095, sz.addr))
|
||||||
sz.addr))
|
|
||||||
rowRes[colId-1] = $(addr buf)
|
rowRes[colId-1] = $(addr buf)
|
||||||
yield rowRes
|
yield rowRes
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
|
|
@ -308,7 +307,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
## on demand using []. Returned handle is valid only within the iterator body.
|
## on demand using []. Returned handle is valid only within the iterator body.
|
||||||
var
|
var
|
||||||
rowRes: Row = @[]
|
rowRes: Row = @[]
|
||||||
sz: TSqlInteger = 0
|
sz: TSqlLen = 0
|
||||||
cCnt: TSqlSmallInt = 0
|
cCnt: TSqlSmallInt = 0
|
||||||
res: TSqlSmallInt = 0
|
res: TSqlSmallInt = 0
|
||||||
res = db.prepareFetch(query, args)
|
res = db.prepareFetch(query, args)
|
||||||
|
|
@ -322,8 +321,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
cast[cstring](buf.addr), 4095, sz.addr))
|
||||||
sz.addr))
|
|
||||||
rowRes[colId-1] = $(addr buf)
|
rowRes[colId-1] = $(addr buf)
|
||||||
yield (row: rowRes, len: cCnt.int)
|
yield (row: rowRes, len: cCnt.int)
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
|
|
@ -349,7 +347,7 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
||||||
## will return a Row with empty strings for each column.
|
## will return a Row with empty strings for each column.
|
||||||
var
|
var
|
||||||
rowRes: Row
|
rowRes: Row
|
||||||
sz: TSqlInteger = 0
|
sz: TSqlLen = 0
|
||||||
cCnt: TSqlSmallInt = 0
|
cCnt: TSqlSmallInt = 0
|
||||||
res: TSqlSmallInt = 0
|
res: TSqlSmallInt = 0
|
||||||
res = db.prepareFetch(query, args)
|
res = db.prepareFetch(query, args)
|
||||||
|
|
@ -362,8 +360,7 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
cast[cstring](buf.addr), 4095, sz.addr))
|
||||||
sz.addr))
|
|
||||||
rowRes[colId-1] = $(addr buf)
|
rowRes[colId-1] = $(addr buf)
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
result = rowRes
|
result = rowRes
|
||||||
|
|
@ -377,7 +374,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
var
|
var
|
||||||
rows: seq[Row] = @[]
|
rows: seq[Row] = @[]
|
||||||
rowRes: Row
|
rowRes: Row
|
||||||
sz: TSqlInteger = 0
|
sz: TSqlLen = 0
|
||||||
cCnt: TSqlSmallInt = 0
|
cCnt: TSqlSmallInt = 0
|
||||||
res: TSqlSmallInt = 0
|
res: TSqlSmallInt = 0
|
||||||
res = db.prepareFetch(query, args)
|
res = db.prepareFetch(query, args)
|
||||||
|
|
@ -391,8 +388,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
cast[cstring](buf.addr), 4095, sz.addr))
|
||||||
sz.addr))
|
|
||||||
rowRes[colId-1] = $(addr buf)
|
rowRes[colId-1] = $(addr buf)
|
||||||
rows.add(rowRes)
|
rows.add(rowRes)
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
|
|
|
||||||
|
|
@ -718,19 +718,19 @@ proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt)
|
||||||
proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||||
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||||
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
||||||
ColumnSize: var TSQLULEN,
|
ColumnSize: var TSqlULen,
|
||||||
DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
|
DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
|
||||||
dynlib: odbclib, importc.}
|
dynlib: odbclib, importc.}
|
||||||
proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
|
proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
|
||||||
FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
|
FetchOffset: TSqlLen): TSqlSmallInt{.dynlib: odbclib,
|
||||||
importc.}
|
importc.}
|
||||||
proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
|
proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
|
||||||
irow: TSqlInteger, pcrow: var TSQLULEN,
|
irow: TSqlLen, pcrow: var TSqlULen,
|
||||||
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||||
importc.}
|
importc.}
|
||||||
proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
BufferLength: TSqlLen, StrLen_or_Ind: ptr TSqlLen): TSqlSmallInt{.
|
||||||
dynlib: odbclib, importc.}
|
dynlib: odbclib, importc.}
|
||||||
proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
||||||
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue