Buffering multiple results
The am_getnext purpose function can find and store several qualified index entries in shared memory before it returns control to the database server.
About this task
Procedure
- Call mi_tab_setniorows() in am_open or am_beginscan to set the number of index entries that the access method can return in one scan.
- Call mi_tab_niorows() at the start of am_getnext to find out how many index entries to return.
- Loop through mi_tab_setnextrow() in am_getnext until the number of qualifying index entries matches the return value of mi_tab_niorows() or until no more qualifying rows remain.
Example
The following figure shows the preceding steps.
Typically, a secondary access method does not create
rows from key data. However, if you intend to set the am_keyscan purpose
flag for a secondary access method, the access method must create
an MI_ROW structure that contains key values in the appropriate order
and of the appropriate data type to match the query specifications
for a projected row.
Important: Although a user can index
UDTs, the database server issues an exception if the secondary access
method creates and returns a row from index keys that contain UDTs.