Merge branch 'db_odbc2' of https://github.com/jlp765/Nim into jlp765-db_odbc2
This commit is contained in:
commit
2ac265696b
2 changed files with 23 additions and 24 deletions
|
|
@ -210,7 +210,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string {.
|
||||||
add(result, c)
|
add(result, c)
|
||||||
|
|
||||||
proc prepareFetch(db: var DbConn, query: SqlQuery,
|
proc prepareFetch(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]) : TSqlSmallInt {.
|
args: varargs[string, `$`]): TSqlSmallInt {.
|
||||||
tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} =
|
tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} =
|
||||||
# Prepare a statement, execute it and fetch the data to the driver
|
# Prepare a statement, execute it and fetch the data to the driver
|
||||||
# ready for retrieval of the data
|
# ready for retrieval of the data
|
||||||
|
|
@ -222,9 +222,8 @@ proc prepareFetch(db: var DbConn, query: SqlQuery,
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
db.sqlCheck(SQLPrepare(db.stmt, q.PSQLCHAR, q.len.TSqlSmallInt))
|
db.sqlCheck(SQLPrepare(db.stmt, q.PSQLCHAR, q.len.TSqlSmallInt))
|
||||||
db.sqlCheck(SQLExecute(db.stmt))
|
db.sqlCheck(SQLExecute(db.stmt))
|
||||||
var retcode = SQLFetch(db.stmt)
|
result = SQLFetch(db.stmt)
|
||||||
db.sqlCheck(retcode)
|
db.sqlCheck(result)
|
||||||
result=retcode
|
|
||||||
|
|
||||||
proc prepareFetchDirect(db: var DbConn, query: SqlQuery,
|
proc prepareFetchDirect(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]) {.
|
args: varargs[string, `$`]) {.
|
||||||
|
|
@ -250,8 +249,8 @@ proc tryExec*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): bool
|
||||||
var
|
var
|
||||||
rCnt = -1
|
rCnt = -1
|
||||||
res = SQLRowCount(db.stmt, rCnt)
|
res = SQLRowCount(db.stmt, rCnt)
|
||||||
if res != SQL_SUCCESS: dbError(db)
|
|
||||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||||
|
if res != SQL_SUCCESS: dbError(db)
|
||||||
except: discard
|
except: discard
|
||||||
return res == SQL_SUCCESS
|
return res == SQL_SUCCESS
|
||||||
|
|
||||||
|
|
@ -286,7 +285,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
|
||||||
sz: TSqlSmallInt = 0
|
sz: TSqlSmallInt = 0
|
||||||
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
res: TSqlSmallInt = 0.TSqlSmallInt
|
res: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
tempcCnt:TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
tempcCnt: TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
||||||
# tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
# tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
||||||
# after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
# after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
||||||
# so the values of the temporary variable to store the cCnt.
|
# so the values of the temporary variable to store the cCnt.
|
||||||
|
|
@ -308,8 +307,8 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
yield rowRes
|
yield rowRes
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
db.sqlCheck(res)
|
|
||||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||||
|
db.sqlCheck(res)
|
||||||
|
|
||||||
iterator instantRows*(db: var DbConn, query: SqlQuery,
|
iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): InstantRow
|
args: varargs[string, `$`]): InstantRow
|
||||||
|
|
@ -317,11 +316,11 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
## Same as fastRows but returns a handle that can be used to get column text
|
## Same as fastRows but returns a handle that can be used to get column text
|
||||||
## on demand using []. Returned handle is valid only within the interator body.
|
## on demand using []. Returned handle is valid only within the interator body.
|
||||||
var
|
var
|
||||||
rowRes: Row
|
rowRes: Row = @[]
|
||||||
sz: TSqlSmallInt = 0
|
sz: TSqlSmallInt = 0
|
||||||
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
res: TSqlSmallInt = 0.TSqlSmallInt
|
res: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
tempcCnt:TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
tempcCnt: TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
||||||
# tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
# tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
||||||
# after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
# after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
||||||
# so the values of the temporary variable to store the cCnt.
|
# so the values of the temporary variable to store the cCnt.
|
||||||
|
|
@ -343,8 +342,8 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
yield (row: rowRes, len: cCnt.int)
|
yield (row: rowRes, len: cCnt.int)
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
db.sqlCheck(res)
|
|
||||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||||
|
db.sqlCheck(res)
|
||||||
|
|
||||||
proc `[]`*(row: InstantRow, col: int): string {.inline.} =
|
proc `[]`*(row: InstantRow, col: int): string {.inline.} =
|
||||||
## Returns text for given column of the row
|
## Returns text for given column of the row
|
||||||
|
|
@ -364,7 +363,7 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
||||||
sz: TSqlSmallInt = 0.TSqlSmallInt
|
sz: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
res: TSqlSmallInt = 0.TSqlSmallInt
|
res: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
tempcCnt:TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
tempcCnt: TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
||||||
## tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
## tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
||||||
## after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
## after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
||||||
## so the values of the temporary variable to store the cCnt.
|
## so the values of the temporary variable to store the cCnt.
|
||||||
|
|
@ -385,8 +384,8 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
result = rowRes
|
result = rowRes
|
||||||
db.sqlCheck(res)
|
|
||||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||||
|
db.sqlCheck(res)
|
||||||
|
|
||||||
proc getAllRows*(db: var DbConn, query: SqlQuery,
|
proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): seq[Row] {.
|
args: varargs[string, `$`]): seq[Row] {.
|
||||||
|
|
@ -398,7 +397,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
sz: TSqlSmallInt = 0
|
sz: TSqlSmallInt = 0
|
||||||
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
cCnt: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
res: TSqlSmallInt = 0.TSqlSmallInt
|
res: TSqlSmallInt = 0.TSqlSmallInt
|
||||||
tempcCnt:TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
tempcCnt: TSqlSmallInt # temporary cCnt,Fix the field values to be null when the release schema is compiled.
|
||||||
## tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
## tempcCnt,A field to store the number of temporary variables, for unknown reasons,
|
||||||
## after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
## after performing a sqlgetdata function and circulating variables cCnt value will be changed to 0,
|
||||||
## so the values of the temporary variable to store the cCnt.
|
## so the values of the temporary variable to store the cCnt.
|
||||||
|
|
@ -421,8 +420,8 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
rows.add(rowRes)
|
rows.add(rowRes)
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
result = rows
|
result = rows
|
||||||
db.sqlCheck(res)
|
|
||||||
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
properFreeResult(SQL_HANDLE_STMT, db.stmt)
|
||||||
|
db.sqlCheck(res)
|
||||||
|
|
||||||
iterator rows*(db: var DbConn, query: SqlQuery,
|
iterator rows*(db: var DbConn, query: SqlQuery,
|
||||||
args: varargs[string, `$`]): Row {.
|
args: varargs[string, `$`]): Row {.
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -2,7 +2,6 @@
|
||||||
nim c --gc:v2 -r -d:useSysAssert -d:useGcAssert -d:smokeCycles -d:useRealtimeGc tests/gc/gctest
|
nim c --gc:v2 -r -d:useSysAssert -d:useGcAssert -d:smokeCycles -d:useRealtimeGc tests/gc/gctest
|
||||||
|
|
||||||
- document ``this`` pragma
|
- document ``this`` pragma
|
||||||
- document and stress test ``.partial`` object declarations
|
|
||||||
|
|
||||||
essential for 1.0
|
essential for 1.0
|
||||||
=================
|
=================
|
||||||
|
|
@ -24,6 +23,7 @@ essential for 1.0
|
||||||
Not critical for 1.0
|
Not critical for 1.0
|
||||||
====================
|
====================
|
||||||
|
|
||||||
|
- document and stress test ``.partial`` object declarations
|
||||||
- add "all threads are blocked" detection to 'spawn'
|
- add "all threads are blocked" detection to 'spawn'
|
||||||
- figure out why C++ bootstrapping is so much slower
|
- figure out why C++ bootstrapping is so much slower
|
||||||
- The bitwise 'not' operator cold be renamed to 'bnot' to
|
- The bitwise 'not' operator cold be renamed to 'bnot' to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue