diff options
Diffstat (limited to '')
-rw-r--r-- | src/vtab_module.hh | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/vtab_module.hh b/src/vtab_module.hh index a45594c..ff08bfd 100644 --- a/src/vtab_module.hh +++ b/src/vtab_module.hh @@ -31,7 +31,6 @@ #define vtab_module_hh #include <string> -#include <utility> #include <vector> #include <sqlite3.h> @@ -41,11 +40,11 @@ #include "base/lnav.console.hh" #include "base/lnav_log.hh" #include "base/string_util.hh" +#include "base/types.hh" #include "fmt/format.h" #include "help_text_formatter.hh" #include "mapbox/variant.hpp" #include "optional.hpp" -#include "shlex.resolver.hh" #include "sqlite-extension-func.hh" lnav::console::user_message sqlite3_error_to_user_message(sqlite3*); @@ -67,10 +66,7 @@ struct sqlite_func_error : std::exception { { } - const char* what() const noexcept override - { - return this->e_what.c_str(); - } + const char* what() const noexcept override { return this->e_what.c_str(); } const std::string e_what; }; @@ -83,12 +79,10 @@ struct nullable { }; template<typename> -struct is_nullable : std::false_type { -}; +struct is_nullable : std::false_type {}; template<typename T> -struct is_nullable<nullable<T>> : std::true_type { -}; +struct is_nullable<nullable<T>> : std::true_type {}; } // namespace vtab_types @@ -158,9 +152,12 @@ template<> struct from_sqlite<string_fragment> { inline string_fragment operator()(int argc, sqlite3_value** val, int argi) { - return string_fragment::from_bytes( - (const char*) sqlite3_value_blob(val[argi]), - sqlite3_value_bytes(val[argi])); + auto ptr = (const char*) sqlite3_value_blob(val[argi]); + + if (ptr == nullptr) { + return string_fragment::invalid(); + } + return string_fragment::from_bytes(ptr, sqlite3_value_bytes(val[argi])); } }; @@ -223,6 +220,9 @@ struct from_sqlite<vtab_types::nullable<T>> { void to_sqlite(sqlite3_context* ctx, const lnav::console::user_message& um); +void set_vtable_errmsg(sqlite3_vtab* vtab, + const lnav::console::user_message& um); + inline void to_sqlite(sqlite3_context* ctx, null_value_t) { @@ -296,7 +296,7 @@ to_sqlite(sqlite3_context* ctx, double val) inline void to_sqlite(sqlite3_context* ctx, auto_mem<char> str) { - auto free_func = str.get_free_func<void(*)(void*)>(); + auto free_func = str.get_free_func<void (*)(void*)>(); sqlite3_result_text(ctx, str.release(), -1, free_func); } @@ -372,8 +372,7 @@ struct optional_counter<Arg> { }; template<typename Arg1, typename... Args> -struct optional_counter<Arg1, Args...> : optional_counter<Args...> { -}; +struct optional_counter<Arg1, Args...> : optional_counter<Args...> {}; template<typename... Args> struct variadic_counter { @@ -391,8 +390,7 @@ struct variadic_counter<Arg> { }; template<typename Arg1, typename... Args> -struct variadic_counter<Arg1, Args...> : variadic_counter<Args...> { -}; +struct variadic_counter<Arg1, Args...> : variadic_counter<Args...> {}; template<typename F, F f> struct sqlite_func_adapter; @@ -821,10 +819,7 @@ struct vtab_module : public vtab_module_base { return sqlite3_exec(db, create_stmt.c_str(), nullptr, nullptr, nullptr); } - int create(sqlite3* db) override - { - return this->create(db, T::NAME); - } + int create(sqlite3* db) override { return this->create(db, T::NAME); } sqlite3_module vm_module; T vm_impl; |