[erlang-questions] Strange ets:select behaviour

Maxim Treskin <>
Thu Dec 11 14:18:09 CET 2008


Hello

I have error with ets:select when I use MatchSpec with tuple matching.

It is my table:

()2> ets:i(controllers).
<1   > {{{192,168,138,73},37100,2},<0.61.0>}
EOT  (q)uit (p)Digits (k)ill /Regexp -->q
quit

it contains IPv4 address, port and assoc_id as key and process Pid.

So, when I select with following two MatchSpecs, I have no problems:

()5> ets:select(controllers, [{{{'$1', '$2', '$3'}, '$4'}, [{'==',
'$3', 2}, {is_pid, '$4'}], ['$4']}]).
[<0.61.0>]
()6> ets:select(controllers, [{{{'$1', '$2', '$3'}, '$4'}, [{'==',
'$2', 37100}, {is_pid, '$4'}], ['$4']}]).
[<0.61.0>]

(see on {'==', $...})

But with this MatchSpec I have error:

()7> ets:select(controllers, [{{{'$1', '$2', '$3'}, '$4'}, [{'==',
'$1', {192,168,138,73}}, {is_pid, '$4'}], ['$4']}]).
** exception error: bad argument
     in function  ets:select/2
        called as ets:select(controllers,
                             [{{{'$1','$2','$3'},'$4'},
                               [{'==','$1',{192,168,138,73}},{is_pid,'$4'}],
                               ['$4']}])


Is it means that impossible to use tuples in MatchSpec guards?

My OTP is R12B-5.

Thank you.

-- 
Maxim Treskin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081211/5111d3f9/attachment.html>


More information about the erlang-questions mailing list