Skip to content

Conversation

trueqbit
Copy link
Collaborator

@trueqbit trueqbit commented Sep 26, 2025

Sharing is caring!

With the potential SQL views as yet another schema object type, code needs to be duplicated - or better factored into shared class templates.

In this PR:

  • Restructured classes representing table database objects:
    • Factored out common functionality into base classes and mixins.
    • Split CTE table class into its own structure, effectively decoupling it from the base table DBO.
    • Moved the facilities for virtual tables into a dedicated header file.
    • Recomposition of the facilities for virtual tables:
      • Split virtual table facilities into: a module tag, virtual table traits that can be specialized, an intermediary description resulting from a using module expression and a concrete virtual table class.
  • Partially renamed structures by removing the _t suffix. Since the advent of alias template for type aliases IMO it isn't the best choice to use it for the library's regular types.
    • virtual_table_t -> virtual_table.
    • Renamed table_t to base_table denoting that it is a table that actually stores data. "base table" is the best word in SQL land for this.
    • The renaming should be done for all other DBOs (index_t, trigger_t) if we agree on this different naming convention. Let me know what you think [yes/no/revert].

Additionally:

  • Ability to create the FTS5 virtual table using table references.

Further changes since the last review on Sep 30 2025:

  • Separated generic facilities for virtual tables from facilities for concrete virtual table provided by modules/extensions.
  • Explicit object mapping for a virtual table must now be specified when calling make_virtual_table<O>() instead of when calling using_module<O>().
  • Converted the dbstat table into an eponymous virtual table, additionally with the option of creating further instances of it.

* Factored out common functionality into common base classes and mixins.
* Renamed structures.
* Split CTE table class into its own structure, effectively decoupling it from a table DBO.
* Split virtual table facilities into: a module tag, virtual table traits that can be specialized, an intermediary description resulting from a `using module` expression and a concrete virtual table class.
* Renamed table DBO classes.
* Removed the `_t` suffix from table DBO classes and renamed `virtual_table_t` -> `virtual_table` and `table_t` -> `base_table`, where the latter denotes a table that actually stores data.
* Finally replaced the 'without rowid' NTTP by a type parameter.
@trueqbit trueqbit requested a review from fnc12 September 29, 2025 17:21
@trueqbit trueqbit marked this pull request as ready for review September 29, 2025 17:22
Copy link
Owner

@fnc12 fnc12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is ok. The PR is good. Thank you @trueqbit

... instead of when making the definition of the table using a specific module.
Additionally:
* Split virtual table modules into separate header files.
@trueqbit trueqbit marked this pull request as draft October 1, 2025 06:51
@trueqbit trueqbit force-pushed the restructure-table-dbos branch from 0a799ab to 464cabb Compare October 1, 2025 17:12
@trueqbit trueqbit marked this pull request as ready for review October 1, 2025 17:28
@trueqbit trueqbit requested a review from fnc12 October 1, 2025 17:28
* @param lambda Lambda called for each column. Function signature: `void(auto& column)`
*/
template<class L>
void for_each_column(L&& lambda) const {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we pass an r-value here? if we don't call std::move(lambda) on the next line then it goes further as an l-value. In that case the smarter way is just passing an l-value, probably const l-value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's just taking anything, which is usually a lambda in its real sense, i.e. created ad-hoc. In the library's logic there's nNo need to pass it on as an rvalue, so we just pass it on as an lvalue. const-qualifying it is not good as the lambda might be modifyable.

*
* [Deprecation notice] This factory function is deprecated and will be removed in v1.11.
*/
template<class O, class M, class... Cs>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add deprecate C++ tag here to produce compiler's warnings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already added the deprecation warning to the using_fts5<O>() factory function. This should be enough, otherwise you get two warnings...


const auto res = sync_schema_result::already_in_sync;
context_t context{this->db_objects};
const serializer_context<db_objects_type> context{this->db_objects};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like for constness here

@trueqbit trueqbit merged commit 9a26019 into dev Oct 2, 2025
3 checks passed
@trueqbit trueqbit deleted the restructure-table-dbos branch October 2, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants