The example stores a query definition and executes it with different variables.
It then changes the query ordering and updates the people that the query selects.
odin 388 B
promote : = stardust. mutation ( db, "people/promote" ) or_return
defer stardust. close ( & promote)
commit : = stardust. run ( promote) or_return
defer stardust. close ( & commit)
query : = stardust. query ( db, "people/by_role" ) or_return
defer stardust. close ( & query)
rows : = stardust. run ( query) or_return
defer stardust. close ( & rows)
result : = stardust. next ( rows) or_return
defer stardust. close ( & result)
TRON89 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 4C 6E616D65 txt "name" 09 3C 416461 txt "Ada" 0D 0F 0A 04000000 0900
0000 map leaf, size 10: @4 → @9 17 4C 6E616D65 txt "name" 1C 3C 426F62 txt "Bob" 20 0F 0A 17000000 1C00
0000 map leaf, size 10: @17 → @1C 2A 4C 6E616D65 txt "name" 2F 2C 4379 txt "Cy" 32 0F 0A 2A000000 2F00
0000 map leaf, size 10: @2A → @2F 3C 0E 15 00 0700 030000
00 0D000000 200000
00 32000000 array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @D → @20 → @32
A transaction records each committed change to a stored definition.
An open definition handle identifies its stored path, so later calls can select the applicable version.
To read a specific historical version, use the as_of rules below.
The plan operation below reads and controls the accepted plan for a stored query or mutation.
It works without a planner plugin. Mutation selections use the query planner and report selection feedback.
Background trials of a mutation execute its selection only. They do not apply its patch.
The adaptive planner can retain separate plans for exact parameter values.
Values without a retained plan use the shared fallback plan.
Measured repeated-use savings must justify the lookup, trial and storage costs within the database memory budget.
Optional anchor probes can improve estimates when their measured cost justifies the work.
An incomplete probe supplies a lower bound and cannot prove that a query is empty.
Use explain for the current accepted state and its paged revision history.
Use status for the current state alone, or history for a history page.
Each history entry includes the plan version, source and reason for the change.
Trial reasons report the candidates and their measured outcomes.
The pin action prevents automatic replacement for every parameter value.
The unpin action permits learning again.
The replan action rebuilds the fallback plan and clears specialized parameter plans. It preserves the global pin.
The revert action restores a complete historical state, including its pin and parameter plans.
Revert requires the exact plan transaction and the same authored definition revision.
Explicit changes compare both authored and accepted plan revisions inside the commit.
A concurrent definition or plan change reports conflict.
Every returned plan document owns its buffers and remains readable after the database closes.
odin 141 B
definition : : proc (
db: Database ,
kind, path: string ,
as_of: builtin. i64 = 0 ,
allocator : = context . allocator ,
) -> (
Document ,
Error ,
)
odin 102 B
result : = stardust. definition ( db, "queries" , "people/by_role" ) or_return
defer stardust. close ( & result)
TRON264 B
Offset (hex) Bytes (hex) Meaning 000 54 52 4F 4E magic TRON 004 5C 3F6E616D65 txt "?name" 00A 0E 0D 00 0100 010000
00 04000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 017 5C 3F6E616D65 txt "?name" 01D 0E 0D 00 0100 010000
00 17000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @17 02A 5C 3F726F6C65 txt "?role" 030 8C 656E67696E6565
72 txt "engineer" 039 0F 0A 2A000000 3000
0000 map leaf, size 10: @2A → @30 043 2C 3F65 txt "?e" 046 4C 726F6C65 txt "role" 04B 5C 3F726F6C65 txt "?role" 051 0E 15 00 0700 030000
00 43000000 460000
00 4B000000 array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @43 → @46 → @4B 066 2C 3F65 txt "?e" 069 4C 6E616D65 txt "name" 06E 5C 3F6E616D65 txt "?name" 074 0E 15 00 0700 030000
00 66000000 690000
00 6E000000 array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @66 → @69 → @6E 089 0E 11 00 0300 020000
00 51000000 740000
00 array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @51 → @74 09A 5C 7768657265 txt "where" 0A0 0F 0A 9A000000 8900
0000 map leaf, size 10: @9A → @89 0AA 4C 66696E64 txt "find" 0AF 0F 0A AA000000 0A00
0000 map leaf, size 10: @AA → @A 0B9 AC 706172616D6574
657273 txt "parameters" 0C4 0F 0A B9000000 3900
0000 map leaf, size 10: @B9 → @39 0CE 7C 6F726465724279 txt "orderBy" 0D6 0F 0A CE000000 1D00
0000 map leaf, size 10: @CE → @1D 0E0 07 0E 20080000 C400
0000 D6000000 map branch, size 14, depth 1, slots 5, 11: @C4 → @D6 0EE 07 12 2A000000 A000
0000 AF000000 E000
0000 map branch, size 18, depth 0 (root), slots 1, 3, 5: @A0 → @AF → @E0
C exports: stardust_db_definition_get , stardust_result_take_document , stardust_result_error , stardust_result_release
odin 199 B
plan : : proc (
db: Database ,
kind, path, action: string ,
argument: builtin. i64 = 0 ,
page_size: builtin. i64 = 0 ,
max_bytes: builtin. i64 = 0 ,
allocator : = context . allocator ,
) -> ( Document , Error )
odin 221 B
pinned : = stardust. plan ( db, "queries" , "people/by_role" , "pin" ) or_return
stardust. close ( & pinned)
result : = stardust. plan ( db, "queries" , "people/by_role" , "explain" , 0 , 16 , 1 << 20 ) or_return
defer stardust. close ( & result)
TRON1 kB
Offset (hex) Bytes (hex) Meaning 000 54 52 4F 4E magic TRON 004 1C 31 txt "1" 006 02 00000000000000
00 i64 0 00F 0F 0A 04000000 0600
0000 map leaf, size 10: @4 → @6 019 02 00000000000000
00 i64 0 022 02 01000000000000
00 i64 1 02B 0E 11 00 0300 020000
00 19000000 220000
00 array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @19 → @22 03C 4C 68617368 txt "hash" 041 0F 0A 3C000000 0F00
0000 map leaf, size 10: @3C → @F 04B 7C 76657273696F6E txt "version" 053 02 01000000000000
00 i64 1 05C 0F 0A 4B000000 5300
0000 map leaf, size 10: @4B → @53 066 AC 706172616D6574
657273 txt "parameters" 071 0C txt "" 072 0F 0A 66000000 7100
0000 map leaf, size 10: @66 → @71 07C 6C 666F726D6174 txt "format" 083 02 02000000000000
00 i64 2 08C 0F 0A 7C000000 8300
0000 map leaf, size 10: @7C → @83 096 07 0E 20200000 7200
0000 8C000000 map branch, size 14, depth 1, slots 5, 13: @72 → @8C 0A4 6C 70696E6E6564 txt "pinned" 0AB 09 bit true 0AC 0F 0A A4000000 AB00
0000 map leaf, size 10: @A4 → @AB 0B6 5C 6F72646572 txt "order" 0BC 0F 0A B6000000 2B00
0000 map leaf, size 10: @B6 → @2B 0C6 07 0E 82000000 AC00
0000 BC000000 map branch, size 14, depth 1, slots 1, 7: @AC → @BC 0D4 6C 736F75726365 txt "source" 0DB 7C 506C616E6E6564 txt "Planned" 0E3 0F 0A D4000000 DB00
0000 map leaf, size 10: @D4 → @DB 0ED 7C 736574746C6564 txt "settled" 0F5 01 bit false 0F6 0F 0A ED000000 F500
0000 map leaf, size 10: @ED → @F5 100 07 0E 01200000 E300
0000 F6000000 map branch, size 14, depth 1, slots 0, 13: @E3 → @F6
Show all 100 nodes Offset (hex) Bytes (hex) Meaning 10E 8C 7265766973696F
6E txt "revision" 117 14 10 376537646533
3266333366353038
6135 txt "7e7de32f33f508a5" 129 0F 0A 0E010000 1701
0000 map leaf, size 10: @10E → @117 133 6C 706F6C696379 txt "policy" 13A 14 10 303030303030
3030303030303030
3030 txt "0000000000000000" 14C 0F 0A 33010000 3A01
0000 map leaf, size 10: @133 → @13A 156 6C 726561736F6E txt "reason" 15D CC 6578706C696369
742070696E txt "explicit pin" 16A 0F 0A 56010000 5D01
0000 map leaf, size 10: @156 → @15D 174 07 26 EA0D0000 4100
0000 5C000000 9600
0000 C6000000 0001
0000 29010000 4C01
0000 6A010000 map branch, size 38, depth 0 (root), slots 1, 3, 5, 6, 7, 8, 10, 11: @41 → @5C → @96 → @C6 → @100 → @129 → @14C → @16A 19A 1C 31 txt "1" 19C 02 00000000000000
00 i64 0 1A5 0F 0A 9A010000 9C01
0000 map leaf, size 10: @19A → @19C 1AF 02 00000000000000
00 i64 0 1B8 02 01000000000000
00 i64 1 1C1 0E 11 00 0300 020000
00 AF010000 B80100
00 array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @1AF → @1B8 1D2 4C 68617368 txt "hash" 1D7 0F 0A D2010000 A501
0000 map leaf, size 10: @1D2 → @1A5 1E1 7C 76657273696F6E txt "version" 1E9 02 01000000000000
00 i64 1 1F2 0F 0A E1010000 E901
0000 map leaf, size 10: @1E1 → @1E9 1FC AC 706172616D6574
657273 txt "parameters" 207 0C txt "" 208 0F 0A FC010000 0702
0000 map leaf, size 10: @1FC → @207 212 6C 666F726D6174 txt "format" 219 02 02000000000000
00 i64 2 222 0F 0A 12020000 1902
0000 map leaf, size 10: @212 → @219 22C 07 0E 20200000 0802
0000 22020000 map branch, size 14, depth 1, slots 5, 13: @208 → @222 23A 6C 70696E6E6564 txt "pinned" 241 09 bit true 242 0F 0A 3A020000 4102
0000 map leaf, size 10: @23A → @241 24C 5C 6F72646572 txt "order" 252 0F 0A 4C020000 C101
0000 map leaf, size 10: @24C → @1C1 25C 07 0E 82000000 4202
0000 52020000 map branch, size 14, depth 1, slots 1, 7: @242 → @252 26A 6C 736F75726365 txt "source" 271 7C 506C616E6E6564 txt "Planned" 279 0F 0A 6A020000 7102
0000 map leaf, size 10: @26A → @271 283 7C 736574746C6564 txt "settled" 28B 01 bit false 28C 0F 0A 83020000 8B02
0000 map leaf, size 10: @283 → @28B 296 07 0E 01200000 7902
0000 8C020000 map branch, size 14, depth 1, slots 0, 13: @279 → @28C 2A4 8C 7265766973696F
6E txt "revision" 2AD 14 10 376537646533
3266333366353038
6135 txt "7e7de32f33f508a5" 2BF 0F 0A A4020000 AD02
0000 map leaf, size 10: @2A4 → @2AD 2C9 6C 706F6C696379 txt "policy" 2D0 14 10 303030303030
3030303030303030
3030 txt "0000000000000000" 2E2 0F 0A C9020000 D002
0000 map leaf, size 10: @2C9 → @2D0 2EC 6C 726561736F6E txt "reason" 2F3 CC 6578706C696369
742070696E txt "explicit pin" 300 0F 0A EC020000 F302
0000 map leaf, size 10: @2EC → @2F3 30A 07 26 EA0D0000 D701
0000 F2010000 2C02
0000 5C020000 9602
0000 BF020000 E202
0000 00030000 map branch, size 38, depth 0 (root), slots 1, 3, 5, 6, 7, 8, 10, 11: @1D7 → @1F2 → @22C → @25C → @296 → @2BF → @2E2 → @300 330 4C 706C616E txt "plan" 335 0F 0A 30030000 0A03
0000 map leaf, size 10: @330 → @30A 33F BC 7472616E736163
74696F6E txt "transaction" 34B 02 0C000000000000
00 i64 12 354 0F 0A 3F030000 4B03
0000 map leaf, size 10: @33F → @34B 35E 07 0E 02020000 3503
0000 54030000 map branch, size 14, depth 0 (root), slots 1, 9: @335 → @354 36C 0E 0D 00 0100 010000
00 5E030000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @35E 379 4C 706C616E txt "plan" 37E 0F 0A 79030000 7401
0000 map leaf, size 10: @379 → @174 388 BC 7472616E736163
74696F6E txt "transaction" 394 02 0C000000000000
00 i64 12 39D 0F 0A 88030000 9403
0000 map leaf, size 10: @388 → @394 3A7 7C 686973746F7279 txt "history" 3AF 0F 0A A7030000 6C03
0000 map leaf, size 10: @3A7 → @36C 3B9 AC 6E6578745F6166
746572 txt "next_after" 3C4 02 00000000000000
00 i64 0 3CD 0F 0A B9030000 C403
0000 map leaf, size 10: @3B9 → @3C4 3D7 07 16 024A0000 7E03
0000 9D030000 AF03
0000 CD030000 map branch, size 22, depth 0 (root), slots 1, 9, 11, 14: @37E → @39D → @3AF → @3CD
Offset (hex) Bytes (hex) Meaning
C exports: stardust_db_plan , stardust_result_take_document , stardust_result_error , stardust_result_release
odin 127 B
definitions : : proc (
db: Database ,
kind: string ,
pattern : = "" ,
allocator : = context . allocator ,
) -> (
Document ,
Error ,
)
odin 98 B
result : = stardust. definitions ( db, "queries" , "people/.*" ) or_return
defer stardust. close ( & result)
TRON40 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 EC 70656F706C652F
62795F726F6C65 txt "people/by_role" 13 0E 0D 00 0100 010000
00 04000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
odin 98 B
result : = stardust. definitions ( db, "queries" , "people/.*" ) or_return
defer stardust. close ( & result)
TRON21 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 0E 09 00 0000 000000
00 array leaf, size 9, shift 0, bitmap 0000, count 0 (root)
odin 98 B
result : = stardust. definitions ( db, "queries" , "people/.*" ) or_return
defer stardust. close ( & result)
TRON40 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 EC 70656F706C652F
62795F726F6C65 txt "people/by_role" 13 0E 0D 00 0100 010000
00 04000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
odin 98 B
result : = stardust. definitions ( db, "queries" , "people/.*" ) or_return
defer stardust. close ( & result)
TRON21 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 0E 09 00 0000 000000
00 array leaf, size 9, shift 0, bitmap 0000, count 0 (root)
C exports: stardust_db_definition_list , stardust_result_take_document , stardust_result_error , stardust_result_release
odin 138 B
patch_definition : : proc (
db: Database ,
kind, path: string ,
patch: Document ,
allocator : = context . allocator ,
) -> (
Commit ,
Error ,
)
definition_text holds this document:
TRON264 B
Offset (hex) Bytes (hex) Meaning 000 54 52 4F 4E magic TRON 004 5C 3F726F6C65 txt "?role" 00A 8C 656E67696E6565
72 txt "engineer" 013 0F 0A 04000000 0A00
0000 map leaf, size 10: @4 → @A 01D 5C 3F6E616D65 txt "?name" 023 0E 0D 00 0100 010000
00 1D000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @1D 030 2C 3F65 txt "?e" 033 4C 726F6C65 txt "role" 038 5C 3F726F6C65 txt "?role" 03E 0E 15 00 0700 030000
00 30000000 330000
00 38000000 array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @30 → @33 → @38 053 2C 3F65 txt "?e" 056 4C 6E616D65 txt "name" 05B 5C 3F6E616D65 txt "?name" 061 0E 15 00 0700 030000
00 53000000 560000
00 5B000000 array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @53 → @56 → @5B 076 0E 11 00 0300 020000
00 3E000000 610000
00 array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @3E → @61 087 5C 3F6E616D65 txt "?name" 08D 0E 0D 00 0100 010000
00 87000000 array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @87 09A 5C 7768657265 txt "where" 0A0 0F 0A 9A000000 7600
0000 map leaf, size 10: @9A → @76 0AA 4C 66696E64 txt "find" 0AF 0F 0A AA000000 2300
0000 map leaf, size 10: @AA → @23 0B9 AC 706172616D6574
657273 txt "parameters" 0C4 0F 0A B9000000 1300
0000 map leaf, size 10: @B9 → @13 0CE 7C 6F726465724279 txt "orderBy" 0D6 0F 0A CE000000 8D00
0000 map leaf, size 10: @CE → @8D 0E0 07 0E 20080000 C400
0000 D6000000 map branch, size 14, depth 1, slots 5, 11: @C4 → @D6 0EE 07 12 2A000000 A000
0000 AF000000 E000
0000 map branch, size 18, depth 0 (root), slots 1, 3, 5: @A0 → @AF → @E0
odin 221 B
patch : = stardust. parse ( definition_text, . TRON ) or_return
defer stardust. close ( & patch)
commit : = stardust. patch_definition ( db, "queries" , "people/by_role" , patch) or_return
defer stardust. close ( & commit)
result : = commit
TRON179 B
Offset (hex) Bytes (hex) Meaning 00 54 52 4F 4E magic TRON 04 0F 02 map leaf, size 2 06 3C 696473 txt "ids" 0A 0F 0A 06000000 0400
0000 map leaf, size 10: @6 → @4 14 6C 737461747573 txt "status" 1B 9C 636F6D6D697474
6564 txt "committed" 25 0F 0A 14000000 1B00
0000 map leaf, size 10: @14 → @1B 2F 07 0E 02040000 0A00
0000 25000000 map branch, size 14, depth 1, slots 1, 10: @A → @25 3D BC 7472616E736163
74696F6E txt "transaction" 49 02 03000000000000
00 i64 3 52 0F 0A 3D000000 4900
0000 map leaf, size 10: @3D → @49 5C CC 636F6D6D697474
65645F6174 txt "committed_at" 69 02 93FF894735AD3F
00 i64 17923367877869459 72 0F 0A 5C000000 6900
0000 map leaf, size 10: @5C → @69 7C 5C 6661637473 txt "facts" 82 02 00000000000000
00 i64 0 8B 0F 0A 7C000000 8200
0000 map leaf, size 10: @7C → @82 95 07 16 01460000 2F00
0000 52000000 7200
0000 8B000000 map branch, size 22, depth 0 (root), slots 0, 9, 10, 14: @2F → @52 → @72 → @8B
C exports: stardust_db_definition_patch , stardust_db_result_commit_info , stardust_result_error , stardust_result_release