Diff

util/sqlite3.lua @ 12848:ccb030d988ac

util.sqlite3: Skip prepared statements when no parameters are given Seems CREATE INDEX is unhappy as a prepared statement. Perhaps because the table has not been COMMIT-ed yet?
author Kim Alvefur <zash@zash.se>
date Mon, 01 Aug 2022 17:25:40 +0200
parent 12847:d6cdde74cd9b
child 12872:a20923f7d5fd
line wrap: on
line diff
--- a/util/sqlite3.lua	Fri Oct 01 02:27:53 2021 +0200
+++ b/util/sqlite3.lua	Mon Aug 01 17:25:40 2022 +0200
@@ -164,6 +164,16 @@
 	if not success then return success, err; end
 	local prepared = self.prepared;
 
+	if select('#', ...) == 0 then
+		local ret = self.conn:exec(sql);
+		if ret ~= lsqlite3.OK then
+			local err = sqlite_errors.new(err);
+			err.text = self.conn:errmsg();
+			return err;
+		end
+		return true;
+	end
+
 	local stmt = prepared[sql];
 	if not stmt then
 		local err;