Strange behaviour of ets

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange behaviour of ets

Max Treskin
Hello

I see some strange behaviour of ets interaction.
After I did an error in ets:select request, all following requests are erroneous until, i.e. ets:new
It is my session:

--------------------------
(ie@sun)89> ets:new(test, [public, named_table]).
test
(ie@sun)90> ets:insert(test, {{as, 2}, 23}).
true
(ie@sun)91> ets:insert(test, {{qwe, 5}, 756}).
true
(ie@sun)92> ets:insert(test, {{xcv, 3}, 111}).
true
(ie@sun)93> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
[111,756,23]
(ie@sun)94>

All is OK

(ie@sun)94> ets:select(qwe, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
** exception error: bad argument
in function ets:select/2
called as ets:select(qwe,[{{{'$1','$2'},'$3'},[],['$3']}])

Error

(ie@sun)95> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
** exception error: bad argument
in function ets:select/2
called as ets:select(test,[{{{'$1','$2'},'$3'},[],['$3']}])

The same request as in 93 line, error also

--------------------------

Why this error happens?


Thank you

--
Maxim Treskin
_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ets

Andreas Hillqvist
It looks to me like you use the key as the table name.
Maybe somthin like this:
    ie@sun)94> ets:select(test, [{{{qwe, '$2'}, '$3'}, [], ['$3']}]).


Kind regards
Andreas Hillqvist

2008/2/27, Maxim Treskin <[hidden email]>:

> Hello
>
> I see some strange behaviour of ets interaction.
> After I did an error in ets:select request, all following requests are
> erroneous until, i.e. ets:new
> It is my session:
>
> --------------------------
> (ie@sun)89> ets:new(test, [public, named_table]).
> test
> (ie@sun)90> ets:insert(test, {{as, 2}, 23}).
> true
> (ie@sun)91> ets:insert(test, {{qwe, 5}, 756}).
> true
> (ie@sun)92> ets:insert(test, {{xcv, 3}, 111}).
>
true
> (ie@sun)93> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
> [111,756,23]
> (ie@sun)94>
>
> All is OK
>
> (ie@sun)94> ets:select(qwe, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
>
** exception error: bad argument
>  in function ets:select/2
>  called as ets:select(qwe,[{{{'$1','$2'},'$3'},[],['$3']}])
>
> Error
>
> (ie@sun)95> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
>
** exception error: bad argument

>  in function ets:select/2
>  called as
> ets:select(test,[{{{'$1','$2'},'$3'},[],['$3']}])
>
> The same request as in 93 line, error also
>
>
> --------------------------
>
> Why this error happens?
>
>
> Thank you
>
> --
> Maxim Treskin
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ets

Christian S-2
In reply to this post by Max Treskin
Remember that you're in the shell when you create the ets table, some
process there becomes the table owner.

My guess that the actual evaluation happens in an isolated process,
and that it crashed when you did see the first exception, and that the
shell spawns a new process to continue with input 94.

Shell-implementation is not my strong side. So I am only guessing.
List all existing ets tables before and after to see if your ets table
has disappeared.

Or surround your crashing select with a catch so the exception is
stopped from crashing the evaluating process.


These errors are not obvious. The abstractions break down. It is sad
but easy to live with. Real code doesn't run in the shell.

2008/2/27 Maxim Treskin <[hidden email]>:
> Hello
_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ets

Sean Hinde
In reply to this post by Max Treskin
Your ets table disappeared when the shell process (its owner) exited.

Sean

On 27 Feb 2008, at 12:01, Maxim Treskin wrote:

> Hello
>
> I see some strange behaviour of ets interaction.
> After I did an error in ets:select request, all following requests  
> are erroneous until, i.e. ets:new
> It is my session:
>
> --------------------------
> (ie@sun)89> ets:new(test, [public, named_table]).
> test
> (ie@sun)90> ets:insert(test, {{as, 2}, 23}).
> true
> (ie@sun)91> ets:insert(test, {{qwe, 5}, 756}).
> true
> (ie@sun)92> ets:insert(test, {{xcv, 3}, 111}).
>
> true
> (ie@sun)93> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
> [111,756,23]
> (ie@sun)94>
>
> All is OK
>
> (ie@sun)94> ets:select(qwe, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
>
> ** exception error: bad argument
>      in function  ets:select/2
>         called as ets:select(qwe,[{{{'$1','$2'},'$3'},[],['$3']}])
>
> Error
>
> (ie@sun)95> ets:select(test, [{{{'$1', '$2'}, '$3'}, [], ['$3']}]).
>
> ** exception error: bad argument
>      in function  ets:select/2
>         called as ets:select(test,[{{{'$1','$2'},'$3'},[],['$3']}])
>
> The same request as in 93 line, error also
>
>
> --------------------------
>
> Why this error happens?
>
>
> Thank you
>
> --
> Maxim Treskin _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://www.erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://www.erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Strange behaviour of ets

Mikl Kurkov-2
In reply to this post by Max Treskin

Hi, Maxim!
The problem is that your shell process is the owner of ets table. When you
make incorrect operation it dies with its ets tables and new shell process
created without any. Just run self() before and after error.
You should create ets in external process via spawn or add catch to function
call.
--
Mikl


Maxim Treskin-2 wrote:

>
> Hello
>
> I see some strange behaviour of ets interaction.
> After I did an error in ets:select request, all following requests are
> erroneous until, i.e. ets:new
> ...
>
> Why this error happens?
>
> ...
>

--
View this message in context: http://www.nabble.com/Strange-behaviour-of-ets-tp15711918p15712654.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ets

Mikl Kurkov
In reply to this post by Max Treskin
Hi, Maxim!
The problem is that your shell process is the owner of ets table. When you make incorrect operation it dies with its ets tables and new shell process created without any. Just run self() before and after error.
You should create ets in external process via spawn or add catch to function call.
--
Mikl

Maxim Treskin-2 wrote
Hello

I see some strange behaviour of ets interaction.
After I did an error in ets:select request, all following requests are
erroneous until, i.e. ets:new
...

Why this error happens?

...