I don't get it why the following Rows iterator is safe and slower and FastRows is not:
iterator Rows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
## same as `FastRows`, but slower and safe.
for r in FastRows(db, query, args): yield r
iterator FastRows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
## executes the query and iterates over the result dataset. This is very
## fast, but potenially dangerous: If the for-loop-body executes another
## query, the results can be undefined. For Sqlite it is safe though.
var stmt = setupQuery(db, query, args)
var L = (columnCount(stmt))
var result = newRow(L)
while step(stmt) == SQLITE_ROW:
setRow(stmt, result, L)
yield result
if finalize(stmt) != SQLITE_OK: dbError(db)
There is no difference for Sqlite. There is only a difference for the MySQL backend. The idea was that you only change the import to make the code use a different DB backend ... (And it works ;-) I did exactly this for this forum...) Ok ok, you may need to adapt the SQL too.
Thinking about it, maybe I shouldn't have introduced it in the first place; it only matters for MySQL optimizations. Maybe we should deprecate it.