How to clear private tabling tables for a thread

I’m using: SWI-Prolog version 8.1.19

I want the code to: clear private tabling tables for a thread.

I would like to have a tabled predicate to live through a higher level predicate call. When the call returns/exits, tabling tables shall be abolished/cleared. Another call comes in and it shall start from fresh.

Doc stated that private tables are abolished when the thread exits. In my case, the thread will not exit, instead it will continue to service other request/users/calls. The thread belongs to a thread pool.

What would be the appropriate way to abolish/clear the private table for a thread? I tried untable(predicate/arity) and seemed not working.


1 Like

Seems this is missing. Internally we have ’tbl_abolish_local_tables'/0, which is part of abolish_all_tables/0. You can use that, but as with every predicate whose names starts with a or which is private to some module, it can always change or disappear. Note that if you do not use shared tables abolish_all_tables/0 is fine. I guess we also need abolish_private_tables/0 and abolish_shared_tables/0.

untable/1 is typically not a good idea. Partial removal is normally done using abolish_table_subgoals/1 or abolish_module_tables/1

1 Like

Hi Jan, thank you very much. abolish_table_subgoals(ip_xquery_value(A, B)) works. But I would like to confirm that if ip_xquery_value/2 is defined as private (and subsumptive) table, abolish_table_subgoals/1 only abolishes the ip_xquery_value(A,B) tables for the calling thread (private). Is it right?
It would provide more flexibility by adding abolish_private_tables/0 and abolish_shared_tables/0.

The git sources provide abolish_private_tables/0 and abolish_shared_tables/0.