summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-04-24 08:44:36 +0200
committerAraq <rumpf_a@web.de>2012-04-24 08:44:36 +0200
commitafd8ca2f156aa76f621145fe0040f7da8be7b126 (patch)
tree83c073863e02cafe8b0fce22cf6b5f12ae3361e3
parent7e7c514dfcb6fcd83356ecadf5fec5526d7c332d (diff)
downloadNim-afd8ca2f156aa76f621145fe0040f7da8be7b126.tar.gz
added db_*.getRow
-rw-r--r--doc/gc.txt7
-rwxr-xr-xlib/impure/db_mysql.nim15
-rwxr-xr-xlib/impure/db_postgres.nim9
-rwxr-xr-xlib/impure/db_sqlite.nim10
-rwxr-xr-xtodo.txt4
-rwxr-xr-xweb/news.txt1
6 files changed, 42 insertions, 4 deletions
diff --git a/doc/gc.txt b/doc/gc.txt
index 26fa1e8a3..b29d6caa5 100644
--- a/doc/gc.txt
+++ b/doc/gc.txt
@@ -22,7 +22,10 @@ The GC is only triggered in a memory allocation operation. It it not triggered
 by some timer and does not run in a background thread.
 
 The cycle collector can be en-/disabled independently from the other parts of
-the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``.
+the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``. The
+compiler analyses the types for their possibility to build cycles, but often
+it is necessary to help this analysis with the ``acyclic`` pragma (see
+`acyclic <manual.html#acyclic-pragma>`_ for further information).
 
 To force a full collection call ``GC_fullCollect``. Note that it is generally
 better to let the GC do its work and not enforce a full collection.
@@ -79,7 +82,7 @@ uses microseconds for convenience.
 
 
 Define the symbol ``reportMissedDeadlines`` to make the GC output whenever it
-missed a deadline. The reporting will be enhances and supported by the API in
+missed a deadline. The reporting will be enhanced and supported by the API in
 later versions of the collector.
 
 
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim
index 70dec21b9..4c77c707f 100755
--- a/lib/impure/db_mysql.nim
+++ b/lib/impure/db_mysql.nim
@@ -99,6 +99,21 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
       yield result
     properFreeResult(sqlres, row)
 
+proc getRow*(db: TDbConn, query: TSqlQuery,
+             args: openarray[string]): TRow =
+  ## retrieves a single row.
+  Exec(db, query, args)
+  var sqlres = mysql.UseResult(db)
+  if sqlres != nil:
+    var L = int(mysql.NumFields(sqlres))
+    var result = newRow(L)
+    var row = mysql.FetchRow(sqlres)
+    if row != nil: 
+      for i in 0..L-1: 
+        setLen(result[i], 0)
+        add(result[i], row[i])
+    properFreeResult(sqlres, row)
+
 proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
                  args: openarray[string]): seq[TRow] =
   ## executes the query and returns the whole result dataset.
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim
index 7e2cef525..dff607081 100755
--- a/lib/impure/db_postgres.nim
+++ b/lib/impure/db_postgres.nim
@@ -103,6 +103,15 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
     yield result
   PQclear(res)
 
+proc getRow*(db: TDbConn, query: TSqlQuery,
+             args: openarray[string]): TRow =
+  ## retrieves a single row.
+  var res = setupQuery(db, query, args)
+  var L = int(PQnfields(res))
+  var result = newRow(L)
+  setRow(res, result, 0, L)
+  PQclear(res)
+
 proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
                  args: openarray[string]): seq[TRow] =
   ## executes the query and returns the whole result dataset.
diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim
index dbe34fd51..d800a2317 100755
--- a/lib/impure/db_sqlite.nim
+++ b/lib/impure/db_sqlite.nim
@@ -101,6 +101,16 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
     yield result
   if finalize(stmt) != SQLITE_OK: dbError(db)
 
+proc getRow*(db: TDbConn, query: TSqlQuery,
+             args: openarray[string]): TRow =
+  ## retrieves a single row.
+  var stmt = setupQuery(db, query, args)
+  var L = int(columnCount(stmt))
+  var result = newRow(L)
+  if step(stmt) == SQLITE_ROW: 
+    setRow(stmt, result, L)
+  if finalize(stmt) != SQLITE_OK: dbError(db)
+
 proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
                  args: openarray[string]): seq[TRow] =
   ## executes the query and returns the whole result dataset.
diff --git a/todo.txt b/todo.txt
index 722f5cef7..761c6d419 100755
--- a/todo.txt
+++ b/todo.txt
@@ -10,14 +10,14 @@ version 0.9.0
   - Test capture of for loop vars; test generics;
   - test constant closures
   - implement closures that support nesting > 1
+- implement proper coroutines
 
-- document and fix 'do' notation
+- document 'do' notation
 - dead code elim for JS backend; 'of' operator for JS backend
 - unsigned ints and bignums; requires abstract integer literal type: 
   use tyInt+node for that
 - implement the high level optimizer
 - change overloading resolution
-- implement proper coroutines
 - ``hoist`` pragma for loop hoisting
 - we need to support iteration of 2 different data structures in parallel
 - make exceptions compatible with C++ exceptions
diff --git a/web/news.txt b/web/news.txt
index 090458d02..8504be619 100755
--- a/web/news.txt
+++ b/web/news.txt
@@ -42,6 +42,7 @@ Library Additions
   values of an enum.
 - Added ``system.TInteger`` and ``system.TNumber`` type classes matching
   any of the corresponding type available in nimrod.
+- Added ``system.clamp`` to limit a value within an interval ``[a, b]``.
 - The GC supports (soft) realtime systems via ``GC_setMaxPause`` 
   and ``GC_step`` procs.