Software /
code /
prosody
Comparison
util/sql.lua @ 6733:36e2b35397b1
util.sql: Rename some variable to match conventions
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 03 Jun 2015 15:54:52 +0100 |
parent | 6730:7889515bac86 |
child | 6734:592f6112563e |
comparison
equal
deleted
inserted
replaced
6732:b5cf091d8c45 | 6733:36e2b35397b1 |
---|---|
161 engine.select = engine.execute_query; | 161 engine.select = engine.execute_query; |
162 engine.delete = engine.execute_update; | 162 engine.delete = engine.execute_update; |
163 engine.update = engine.execute_update; | 163 engine.update = engine.execute_update; |
164 function engine:_transaction(func, ...) | 164 function engine:_transaction(func, ...) |
165 if not self.conn then | 165 if not self.conn then |
166 local a,b = self:connect(); | 166 local ok, err = self:connect(); |
167 if not a then return a,b; end | 167 if not ok then return ok, err; end |
168 end | 168 end |
169 --assert(not self.__transaction, "Recursive transactions not allowed"); | 169 --assert(not self.__transaction, "Recursive transactions not allowed"); |
170 local args, n_args = {...}, select("#", ...); | 170 local args, n_args = {...}, select("#", ...); |
171 local function f() return func(unpack(args, 1, n_args)); end | 171 local function f() return func(unpack(args, 1, n_args)); end |
172 self.__transaction = true; | 172 self.__transaction = true; |
182 if self.conn then self.conn:rollback(); end | 182 if self.conn then self.conn:rollback(); end |
183 return success, a; | 183 return success, a; |
184 end | 184 end |
185 end | 185 end |
186 function engine:transaction(...) | 186 function engine:transaction(...) |
187 local a,b = self:_transaction(...); | 187 local ok, ret = self:_transaction(...); |
188 if not a then | 188 if not ok then |
189 local conn = self.conn; | 189 local conn = self.conn; |
190 if not conn or not conn:ping() then | 190 if not conn or not conn:ping() then |
191 self.conn = nil; | 191 self.conn = nil; |
192 a,b = self:_transaction(...); | 192 ok, ret = self:_transaction(...); |
193 end | 193 end |
194 end | 194 end |
195 return a,b; | 195 return ok, ret; |
196 end | 196 end |
197 function engine:_create_index(index) | 197 function engine:_create_index(index) |
198 local sql = "CREATE INDEX `"..index.name.."` ON `"..index.table.."` ("; | 198 local sql = "CREATE INDEX `"..index.name.."` ON `"..index.table.."` ("; |
199 for i=1,#index do | 199 for i=1,#index do |
200 sql = sql.."`"..index[i].."`"; | 200 sql = sql.."`"..index[i].."`"; |