Software / code / prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
| 12847:d6cdde74cd9b | 12848:ccb030d988ac |
|---|---|
| 162 function engine:execute(sql, ...) | 162 function engine:execute(sql, ...) |
| 163 local success, err = self:connect(); | 163 local success, err = self:connect(); |
| 164 if not success then return success, err; end | 164 if not success then return success, err; end |
| 165 local prepared = self.prepared; | 165 local prepared = self.prepared; |
| 166 | 166 |
| 167 if select('#', ...) == 0 then | |
| 168 local ret = self.conn:exec(sql); | |
| 169 if ret ~= lsqlite3.OK then | |
| 170 local err = sqlite_errors.new(err); | |
| 171 err.text = self.conn:errmsg(); | |
| 172 return err; | |
| 173 end | |
| 174 return true; | |
| 175 end | |
| 176 | |
| 167 local stmt = prepared[sql]; | 177 local stmt = prepared[sql]; |
| 168 if not stmt then | 178 if not stmt then |
| 169 local err; | 179 local err; |
| 170 stmt, err = self.conn:prepare(sql); | 180 stmt, err = self.conn:prepare(sql); |
| 171 if not stmt then | 181 if not stmt then |