MCPcopy Create free account
hub / github.com/audacity/audacity / Execute

Method Execute

libraries/lib-sqlite-helpers/sqlite/Connection.cpp:160–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160Error Connection::Execute(std::string_view sql) noexcept
161{
162 if (mInDestructor || mConnection == nullptr)
163 return Error(SQLITE_MISUSE);
164
165 auto tx = BeginTransaction("Connection_Execute");
166
167 auto first = sql.data();
168 auto last = first + sql.size();
169
170 while (first != last)
171 {
172 const char* next = nullptr;
173 sqlite3_stmt* statement = nullptr;
174
175 int result = sqlite3_prepare_v2 (
176 mConnection, first, last - first, &statement, &next);
177
178 if (result != SQLITE_OK)
179 return Error(result);
180
181 first = next;
182
183 if (statement == nullptr)
184 continue;
185
186 auto finalizer = finally([statement] { sqlite3_finalize(statement); });
187
188 result = sqlite3_step(statement);
189
190 if (result != SQLITE_OK && result != SQLITE_DONE && result != SQLITE_ROW)
191 return Error(result);
192
193 while (result == SQLITE_ROW)
194 result = sqlite3_step(statement);
195 }
196
197 return tx.Commit();
198}
199
200Transaction Connection::BeginTransaction(std::string name)
201{

Callers 4

OpenConnectionMethod · 0.80
RunMigrationsMethod · 0.80

Calls 5

finallyFunction · 0.85
ErrorFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected