Skip to content

Conversation

@evgenyz
Copy link
Member

@evgenyz evgenyz commented Nov 11, 2025

Fixes: #13

}

// FIXME: This is REALLY ugly!
fmt_q := fmt.Sprintf(strings.Replace(query, "$1", "'%s'", 1), formatStringArrayFromUUIDs(uuids))
Copy link
Member

Choose a reason for hiding this comment

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

What's the problem using parametrized queries on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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);`
Copy link
Member

Choose a reason for hiding this comment

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

Let's add to top of this method

    zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.DeleteUpdateOperations")

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

// 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!")
Copy link
Member

Choose a reason for hiding this comment

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

Add

    zlog.Debug(ctx).Msg(">>> sqliteMatcherStore.GC")

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

)

// gather any update operations exceeding our keep value.
// keep+1 is used because PG's array slicing is inclusive,
Copy link
Member

Choose a reason for hiding this comment

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

How is Postgres (PG) relevant here?

Copy link
Member Author

@evgenyz evgenyz Nov 12, 2025

Choose a reason for hiding this comment

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

Not relevant at all. Gone.

@evgenyz evgenyz force-pushed the add-sqlite-storage-gc branch from 1b6d22b to be6fb4e Compare November 12, 2025 08:32
@Mab879 Mab879 merged commit 416d008 into ComplianceAsCode:main Nov 12, 2025
5 checks passed
@evgenyz evgenyz deleted the add-sqlite-storage-gc branch November 12, 2025 14:23
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.

Implement garbage collection for the SQLite storage

2 participants