bugfixes for the high-level postgreSQL wrapper
This commit is contained in:
parent
5eea125ba7
commit
ecb5a8db99
8 changed files with 29 additions and 49 deletions
0
lib/devel/httpclient.nim
Normal file → Executable file
0
lib/devel/httpclient.nim
Normal file → Executable file
0
lib/devel/parseurl.nim
Normal file → Executable file
0
lib/devel/parseurl.nim
Normal file → Executable file
|
|
@ -21,7 +21,7 @@ proc dbError(db: TDbConn) {.noreturn.} =
|
||||||
## raises an EDb exception.
|
## raises an EDb exception.
|
||||||
var e: ref EDb
|
var e: ref EDb
|
||||||
new(e)
|
new(e)
|
||||||
e.msg = PQerrorMessage(db)
|
e.msg = $PQerrorMessage(db)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
proc dbError*(msg: string) {.noreturn.} =
|
proc dbError*(msg: string) {.noreturn.} =
|
||||||
|
|
@ -31,17 +31,9 @@ proc dbError*(msg: string) {.noreturn.} =
|
||||||
e.msg = msg
|
e.msg = msg
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
when false:
|
|
||||||
proc dbQueryOpt*(db: TDbConn, query: string, args: openarray[string]) =
|
|
||||||
var stmt = mysql_stmt_init(db)
|
|
||||||
if stmt == nil: dbError(db)
|
|
||||||
if mysql_stmt_prepare(stmt, query, len(query)) != 0:
|
|
||||||
dbError(db)
|
|
||||||
var
|
|
||||||
bindings: seq[MYSQL_BIND]
|
|
||||||
discard mysql_stmt_close(stmt)
|
|
||||||
|
|
||||||
proc dbQuote(s: string): string =
|
proc dbQuote(s: string): string =
|
||||||
|
#if s.len > 0 and allCharsInSet(s, {'0'..'9'}): result = s
|
||||||
|
#else:
|
||||||
result = "'"
|
result = "'"
|
||||||
for c in items(s):
|
for c in items(s):
|
||||||
if c == '\'': add(result, "''")
|
if c == '\'': add(result, "''")
|
||||||
|
|
@ -86,7 +78,8 @@ proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||||
proc setRow(res: PPGresult, r: var TRow, line, cols: int) =
|
proc setRow(res: PPGresult, r: var TRow, line, cols: int) =
|
||||||
for col in 0..cols-1:
|
for col in 0..cols-1:
|
||||||
setLen(r[col], 0)
|
setLen(r[col], 0)
|
||||||
add(r[col], PQgetvalue(res, line, cols))
|
var x = PQgetvalue(res, line, col)
|
||||||
|
add(r[col], x)
|
||||||
|
|
||||||
iterator dbFastRows*(db: TDbConn, query: TSqlQuery,
|
iterator dbFastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: openarray[string]): TRow =
|
||||||
|
|
@ -118,10 +111,8 @@ proc dbGetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
## executes the query and returns the result dataset's the first column
|
## executes the query and returns the result dataset's the first column
|
||||||
## of the first row. Returns "" if the dataset contains no rows. This uses
|
## of the first row. Returns "" if the dataset contains no rows. This uses
|
||||||
## `dbFastRows`, so it inherits its fragile behaviour.
|
## `dbFastRows`, so it inherits its fragile behaviour.
|
||||||
result = ""
|
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
|
||||||
for row in dbFastRows(db, query, args):
|
result = if isNil(x): "" else: $x
|
||||||
result = row[0]
|
|
||||||
break
|
|
||||||
|
|
||||||
proc dbTryInsertID*(db: TDbConn, query: TSqlQuery,
|
proc dbTryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): int64 =
|
args: openarray[string]): int64 =
|
||||||
|
|
@ -134,11 +125,6 @@ proc dbTryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
result = ParseBiggestInt(val)
|
result = ParseBiggestInt(val)
|
||||||
else:
|
else:
|
||||||
result = -1
|
result = -1
|
||||||
#if mysqlRealQuery(db, q, q.len) != 0'i32:
|
|
||||||
# result = -1'i64
|
|
||||||
#else:
|
|
||||||
# result = mysql_insert_id(db)
|
|
||||||
#LAST_INSERT_ID()
|
|
||||||
|
|
||||||
proc dbInsertID*(db: TDbConn, query: TSqlQuery,
|
proc dbInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: openArray[string]): int64 =
|
||||||
|
|
|
||||||
|
|
@ -194,13 +194,15 @@ proc signalHandler(sig: cint) {.exportc: "signalHandler", noconv.} =
|
||||||
rawWriteStackTrace(buf)
|
rawWriteStackTrace(buf)
|
||||||
|
|
||||||
if s == SIGINT: add(buf, "SIGINT: Interrupted by Ctrl-C.\n")
|
if s == SIGINT: add(buf, "SIGINT: Interrupted by Ctrl-C.\n")
|
||||||
elif s == SIGSEGV: add(buf, "SIGSEGV: Illegal storage access.\n")
|
elif s == SIGSEGV:
|
||||||
|
add(buf, "SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")
|
||||||
elif s == SIGABRT:
|
elif s == SIGABRT:
|
||||||
if dbgAborting: return # the debugger wants to abort
|
if dbgAborting: return # the debugger wants to abort
|
||||||
add(buf, "SIGABRT: Abnormal termination.\n")
|
add(buf, "SIGABRT: Abnormal termination.\n")
|
||||||
elif s == SIGFPE: add(buf, "SIGFPE: Arithmetic error.\n")
|
elif s == SIGFPE: add(buf, "SIGFPE: Arithmetic error.\n")
|
||||||
elif s == SIGILL: add(buf, "SIGILL: Illegal operation.\n")
|
elif s == SIGILL: add(buf, "SIGILL: Illegal operation.\n")
|
||||||
elif s == SIGBUS: add(buf, "SIGBUS: Illegal storage access.\n")
|
elif s == SIGBUS:
|
||||||
|
add(buf, "SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
|
||||||
else: add(buf, "unknown signal\n")
|
else: add(buf, "unknown signal\n")
|
||||||
writeToStdErr(buf)
|
writeToStdErr(buf)
|
||||||
dbgAborting = True # play safe here...
|
dbgAborting = True # play safe here...
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ proc readLine(f: TFile): string =
|
||||||
result = ""
|
result = ""
|
||||||
rawReadLine(f, result)
|
rawReadLine(f, result)
|
||||||
|
|
||||||
proc write(f: TFile, s: string) = fputs(s, f)
|
|
||||||
proc write(f: TFile, i: int) =
|
proc write(f: TFile, i: int) =
|
||||||
when sizeof(int) == 8:
|
when sizeof(int) == 8:
|
||||||
fprintf(f, "%lld", i)
|
fprintf(f, "%lld", i)
|
||||||
|
|
@ -167,6 +166,10 @@ proc writeChars(f: TFile, a: openarray[char], start, len: int): int =
|
||||||
proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
|
proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
|
||||||
result = fwrite(buffer, 1, len, f)
|
result = fwrite(buffer, 1, len, f)
|
||||||
|
|
||||||
|
proc write(f: TFile, s: string) =
|
||||||
|
if writeBuffer(f, cstring(s), s.len) != s.len:
|
||||||
|
raise newException(EIO, "cannot write string to file")
|
||||||
|
|
||||||
proc setFilePos(f: TFile, pos: int64) =
|
proc setFilePos(f: TFile, pos: int64) =
|
||||||
if fseek(f, clong(pos), 0) != 0:
|
if fseek(f, clong(pos), 0) != 0:
|
||||||
raise newException(EIO, "cannot set file position")
|
raise newException(EIO, "cannot set file position")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
Discuss Nimrod in our `forum <http://force7.de/heimdall>`_.
|
Discuss Nimrod in our `forum <http://force7.de/heimdall>`_.
|
||||||
|
|
||||||
|
We also have a `Wiki <http://force7.de/niwiki>`_.
|
||||||
|
|
||||||
Visit our project page at Launchpad: https://launchpad.net/nimrod.
|
Visit our project page at Launchpad: https://launchpad.net/nimrod.
|
||||||
|
|
||||||
Bug reports: https://bugs.launchpad.net/nimrod.
|
Bug reports: https://bugs.launchpad.net/nimrod.
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ Bugfixes
|
||||||
- Fixed bug #502670 (underscores in identifiers).
|
- Fixed bug #502670 (underscores in identifiers).
|
||||||
- Fixed a bug in the ``parsexml`` module concerning the parsing of
|
- Fixed a bug in the ``parsexml`` module concerning the parsing of
|
||||||
``<tag attr="value" />``.
|
``<tag attr="value" />``.
|
||||||
|
- ``system.write(f: TFile, s: string)`` now works even if ``s`` contains binary
|
||||||
|
zeros.
|
||||||
|
|
||||||
|
|
||||||
Additions
|
Additions
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ flexibility for speed. You get both.
|
||||||
this programming modell as convenient as possible
|
this programming modell as convenient as possible
|
||||||
|
|
||||||
|
|
||||||
|
Why is it named Nimrod?
|
||||||
|
-----------------------
|
||||||
|
You have to find out for yourself. If you don't find a tongue-in-cheek
|
||||||
|
interpretation you have to look harder.
|
||||||
|
|
||||||
|
|
||||||
How is Nimrod licensed?
|
How is Nimrod licensed?
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|
@ -54,9 +60,9 @@ If you delete the line ``gcc.path = r"$nimrod\dist\mingw\bin"``, Nimrod uses
|
||||||
the GCC from your ``PATH`` environment variable.
|
the GCC from your ``PATH`` environment variable.
|
||||||
|
|
||||||
If you cannot modify ``$nimrod\config\nimrod.cfg``, copy
|
If you cannot modify ``$nimrod\config\nimrod.cfg``, copy
|
||||||
``$nimrod\config\nimrod.cfg`` to ``$APPDATA\nimrod.cfg`` and modify
|
``$nimrod\config\nimrod.cfg`` to ``%APPDATA%\nimrod.cfg`` and modify
|
||||||
``$APPDATA\nimrod.cfg`` instead. To determine what ``$APPDATA`` means for your
|
``%APPDATA%\nimrod.cfg`` instead. To determine what ``%APPDATA%`` means for
|
||||||
Windows account, use the shell command::
|
your Windows account, use the shell command::
|
||||||
|
|
||||||
echo %APPDATA%
|
echo %APPDATA%
|
||||||
|
|
||||||
|
|
@ -90,26 +96,5 @@ different command line arguments try the ``--passc`` and ``--passl`` switches.
|
||||||
Unsupported compilers contain serious bugs that keep them from bootstrapping
|
Unsupported compilers contain serious bugs that keep them from bootstrapping
|
||||||
Nimrod.
|
Nimrod.
|
||||||
|
|
||||||
The linker outputs strange errors about missing symbols
|
|
||||||
-------------------------------------------------------
|
|
||||||
|
|
||||||
I have seen this bug only with the GNU linker. The reason for this unknown.
|
|
||||||
Try recompiling your code with the ``--force_build`` command line switch.
|
|
||||||
|
|
||||||
|
|
||||||
Why is compilation so slow?
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
There are two reasons for this:
|
|
||||||
|
|
||||||
(1) Nimrod always recompiles **everything** (but only calls the C compiler for
|
|
||||||
modules that changed). In a future version, only modules that have changed
|
|
||||||
will be recompiled.
|
|
||||||
(2) The C compiler that is called by Nimrod may be slow.
|
|
||||||
Especially GCC's compile times are not very heady. On Linux you may be able
|
|
||||||
to get `Tiny C <http://bellard.org/tcc/>`_ to work. TCC has excellent
|
|
||||||
compile times. You should not use TCC for producing the release version
|
|
||||||
though, as it has no optimizer.
|
|
||||||
|
|
||||||
Note that from version 0.7.10 onwards the default build produces an optimized
|
|
||||||
binary.
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue