shift modules around.

This commit is contained in:
Vitor Santos Costa 2019-03-31 11:46:17 +01:00
parent 4dff2ad2ec
commit 4926067be9
5 changed files with 68 additions and 29 deletions

View File

@ -22,30 +22,30 @@
#define SWITCH(Contype, G) \
( Contype == mysql -> \
my_ ## G \
myddas_my:my_ ## G \
; \
Contype == sqlite3 -> \
sqlite3_ ## G \
myddas_sqlite3:sqlite3_ ## G \
; \
Contype == postgres -> \
postgres_ ## G \
myddas_postgres:postgres_ ## G \
; \
Contype == odbc -> \
odbc_ ## G \
myddas_odbc:odbc_ ## G \
)
#define C_SWITCH(Contype, G) \
( Contype == mysql -> \
c_my_ ## G \
myddas_my:c_my_ ## G \
; \
Contype == sqlite3 -> \
c_sqlite3_ ## G \
myddas_sqlite3:c_sqlite3_ ## G \
; \
Contype == postgres -> \
c_postgres_ ## G \
myddas_postgres:c_postgres_ ## G \
; \
Contype == odbc -> \
c_odbc_ ## G \
myddas_odbc:c_odbc_ ## G \
)
:- module(myddas,[
@ -85,19 +85,49 @@
db_get_attributes_types/3,
db_number_of_fields/2,
db_number_of_fields/3,
db_multi_queries_number/2
% myddas_shared.c
c_db_connection_type/2,
c_db_add_preds/4,
c_db_preds_conn/4,
c_db_connection/1,
c_db_check_if_exists_pred/3,
c_db_delete_predicate/2,
c_db_multi_queries_number/2,
#ifdef MYDDAS_STATS
c_db_stats/2,
c_db_stats_walltime/1,
c_db_stats_translate/2,
c_db_stats_time/2,
#endif
#ifdef DEBUG
c_db_check/0,
#endif
c_db_initialize_myddas/0,
c_db_connection_type/2,
c_db_add_preds/4,
c_db_preds_conn/4,
c_db_connection/1,
c_db_check_if_exists_pred/3,
c_db_delete_predicate/2,
c_db_multi_queries_number/2,
#ifdef MYDDAS_STATS
c_db_stats/2,
c_db_stats_walltime/1,
c_db_stats_translate/2,
c_db_stats_time/2,
#endif
#ifdef DEBUG
c_db_check/0,
#endif
% myddas_top_level.ypp
#ifdef MYDDAS_TOP_LEVEL
,
db_top_level/4,
db_top_level/4,
db_top_level/5,
db_datalog_select/3
db_datalog_select/3,
#endif
% myddas_assert_predicates.ypp
,
% myddas_mysql.ypp
% myddas_mysql.ypp,
db_multi_queries_number/2
]).
@ -386,7 +416,7 @@ db_sql_(ConType, Con, SQL,LA):-
c_postgres_query(SQL,ResultSet,Con,Mode,Arity)
;ConType == sqlite3 ->
sqlite3_result_set(Mode),
myddas_myddas_sqlite3:c_sqlite3_query(SQL,ResultSet,Con,Mode,Arity)
c_sqlite3_query(SQL,ResultSet,Con,Mode,Arity)
;
c_odbc_query(SQL,ResultSet,Arity,LA,Con),
c_odbc_number_of_fields_in_query(SQL,Con,Arity)

View File

@ -30,8 +30,15 @@
:- use_module(myddas,[
db_module/1,
c_db_connection_type/2
]).
c_db_check_if_exists_pred/3,
c_db_preds_conn/4,
c_db_connection_type/2,
c_db_add_preds/4,
c_db_preds_conn/4,
c_db_connection/1,
c_db_check_if_exists_pred/3,
c_db_delete_predicate/2
]).
:- use_module(myddas_errors,[
'$error_checks'/1
@ -58,6 +65,7 @@
:- use_module(myddas_sqlite3,[
sqlite3_result_set/1,
sqlite3_show_tables/1,
c_sqlite3_change_database/2,
c_sqlite3_connect/4,
c_sqlite3_disconnect/1,
@ -92,8 +100,8 @@
% db_import/3
% db_import/2
%
db_import(RelationName,PredName):-
db_import(myddas,RelationName,PredName).
db_import(RelationName,PredName0):-
db_import(myddas,RelationName,PredName0).
db_import(Connection,RelationName,PredName0) :-
'$error_checks'(db_import(Connection,RelationName,PredName0)),
get_value(Connection,Con),
@ -319,9 +327,9 @@ table_access_predicate( sqlite3, Con, Arity, P, LA, M,
myddas_prolog2sql:queries_atom(Code,FinalSQL),
myddas_sqlite3:sqlite3_result_set(Mode),
myddas_util_predicates:'$write_or_not'(FinalSQL),
user:c_sqlite3_query(FinalSQL,ResultSet,Con,Mode,_),
myddas_sqlite3:c_sqlite3_query(FinalSQL,ResultSet,Con,Mode,_),
!,
myddas_aqlite3:sqlite3_row(ResultSet,Arity,LA)
myddas_sqlite3:sqlite3_row(ResultSet,Arity,LA)
) )).
table_access_predicate( odbc, Con, Arity, P, LA, M,
@ -416,6 +424,6 @@ table_view( sqlite3, Con, CopyView, CopyGoal, Arity, LA, M,
translate(ProjT,NG,Code),
queries_atom(Code,FinalSQL),
'$write_or_not'(FinalSQL),
c_sqlite3_query(FinalSQL,ResultSet,Con,_,_),
myddas_sqlite3:c_sqlite3_query(FinalSQL,ResultSet,Con,_,_),
!,
c_sqlite3_row(ResultSet,Arity,LA) ))).
myddas_sqlite3:sqlite3_row(ResultSet,Arity,LA) ))).

View File

@ -10,7 +10,7 @@
* *
* File: myddas_mysql.yap *
* Last rev: *
* mods: *
* mods: *show
* comments: MySQL Predicates *
* *
*************************************************************************/
@ -151,7 +151,7 @@ DBMS(datalog_show_tables)(Connection) :-
% DBMS(show_tables)/2
% gives the results of the SHOW TABLES statement
% by backtracking
DBMS(showq_tables)(Connection,table(Table)) :-
DBMS(show_tables)(Connection,table(Table)) :-
'$get_value'(Connection,Conn),
SQL = 'SELECT name FROM sqlite_master WHERE type=\'table\' ORDER BY name',
DBMS(result_set)(Mode),

View File

@ -46,7 +46,8 @@
]).
:- use_module(myddas,[
db_verbose/1
db_verbose/1,
c_db_preds_conn/4
]).
:- use_module(myddas_errors,[

View File

@ -75,7 +75,7 @@ test(att_types, true((Als == ['AlbumId','','Title','','ArtistId',''],
As == ['ArtistId','','Name',''],
Ts == ['TrackId','','Name','','AlbumId','','MediaTypeId','','GenreId','',
'Composer','','Milliseconds','','Bytes','','UnitPrice','']))) :-
db_get_attributes_types(albums,Als),
.,
db_get_attributes_types(tracks,Ts),
db_get_attributes_types(artists,As).