| 69 | } |
| 70 | |
| 71 | mz::PeekResults mz::peekView(pqxx::connection &c, const std::string &name, const std::optional<std::string> &order, |
| 72 | std::optional<unsigned> limit) { |
| 73 | std::string query = "SELECT * FROM " + name; |
| 74 | if (order) { |
| 75 | query += " ORDER BY " + order.value(); |
| 76 | } |
| 77 | if (limit) { |
| 78 | query += " LIMIT " + std::to_string(limit.value()); |
| 79 | } |
| 80 | |
| 81 | auto [time, results] = timeInvocation([&query, &c]() { |
| 82 | pqxx::nontransaction w(c); |
| 83 | try { |
| 84 | return w.exec(query); |
| 85 | } catch (const pqxx::sql_error &e) { |
| 86 | // 03000 is the SQLSTATE code for SQL_STATEMENT_NOT_YET_COMPLETE |
| 87 | if (e.sqlstate() == "03000") { |
| 88 | fprintf(stderr, "WARNING: ignoring \"no complete timestamps\" error."); |
| 89 | return pqxx::result {}; |
| 90 | } else { |
| 91 | throw; |
| 92 | } |
| 93 | } |
| 94 | }); |
| 95 | |
| 96 | return {time, results}; |
| 97 | } |
| 98 | |
| 99 | const char *mz::UnexpectedCreateSourcesResult::what() const noexcept { |
| 100 | return what_rendered.c_str(); |
nothing calls this directly
no test coverage detected