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?
This commit is contained in:
Kim Alvefur 2022-08-01 17:25:40 +02:00
parent 320d4032a2
commit e3836f22e0

View file

@ -164,6 +164,16 @@ function engine:execute(sql, ...)
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;