aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-12-27 11:40:05 +0000
committerstephan <stephan@noemail.net>2022-12-27 11:40:05 +0000
commitc8f245ab5cebef696de1a59d4568722634b4aaa2 (patch)
tree2edfee4a3ee5ef406d79d1883e0b5b507bb51b8c /ext/wasm/api/sqlite3-api-oo1.js
parent84261bac96a9d5faeb76aec5bcd97d5fdc707400 (diff)
downloadsqlite-c8f245ab5cebef696de1a59d4568722634b4aaa2.tar.gz
sqlite-c8f245ab5cebef696de1a59d4568722634b4aaa2.zip
Add an optional argument to oo1.DB.transaction() to specify an explicit BEGIN qualifier.
FossilOrigin-Name: 507335c12b1dbe21d180cf6f0a0deb4cc737417acb44c8f1d8fac98b86f62b01
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index f72def751..ba210e7f9 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -1180,9 +1180,25 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
Note that transactions may not be nested, so this will throw if
it is called recursively. For nested transactions, use the
savepoint() method or manually manage SAVEPOINTs using exec().
+
+ If called with 2 arguments, the first must be a keyword which
+ is legal immediately after a BEGIN statement, e.g. one of
+ "DEFERRED", "IMMEDIATE", or "EXCLUSIVE". Though the exact list
+ of supported keywords is not hard-coded here, in order to be
+ future-compatible, if the argument does not look like a single
+ keyword then an exception is triggered with a description of
+ the problem.
*/
- transaction: function(callback){
- affirmDbOpen(this).exec("BEGIN");
+ transaction: function(/* [beginQualifier,] */callback){
+ let opener = 'BEGIN';
+ if(arguments.length>1){
+ if(/[^a-zA-Z]/.test(arguments[0])){
+ toss3(capi.SQLITE_MISUSE, "Invalid argument for BEGIN qualifier.");
+ }
+ opener += ' '+arguments[0];
+ callback = arguments[1];
+ }
+ affirmDbOpen(this).exec(opener);
try {
const rc = callback(this);
this.exec("COMMIT");