tp: add support for dynamic tables and migrate flamegraph/counter dur

This CL introduces proper support for dynamic tables in SqliteDbTable
instead of the hacky thing we were doing before this point which was
subclassing and using parts of SqliteDbTable in arbitrary ways (e.g.
passing nullptr as the table and then overriding all methods, creating
a cursor but not using any of the rest of the code etc).

This prepares the way for describe_event in go/perfetto-analysis-design
which will be implemented as a dynamic table similar to the flamegraph
and counter-with-dur ones.

Change-Id: I8cff6554a2f54afa92dbf64c3eac7e6f70fbbdba
diff --git a/src/trace_processor/sqlite/sqlite_table.h b/src/trace_processor/sqlite/sqlite_table.h
index 2cb7a0f..a6a038f 100644
--- a/src/trace_processor/sqlite/sqlite_table.h
+++ b/src/trace_processor/sqlite/sqlite_table.h
@@ -20,6 +20,7 @@
 #include <sqlite3.h>
 
 #include <functional>
+#include <limits>
 #include <memory>
 #include <string>
 #include <vector>
@@ -212,7 +213,7 @@
     auto create_fn = [](sqlite3* xdb, void* arg, int argc,
                         const char* const* argv, sqlite3_vtab** tab,
                         char** pzErr) {
-      const auto* xdesc = static_cast<const TableDescriptor<Context>*>(arg);
+      auto* xdesc = static_cast<TableDescriptor<Context>*>(arg);
       auto table = xdesc->factory(xdb, std::move(xdesc->context));
       table->name_ = xdesc->name;