#include "db.h" long dbmatches(Dbptr dbk, Dbptr dbt, Tbl **kpattern, Tbl **tpattern, Hook **hookp, Tbl **tblp)
dbk should specify a single record of some table (this could be the scratch record). dbt specifies a whole table (it might be the same table). kpattern and tpattern are patterns (lists of field names, expressions or ranges) on which the record specified by dbk is to be matched in the table specified by dbt.
Just as in dbjoin, these two patterns may be specified as null, or as Tbl *pointers which are initially zero. If the patterns are not specified, they are inferred from the primary and alternate keys of the respective tables.
The process of setting up to perform a match involves computing some intermediate results, among them an index. The routine requires a place to store this information, which is provided by hook. *hook should be set to zero at the first call to dbmatches. Each separate call to dbmatches should have its own hook; the hook minimizes initial computations between successive calls with the same input parameters (but different rows in the table for dbk, or perhaps an updated table dbt).
The returned list is a list of the record numbers which satisfy the match. It is the responsibility of the caller to free this list with the call:
The list is reallocated at every call to dbmatches.freetbl(tbl, 0) ;
hook(3) dblist2subset(3)