mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
When a row is deleted from a vec0 virtual table, the rowid slot in _chunks.rowids and vector data in _vector_chunksNN.vectors are now zeroed out (previously left as stale data, tracked in #54). When all rows in a chunk are deleted (validity bitmap all zeros), the chunk and its associated vector/metadata shadow table rows are reclaimed. - Add vec0Update_Delete_ClearRowid to zero the rowid blob slot - Add vec0Update_Delete_ClearVectors to zero all vector blob slots - Add vec0Update_Delete_DeleteChunkIfEmpty to detect and delete fully-empty chunks from _chunks, _vector_chunksNN, _metadatachunksNN - Fix missing rc check in ClearMetadata loop (bug: errors were silently ignored) - Fix vec0_new_chunk to explicitly set _rowid_ on shadow table INSERTs (SHADOW_TABLE_ROWID_QUIRK: "rowid PRIMARY KEY" without INTEGER type is not a true rowid alias, causing blob_open failures after chunk delete+recreate cycles) - Add 13 new tests covering rowid/vector zeroing, chunk reclamation, metadata/auxiliary/partition/text-PK/int8/bit variants, and page_count shrinkage verification - Add vec0-delete-completeness fuzz target - Update snapshots for new delete zeroing behavior Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
85 lines
3 KiB
Makefile
85 lines
3 KiB
Makefile
# Auto-detect clang with libFuzzer support.
|
|
# Priority: Homebrew LLVM (macOS ARM) → Homebrew LLVM (macOS Intel) →
|
|
# versioned clang (Linux) → system clang
|
|
FUZZ_CC ?= $(shell \
|
|
if [ -x /opt/homebrew/opt/llvm/bin/clang ]; then \
|
|
echo "/opt/homebrew/opt/llvm/bin/clang"; \
|
|
elif [ -x /usr/local/opt/llvm/bin/clang ]; then \
|
|
echo "/usr/local/opt/llvm/bin/clang"; \
|
|
elif command -v clang-18 >/dev/null 2>&1; then \
|
|
echo "clang-18"; \
|
|
elif command -v clang-17 >/dev/null 2>&1; then \
|
|
echo "clang-17"; \
|
|
elif command -v clang >/dev/null 2>&1; then \
|
|
echo "clang"; \
|
|
else \
|
|
echo "FUZZ_CC_NOT_FOUND"; \
|
|
fi)
|
|
|
|
# AddressSanitizer + UndefinedBehaviorSanitizer + libFuzzer.
|
|
# Override FUZZ_SANITIZERS to change (e.g., drop ubsan on Windows).
|
|
FUZZ_SANITIZERS ?= -fsanitize=address,undefined,fuzzer
|
|
|
|
# On macOS, Homebrew LLVM may need -Wl,-ld_classic to work with the system linker.
|
|
FUZZ_LDFLAGS ?= $(shell \
|
|
if [ "$$(uname -s)" = "Darwin" ]; then \
|
|
echo "-Wl,-ld_classic"; \
|
|
fi)
|
|
|
|
FUZZ_CFLAGS = $(FUZZ_SANITIZERS) -I ../../ -I ../../vendor -DSQLITE_CORE -g $(FUZZ_LDFLAGS)
|
|
FUZZ_SRCS = ../../vendor/sqlite3.c ../../sqlite-vec.c
|
|
|
|
TARGET_DIR = ./targets
|
|
|
|
$(TARGET_DIR):
|
|
mkdir -p $@
|
|
|
|
# Existing targets (filename uses -, Makefile target uses _)
|
|
$(TARGET_DIR)/vec0_create: vec0-create.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/exec: exec.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/json: json.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/numpy: numpy.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
# New targets
|
|
$(TARGET_DIR)/shadow_corrupt: shadow-corrupt.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/vec0_operations: vec0-operations.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/scalar_functions: scalar-functions.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/vec0_create_full: vec0-create-full.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/metadata_columns: metadata-columns.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/vec_each: vec-each.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/vec_mismatch: vec-mismatch.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
$(TARGET_DIR)/vec0_delete_completeness: vec0-delete-completeness.c $(FUZZ_SRCS) | $(TARGET_DIR)
|
|
$(FUZZ_CC) $(FUZZ_CFLAGS) $(FUZZ_SRCS) $< -o $@
|
|
|
|
FUZZ_TARGETS = vec0_create exec json numpy \
|
|
shadow_corrupt vec0_operations scalar_functions \
|
|
vec0_create_full metadata_columns vec_each vec_mismatch \
|
|
vec0_delete_completeness
|
|
|
|
all: $(addprefix $(TARGET_DIR)/,$(FUZZ_TARGETS))
|
|
|
|
clean:
|
|
rm -rf $(TARGET_DIR)/*
|
|
|
|
.PHONY: all clean
|