Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom types in tables #12386

Open
mattsse opened this issue Nov 7, 2024 · 0 comments
Open

Support custom types in tables #12386

mattsse opened this issue Nov 7, 2024 · 0 comments
Assignees
Labels
A-db Related to the database C-enhancement New feature or request S-needs-design This issue requires design work to think about how it would best be accomplished

Comments

@mattsse
Copy link
Collaborator

mattsse commented Nov 7, 2024

Describe the feature

currently the tables! generates a fixed enum

// Tables enum.
// NOTE: the ordering of the enum does not matter, but it is assumed that the discriminants
// start at 0 and increment by 1 for each variant (the default behavior).
// See for example `reth_db::implementation::mdbx::tx::Tx::db_handles`.
/// A table in the database.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub enum Tables {

this must be changed so that custom types for tables can be configured so that

|| Ok(self.tx.get::<tables::Headers>(num)?),

works with arbitrary types.

this likely means that the entire enum approach no longer works in its current form.
the way tables interact with the db env itself is like:

/// Creates all the defined tables, if necessary.
pub fn create_tables(&self) -> Result<(), DatabaseError> {
let tx = self.inner.begin_rw_txn().map_err(|e| DatabaseError::InitTx(e.into()))?;
for table in Tables::ALL {

there has been some preliminary work on custom tables, unsure how relevant this still is
#7832

looking at create_tables the trait extension in #7832 make sense

the table name is important for

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Nov 7, 2024
@mattsse mattsse added S-needs-design This issue requires design work to think about how it would best be accomplished A-db Related to the database and removed S-needs-triage This issue needs to be labelled labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database C-enhancement New feature or request S-needs-design This issue requires design work to think about how it would best be accomplished
Projects
Status: Todo
Development

No branches or pull requests

2 participants