Previous Section Next Section

sequence

Search a series of database maps V8.7 and above

The sequence type allows you to declare a single name that will be used to search a series of databases. It is declared like this:

Kname sequence  map1  map2 ...

Here, a key (in a later rule set) will be looked up first in the database map named map1, and if not found there, it will be looked up in the database map named map2. The type of each of the listed database maps should logically relate but need not be the same. Consider, for example, a rule's RHS, where a lookup will match if the workspace contains either a user's login name or the name of a host, with the hostname taking precedence:

Khosts host  -a<+> /etc/hosts
Kpasswd user -a<-> /etc/passwd
Kboth sequence hosts passwd

R$-     $: $(both $1 $)

Here, we say that the database map named both is of type sequence. Any single token in the LHS will be looked up first in the database map named hosts, and if it is found there the hostname will be returned with a <+> appended. If it is not found in the hosts database map, it will be next looked up in the passwd database map. If it is found there, the original workspace will be returned with a <-> appended. If the workspace is not found in either database map, the lookup fails and the workspace remains unchanged.

If any database map in the series of database maps declared with the K command does not exist, as for example:

Kboth sequence hosts passwd badname

the following error is logged and printed, and that database map is ignored:

Sequence map both: unknown member map  badname  

If the number of database maps that are sequenced exceeds the maximum allowed (MAXMAPSTACK in conf.h, currently 12), the following error is printed, and the overflow of database maps is ignored:

Sequence map name: too many member maps ( max  max)

None of the K command switches can be used with the sequence type. If you try to use any, they will be wrongly interpreted as database-map names.

    Previous Section Next Section