MYDDAS: Fixed some single_var_warnings

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1673 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
tiagosoares 2006-06-09 18:32:01 +00:00
parent 21662f4015
commit 3af669d7d2
4 changed files with 31 additions and 17 deletions

View File

@ -18,7 +18,11 @@
/* Initialize MYDDAS GLOBAL STRUCTURES */ /* Initialize MYDDAS GLOBAL STRUCTURES */
:- c_db_initialize_myddas. :- c_db_initialize_myddas.
#ifdef DEBUG
:- yap_flag(single_var_warnings,on).
#endif
:- module(myddas,[ :- module(myddas,[
db_open/5, db_open/5,
db_open/4, db_open/4,
@ -479,7 +483,7 @@ db_export_view(Connection,TableViewName,SQLorDbGoal,FieldsInf):-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% db_update/2 % db_update/2
% BUB: db_update dosen't work for this case, just an example % BUG: db_update dosen't work for this case, just an example
% db_update(my1,edge(1,3)-edge(99,99)). % db_update(my1,edge(1,3)-edge(99,99)).
% The case where the set condition is "set" to change all the fields % The case where the set condition is "set" to change all the fields
db_update(Connection,WherePred-SetPred):- db_update(Connection,WherePred-SetPred):-

View File

@ -120,8 +120,8 @@
nonvar(DbGoal), nonvar(DbGoal),
nonvar(Pred), nonvar(Pred),
nonvar(DbGoal), nonvar(DbGoal),
Pred =.. [_|PredArgs], Pred =.. [_|_],
DbGoal =.. [_|DbGoalArgs]. DbGoal =.. [_|_].
%'$check_list_on_list'(PredArgs,DbGoalArgs). %'$check_list_on_list'(PredArgs,DbGoalArgs).
'$error_checks'(db_import(Connection,RelationName,PredName)) :- !, '$error_checks'(db_import(Connection,RelationName,PredName)) :- !,
atom(Connection), atom(Connection),

View File

@ -207,7 +207,7 @@ db_change_database(Connection,Database) :-
db_call_procedure(Procedure,Args,Result) :- db_call_procedure(Procedure,Args,Result) :-
db_call_procedure(myddas,Procedure,Args,Result). db_call_procedure(myddas,Procedure,Args,Result).
db_call_procedure(Connection,Procedure,Args,LA) :- db_call_procedure(Connection,Procedure,Args,LA) :-
'$error_checks'(db_call_procedure(Connection,Procedure,Args,Result)), '$error_checks'(db_call_procedure(Connection,Procedure,Args,LA)),
'$make_atom_args'(Args,ArgsSQL), '$make_atom_args'(Args,ArgsSQL),
'$make_atom'(['CALL ',Procedure,'(',ArgsSQL,')'],SQL), '$make_atom'(['CALL ',Procedure,'(',ArgsSQL,')'],SQL),
db_sql(Connection,SQL,LA). db_sql(Connection,SQL,LA).

View File

@ -393,14 +393,14 @@ translate_arithmetic_function('$var$'(VarId),Expression,ArithComparison,Dict,Dic
% Left side consists of qualified attribute, i.e. range variable must not be % Left side consists of qualified attribute, i.e. range variable must not be
% arithmetic operator is/2 % arithmetic operator is/2
lookup(VarId,Dict,PrevRangeVar,PrevAtt,PrevType), lookup(VarId,Dict,PrevRangeVar,PrevAtt,_),
not (PrevRangeVar = is), not (PrevRangeVar = is),
% test whether type of attribute is numeric - if not, there's no sense in % test whether type of attribute is numeric - if not, there's no sense in
% continuing the translation % continuing the translation
%type_compatible(PrevType,number), %type_compatible(PrevType,number),
evaluable_expression(Expression,Dict,ArithExpression,ExprType), evaluable_expression(Expression,Dict,ArithExpression,_),
%type_compatible(ExprType,number), %type_compatible(ExprType,number),
ArithComparison = [comp(att(PrevRangeVar,PrevAtt),'=',ArithExpression)]. ArithComparison = [comp(att(PrevRangeVar,PrevAtt),'=',ArithExpression)].
@ -411,18 +411,18 @@ translate_arithmetic_function('$var$'(VarId),Expression,ArithComparison,Dict,Dic
% belonging to arithmetic expression which is expressed as RangeVar-argument % belonging to arithmetic expression which is expressed as RangeVar-argument
% of lookup returning is/2. Type information is implicit through the is/2 functor % of lookup returning is/2. Type information is implicit through the is/2 functor
lookup(VarId,Dict,is,LeftExpr,Type), lookup(VarId,Dict,is,LeftExpr,_),
%type_compatible(Type,number), %type_compatible(Type,number),
evaluable_expression(Expression,Dict,RightExpr,ExprType), evaluable_expression(Expression,Dict,RightExpr,_),
%type_compatible(ExprType,number), %type_compatible(ExprType,number),
ArithComparison = [comp(LeftExpr,'=',RightExpr)]. ArithComparison = [comp(LeftExpr,'=',RightExpr)].
translate_arithmetic_function('$const$'(Constant),Expression,ArithComparison,Dict,Dict):- translate_arithmetic_function('$const$'(Constant),Expression,ArithComparison,Dict,Dict):-
% --- is/2 used to test whether left side evaluates to right side ------------------- % --- is/2 used to test whether left side evaluates to right side -------------------
get_type('$const$'(Constant),ConstantType), get_type('$const$'(Constant),_),
%type_compatible(ConstantType,number), %type_compatible(ConstantType,number),
evaluable_expression(Expression,Dict,ArithExpression,ExprType), evaluable_expression(Expression,Dict,ArithExpression,_),
%type_compatible(ExprType,number), %type_compatible(ExprType,number),
ArithComparison = [comp('$const$'(Constant),'=',ArithExpression)]. ArithComparison = [comp('$const$'(Constant),'=',ArithExpression)].
@ -437,8 +437,8 @@ translate_arithmetic_function('$const$'(Constant),Expression,ArithComparison,Dic
% ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------
translate_comparison(LeftArg,RightArg,CompOp,Dict,Comparison):- translate_comparison(LeftArg,RightArg,CompOp,Dict,Comparison):-
evaluable_expression(LeftArg,Dict,LeftTerm,LeftArgType), evaluable_expression(LeftArg,Dict,LeftTerm,_),
evaluable_expression(RightArg,Dict,RightTerm,RightArgType), evaluable_expression(RightArg,Dict,RightTerm,_),
%type_compatible(LeftArgType,RightArgType), %type_compatible(LeftArgType,RightArgType),
Comparison = [comp(LeftTerm,CompOp,RightTerm)]. Comparison = [comp(LeftTerm,CompOp,RightTerm)].
@ -498,14 +498,14 @@ translate_argument('$var$'(VarId),rel(SQLTable,RangeVar),Position,[],Dict,NewDic
translate_argument('$var$'(VarId),rel(SQLTable,RangeVar),Position,AttComparison,Dict,Dict):- translate_argument('$var$'(VarId),rel(SQLTable,RangeVar),Position,AttComparison,Dict,Dict):-
% --- Variable occurred previously - retrieve first occurrence data from dictionary - % --- Variable occurred previously - retrieve first occurrence data from dictionary -
lookup(VarId,Dict,PrevRangeVar,PrevAtt,PrevType), lookup(VarId,Dict,PrevRangeVar,PrevAtt,_),
attribute(Position,SQLTable,Attribute,Type), attribute(Position,SQLTable,Attribute,_),
% type_compatible(PrevType,Type), % type_compatible(PrevType,Type),
AttComparison = [comp(att(RangeVar,Attribute),=,att(PrevRangeVar,PrevAtt))]. AttComparison = [comp(att(RangeVar,Attribute),=,att(PrevRangeVar,PrevAtt))].
translate_argument('$const$'(Constant),rel(SQLTable,RangeVar),Position,ConstComparison,Dict,Dict):- translate_argument('$const$'(Constant),rel(SQLTable,RangeVar),Position,ConstComparison,Dict,Dict):-
% --- Equality comparison of constant value and attribute in table ------------------ % --- Equality comparison of constant value and attribute in table ------------------
attribute(Position,SQLTable,Attribute,Type), attribute(Position,SQLTable,Attribute,_),
%get_type('$const$'(Constant),ConstType), %get_type('$const$'(Constant),ConstType),
%type_compatible(ConstType,Type), %type_compatible(ConstType,Type),
ConstComparison = [comp(att(RangeVar,Attribute),=,'$const$'(Constant))]. ConstComparison = [comp(att(RangeVar,Attribute),=,'$const$'(Constant))].
@ -1021,8 +1021,18 @@ print_column(existential_subquery(Select,From,Where)):-
% transformed to an atom by name/2 % transformed to an atom by name/2
% ---------------------------------------------------------------- % ----------------------------------------------------------------
#ifdef MYDDAS_STATS
queries_atom(Queries,QueryAtom):- queries_atom(Queries,QueryAtom):-
c_db_stats_walltime(Start),
queries_atom_(Queries,QueryAtom),
c_db_stats_walltime(End),
c_db_stats_translate(Start,End).
queries_atom_(Queries,QueryAtom):-
#else
queries_atom(Queries,QueryAtom):-
#endif
queries_atom(Queries,QueryList,[]), queries_atom(Queries,QueryList,[]),
name(QueryAtom,QueryList). name(QueryAtom,QueryList).