Add GC functionality to SQLite datastore#31
Merged
Mab879 merged 1 commit intoComplianceAsCode:mainfrom Nov 12, 2025
Merged
Conversation
Mab879
reviewed
Nov 11, 2025
| } | ||
|
|
||
| // FIXME: This is REALLY ugly! | ||
| fmt_q := fmt.Sprintf(strings.Replace(query, "$1", "'%s'", 1), formatStringArrayFromUUIDs(uuids)) |
Member
There was a problem hiding this comment.
What's the problem using parametrized queries on this?
Member
Author
There was a problem hiding this comment.
Well, Go's SQL adapters can't really convert arrays into IN lists. It is a problem specifically for SQLite as there is no workaround (or at least a simple workaround) unlike other DBMS.
Member
Author
There was a problem hiding this comment.
I intend to kick this can further down the road at this moment.
| func (ms *sqliteMatcherStore) DeleteUpdateOperations(ctx context.Context, uuids ...uuid.UUID) (int64, error) { | ||
| zlog.Warn(ctx).Msg("sqliteMatcherStore.DeleteUpdateOperations is not implemented!") | ||
| return 0, nil | ||
| const query = `DELETE FROM update_operation WHERE ref IN ($1);` |
Member
There was a problem hiding this comment.
Let's add to top of this method
zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.DeleteUpdateOperations")| // The returned int64 value indicates the remaining number of update operations needing GC. | ||
| // Running this method till the returned value is 0 accomplishes a full GC of the vulnstore. | ||
| func (ms *sqliteMatcherStore) GC(ctx context.Context, count int) (int64, error) { | ||
| zlog.Warn(ctx).Msg("sqliteMatcherStore.GC is not implemented!") |
Member
There was a problem hiding this comment.
Add
zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.GC")
datastore/sqlite_store.go
Outdated
| ) | ||
|
|
||
| // gather any update operations exceeding our keep value. | ||
| // keep+1 is used because PG's array slicing is inclusive, |
Member
There was a problem hiding this comment.
How is Postgres (PG) relevant here?
Member
Author
There was a problem hiding this comment.
Not relevant at all. Gone.
1b6d22b to
be6fb4e
Compare
Mab879
approved these changes
Nov 12, 2025
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.
Fixes: #13