(pre-define no-more-data-exit (status-set-both-goto dg-status-group-dg dg-status-id-no-more-data)) (pre-define (dg-relation-select-cursor-initialise name state state-field-name) (dg-mdb-initialise-cursor txn name) (status-set-id (mdb-cursor-get name (address-of val-null) (address-of val-null) MDB-FIRST)) (if (not dg-mdb-status-success?) (begin dg-mdb-status-require-notfound (status-set-both-goto dg-status-group-dg dg-status-id-no-more-data))) (struct-pointer-set state state-field-name name)) (pre-define (dg-relation-select-initialise-set name state) (define (pre-concat name _set) imht-set-t*) (status-require! (dg-ids->set name (address-of (pre-concat name _set)))) (struct-pointer-set state name (pre-concat name _set) options (bit-or (pre-concat dg-read-option-is-set_ name) (struct-pointer-get state options)))) (pre-define (dg-relation-reader-header state) status-init dg-mdb-introduce-val-relation-key (dg-define-relation-key relation-key) (dg-define-relation-record record) (define result-temp dg-relation-records-t*) (define skip? boolean (bit-and dg-read-option-skip (struct-pointer-get state options)))) (pre-define (dg-relation-reader-header-0000 state) status-init dg-mdb-introduce-val-relation-key (dg-define-relation-record record) (define result-temp dg-relation-records-t*) (define skip? boolean (bit-and dg-read-option-skip (struct-pointer-get state options)))) (pre-define (dg-relation-reader-get-ordinal-data state) (define ordinal-min dg-ordinal-t (struct-get (deref (struct-pointer-get state ordinal)) min)) (define ordinal-max dg-ordinal-t (struct-get (deref (struct-pointer-get state ordinal)) max))) (define (dg-relation-read-1000 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-relation-data (define left->right MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 0 (dg-ids-first left)) (if (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (goto each-data) (label set-range (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-SET-RANGE) (label each-key (if dg-mdb-status-success? (if (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (goto each-data)) dg-mdb-status-require-notfound) (set left (dg-ids-rest left)) (if left (begin (array-set-index relation-key 0 (dg-ids-first left)) (goto set-range)) no-more-data-exit)))) (label each-data stop-if-count-zero (if (not skip?) (begin (struct-set record left (dg-mdb-val->id-at val-relation-key 0) right (dg-mdb-val-relation-data->id val-relation-data) label (dg-mdb-val->id-at val-relation-key 1) ordinal (dg-mdb-val-relation-data->ordinal val-relation-data)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound)) (dg-mdb-cursor-next-nodup! left->right val-relation-key val-relation-data) (goto each-key) (label exit (struct-pointer-set state status status left left) (return status))) (define (dg-relation-read-1010 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-relation-data (define left->right MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (define left-first dg-ids-t* (struct-pointer-get state left-first)) (define label dg-ids-t* (struct-pointer-get state label)) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 0 (dg-ids-first left) 1 (dg-ids-first label)) (if (dg-relation-key-equal? relation-key (dg-mdb-val->relation-key val-relation-key)) (goto each-data) (label set-key (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-SET-KEY) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound) (label next-key (set left (dg-ids-rest left)) (if left (begin (array-set-index relation-key 0 (dg-ids-first left)) (goto set-key)) (begin (set label (dg-ids-rest label)) (if label (begin (set left left-first) (array-set-index relation-key 0 (dg-ids-first left) 1 (dg-ids-first label)) (goto set-key)) no-more-data-exit)))))) (label each-data stop-if-count-zero (if (not skip?) (begin (struct-set record left (dg-mdb-val->id-at val-relation-key 0) right (dg-mdb-val-relation-data->id val-relation-data) label (dg-mdb-val->id-at val-relation-key 1) ordinal (dg-mdb-val-relation-data->ordinal val-relation-data)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-data) (goto next-key))) (label exit (struct-pointer-set state status status left left label label) (return status))) (define (dg-relation-read-1100 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-id (define right->left MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (define left-first dg-ids-t* (struct-pointer-get state left-first)) (define right dg-ids-t* (struct-pointer-get state right)) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 0 (dg-ids-first right)) (if (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (goto each-left) (label set-range (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-SET-RANGE) (label each-right (if dg-mdb-status-success? (if (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (goto each-left)) dg-mdb-status-require-notfound) (set right (dg-ids-rest right)) (if right (array-set-index relation-key 0 (dg-ids-first right)) no-more-data-exit) (goto set-range)))) (label each-left stop-if-count-zero (struct-set val-id mv-data (dg-ids-first-address left)) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-GET-BOTH) (if dg-mdb-status-success? (begin (if (not skip?) (begin (struct-set record left (dg-mdb-val->id val-id) right (dg-mdb-val->id-at val-relation-key 0) label (dg-mdb-val->id-at val-relation-key 1)) (dg-relation-records-add! (deref result) record result-temp) reduce-count))) dg-mdb-status-require-notfound) (set left (dg-ids-rest left)) (if left (goto each-left) (set left left-first))) (dg-mdb-cursor-next-nodup! right->left val-relation-key val-id) (goto each-right) (label exit (struct-pointer-set state status status left left right right) (return status))) (define (dg-relation-read-1110 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-id (define right->left MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (define left-first dg-ids-t* (struct-pointer-get state left-first)) (define right dg-ids-t* (struct-pointer-get state right)) (define right-first dg-ids-t* (struct-pointer-get state right-first)) (define label dg-ids-t* (struct-pointer-get state label)) (define id-left dg-id-t) (array-set-index relation-key 1 (dg-ids-first label)) (set id-left (dg-ids-first left)) (array-set-index relation-key 0 (dg-ids-first right)) (label set-cursor (struct-set val-relation-key mv-data relation-key) (struct-set val-id mv-data (address-of id-left)) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-GET-BOTH) (if dg-mdb-status-success? (goto match) dg-mdb-status-require-notfound) (label next-query (set right (dg-ids-rest right)) (if right (begin stop-if-count-zero (array-set-index relation-key 0 (dg-ids-first right)) (goto set-cursor)) (begin (set right right-first) (array-set-index relation-key 0 (dg-ids-first right)) (set left (dg-ids-rest left)) (if left (begin stop-if-count-zero (set id-left (dg-ids-first left)) (goto set-cursor)) (begin (set left left-first) (set id-left (dg-ids-first left)) (set label (dg-ids-rest label)) (if label (begin stop-if-count-zero (array-set-index relation-key 1 (dg-ids-first label)) (goto set-cursor)) no-more-data-exit))))))) (label match (if (not skip?) (begin (struct-set record left (dg-mdb-val->id val-id) right (dg-mdb-val->id-at val-relation-key 0) label (dg-mdb-val->id-at val-relation-key 1)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (goto next-query)) (label exit (struct-pointer-set state status status left left right right label label) (return status))) (define (dg-relation-read-1001-1101 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-relation-data (define left->right MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (define right imht-set-t* (struct-pointer-get state right)) (dg-relation-reader-get-ordinal-data state) (dg-define-relation-data relation-data) (dg-relation-data-set-ordinal relation-data ordinal-min) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (if left (array-set-index relation-key 0 (dg-ids-first left)) no-more-data-exit) (if (and (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (or (not ordinal-min) (>= (dg-mdb-val-relation-data->ordinal val-relation-data) ordinal-min)) (or (not ordinal-max) (<= (dg-mdb-val-relation-data->ordinal val-relation-data) ordinal-max))) (goto each-data) (label each-left (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-SET-RANGE) (label each-key (if dg-mdb-status-success? (if (dg-id-equal? (dg-mdb-val->id-at val-relation-key 0) (array-get relation-key 0)) (begin (struct-set val-relation-data mv-data relation-data) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-BOTH-RANGE) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound) (dg-mdb-cursor-next-nodup! left->right val-relation-key val-relation-data) (goto each-key))) dg-mdb-status-require-notfound) (set left (dg-ids-rest left)) (if left (array-set-index relation-key 0 (dg-ids-first left)) no-more-data-exit) (goto each-left)))) (label each-data stop-if-count-zero (if (or (not ordinal-max) (<= (dg-mdb-val-relation-data->ordinal val-relation-data) ordinal-max)) (begin (if (or (not right) (imht-set-contains? right (dg-mdb-val-relation-data->id val-relation-data))) (begin (if (not skip?) (begin (struct-set record left (dg-mdb-val->id-at val-relation-key 0) label (dg-mdb-val->id-at val-relation-key 1) ordinal (dg-mdb-val-relation-data->ordinal val-relation-data) right (dg-mdb-val-relation-data->id val-relation-data)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count)) (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound)))) (dg-mdb-cursor-next-nodup! left->right val-relation-key val-relation-data) (goto each-key) (label exit (struct-pointer-set state status status left left) (return status))) (define (dg-relation-read-1011-1111 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-relation-data (dg-define-relation-data relation-data) (define left->right MDB-cursor* (struct-pointer-get state cursor)) (define left dg-ids-t* (struct-pointer-get state left)) (define left-first dg-ids-t* (struct-pointer-get state left-first)) (define label dg-ids-t* (struct-pointer-get state label)) (define right imht-set-t* (struct-pointer-get state right)) (dg-relation-reader-get-ordinal-data state) (dg-relation-data-set-ordinal relation-data ordinal-min) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 0 (dg-ids-first left) 1 (dg-ids-first label)) (if (dg-relation-key-equal? relation-key (dg-mdb-val->relation-key val-relation-key)) (goto each-data) (label set-key (struct-set val-relation-key mv-data relation-key) (struct-set val-relation-data mv-data relation-data) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-BOTH-RANGE) (if dg-mdb-status-success? (goto each-data) (begin dg-mdb-status-require-notfound (label each-key (set left (dg-ids-rest left)) (if left (array-set-index relation-key 0 (dg-ids-first left)) (begin (set label (dg-ids-rest label)) (if label (begin (array-set-index relation-key 1 (dg-ids-first label)) (set left left-first) (array-set-index relation-key 0 (dg-ids-first left))) no-more-data-exit))) (goto set-key)))))) (label each-data stop-if-count-zero (if (or (not ordinal-max) (<= (dg-mdb-val-relation-data->ordinal val-relation-data) ordinal-max)) (begin (if (or (not right) (imht-set-contains? right (dg-mdb-val-relation-data->id val-relation-data))) (begin (if (not skip?) (begin (struct-set record left (dg-mdb-val->id-at val-relation-key 0) right (dg-mdb-val-relation-data->id val-relation-data) label (dg-mdb-val->id-at val-relation-key 1) ordinal (dg-mdb-val-relation-data->ordinal val-relation-data)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count)) (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-data) (goto each-key))) (goto each-key))) (label exit (struct-pointer-set state status status left left label label) (return status))) (define (dg-relation-read-0010 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-id dg-mdb-introduce-val-id-2 dg-mdb-introduce-val-relation-data (define label->left MDB-cursor* (struct-pointer-get state cursor)) (define left->right MDB-cursor* (struct-pointer-get state cursor-2)) (define label dg-ids-t* (struct-pointer-get state label)) (define id-left dg-id-t id-label dg-id-t) (dg-mdb-cursor-get! label->left val-id val-id-2 MDB-GET-CURRENT) dg-mdb-status-require (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (if label (set id-label (dg-ids-first label)) no-more-data-exit) (if (dg-id-equal? id-label (dg-mdb-val->id val-id)) (begin (array-set-index relation-key 1 id-label) (goto each-label-data)) (label set-label-key (struct-set val-id mv-data (address-of id-label)) (dg-mdb-cursor-get! label->left val-id val-id-2 MDB-SET-KEY) (if dg-mdb-status-success? (begin (array-set-index relation-key 1 id-label) (goto each-label-data)) (begin dg-mdb-status-require-notfound (set label (dg-ids-rest label)) (if label (set id-label (dg-ids-first label)) no-more-data-exit) (goto set-label-key))))) (label each-label-data (set id-left (dg-mdb-val->id val-id-2)) (if (dg-id-equal? id-left (dg-mdb-val->id-at val-relation-key 0)) (goto each-left-data) (begin (array-set-index relation-key 0 id-left) (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-SET-KEY) (if dg-mdb-status-success? (goto each-left-data) (goto exit)))) (label each-left-data stop-if-count-zero (if (not skip?) (begin (struct-set record left id-left right (dg-mdb-val-relation-data->id val-relation-data) label id-label) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-left-data) dg-mdb-status-require-notfound)) (dg-mdb-cursor-next-dup! label->left val-id val-id-2) (if dg-mdb-status-success? (goto each-label-data) (begin (set label (dg-ids-rest label)) (if label (set id-label (dg-ids-first label)) no-more-data-exit) (goto set-label-key)))) (label exit (struct-pointer-set state status status label label) (return status))) (define (dg-relation-read-0110 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-id (define right->left MDB-cursor* (struct-pointer-get state cursor)) (define label dg-ids-t* (struct-pointer-get state label)) (define right dg-ids-t* (struct-pointer-get state right)) (define right-first dg-ids-t* (struct-pointer-get state right-first)) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 1 (dg-ids-first label)) (array-set-index relation-key 0 (dg-ids-first right)) (if (dg-relation-key-equal? relation-key (dg-mdb-val->relation-key val-relation-key)) (goto each-data) (label set-key (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-SET-KEY) (if dg-mdb-status-success? (goto each-data) (label each-key dg-mdb-status-require-notfound (set right (dg-ids-rest right)) (if right (array-set-index relation-key 0 (dg-ids-first right)) (begin (set label (dg-ids-rest label)) (if label (begin (array-set-index relation-key 1 (dg-ids-first label)) (set right right-first) (array-set-index relation-key 0 (dg-ids-first right))) no-more-data-exit))) (goto set-key))))) (label each-data stop-if-count-zero (if (not skip?) (begin (struct-set record left (dg-mdb-val->id val-id) right (array-get relation-key 0) label (array-get relation-key 1)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! right->left val-relation-key val-id) (if dg-mdb-status-success? (goto each-data) (goto each-key))) (label exit (struct-pointer-set state status status right right label label) (return status))) (define (dg-relation-read-0100 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header state) dg-mdb-introduce-val-id (define right->left MDB-cursor* (struct-pointer-get state cursor)) (define right dg-ids-t* (struct-pointer-get state right)) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-GET-CURRENT) dg-mdb-status-require (array-set-index relation-key 0 (dg-ids-first right)) (if (dg-id-equal? (array-get relation-key 0) (dg-mdb-val->id-at val-relation-key 0)) (goto each-key) (label set-range (struct-set val-relation-key mv-data relation-key) (dg-mdb-cursor-get! right->left val-relation-key val-id MDB-SET-RANGE) (if dg-mdb-status-success? (if (dg-id-equal? (array-get relation-key 0) (dg-mdb-val->id-at val-relation-key 0)) (goto each-key)) dg-mdb-status-require-notfound) (set right (dg-ids-rest right)) (if right (array-set-index relation-key 0 (dg-ids-first right)) no-more-data-exit) (goto set-range))) (label each-key (label each-data stop-if-count-zero (if (not skip?) (begin (struct-set record left (dg-mdb-val->id val-id) right (dg-mdb-val->id-at val-relation-key 0) label (dg-mdb-val->id-at val-relation-key 1)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! right->left val-relation-key val-id) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound)) (dg-mdb-cursor-next-nodup! right->left val-relation-key val-id) (if dg-mdb-status-success? (if (dg-id-equal? (array-get relation-key 0) (dg-mdb-val->id-at val-relation-key 0)) (goto each-key)) dg-mdb-status-require-notfound) (set right (dg-ids-rest right)) (if right (array-set-index relation-key 0 (dg-ids-first right)) no-more-data-exit) (goto set-range)) (label exit (struct-pointer-set state status status right right) (return status))) (define (dg-relation-read-0000 state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) (dg-relation-reader-header-0000 state) dg-mdb-introduce-val-relation-data (define left->right MDB-cursor* (struct-pointer-get state cursor)) (dg-mdb-cursor-get! left->right val-relation-key val-relation-data MDB-GET-CURRENT) dg-mdb-status-require (label each-key (label each-data stop-if-count-zero (if (not skip?) (begin (struct-set record left (dg-mdb-val->id-at val-relation-key 0) right (dg-mdb-val-relation-data->id val-relation-data) label (dg-mdb-val->id-at val-relation-key 1) ordinal (dg-mdb-val-relation-data->ordinal val-relation-data)) (dg-relation-records-add! (deref result) record result-temp))) reduce-count (dg-mdb-cursor-next-dup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-data) dg-mdb-status-require-notfound)) (dg-mdb-cursor-next-nodup! left->right val-relation-key val-relation-data) (if dg-mdb-status-success? (goto each-key) dg-mdb-status-require-notfound)) (label exit (struct-pointer-set state status status) (return status))) (define (dg-relation-select txn left right label ordinal offset result) (status-t dg-txn-t* dg-ids-t* dg-ids-t* dg-ids-t* dg-ordinal-match-data-t* b32 dg-relation-read-state-t*) "prepare the state and select the reader. readers are specialised for filter combinations. the 1/0 pattern at the end of reader names corresponds to the filter combination the reader is supposed to handle. 1 stands for filter given, 0 stands for not given. the order is left-right-label-ordinal. readers always leave cursors at a valid entry, usually the next entry unless the results have been exhausted" status-init (dg-mdb-declare-cursor-3 left->right right->left label->left) (struct-pointer-set result status status left left left-first left right right right-first right label label ordinal ordinal cursor 0 cursor-2 0 options 0) (if left (if ordinal (begin (if right (dg-relation-select-initialise-set right result)) (dg-relation-select-cursor-initialise left->right result cursor) (if label (struct-pointer-set result reader dg-relation-read-1011-1111) (struct-pointer-set result reader dg-relation-read-1001-1101))) (if right (begin (dg-relation-select-cursor-initialise right->left result cursor) (if label (struct-pointer-set result reader dg-relation-read-1110) (struct-pointer-set result reader dg-relation-read-1100))) (begin (dg-relation-select-cursor-initialise left->right result cursor) (if label (struct-pointer-set result reader dg-relation-read-1010) (struct-pointer-set result reader dg-relation-read-1000))))) (if right (begin (dg-relation-select-cursor-initialise right->left result cursor) (struct-pointer-set result reader (if* label dg-relation-read-0110 dg-relation-read-0100))) (if label (begin (dg-relation-select-cursor-initialise label->left result cursor) (dg-relation-select-cursor-initialise left->right result cursor-2) (struct-pointer-set result reader dg-relation-read-0010)) (begin (dg-relation-select-cursor-initialise left->right result cursor) (struct-pointer-set result reader dg-relation-read-0000))))) (define reader dg-relation-reader-t (struct-pointer-get result reader)) (dg-select-ensure-offset result offset reader) (label exit (struct-pointer-set result status status) (return status))) (define (dg-relation-read state count result) (status-t dg-relation-read-state-t* b32 dg-relation-records-t**) status-init (set count (optional-count count)) (status-require! (struct-pointer-get state status)) (set status ((convert-type (struct-pointer-get state reader) dg-relation-reader-t) state count result)) (label exit dg-status-no-more-data-if-mdb-notfound (return status))) (define (dg-relation-selection-destroy state) (b0 dg-relation-read-state-t*) (dg-mdb-cursor-close-2 (struct-pointer-get state cursor) (struct-pointer-get state cursor-2)) (if (bit-and dg-read-option-is-set-right (struct-pointer-get state options)) (begin (imht-set-destroy (convert-type (struct-pointer-get state right) imht-set-t*)) (struct-pointer-set state right 0))))