MyDDAS: Enhanced the MyDDAS interface Statistics capabilities
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1502 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
f62f62537b
commit
c0a9fa5cab
@ -180,7 +180,8 @@ db_is_database_predicate(PredName,Arity,Module):-
|
|||||||
%
|
%
|
||||||
:- set_value(db_myddas_stats_count,0).
|
:- set_value(db_myddas_stats_count,0).
|
||||||
db_stats(Connection,List):-
|
db_stats(Connection,List):-
|
||||||
NumberOfStats = 6,
|
'$error_checks'(db_stats(Connection,List)),
|
||||||
|
NumberOfStats = 9,
|
||||||
'$make_a_list'(NumberOfStats,List),
|
'$make_a_list'(NumberOfStats,List),
|
||||||
( var(Connection) ->
|
( var(Connection) ->
|
||||||
c_db_stats(0,List)
|
c_db_stats(0,List)
|
||||||
@ -188,9 +189,9 @@ db_stats(Connection,List):-
|
|||||||
get_value(Connection,Conn),
|
get_value(Connection,Conn),
|
||||||
c_db_stats(Conn,List)
|
c_db_stats(Conn,List)
|
||||||
),
|
),
|
||||||
write('MYDDAS'),nl,write(List),nl,
|
write('MYDDAS: '),nl,write(List),nl,
|
||||||
get_value(db_myddas_stats_count,Value),
|
get_value(db_myddas_stats_count,Value),
|
||||||
write(Value),nl.
|
write('Stats Counts '),write(Value),nl.
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,35 +93,44 @@ db_import(Connection,RelationName,PredName) :-
|
|||||||
'$copy_term_nv'(P,[],G,_),
|
'$copy_term_nv'(P,[],G,_),
|
||||||
|
|
||||||
%generate the SQL query
|
%generate the SQL query
|
||||||
translate(G,G,Code),
|
%translate(G,G,Code),
|
||||||
queries_atom(Code,SQL),
|
%queries_atom(Code,SQL),
|
||||||
|
|
||||||
|
M=myddas_assert_predicates,
|
||||||
%build PredName clause
|
%build PredName clause
|
||||||
( ConType == mysql ->
|
( ConType == mysql ->
|
||||||
Assert =..[':-',P,','(myddas_assert_predicates:'$build_query'(0,SQL,Code,LA,FinalSQL),
|
|
||||||
','(myddas_assert_predicates:db_my_result_set(Mode),
|
Assert =..[':-',P,','(M:translate(G,G,Code),
|
||||||
','(myddas_assert_predicates:'$write_or_not'(FinalSQL),
|
','(M:queries_atom(Code,FinalSQL),
|
||||||
','(myddas_assert_predicates:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
','(M:db_my_result_set(Mode),
|
||||||
','(!,myddas_assert_predicates:c_db_my_row(ResultSet,Arity,LA))))))]
|
','(M:'$write_or_not'(FinalSQL),
|
||||||
|
','(M:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
||||||
|
','(!,M:c_db_my_row(ResultSet,Arity,LA)))))))]
|
||||||
|
|
||||||
|
% Assert =..[':-',P,','(M:'$build_query'(0,SQL,Code,LA,FinalSQL),
|
||||||
|
% ','(M:db_my_result_set(Mode),
|
||||||
|
% ','(M:'$write_or_not'(FinalSQL),
|
||||||
|
% ','(M:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
||||||
|
% ','(!,M:c_db_my_row(ResultSet,Arity,LA))))))]
|
||||||
|
|
||||||
% Assert =..[':-',P,','(get_value(db_myddas_stats_count,Number),
|
% Assert =..[':-',P,','(get_value(db_myddas_stats_count,Number),
|
||||||
% ','(statistics(cputime,TimeI),
|
% ','(statistics(cputime,TimeI),
|
||||||
% ','(myddas_assert_predicates:'$build_query'(0,SQL,Code,LA,FinalSQL),
|
% ','(M:'$build_query'(0,SQL,Code,LA,FinalSQL),
|
||||||
% ','(myddas_assert_predicates:db_my_result_set(Mode),
|
% ','(M:db_my_result_set(Mode),
|
||||||
% ','(myddas_assert_predicates:'$write_or_not'(FinalSQL),
|
% ','(M:'$write_or_not'(FinalSQL),
|
||||||
% ','(myddas_assert_predicates:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
% ','(M:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
||||||
% ','(statistics(cputime,TimeF),
|
% ','(statistics(cputime,TimeF),
|
||||||
% ','(Temp is TimeF - TimeI,
|
% ','(Temp is TimeF - TimeI,
|
||||||
% ','(Temp2 is Temp + Number,
|
% ','(Temp2 is Temp + Number,
|
||||||
% ','(set_value(db_myddas_stats_count,Temp2),
|
% ','(set_value(db_myddas_stats_count,Temp2),
|
||||||
% ','(!,myddas_assert_predicates:c_db_my_row(ResultSet,Arity,LA))))))))))))]
|
% ','(!,M:c_db_my_row(ResultSet,Arity,LA))))))))))))]
|
||||||
;
|
;
|
||||||
|
'$make_a_list'(Arity,BindList),
|
||||||
Assert =..[':-',P,','(myddas_assert_predicates:'$build_query'(0,SQL,Code,LA,FinalSQL),
|
Assert =..[':-',P,','(M:translate(G,G,Code),
|
||||||
','(myddas_assert_predicates:'$make_a_list'(Arity,BindList),
|
','(M:queries_atom(Code,FinalSQL),
|
||||||
','(myddas_assert_predicates:c_db_odbc_query(FinalSQL,ResultSet,Arity,BindList,Connection),
|
','(M:c_db_odbc_query(FinalSQL,ResultSet,Arity,BindList,Connection),
|
||||||
','(myddas_assert_predicates:'$write_or_not'(FinalSQL),
|
','(M:'$write_or_not'(FinalSQL),
|
||||||
','(!,myddas_assert_predicates:c_db_odbc_row(ResultSet,BindList,LA))))))]
|
','(!,M:c_db_odbc_row(ResultSet,BindList,LA))))))]
|
||||||
),
|
),
|
||||||
|
|
||||||
assert(Module:Assert),
|
assert(Module:Assert),
|
||||||
@ -147,30 +156,29 @@ db_view(Connection,PredName,DbGoal) :-
|
|||||||
% This copy_term is done to prevent the unification
|
% This copy_term is done to prevent the unification
|
||||||
% with top-level variables A='var('A')' error
|
% with top-level variables A='var('A')' error
|
||||||
copy_term((PredName,DbGoal),(CopyView,CopyGoal)),
|
copy_term((PredName,DbGoal),(CopyView,CopyGoal)),
|
||||||
translate(CopyView,CopyGoal,Code),
|
|
||||||
queries_atom(Code,SQL),
|
|
||||||
|
|
||||||
% checks if the WHERE commend of SQL exists in the string
|
|
||||||
'$where_exists'(SQL,Flag),
|
|
||||||
|
|
||||||
'$make_list_of_args'(1,Arity,NewName,LA),
|
'$make_list_of_args'(1,Arity,NewName,LA),
|
||||||
|
|
||||||
|
M=myddas_assert_predicates,
|
||||||
c_db_connection_type(Con,ConType),
|
c_db_connection_type(Con,ConType),
|
||||||
|
|
||||||
% build view clause
|
% build view clause
|
||||||
( ConType == mysql ->
|
( ConType == mysql ->
|
||||||
Assert =..[':-',NewName,
|
Assert =..[':-',NewName,
|
||||||
','(myddas_assert_predicates:'$build_query'(Flag,SQL,Code,LA,FinalSQL),
|
','(M:translate(CopyView,CopyGoal,Code),
|
||||||
','(myddas_assert_predicates:db_my_result_set(Mode),
|
','(M:queries_atom(Code,FinalSQL),
|
||||||
','(myddas_assert_predicates:'$write_or_not'(FinalSQL),
|
','(M:db_my_result_set(Mode),
|
||||||
','(myddas_assert_predicates:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
','(M:'$write_or_not'(FinalSQL),
|
||||||
','(!,myddas_assert_predicates:c_db_my_row(ResultSet,Arity,LA))))))]
|
','(M:c_db_my_query(FinalSQL,ResultSet,Con,Mode),
|
||||||
|
','(!,M:c_db_my_row(ResultSet,Arity,LA)))))))]
|
||||||
;
|
;
|
||||||
Assert =..[':-',NewName,
|
Assert =..[':-',NewName,
|
||||||
','(myddas_assert_predicates:'$build_query'(Flag,SQL,Code,LA,FinalSQL),
|
','(M:translate(CopyView,CopyGoal,Code),
|
||||||
','(myddas_assert_predicates:'$make_a_list'(Arity,BindList),
|
','(M:queries_atom(Code,FinalSQL),
|
||||||
','(myddas_assert_predicates:'$write_or_not'(FinalSQL),
|
','(M:'$make_a_list'(Arity,BindList),
|
||||||
','(myddas_assert_predicates:c_db_odbc_query(FinalSQL,ResultSet,Arity,BindList,Con),
|
','(M:'$write_or_not'(FinalSQL),
|
||||||
','(!,myddas_assert_predicates:c_db_odbc_row(ResultSet,BindList,LA))))))]
|
','(M:c_db_odbc_query(FinalSQL,ResultSet,Arity,BindList,Con),
|
||||||
|
','(!,M:c_db_odbc_row(ResultSet,BindList,LA)))))))]
|
||||||
|
|
||||||
),
|
),
|
||||||
assert(Module:Assert),
|
assert(Module:Assert),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
is_list/1
|
is_list/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
'$error_checks'(db_stats(_,List)):-!,
|
||||||
|
var(List).
|
||||||
'$error_checks'(db_export_view(Connection,TableViewName,SQLorDbGoal,FieldsInf)):-!,
|
'$error_checks'(db_export_view(Connection,TableViewName,SQLorDbGoal,FieldsInf)):-!,
|
||||||
atom(Connection),
|
atom(Connection),
|
||||||
( atom(TableViewName) -> atom(SQLorDbGoal) ; true ),
|
( atom(TableViewName) -> atom(SQLorDbGoal) ; true ),
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
:- module(myddas_test_predicates,[
|
:- module(myddas_test_predicates,[
|
||||||
% Tests or Debug Predicates
|
% Tests or Debug Predicates
|
||||||
%db_my_delete/2,
|
%db_my_delete/2,
|
||||||
db_create_table/3,
|
|
||||||
db_export_view/4,
|
|
||||||
db_assert_view/4,
|
db_assert_view/4,
|
||||||
db_my_insert_test/2,
|
db_my_insert_test/2,
|
||||||
db_my_update/3,
|
db_my_update/3,
|
||||||
db_my_import_query_normal/3,
|
db_my_import_michel/3,
|
||||||
db_view_original/3, % DEBUG ONLY
|
db_view_original/3, % DEBUG ONLY
|
||||||
db_my_ilpview/4
|
db_ilpview/4
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
|
||||||
@ -45,11 +43,6 @@ db_assert_view(ViewName,SQLorDbGoal,FieldsInf,Connection):-
|
|||||||
db_my_import(TableName,TableName,Connection).
|
db_my_import(TableName,TableName,Connection).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% db_my_insert/2
|
% db_my_insert/2
|
||||||
%
|
%
|
||||||
@ -109,7 +102,7 @@ db_my_update(UpdateList,Relation,Connection):-
|
|||||||
% db_my_import_michel/3
|
% db_my_import_michel/3
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
db_my_import_query_normal(RelationName,PredName,Connection) :-
|
db_my_import_michel(RelationName,PredName,Connection) :-
|
||||||
'$error_checks'(db_my_import(RelationName,PredName,Connection)),
|
'$error_checks'(db_my_import(RelationName,PredName,Connection)),
|
||||||
% get connection id based on given atom
|
% get connection id based on given atom
|
||||||
'$get_value'(Connection,Conn),
|
'$get_value'(Connection,Conn),
|
||||||
@ -278,24 +271,30 @@ db_my_import_query_normal(RelationName,PredName,Connection) :-
|
|||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% db_my_ilpview/4
|
% db_ilpview/4
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
db_my_ilpview(LA,ViewName,DbGoal,Connection):-
|
db_ilpview(Connection,LA,ViewName,DbGoal):-
|
||||||
'$get_value'(Connection,Conn),
|
|
||||||
functor(ViewName,PredName,Arity),
|
functor(ViewName,PredName,Arity),
|
||||||
functor(NewName,PredName,Arity),
|
functor(NewName,PredName,Arity),
|
||||||
translate(ViewName,DbGoal,Code),
|
translate(ViewName,DbGoal,Code),
|
||||||
queries_atom(Code,SQL),
|
queries_atom(Code,SQL),
|
||||||
|
|
||||||
% build arg list for db_my_row/2
|
% build arg list for db_my_row/2
|
||||||
'$make_list_of_args'(1,Arity,NewName,LA),
|
'$make_list_of_args'(1,Arity,NewName,LA),
|
||||||
% checks if the WHERE commend of SQL exists in the string
|
|
||||||
'$where_exists'(SQL,Flag),
|
get_value(Connection,Con),
|
||||||
'$build_query'(Flag,SQL,Code,LA,FinalSQL),
|
c_db_connection_type(Con,ConType),
|
||||||
|
'$write_or_not'(SQL),
|
||||||
|
( ConType == mysql ->
|
||||||
db_my_result_set(Mode),
|
db_my_result_set(Mode),
|
||||||
'$write_or_not'(FinalSQL),
|
c_db_my_query(SQL,ResultSet,Con,Mode),
|
||||||
c_db_my_query(FinalSQL,ResultSet,Conn,Mode),
|
!,c_db_my_row(ResultSet,Arity,LA)
|
||||||
!,c_db_my_row(ResultSet,Arity,LA).
|
;
|
||||||
|
true
|
||||||
|
).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user