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

refactor: Eliminate remaining repeat_vars() calls (#6359) #6375

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

iequidoo
Copy link
Collaborator

Close #6359

@iequidoo iequidoo marked this pull request as ready for review December 31, 2024 03:27
@iequidoo iequidoo requested a review from link2xt December 31, 2024 03:27
src/chat.rs Show resolved Hide resolved
src/message.rs Show resolved Hide resolved
src/receive_imf.rs Outdated Show resolved Hide resolved
src/receive_imf.rs Show resolved Hide resolved
@iequidoo iequidoo force-pushed the iequidoo/drop-repeat_vars branch from 92adf14 to 50ad130 Compare January 5, 2025 19:06
src/contact.rs Outdated Show resolved Hide resolved
src/contact.rs Outdated Show resolved Hide resolved
src/sql.rs Outdated Show resolved Hide resolved
src/receive_imf.rs Outdated Show resolved Hide resolved
) STRICT",
(),
)?;
let mut stmt = t.prepare("INSERT INTO contacts_tmp(id) VALUES (?)")?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably better specify it as temp.contacts_tmp to make sure this is not accidentally using a table with the same name from the real database.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to temp.contacts, should be sufficient.

src/receive_imf.rs Outdated Show resolved Hide resolved
src/receive_imf.rs Outdated Show resolved Hide resolved
@iequidoo iequidoo force-pushed the iequidoo/drop-repeat_vars branch from 50ad130 to 2eaf3cc Compare January 14, 2025 01:11
@iequidoo iequidoo requested a review from link2xt January 14, 2025 01:37
Copy link
Collaborator

@link2xt link2xt left a comment

Choose a reason for hiding this comment

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

Should go into refactor instead of feat I think? This does not change anything for the user.

Using `repeat_vars()` to generate SQL statements led to some of them having more than
`SQLITE_MAX_VARIABLE_NUMBER` parameters and thus failing, so let's get rid of this pattern. But
let's not optimise for now and just repeat executing an SQL statement in a loop, all the places
where `repeat_vars()` is used seem not performance-critical and containing functions execute other
SQL statements in loops. If needed, performance can be improved by preparing a statement and
executing it in a loop. An exception is `lookup_chat_or_create_adhoc_group()` where `repeat_vars()`
can't be replaced with a query loop, there we need to replace the `SELECT` query with a read
transaction creating a temporary table which is used to perform the SELECT query then.
@iequidoo iequidoo force-pushed the iequidoo/drop-repeat_vars branch from 2eaf3cc to ecc93d9 Compare January 14, 2025 04:13
@iequidoo iequidoo changed the title feat: Eliminate remaining repeat_vars() calls (#6359) refactor: Eliminate remaining repeat_vars() calls (#6359) Jan 14, 2025
@iequidoo iequidoo merged commit 53dca8c into main Jan 14, 2025
24 checks passed
@iequidoo iequidoo deleted the iequidoo/drop-repeat_vars branch January 14, 2025 04:14
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.

Eliminate remaining repeat_vars() calls
2 participants