Skip to content

Commit

Permalink
use name transactions (savepoints) for sqlite transactions
Browse files Browse the repository at this point in the history
Pg_qlite_begin and Pg_sqlite_commit are functions used by the Pgtcl pg_sqlite command to begin and commit transactions in sqlite. They used to just do a sqlite "begin" and "commit", but we now swap them to use a named transaction via "savepoint pg_sqlite;" and "release savepoint pg_sqlite;".

This allows the import of postgres results using pg_sqlite to occur within an outer sqlite transaction.

Version bump to 2.6.2.

* https://www.sqlite.org/lang_transaction.html
* https://www.sqlite.org/lang_savepoint.html
  • Loading branch information
lehenbauer committed Mar 2, 2019
1 parent fb5910b commit 1cf244a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([pgtcl], [2.6.1])
AC_INIT([pgtcl], [2.6.2])

#-----
# Version with patch stripped
Expand Down
4 changes: 2 additions & 2 deletions generic/pgtclSqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int
Pg_sqlite_begin(Tcl_Interp *interp, sqlite3 *sqlite_db)
{
char *errMsg;
if(sqlite3_exec(sqlite_db, "begin;", NULL, NULL, &errMsg) != SQLITE_OK) {
if(sqlite3_exec(sqlite_db, "savepoint pg_sqlite;", NULL, NULL, &errMsg) != SQLITE_OK) {
Tcl_AppendResult(interp, errMsg, " when beginning a transaction", (char *)NULL);
return TCL_ERROR;
}
Expand All @@ -73,7 +73,7 @@ int
Pg_sqlite_commit(Tcl_Interp *interp, sqlite3 *sqlite_db)
{
char *errMsg;
if(sqlite3_exec(sqlite_db, "commit;", NULL, NULL, &errMsg) != SQLITE_OK) {
if(sqlite3_exec(sqlite_db, "release savepoint pg_sqlite;", NULL, NULL, &errMsg) != SQLITE_OK) {
Tcl_AppendResult(interp, errMsg, " when comitting a transaction", (char *)NULL);
return TCL_ERROR;
}
Expand Down

0 comments on commit 1cf244a

Please sign in to comment.