Commit 76c20f0
committed
BACPAC fidelity polish — natively-compiled procedures + geography WKB decoder. Two related bundles that close the last two known gaps across the gathered samples: WideWorldImporters-Full reaches **zero Skipped categories** (every element type loads end-to-end), and AdventureWorks2025's
# Bundle 1 — Natively-compiled SP body
WWI-Full's `Website.RecordColdRoomTemperatures` is the only natively-compiled SP across the gathered samples. The DACFx-emitted CREATE shape is `CREATE PROCEDURE … WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'English') <body> END`. Two parser changes unblock it:
**`Simulation/Simulation.CreateProcedure.cs::ParseProcedureWithOptions`** now accepts `SCHEMABINDING` and `NATIVE_COMPILATION` alongside the previously-handled RECOMPILE / EXECUTE AS / ENCRYPTION / FOR REPLICATION. Both new options are parse-and-discard — the simulator doesn't model schema-binding enforcement or native compilation. `Native_Compilation` joins `ContextualKeyword`; `SchemaBinding` was already there.
**`Simulation/Simulation.cs`** BEGIN ATOMIC dispatch arm flipped from `throw NotSupportedException` to call into a new `ParseBeginAtomicBlock` in `Simulation/Simulation.IfBlock.cs`. The new method consumes `BEGIN ATOMIC [WITH (...)]`, balanced-paren-skips the WITH options (TRANSACTION ISOLATION LEVEL / LANGUAGE / DATEFORMAT / DATEFIRST / DELAYED_DURABILITY — no semantic effect in the simulator), then dispatches body statements like `ParseBeginBlock` until `END`. The atomic-transaction boundary that real SQL Server enforces (the block is its own transaction) is approximated by the existing implicit per-statement undo plus any outer explicit transaction — sufficient for SqlPackage-emitted bodies and for any production code that doesn't rely on per-block isolation overrides, but a caller asserting "this block opened a new tx" would see fall-through to the session's isolation level.
**Tests** in `SqlServerSimulator.Tests/StoredProcedureTests.cs`:
- `Create_With_NativeCompilation_Schemabinding_Parses` — header-only smoke (NATIVE_COMPILATION + SCHEMABINDING + EXECUTE AS OWNER on a SELECT-1 body).
- `BeginAtomic_Body_Runs` — INSERT inside the atomic body lands rows when the proc is EXEC'd.
- `BeginAtomic_With_TryCatch_Body` — mirrors the WWI-Full SP shape (BEGIN ATOMIC wrapping BEGIN TRY / BEGIN CATCH with THROW); verifies CATCH-side INSERT runs.
- `BeginAtomic_Without_With_Options_Block_Parses` — bare BEGIN ATOMIC (no WITH options) — future-compat for ATOMIC outside natively-compiled procs.
- `BeginAtomic_Empty_Body_RaisesSyntax_On_Exec` — empty atomic body rejected at EXEC time (matches BEGIN…END empty-body rule).
The prior `IfBlockTests.BeginAtomic_NotSupported` test was inverted to `BeginAtomic_AtBatchTopLevel_DispatchesBody` since BEGIN ATOMIC at batch top level now succeeds.
WWI-Full Skipped: 1 → 0. The `Load_WWIFull_Known_Gaps_Recorded_In_Skipped` regression test now asserts `IsEmpty(diagnostics.Skipped)`.
# Bundle 2 — Geography simple-point WKB → WKT decoder
AW's 19,614 `Person.Address.SpatialLocation` rows previously loaded as NULL — the BCP wire format was drained (so subsequent column boundaries didn't corrupt) but the bytes weren't decoded. AW uses only simple points, so the simple-point shortcut path covers the full sample.
**New `Storage/Bacpac/SpatialWkbDecoder.cs`**: `TryDecodeSimplePoint(wkb, isGeography)` decodes the Microsoft spatial UDT simple-point shape:
- 4-byte SRID (LE int32)
- 1-byte version (0x01 or 0x02 accepted)
- 1-byte properties bitfield — `IsSinglePoint` (0x08) required; `HasZ` / `HasM` reject (simple-point shortcut is 2D only)
- 16-byte coordinate payload (two IEEE 754 doubles, LE)
Total wire length is exactly 22 bytes — any other length returns null. **Geography axis inversion**: geography stores `(lat, long)` in binary but WKT prints `POINT (long lat)` per OGC; geometry uses `(x, y)` for both. WKT formatting uses `CultureInfo.InvariantCulture` with the `"R"` round-trip specifier so coordinate values reproduce bit-for-bit on re-parse.
Complex shapes (LineString, Polygon, MultiPolygon, FullGlobe, GeometryCollection, anything with Z/M coordinates, unknown versions) return null and the row loader falls back to `SqlValue.Null` — keeps the loader resilient so a single non-simple-point row in a future sample doesn't fail its whole BCP file.
**`Storage/Bacpac/BcpRowReader.cs`** split the prior `SpatialDeferToNull` payload kind into separate `Geography` + `Geometry` payloads so each calls the decoder with the right axis-order flag. The decoder result is wrapped via `SqlValue.FromGeography` / `SqlValue.FromGeometry` on success; null result falls back to `SqlValue.Null(type)`.
**Tests** in `SqlServerSimulator.Tests.Internal/Storage/SpatialWkbDecoderTests.cs` (7 new): axis inversion (geography vs geometry), bit-for-bit coordinate round-trip via the `"R"` specifier, truncated payload, non-simple-point properties bit, Z/M bits with IsSinglePoint set, unknown version. The previous `Load_AW_Geography_Column_Drops_To_Null` regression test in `BacpacLoaderTests` was inverted to `Load_AW_Geography_Column_Decodes_To_Point_Wkt` — asserts 0 NULL rows, all 19,614 round-trip, and spot-checks that AddressID=1's SpatialLocation casts to a `POINT (` WKT string.
# Cross-cutting doc updates
- `CLAUDE.md`: "What's modeled" programmable-objects pointer gains the NATIVE_COMPILATION / BEGIN ATOMIC paragraph (with the BEGIN-ATOMIC-is-not-a-real-tx-boundary caveat); BACPAC pointer entry's WWI-Full status now reads "zero remaining `Skipped` categories"; spatial paragraph updated from "WKB→WKT decoding deferred" to the simple-point shortcut summary.
- `docs/claude/bacpac-prerequisites.md` step 13 (natively-compiled SP) struck through with the full implementation detail; step 14 (geography WKB decoder) struck through likewise; Status section updated.Person.Address.SpatialLocation column decodes to POINT (long lat) WKT for all 19,614 rows instead of dropping to NULL. Both flagship public bacpacs are now structurally + data-complete in the simulator.1 parent bd022ad commit 76c20f0
14 files changed
Lines changed: 441 additions & 38 deletions
File tree
- SqlServerSimulator.Tests.Internal/Storage
- SqlServerSimulator.Tests
- SqlServerSimulator
- Parser
- Simulation
- Storage/Bacpac
- docs/claude
Large diffs are not rendered by default.
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
397 | 395 | | |
398 | | - | |
| 396 | + | |
399 | 397 | | |
400 | | - | |
| 398 | + | |
| 399 | + | |
401 | 400 | | |
402 | | - | |
| 401 | + | |
403 | 402 | | |
404 | 403 | | |
405 | 404 | | |
406 | 405 | | |
407 | 406 | | |
| 407 | + | |
| 408 | + | |
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
| |||
967 | 968 | | |
968 | 969 | | |
969 | 970 | | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
| |||
Lines changed: 109 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
177 | 184 | | |
| 185 | + | |
178 | 186 | | |
179 | 187 | | |
180 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
431 | 543 | | |
432 | 544 | | |
433 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
0 commit comments