Skip to content

Commit b3a463e

Browse files
committed
More notes
1 parent 9f98c9f commit b3a463e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sqllib.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,19 @@ This means you do not need the `SQL_ROW` as such, you can simply `while(sql_fetc
101101

102102
The transaction functions are only slightly modified. `sql_transaction(&sql)` to start, but `sql_safe_commit(&sql)` to commit, and `sql_safe_rollback(&sql)` to roll back. These abort on error with an error to stderr.
103103

104-
Setting up a transaction for your code is recommended, and idea when using the `_safe` functions that abort on error.
104+
Setting up a transaction for your code is recommended, and ideal when using the `_safe` functions that abort on error.
105105

106106
Also, when not in transactions, and single SQL query can fail with a *failed to get lock* error. In such cases the query is automatically retried once before failing.
107107

108+
One trick for using debug is to end with something like
109+
110+
```
111+
if(sqldebug)sql_safe_rollback(&sql);
112+
else sql_safe_commit(&sql);
113+
```
114+
115+
This means you can use the debug mode to print all the queries but not actually do any of the actual SQL at the end, rolling back.
116+
108117
# Examples
109118

110119
## Scanning a table

0 commit comments

Comments
 (0)