java-topology/tools/tickets/scans/mysql-server.md
russell@unturf.com db29a08762 undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections.
Squash of 94 local commits onto remote master.
2026-03-26 19:48:18 -04:00

2.2 KiB

id priority status created
scan-mysql-server high unscanned 2026-03-23

Target

Repo: https://github.com/mysql/mysql-server Language: C++ Why: Query optimizer join reordering — linear vector scans during join-order search inflate planning time on multi-table queries in high-concurrency production workloads.

Scan command

# Shallow clone
git clone --depth 1 https://github.com/mysql/mysql-server /tmp/mysql-server

# Submit to unsandbox
cat > /tmp/scan-mysql-server.sh << 'EOF'
#!/usr/bin/env bash
set -euo pipefail
GRAPH_KW="tarjan|strongly.connected|dfs|scc|topolog|topo.sort|cycle|reachab|postorder|dominator|liveness|digraph|shortest.path|path.find"
MEM="std::find|\.count\(|vector.*find|find.*begin.*end|push_back.*visited|visited\.push_back"
find /tmp/mysql-server/sql -name "*.cc" -o -name "*.h" | sort | while read f; do
  graph_lines=$(grep -inE "$GRAPH_KW" "$f" 2>/dev/null | cut -d: -f1 | head -5 || true)
  [ -z "$graph_lines" ] && continue
  while IFS= read -r lineno; do
    s=$(( lineno > 20 ? lineno - 20 : 1 )); e=$(( lineno + 20 ))
    hit=$(sed -n "${s},${e}p" "$f" 2>/dev/null | grep -iE "$MEM" | head -1 | sed 's/^\s*//' || true)
    [ -n "$hit" ] && echo "CANDIDATE\t${f}:${lineno}\t${hit}"
  done <<< "$graph_lines"
done
EOF
export UNSANDBOX_PUBLIC_KEY=unsb-pk-russ-test-isth-best
export UNSANDBOX_SECRET_KEY=unsb-sk-rk46c-3zvpg-zjf6z-hjrge
~/git/un-inception/build/un /tmp/scan-mysql-server.sh

Key files to check

  • sql/opt_range.cc — Range optimizer; range list and index scan membership
  • sql/sql_optimizer.cc — Core optimizer; join graph construction and traversal
  • sql/sql_planner.cc — Join order search; best-plan selection over join combinations

Expected pattern

std::find(tables.begin(), tables.end(), tbl) where tables is a std::vector<TABLE*> used as a visited or remaining set inside greedy_search or best_extension_by_limited_search — the join-order enumeration inner loop.

Acceptance criteria

  • Scan run and results saved to tools/scan-results/mysql-server.txt
  • All CANDIDATE hits triaged (confirmed defect or false positive)
  • If confirmed: defect ticket created in tools/tickets/defects/