This commit is contained in:
Vitor Santos Costa 2018-11-25 13:27:48 +00:00
parent b87f0c79e9
commit 66167abba6
6 changed files with 82 additions and 85 deletions

View File

@ -225,7 +225,7 @@ user:prolog_file_type( db, dataset ).
%
db_open(Interface,HostDb,User,Password):-
db_open(Interface,myddas,HostDb,User,Password).
#ifdef MYDDAS_MYSQL
db_open(mysql,Connection,Host/Db/Port/Socket,User,Password) :- !,
'$error_checks'(db_open(mysql,Connection,Host/Db/Port/Socket,User,Password)),
@ -263,7 +263,7 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
%% sqlite3
db_open(sqlite3,Connection,File,User,Password) :-
absolute_file_name(File,Db,[,access(write),file_type(myddas),expand(true)]),
absolute_file_name(File,Db,[access(write),file_type(myddas),expand(true)]),
'$error_checks'(db_open(sqlite3,Connection,Db,User,Password)),
c_sqlite3_connect(Db,User,Password,Con),
set_value(Connection,Con).

View File

@ -98,7 +98,7 @@ db_import(Connection,RelationName,PredName0) :-
get_value(Connection,Con),
table_arity( Con, ConType, RelationName, Arity ),
strip_module(PredName0, Module, PredName),
not c_db_check_if_exists_pred(PredName,Arity,Module),
\+ c_db_check_if_exists_pred(PredName,Arity,Module),
R=..[relation,PredName,Arity,RelationName],
% assert relation fact
assert(Module:R),

View File

@ -156,7 +156,7 @@ DBMS(datalog_show_tables)(Connection) :-
% DBMS(show_tables)/2
% gives the results of the SHOW TABLES statement
% by backtracking
%#if sqlite3
#if sqlite3
DBMS(show_tables)(Connection,table(Table)) :-
'$get_value'(Connection,Conn),
SQL = 'SELECT name FROM sqlite_master WHERE type=\'table\' ORDER BY name',
@ -165,7 +165,7 @@ DBMS(show_tables)(Connection,table(Table)) :-
c_DBMS(query)(SQL,ResultSet,Conn,Mode,_),
!,
DBMS(row)(ResultSet,1,[Table]).
%#endif
#endif
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File diff suppressed because one or more lines are too long

View File

@ -88,80 +88,80 @@
*/
/** @pred forall(: _Cond_,: _Action_)
*
*
*
*
* For all alternative bindings of _Cond_ _Action_ can be
* proven. The example verifies that all arithmetic statements in the list
* _L_ are correct. It does not say which is wrong if one proves wrong.
*
*
* ~~~~~{.prolog}
* ?- forall(member(Result = Formula, [2 = 1 + 1, 4 = 2 * 2]),
* Result =:= Formula).
* ~~~~~
*
*
*
*
*/
forall(Cond, Action) :- \+((Cond, \+(Action))).
/** @pred ignore(: _Goal_)
*
*
*
*
* Calls _Goal_ as once/1, but succeeds, regardless of whether
* `Goal` succeeded or not. Defined as:
*
*
* ~~~~~{.prolog}
* ignore(Goal) :-
* Goal, !.
* ignore(_).
* ~~~~~
*
*
*
*
*/
ignore(Goal) :- (Goal->true;true).
/** @pred if(? _G_,? _H_,? _I_)
*
*
* Call goal _H_ once per each solution of goal _H_. If goal
* _H_ has no solutions, call goal _I_.
*
*
* The built-in `if/3` is similar to `->/3`, with the difference
* that it will backtrack over the test. Consider the following
* small data-base:
*
*
* ~~~~~{.prolog}
* a(1). b(a). c(x).
* a(2). b(b). c(y).
* ~~~~~
*
*
* Execution of an `if/3` query will proceed as follows:
*
*
* ~~~~~{.prolog}
* ?- if(a(X),b(Y),c(Z)).
*
*
* X = 1,
* Y = a ? ;
*
*
* X = 1,
* Y = b ? ;
*
*
* X = 2,
* Y = a ? ;
*
*
* X = 2,
* Y = b ? ;
*
*
* no
* ~~~~~
*
*
* The system will backtrack over the two solutions for `a/1` and the
* two solutions for `b/1`, generating four solutions.
*
*
* Cuts are allowed inside the first goal _G_, but they will only prune
* over _G_.
*
*
* If you want _G_ to be deterministic you should use if-then-else, as
* it is both more efficient and more portable.
*
*
*/
if(X,Y,Z) :-
(
@ -175,12 +175,12 @@ if(X,Y,Z) :-
).
/** @pred call( Closure,...,? Ai,...) is iso
*
*
*
*
* Meta-call with extra pattern arguments, where _Closure_ is a closure
* that is converted into a goal by appending the _Ai_ additional
* arguments. YAP supports up to 10 extra arguments.
*
*
*/
call(X,A) :- '$execute'(X,A).
@ -205,10 +205,10 @@ call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11).
/** @pred call_cleanup(: _Goal_, : _CleanUpGoal_)
*
*
* This is similar to call_cleanup/1 but with an additional
* _CleanUpGoal_ which gets called after _Goal_ is finished.
*
*
*/
call_cleanup(Goal, Cleanup) :-
'$gated_call'( false , Goal,_Catcher, Cleanup) .
@ -412,14 +412,14 @@ query_to_answer(G, V, Status, Bindings) :-
%% @{
/** @pred nb_getval(+ _Name_,- _Value_)
*
*
*
*
* The nb_getval/2 predicate is a synonym for b_getval/2, introduced for
* compatibility and symmetry. As most scenarios will use a particular
* global variable either using non-backtrackable or backtrackable
* assignment, using nb_getval/2 can be used to document that the
* variable is used non-backtrackable.
*
*
*/
nb_getval(GlobalVariable, Val) :-
'__NB_getval__'(GlobalVariable, Val, Error),
@ -435,18 +435,18 @@ nb_getval(GlobalVariable, Val) :-
/** @pred b_getval(+ _Name_, - _Value_)
*
*
*
*
* Get the value associated with the global variable _Name_ and unify
* it with _Value_. Note that this unification may further
* instantiate the value of the global variable. If this is undesirable
* the normal precautions (double negation or copy_term/2) must be
* taken. The b_getval/2 predicate generates errors if _Name_ is not
* an atom or the requested variable does not exist.
*
*
* Notice that for compatibility with other systems _Name_ <em>must</em> be already associated with a term: otherwise the system will generate an error.
*
*
*
*
*/
b_getval(GlobalVariable, Val) :-
'__NB_getval__'(GlobalVariable, Val, Error),
@ -487,7 +487,7 @@ b_getval(GlobalVariable, Val) :-
b_setval('$spy_glist',[]),
'$disable_debugging'.
'$debug_restart'(state(Trace, Debug, State, SPY_GN, GList)) :-
'$debug_restore'(state(Trace, Debug, State, SPY_GN, GList)) :-
b_setval('$spy_glist',GList),
b_setval('$spy_gn',SPY_GN),
set_prolog_flag(debug, Debug),
@ -520,7 +520,7 @@ break :-
NBL is BL+1,
set_prolog_flag(break_level, NBL ),
format(user_error, '% Break (level ~w)~n', [NBL]),
'$do_live',
live,
!,
set_value('$live','$true'),
'$debug_restore'(DState),

View File

@ -109,22 +109,16 @@ error_handler(Error, Level) :-
'$process_error'('$forward'(Msg), _) :-
!,
throw( '$forward'(Msg) ).
'$process_error'(abort, Level) :-
'$process_error'(error(event(abort,I),C), Level) :-
!,
(
current_prolog_flag(break_level, 0),
Level \== top
->
throw( abort )
;
current_prolog_flag(break_level, 0)
->
print_message(informational,abort(user)),
fail
;
current_prolog_flag(break_level, I0),
I is I0-1,
current_prolog_flag(break_level, I),
throw(abort)
print_message(informational,abort(user)),
fail
;
throw( error(event(abort,I),C) )
).
'$process_error'(error(permission_error(module,redefined,A),B), Level) :-
Level \= top, !,