2012-10-26 25 views
1

查找在ETS不存在的表(T3)後,所有的用戶創建的表(t1和t2)將被刪除。這是一個錯誤還是隻是ets的一個奇特功能?爲什麼ets粗暴地刪除我的表格?

這裏是ESHELL代碼。


Eshell V5.9.1 (abort with ^G) 

1> ets:new(t1, [named_table]). 

t1 

2> ets:new(t2, [named_table]). 

t2 

3> ets:all(). 

[t2,t1,8207,4110,13,file_io_servers,inet_hosts_file_byaddr, 
inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname, 
inet_cache,inet_db,global_pid_ids,global_pid_names, 
global_names_ext,global_names,global_locks,ac_tab] 

4> ets:insert(t1, {1,2}). 

true 

5> ets:lookup(t1, 1). 

[{1,2}] 

6> ets:lookup(t2, 1). 

[] 

7> ets:all().   

[t2,t1,8207,4110,13,file_io_servers,inet_hosts_file_byaddr, 
inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname, 
inet_cache,inet_db,global_pid_ids,global_pid_names, 
global_names_ext,global_names,global_locks,ac_tab] 

8> ets:lookup(t3, 1). 

** exception error: bad argument 
    in function ets:lookup/2 
     called as ets:lookup(t3,1) 

9> ets:all().   

[8207,4110,13,file_io_servers,inet_hosts_file_byaddr, 
inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname, 
inet_cache,inet_db,global_pid_ids,global_pid_names, 
global_names_ext,global_names,global_locks,ac_tab] 

10> 

任何人誰可以告訴我這裏有什麼問題嗎?

+5

http://stackoverflow.com/questions/1964990/erlang-ets-reset-ets-table-after-getting-a-bad-argument – couchemar

+0

我真的很感謝你的幫助。非常感謝。 – wizawu

回答

6

您lookuup在不存在的表,那麼你會得到一個錯誤,「崩潰」你的shell。一個新的shell會啓動,它看起來很透明,除了屬於第一個shell的ets被刪除。

+0

謝謝soooooo多:) – wizawu

相關問題