Open
Conversation
Author
|
@drebelsky Kinfdly help review |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the redundant StatementContext wrapper and standardizes prepared-statement usage across Stellar Core by returning and using soci::statement handles directly from Database::getPreparedStatement.
Changes:
- Deleted
StatementContextand changedDatabase::getPreparedStatementto returnsoci::statementby value. - Refactored SQL call sites to operate directly on the returned
soci::statement(remove.statement()indirection). - Updated affected helper function signatures (e.g., offer-loading helpers) to accept
soci::statement&.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/overlay/PeerManager.cpp | Updated peer DB queries to use soci::statement directly. |
| src/overlay/BanManagerImpl.cpp | Updated ban table queries to use soci::statement directly. |
| src/main/PersistentState.cpp | Updated persistent state DB reads/writes to use soci::statement directly. |
| src/ledger/LedgerTxnOfferSQL.cpp | Updated offer SQL loading/upsert/delete paths and helper signatures to use soci::statement directly. |
| src/ledger/LedgerTxnImpl.h | Updated declarations to match new soci::statement& offer-loading signatures. |
| src/ledger/LedgerHeaderUtils.cpp | Updated ledger header insert/load statements to use soci::statement directly. |
| src/herder/test/HerderTests.cpp | Updated test query iteration to use soci::statement directly. |
| src/herder/HerderPersistenceImpl.cpp | Updated SCP history persistence queries to use soci::statement directly. |
| src/database/test/DatabaseTests.cpp | Updated migration test helpers/queries to use soci::statement directly. |
| src/database/Database.h | Removed StatementContext; changed getPreparedStatement API to return soci::statement. |
| src/database/Database.cpp | Implemented getPreparedStatement returning a prepared soci::statement by value. |
Author
|
@drebelsky pinging you on this again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves #5171
This PR removes the redundant
StatementContextclass and refactors the codebase to usesoci::statementhandles directly.Rationale
StatementContextwas originally an RAII wrapper forstd::shared_ptr<soci::statement>, primarily serving the prepared statement cache. Since the cache was removed in #5094, the custom wrapper no longer provides additional benefit.soci::statementis its own handle-based class with internal reference counting, making it the idiomatic way to manage SQL statements when no custom metadata is required.Changes
StatementContextdefinition from src/database/Database.h.Database::getPreparedStatementto returnsoci::statementby value.soci::statementdirectly, removing all.statement()calls.Checklist
clang-formatv8.0.0 (viamake formator the Visual Studio extension)Verification Proof
src/stellar-core test "[db]"PASSED.src/stellar-core test "[ledger]"PASSED.StatementContextinsrc/.