java-topology/defects/scylladb/patch/scylladb-0001-cql-selection-from-selectors-column-dedup-linear-scan.patch
russell@unturf.com 76ffba4a60 tidb/scylladb: CWE-407 scan — renumber tidb patches, stamp UNDF
tidb-0001: partition drop name lookup O(P×D) → O(P+D) (27x at P=8192)
tidb-0002: predicate simplification (merged into tidb-0002 in prior commit)
tidb-0003: list partition group intersect O(G²) → O(G) (renumbered from 0002)
scylladb-0001: UNDF stamp added
2026-03-30 10:13:33 -04:00

20 lines
939 B
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UNDF: UNDF-2026-000000529
# UNDF: (leave blank)
--- a/cql3/selection/selection.cc
+++ b/cql3/selection/selection.cc
@@ -499,11 +499,15 @@ selection::from_selectors(data_dictionary::database db, schema_ptr schema, const
std::vector<const column_definition*> defs;
+ // Use an unordered_set for O(1) deduplication instead of O(D) linear
+ // std::find scan per column reference. For a SELECT with S column
+ // references over D distinct columns the old code was O(S×D); the patch
+ // makes it O(S).
+ std::unordered_set<const column_definition*> defs_seen;
for (auto&& [sel, alias] : prepared_selectors) {
expr::for_each_expression<expr::column_value>(sel, [&] (const expr::column_value& cv) {
- if (std::find(defs.begin(), defs.end(), cv.col) == defs.end()) {
+ if (defs_seen.insert(cv.col).second) {
defs.push_back(cv.col);
}
});
}