This commit is contained in:
Vitor Santos Costa 2018-06-26 15:35:47 +01:00
parent e97ea388f8
commit 8911fea5ae
10 changed files with 38 additions and 37 deletions

View File

@ -656,7 +656,7 @@ static Int code_in_pred(PredEntry *pp, Atom *pat, UInt *parity,
PELOCK(40, pp);
/* check if the codeptr comes from the indexing code */
if (pp->PredFlags & IndexedPredFlag) {
if (pp->PredFlags & IndexedPredFlag && pp->OpcodeOfPred != INDEX_OPCODE) {
if (pp->PredFlags & LogUpdatePredFlag) {
if (code_in_pred_lu_index(
ClauseCodeToLogUpdIndex(pp->cs.p_code.TrueCodeOfPred), codeptr,

View File

@ -1038,6 +1038,7 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
init_globals(yap_init);
start_modules();
CurrentModule = PROLOG_MODULE;
TermEof = MkAtomTerm( Yap_LookupAtom("end_of_file"));
consult(Yap_BOOTSTRAP PASS_REGS);
setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG,

View File

@ -72,7 +72,7 @@ foreach (driver ${MYDDAS_DBMS})
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
endforeach ()
list (APPEND MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/test.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
list (APPEND MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
add_to_group(MYDDAS_YAP pl_library )
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )

View File

@ -188,7 +188,6 @@
%
%% @pred db_open(+Interface,-Handle,+HostDb,+User,+Password)
%% @pred db_open(+Interface,+HostDb,+User,+Password)
%
@ -243,7 +242,7 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
%% sqlite3
db_open(sqlite3,Connection,File,User,Password) :-
'$error_checks'(db_open(sqlite3,Connection,File,User,Password)),
c_sqlite3_connect(File,User,Password,Con),
myddas_sqlite3:c_sqlite3_connect(File,User,Password,Con),
set_value(Connection,Con).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -369,7 +368,7 @@ db_sql_(ConType, Con, SQL,LA):-
c_postgres_query(SQL,ResultSet,Con,Mode,Arity)
;ConType == sqlite3 ->
sqlite3_result_set(Mode),
c_sqlite3_query(SQL,ResultSet,Con,Mode,Arity)
myddas_myddas_sqlite3: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)
@ -459,7 +458,7 @@ db_assert(Connection,PredName):-
c_postgres_query(SQL,_,Con,Mode,_)
;ConType == sqlite3 ->
sqlite3_result_set(Mode),
c_sqlite3_query(SQL,_,Con,Mode,_)
myddas_myddas_sqlite3:c_sqlite3_query(SQL,_,Con,Mode,_)
;
c_odbc_query(SQL,_,_,_,Con)
).
@ -488,7 +487,7 @@ db_create_table(Connection,TableName,FieldsInf):-
c_postsgres_query(FinalSQL,_,Con,Mode,_)
;ConType == sqlite3 ->
sqlite3_result_set(Mode),
c_sqlite3_query(FinalSQL,_,Con,Mode,_)
myddas_myddas_sqlite3:c_sqlite3_query(FinalSQL,_,Con,Mode,_)
;
c_odbc_query(FinalSQL,_,_,_,Con)
).
@ -565,7 +564,7 @@ db_update(Connection,WherePred-SetPred):-
;
ConType == sqlite3 ->
sqlite3_result_set(Mode),
c_sqlite3_query(SQL,_,Conn,Mode,_)
myddas_sqlite3:c_sqlite3_query(SQL,_,Conn,Mode,_)
;
ConType == odbc ->
odbc_result_set(Mode),

View File

@ -69,7 +69,7 @@
'$make_a_list'/2,
'$write_or_not'/1
]).
:- load_foreign_files( [NAME()], [], INIT()).
% :- load_foreign_files( [NAME()], [], INIT()).
%--------------------------------------------------------
% Public Predicates

View File

@ -2,7 +2,7 @@ message( " * Sqlite3 Data-Base (http://www.sqlite3ql.org), distributed with MY
set (SQLITE_EXTRA
chinook.db
test.yap)
sqlitest.yap)
set( YAPSQLITE3_SOURCES
myddas_sqlite3.c
@ -61,5 +61,3 @@ endif()
install(FILES ${SQLITE_EXTRA}
DESTINATION ${libpl}
)
# file (INSTALL chinook.db test.yap DESTINATION ${libpl})

View File

@ -672,14 +672,13 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
}
X_API void init_sqlite3(void) {
//Term cm = CurrentModule;
//CurrentModule = MkAtomTerm(Yap_LookupAtom("myddas_sqlite3"));
Term cm = CurrentModule;
CurrentModule = MkAtomTerm(Yap_LookupAtom("myddas_sqlite3"));
Yap_InitMYDDAS_SQLITE3Preds();
Yap_InitBackMYDDAS_SQLITE3Preds();
//CurrentModule = cm;
CurrentModule = cm;
}

View File

@ -1,5 +1,5 @@
:- compile(library(maplist)).
:- stop_low_level_trace.
:- use_module(library(maplist)).
:- use_module(library(myddas)).
main :-
@ -13,24 +13,23 @@ main_ .
init :-
%start_low_level_trace,
start_low_level_trace,
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
writeln('chinook has landed').
go :-
stop_low_level_trace,
db_import('Artist', artist),
writeln(('Artist -> artist')),
db_import('Album', album),
writeln(('Album -> album')),
db_import('Track', track),
writeln(('Track -> track')).
db_import('artists', artist),
writeln(('artist -> artist')),
db_import('albums', album),
writeln(('albums -> album')),
db_import('track', track),
writeln(('track -> track')).
go :-
db_get_attributes_types(album,Als),
format('~w -> ~w~n',[album,Als]),
db_get_attributes_types(track,Ts),
format('~w -> ~w~n',[track,Ts]),
format('~w -> ~w~n',[track,Ts]),
db_get_attributes_types(artist,As),
format('~w -> ~w~n',[artist,As]).
go :-

View File

@ -740,6 +740,7 @@ db_files(Fs) :-
true
),
'$loop'(Stream,Reconsult),
'$lf_opt'(imports, TOpts, Imports),
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
'$current_module'(Mod, SourceModule),

View File

@ -26,8 +26,7 @@
*
*/
:- module(system('$messages'),
:- module(system('$messages',[]),
[system_message/4,
prefix/2,
prefix/5,
@ -221,7 +220,7 @@ compose_message( loaded(included,AbsFileName,Mod,Time,Space), _Level) --> !,
[ '~a included in module ~a, ~d msec ~d bytes' -
[AbsFileName,Mod,Time,Space] ].
compose_message( loaded(What,AbsoluteFileName,Mod,Time,Space), _Level) --> !,
[ '~a ~a in module ~a, ~d msec ~d bytes' -
[ '~a ~a in module ~a, ~d msec ~g bytes' -
[What, AbsoluteFileName,Mod,Time,Space] ].
compose_message(signal(SIG,_), _) -->
!,
@ -829,8 +828,11 @@ prefix(debug, '~N'-[]).
prefix(warning, '~N'-[]).
prefix(error, '~N'-[]).
prefix(banner, '~N'-[]).
prefix(informational, '~N~*| '-[]) :-
('$show_consult_level'(LC) -> true ; LC = 0).
prefix(informational, '~N~*|% '-[LC]) :-
'$show_consult_level'(LC),
LC > 0,
!.
prefix(informational, '~N'-[]).
prefix(debug(_), '~N'-[]).
/* { thread_self(Id) },
@ -1017,15 +1019,15 @@ prolog:print_message(force(_Severity), Msg) :- !,
print(user_error,Msg).
% This predicate has more hooks than a pirate ship!
prolog:print_message(Severity, Term) :-
prolog:message( Term,Lines0, [ end(Id)]),
message( Term,Lines0, [ end(Id)]),
Lines = [begin(Severity, Id)| Lines0],
(
user:message_hook(Term, Severity, Lines)
->
true
;
prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)
ignore((prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)))
),
!.
prolog:print_message(Severity, Term) :-
@ -1036,10 +1038,12 @@ prolog:print_message(Severity, Term) :-
->
true
;
prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)
ignore(( prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)))
),
!.
prolog:print_message(_Severity, _Term) :-
format(user_error,'failed to print ~w: ~w~n` ,[ _Severity, _Term]).
'$error_descriptor'( Info, Info ).
/**