|
| 1 | +# Mission: RFC-0201 Phase 2c — Blob in Projection/Selection |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Claimed |
| 6 | + |
| 7 | +## Claimant |
| 8 | + |
| 9 | +@claude-agent |
| 10 | + |
| 11 | +## RFC |
| 12 | + |
| 13 | +- RFC-0201 (Storage): Binary BLOB Type for Deterministic Hash Storage — Phase 2c |
| 14 | +- RFC-0127 (Numeric): DCS Blob Amendment — Accepted |
| 15 | + |
| 16 | +## Dependencies |
| 17 | + |
| 18 | +- Phase 1 (core BYTEA): DataType::Blob, Value::Blob, wire tag 12 — **Complete** |
| 19 | +- Phase 2b (Blob Equality in Expression Evaluation) — recommended before this phase |
| 20 | + |
| 21 | +## Context |
| 22 | + |
| 23 | +Phase 2c verifies that Blob columns work correctly in SQL projection and selection contexts: |
| 24 | + |
| 25 | +```sql |
| 26 | +SELECT key_hash, signature FROM usage_ledger WHERE event_id = $1; |
| 27 | +``` |
| 28 | + |
| 29 | +**What's needed:** |
| 30 | +- Integration tests verifying Blob columns appear correctly in SELECT results |
| 31 | +- Verify `Value::Blob` serializes correctly through the query result encoding path |
| 32 | +- Hash index usage for Blob equality in WHERE clauses |
| 33 | + |
| 34 | +**stoolap implementation status:** |
| 35 | +- `Value::Blob` already has full comparison (byte-by-byte), hashing, and Display implemented |
| 36 | +- `serialize_value` / `deserialize_value` handle wire tag 12 correctly |
| 37 | +- Hash table hashing already handles `Value::Blob` |
| 38 | +- Phase 2a (hash index) and 2b (expression equality) are likely already satisfied by existing code |
| 39 | + |
| 40 | +## Acceptance Criteria |
| 41 | + |
| 42 | +- [ ] Integration test: `CREATE TABLE t (id INTEGER, key_hash BYTEA(32)); INSERT INTO t VALUES (1, $1); SELECT key_hash FROM t WHERE id = 1;` |
| 43 | +- [ ] Verify result set correctly returns Blob value (hex-encoded in wire response) |
| 44 | +- [ ] Verify Blob equality works in WHERE clause with hash index available |
| 45 | +- [ ] `cargo test --lib` passes with 0 failures |
| 46 | +- [ ] `cargo clippy --all-targets --all-features -- -D warnings` passes |
| 47 | + |
| 48 | +## Technical Notes |
| 49 | + |
| 50 | +### Blob Wire Format (per RFC-0201) |
| 51 | + |
| 52 | +Format: `[u8:12][u32_be:length][u8..len:data]` |
| 53 | +- Tag 12 for Blob |
| 54 | +- Big-endian length prefix |
| 55 | +- Raw bytes (no UTF-8 validation) |
| 56 | + |
| 57 | +### Result Set Encoding |
| 58 | + |
| 59 | +stoolap's result set uses `serialize_value` for encoding column values. This already handles `Value::Blob` correctly — no special result encoding needed. |
| 60 | + |
| 61 | +## Key Files to Modify |
| 62 | + |
| 63 | +| File | Change | |
| 64 | +|------|--------| |
| 65 | +| `tests/` | Add integration tests for Blob in projection/selection | |
| 66 | + |
| 67 | +## Design Reference |
| 68 | + |
| 69 | +- RFC-0201 Phase 2c specification: `rfcs/accepted/storage/0201-binary-blob-type-support.md` §Phase 2c |
| 70 | +- Existing Blob implementation: `src/core/value.rs`, `src/storage/mvcc/persistence.rs` |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +**Mission Type:** Testing / Verification |
| 75 | +**Priority:** Medium |
| 76 | +**Phase:** Phase 2c |
0 commit comments