mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 00:24:21 +01:00
1. Add script that cleans simulator logs into just the SQL statements 2. Add script that bisects a set of SQL statements to find the minimal prefix set of statements that fails SQLite integrity check
40 lines
1.4 KiB
Bash
Executable File
40 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Clean lines from simulator output by:
|
|
# 1) Removing everything up to and including "interaction="
|
|
# 2) Replacing everything from "}:" to the end with a single semicolon
|
|
# 3) Only retaining lines containing CREATE/INSERT/UPDATE/DELETE/DROP (the rest are usually meaningless for debugging)
|
|
#
|
|
# The purpose of this is to transform the interaction plan into a list of executable SQL statements
|
|
# in cases where:
|
|
# 1. Shrinking the plan failed
|
|
# 2. We know the point at which the simulator failure occurred.
|
|
#
|
|
# I use this script like this in the simulator directory:
|
|
# cargo run &> raw_output.txt
|
|
# manually edit out the shrinking parts and the WarGames intro graphics etc and save the file
|
|
# then run:
|
|
# ./clean_interactions.sh raw_output.txt > interactions.sql
|
|
#
|
|
# Usage:
|
|
# clean_interactions.sh INPUT [OUTPUT]
|
|
#
|
|
# If OUTPUT is omitted, the result is written to stdout.
|
|
|
|
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
|
echo "Usage: $0 INPUT [OUTPUT]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
input_path="$1"
|
|
output_path="${2:-}"
|
|
|
|
if [[ -z "${output_path}" ]]; then
|
|
awk '{ line=$0; sub(/^[^\n]*interaction=/, "", line); sub(/}:.*/, ";", line); print line }' "${input_path}" | grep -E 'CREATE|INSERT|UPDATE|DELETE|DROP'
|
|
else
|
|
awk '{ line=$0; sub(/^[^\n]*interaction=/, "", line); sub(/}:.*/, ";", line); print line }' "${input_path}" | grep -E 'CREATE|INSERT|UPDATE|DELETE|DROP' > "${output_path}"
|
|
fi
|
|
|
|
|