CUT_C and MYDDAS support for 64 bits architectures
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1564 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
1f5f6c7f12
commit
6f409cb962
@ -10,8 +10,11 @@
|
||||
* File: c_interface.c *
|
||||
* comments: c_interface primitives definition *
|
||||
* *
|
||||
* Last rev: $Date: 2006-02-08 17:29:54 $,$Author: tiagosoares $ *
|
||||
* Last rev: $Date: 2006-03-09 15:52:04 $,$Author: tiagosoares $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.83 2006/02/08 17:29:54 tiagosoares
|
||||
* MYDDAS: Myddas Top Level for MySQL and Datalog
|
||||
*
|
||||
* Revision 1.82 2006/01/18 15:34:53 vsc
|
||||
* avoid sideffects from MkBigInt
|
||||
*
|
||||
@ -649,7 +652,7 @@ YAP_ExtraSpaceCut(void)
|
||||
void *ptr;
|
||||
BACKUP_B();
|
||||
|
||||
ptr = (void *)(((CELL *)(Yap_regp->CUT_C_TOP))-(((yamop *)Yap_regp->CUT_C_TOP->try_userc_cut_yamop)->u.lds.extra));
|
||||
ptr = (void *)(((CELL *)(Yap_REGS.CUT_C_TOP))-(((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.lds.extra));
|
||||
|
||||
RECOVER_B();
|
||||
return(ptr);
|
||||
|
12
C/cut_c.c
12
C/cut_c.c
@ -5,29 +5,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void cut_c_initialize(void){
|
||||
Yap_regp->CUT_C_TOP=(cut_c_str_ptr)Yap_LocalBase;
|
||||
Yap_REGS.CUT_C_TOP=(cut_c_str_ptr)Yap_LocalBase;
|
||||
}
|
||||
|
||||
/*Removes a choice_point from the stack*/
|
||||
void cut_c_pop(void){
|
||||
cut_c_str_ptr to_delete = NULL;
|
||||
if (((int)Yap_regp->CUT_C_TOP) == ((int)Yap_LocalBase))
|
||||
if (((CELL *)Yap_REGS.CUT_C_TOP) == ((CELL *)Yap_LocalBase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{ /* removes the top element
|
||||
from the stack */
|
||||
to_delete = Yap_regp->CUT_C_TOP;
|
||||
Yap_regp->CUT_C_TOP = to_delete->before;
|
||||
to_delete = Yap_REGS.CUT_C_TOP;
|
||||
Yap_REGS.CUT_C_TOP = to_delete->before;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*Insert a choice_point in the stack*/
|
||||
void cut_c_push(cut_c_str_ptr new_top){
|
||||
new_top->before = Yap_regp->CUT_C_TOP;
|
||||
Yap_regp->CUT_C_TOP=new_top;
|
||||
new_top->before = Yap_REGS.CUT_C_TOP;
|
||||
Yap_REGS.CUT_C_TOP=new_top;
|
||||
return;
|
||||
}
|
||||
|
||||
|
2
C/exec.c
2
C/exec.c
@ -1807,7 +1807,7 @@ Yap_InitYaamRegs(void)
|
||||
cut_c_initialize();
|
||||
#endif
|
||||
#if defined CUT_C && (defined MYDDAS_ODBC || defined MYDDAS_MYSQL)
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER = myddas_util_initialize_myddas();
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = myddas_util_initialize_myddas();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
8
C/grow.c
8
C/grow.c
@ -135,8 +135,8 @@ SetHeapRegs(void)
|
||||
if (B)
|
||||
B = ChoicePtrAdjust(B);
|
||||
#ifdef CUT_C
|
||||
if (Yap_regp->CUT_C_TOP)
|
||||
Yap_regp->CUT_C_TOP = (cut_c_str_ptr)ChoicePtrAdjust((choiceptr)Yap_regp->CUT_C_TOP);
|
||||
if (Yap_REGS.CUT_C_TOP)
|
||||
Yap_REGS.CUT_C_TOP = (cut_c_str_ptr)ChoicePtrAdjust((choiceptr)Yap_REGS.CUT_C_TOP);
|
||||
#endif
|
||||
#ifdef TABLING
|
||||
if (B_FZ)
|
||||
@ -197,8 +197,8 @@ SetStackRegs(void)
|
||||
if (B)
|
||||
B = ChoicePtrAdjust(B);
|
||||
#ifdef CUT_C
|
||||
if (Yap_regp->CUT_C_TOP)
|
||||
Yap_regp->CUT_C_TOP = (cut_c_str_ptr)ChoicePtrAdjust((choiceptr)Yap_regp->CUT_C_TOP);
|
||||
if (Yap_REGS.CUT_C_TOP)
|
||||
Yap_REGS.CUT_C_TOP = (cut_c_str_ptr)ChoicePtrAdjust((choiceptr)Yap_REGS.CUT_C_TOP);
|
||||
#endif
|
||||
#ifdef TABLING
|
||||
if (B_FZ)
|
||||
|
3
H/Yap.h
3
H/Yap.h
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h,v 1.12 2006-01-08 23:01:47 vsc Exp $ *
|
||||
* version: $Id: Yap.h,v 1.13 2006-03-09 15:52:04 tiagosoares Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -1268,3 +1268,4 @@ extern char emacs_tmp[], emacs_tmp2[];
|
||||
#if SBA
|
||||
#include "sbaunify.h"
|
||||
#endif
|
||||
|
||||
|
60
H/Yapproto.h
60
H/Yapproto.h
@ -10,7 +10,7 @@
|
||||
* File: Yap.proto *
|
||||
* mods: *
|
||||
* comments: Function declarations for YAP *
|
||||
* version: $Id: Yapproto.h,v 1.69 2006-02-05 02:26:35 tiagosoares Exp $ *
|
||||
* version: $Id: Yapproto.h,v 1.70 2006-03-09 15:52:05 tiagosoares Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* prototype file for Yap */
|
||||
@ -319,20 +319,70 @@ void STD_PROTO(Yap_InitUtilCPreds,(void));
|
||||
|
||||
/* yap.c */
|
||||
|
||||
/* myddas_* */
|
||||
#if defined CUT_C && defined MYDDAS_MYSQL
|
||||
/* MYDDAS */
|
||||
|
||||
/* myddas_initialization.c */
|
||||
MYDDAS_GLOBAL STD_PROTO(myddas_util_initialize_myddas,(void));
|
||||
|
||||
/* myddas_util.c */
|
||||
#ifdef MYDDAS_MYSQL
|
||||
void STD_PROTO(myddas_util_table_write,(MYSQL_RES *));
|
||||
#endif
|
||||
/* Returns the connection type (mysql -> 1 or odbc -> 2) */
|
||||
Short STD_PROTO(myddas_util_connection_type,(void *));
|
||||
/* Adds a connection identifier to the MYDDAS connections list*/
|
||||
MYDDAS_UTIL_CONNECTION STD_PROTO(myddas_util_add_connection,(void *,void *));
|
||||
/* Search for the node of the specified connection*/
|
||||
MYDDAS_UTIL_CONNECTION STD_PROTO(myddas_util_search_connection,(void *));
|
||||
/* Deletes a connection node from the MYDDAS connections list*/
|
||||
void STD_PROTO(myddas_util_delete_connection,(void *));
|
||||
/* Adds a new predicate to it's connection node list*/
|
||||
MYDDAS_UTIL_CONNECTION STD_PROTO(myddas_util_add_predicate,(char * ,Int , char *,void *));
|
||||
/* Search for a predicate node*/
|
||||
MYDDAS_UTIL_PREDICATE STD_PROTO(myddas_util_search_predicate,(char * ,Int , char *));
|
||||
/* Deletes predicate from the prediate list */
|
||||
void STD_PROTO(myddas_util_delete_predicate,(MYDDAS_UTIL_PREDICATE));
|
||||
|
||||
/* Get's the number of queries to save */
|
||||
UInt STD_PROTO(myddas_util_get_total_multi_queries_number,(MYDDAS_UTIL_CONNECTION));
|
||||
void STD_PROTO(myddas_util_set_total_multi_queries_number,(MYDDAS_UTIL_CONNECTION,UInt));
|
||||
#ifdef MYDDAS_ODBC
|
||||
/* Return enviromment identifier*/
|
||||
SQLHENV STD_PROTO(myddas_util_get_odbc_enviromment,(SQLHDBC));
|
||||
#endif
|
||||
|
||||
void * STD_PROTO(myddas_util_get_list_pred,(MYDDAS_UTIL_CONNECTION));
|
||||
void * STD_PROTO(myddas_util_get_pred_next,(void *));
|
||||
char * STD_PROTO(myddas_util_get_pred_module,(void *));
|
||||
char * STD_PROTO(myddas_util_get_pred_name,(void *));
|
||||
Int STD_PROTO(myddas_util_get_pred_arity,(void *));
|
||||
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
||||
Int STD_PROTO(get_myddas_top,(void));
|
||||
|
||||
#ifdef DEBUG
|
||||
void check_int(void);
|
||||
#endif
|
||||
|
||||
/* myddas_mysql.c */
|
||||
#if defined MYDDAS_MYSQL
|
||||
void STD_PROTO(Yap_InitMYDDAS_MySQLPreds,(void));
|
||||
void STD_PROTO(Yap_InitBackMYDDAS_MySQLPreds,(void));
|
||||
#endif
|
||||
#if defined CUT_C && defined MYDDAS_ODBC
|
||||
|
||||
/* myddas_odbc.c */
|
||||
#if defined MYDDAS_ODBC
|
||||
void STD_PROTO(Yap_InitMYDDAS_ODBCPreds,(void));
|
||||
void STD_PROTO(Yap_InitBackMYDDAS_ODBCPreds,(void));
|
||||
#endif
|
||||
#if defined CUT_C && (defined MYDDAS_ODBC || defined MYDDAS_MYSQL)
|
||||
|
||||
/* myddas_shared.c */
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
void STD_PROTO(Yap_MyDDAS_delete_all_myddas_structs,(void));
|
||||
void STD_PROTO(Yap_InitMYDDAS_SharedPreds,(void));
|
||||
void STD_PROTO(Yap_InitBackMYDDAS_SharedPreds,(void));
|
||||
#endif
|
||||
|
||||
/* myddas_top_level.c */
|
||||
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL //&& defined HAVE_LIBREADLINE
|
||||
void STD_PROTO(Yap_InitMYDDAS_TopLevelPreds,(void));
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@ struct cut_c_str{
|
||||
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
|
||||
|
||||
#define EXTRA_CBACK_CUT_ARG(Type,Offset) \
|
||||
((Type) (*(Type *)(((CELL *)Yap_regp->CUT_C_TOP) - (((yamop *)Yap_regp->CUT_C_TOP->try_userc_cut_yamop)->u.lds.extra)) + (Offset-1)))
|
||||
((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.lds.extra)) + (Offset-1)))
|
||||
|
||||
#define CUT_C_PUSH(YAMOP,S_YREG) \
|
||||
{ \
|
||||
@ -32,11 +32,12 @@ struct cut_c_str{
|
||||
|
||||
|
||||
#define POP_CHOICE_POINT(B) \
|
||||
(((int)Yap_regp->CUT_C_TOP != (int)Yap_LocalBase) && ((int)B > (int)Yap_regp->CUT_C_TOP))
|
||||
(((CELL *)Yap_REGS.CUT_C_TOP != (CELL *)Yap_LocalBase) && ((CELL *)B > (CELL *)Yap_REGS.CUT_C_TOP))
|
||||
//(((int)Yap_REGS.CUT_C_TOP != (int)Yap_LocalBase) && ((int)B > (int)Yap_REGS.CUT_C_TOP))
|
||||
|
||||
|
||||
#define POP_EXECUTE() \
|
||||
cut_c_str_ptr TOP = Yap_regp->CUT_C_TOP; \
|
||||
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
||||
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.lds.f; \
|
||||
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.lds.p; \
|
||||
YAP_Execute(pred,func); \
|
||||
|
@ -9,7 +9,7 @@ myddas_util_initialize_predicate(char *, int,char *,
|
||||
MYDDAS_UTIL_PREDICATE);
|
||||
|
||||
MYDDAS_GLOBAL
|
||||
myddas_util_initialize_myddas(){
|
||||
myddas_util_initialize_myddas(void){
|
||||
MYDDAS_GLOBAL global = NULL;
|
||||
|
||||
global = (MYDDAS_GLOBAL) malloc (sizeof(struct myddas_global));
|
||||
|
@ -41,26 +41,26 @@
|
||||
FIELD == FIELD_TYPE_FLOAT
|
||||
|
||||
|
||||
static int null_id = 0;
|
||||
static Int null_id = 0;
|
||||
|
||||
STATIC_PROTO(int c_db_my_connect,(void));
|
||||
STATIC_PROTO(int c_db_my_disconnect,(void));
|
||||
STATIC_PROTO(int c_db_my_number_of_fields,(void));
|
||||
STATIC_PROTO(int c_db_my_get_attributes_types,(void));
|
||||
STATIC_PROTO(int c_db_my_query,(void));
|
||||
STATIC_PROTO(int c_db_my_table_write,(void));
|
||||
STATIC_PROTO(int c_db_my_row,(void));
|
||||
STATIC_PROTO(int c_db_my_row_cut,(void));
|
||||
STATIC_PROTO(int c_db_my_get_fields_properties,(void));
|
||||
STATIC_PROTO(int c_db_my_number_of_fields_in_query,(void));
|
||||
STATIC_PROTO(int c_db_my_get_next_result_set,(void));
|
||||
STATIC_PROTO(int c_db_my_get_database,(void));
|
||||
STATIC_PROTO(int c_db_my_change_database,(void));
|
||||
STATIC_PROTO(Int c_db_my_connect,(void));
|
||||
STATIC_PROTO(Int c_db_my_disconnect,(void));
|
||||
STATIC_PROTO(Int c_db_my_number_of_fields,(void));
|
||||
STATIC_PROTO(Int c_db_my_get_attributes_types,(void));
|
||||
STATIC_PROTO(Int c_db_my_query,(void));
|
||||
STATIC_PROTO(Int c_db_my_table_write,(void));
|
||||
STATIC_PROTO(Int c_db_my_row,(void));
|
||||
STATIC_PROTO(Int c_db_my_row_cut,(void));
|
||||
STATIC_PROTO(Int c_db_my_get_fields_properties,(void));
|
||||
STATIC_PROTO(Int c_db_my_number_of_fields_in_query,(void));
|
||||
STATIC_PROTO(Int c_db_my_get_next_result_set,(void));
|
||||
STATIC_PROTO(Int c_db_my_get_database,(void));
|
||||
STATIC_PROTO(Int c_db_my_change_database,(void));
|
||||
|
||||
void Yap_InitMYDDAS_MySQLPreds(void)
|
||||
{
|
||||
/* db_connect: Host x User x Passwd x Database x Connection x ERROR_CODE */
|
||||
Yap_InitCPred("c_db_my_connect", 5, c_db_my_connect, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("c_db_my_connect", 5, c_db_my_connect, 0);
|
||||
|
||||
/* db_number_of_fields: Relation x Connection x NumberOfFields */
|
||||
Yap_InitCPred("c_db_my_number_of_fields",3, c_db_my_number_of_fields, 0);
|
||||
@ -98,14 +98,14 @@ void Yap_InitMYDDAS_MySQLPreds(void)
|
||||
void Yap_InitBackMYDDAS_MySQLPreds(void)
|
||||
{
|
||||
/* db_row: ResultSet x Arity x ListOfArgs */
|
||||
Yap_InitCPredBackCut("c_db_my_row", 3, sizeof(int),
|
||||
Yap_InitCPredBackCut("c_db_my_row", 3, sizeof(Int),
|
||||
c_db_my_row,
|
||||
c_db_my_row,
|
||||
c_db_my_row_cut, 0);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_connect(void) {
|
||||
Term arg_host = Deref(ARG1);
|
||||
Term arg_user = Deref(ARG2);
|
||||
@ -134,7 +134,7 @@ c_db_my_connect(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!Yap_unify(arg_conn, MkIntegerTerm((int)conn)))
|
||||
if (!Yap_unify(arg_conn, MkIntegerTerm((Int)conn)))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
@ -150,7 +150,7 @@ c_db_my_connect(void) {
|
||||
}
|
||||
|
||||
/* db_query: SQLQuery x ResultSet x Connection */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_query(void) {
|
||||
Term arg_sql_query = Deref(ARG1);
|
||||
Term arg_result_set = Deref(ARG2);
|
||||
@ -163,13 +163,13 @@ c_db_my_query(void) {
|
||||
|
||||
MYSQL_RES *res_set;
|
||||
|
||||
int length=strlen(sql);
|
||||
Int length=strlen(sql);
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
MYDDAS_UTIL_CONNECTION node = myddas_util_search_connection(conn);
|
||||
|
||||
/* Count the number of querys made to the server */
|
||||
unsigned long number_querys;
|
||||
UInt number_querys;
|
||||
MYDDAS_STATS_CON_GET_NUMBER_QUERIES_MADE(node,number_querys);
|
||||
MYDDAS_STATS_CON_SET_NUMBER_QUERIES_MADE(node,++number_querys);
|
||||
|
||||
@ -247,17 +247,17 @@ c_db_my_query(void) {
|
||||
returns a NULL pointer*/
|
||||
|
||||
/* This is only works if we use mysql_store_result */
|
||||
unsigned long numberRows = mysql_num_rows(res_set);
|
||||
unsigned long rows;
|
||||
UInt numberRows = mysql_num_rows(res_set);
|
||||
UInt rows;
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_ROWS(node,rows);
|
||||
numberRows = numberRows + rows;
|
||||
MYDDAS_STATS_CON_SET_TOTAL_ROWS(node,numberRows);
|
||||
|
||||
/* Calculate the ammount of data sent by the server */
|
||||
unsigned long int total,number_fields = mysql_num_fields(res_set);
|
||||
UInt total,number_fields = mysql_num_fields(res_set);
|
||||
MYSQL_ROW row;
|
||||
unsigned int i;
|
||||
UInt i;
|
||||
total=0;
|
||||
while ((row = mysql_fetch_row(res_set)) != NULL){
|
||||
mysql_field_seek(res_set,0);
|
||||
@ -268,7 +268,7 @@ c_db_my_query(void) {
|
||||
}
|
||||
}
|
||||
MYDDAS_STATS_CON_SET_LAST_BYTES_TRANSFERING_FROM_DBSERVER(node,total);
|
||||
unsigned long bytes;
|
||||
UInt bytes;
|
||||
|
||||
MYDDAS_STATS_CON_GET_TOTAL_BYTES_TRANSFERING_FROM_DBSERVER(node,bytes);
|
||||
total = total + bytes;
|
||||
@ -287,7 +287,7 @@ c_db_my_query(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!Yap_unify(arg_result_set, MkIntegerTerm((int) res_set)))
|
||||
if (!Yap_unify(arg_result_set, MkIntegerTerm((Int) res_set)))
|
||||
{
|
||||
mysql_free_result(res_set);
|
||||
return FALSE;
|
||||
@ -298,7 +298,7 @@ c_db_my_query(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_number_of_fields(void) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -342,7 +342,7 @@ c_db_my_number_of_fields(void) {
|
||||
|
||||
|
||||
/* db_get_attributes_types: RelName x Connection -> TypesList */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_get_attributes_types(void) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -399,7 +399,7 @@ c_db_my_get_attributes_types(void) {
|
||||
}
|
||||
|
||||
/* db_disconnect */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_disconnect(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
@ -418,7 +418,7 @@ c_db_my_disconnect(void) {
|
||||
}
|
||||
|
||||
/* db_table_write: Result Set */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_table_write(void) {
|
||||
Term arg_res_set = Deref(ARG1);
|
||||
|
||||
@ -430,7 +430,7 @@ c_db_my_table_write(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_row_cut(void) {
|
||||
MYSQL_RES *mysql_res=NULL;
|
||||
|
||||
@ -440,7 +440,7 @@ c_db_my_row_cut(void) {
|
||||
}
|
||||
|
||||
/* db_row: ResultSet x Arity_ListOfArgs x ListOfArgs -> */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_row(void) {
|
||||
#ifdef MYDDAS_STATS
|
||||
/* Measure time used by the
|
||||
@ -453,13 +453,13 @@ c_db_my_row(void) {
|
||||
Term arg_list_args = Deref(ARG3);
|
||||
|
||||
MYSQL_RES *res_set = (MYSQL_RES *) IntegerOfTerm(arg_result_set);
|
||||
EXTRA_CBACK_ARG(3,1)=(CELL) MkIntegerTerm((int)res_set);
|
||||
EXTRA_CBACK_ARG(3,1)=(CELL) MkIntegerTerm((Int)res_set);
|
||||
MYSQL_ROW row;
|
||||
MYSQL_FIELD *field;
|
||||
|
||||
|
||||
Term head, list, null_atom[1];
|
||||
int i, arity;
|
||||
Int i, arity;
|
||||
|
||||
arity = IntegerOfTerm(arg_arity);
|
||||
|
||||
@ -547,7 +547,7 @@ c_db_my_row(void) {
|
||||
|
||||
/* Mudar esta funcao de forma a nao fazer a consulta, pois
|
||||
no predicate db_sql_selet vai fazer duas vezes a mesma consutla*/
|
||||
static int
|
||||
static Int
|
||||
c_db_my_number_of_fields_in_query(void) {
|
||||
Term arg_query = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -583,7 +583,7 @@ c_db_my_number_of_fields_in_query(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_get_fields_properties(void) {
|
||||
Term nome_relacao = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -592,7 +592,7 @@ c_db_my_get_fields_properties(void) {
|
||||
|
||||
char *relacao = AtomName(AtomOfTerm(nome_relacao));
|
||||
char sql[256];
|
||||
int num_fields,i;
|
||||
Int num_fields,i;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_RES *res_set;
|
||||
MYSQL *conn = (MYSQL *) (IntegerOfTerm(arg_conn));
|
||||
@ -663,7 +663,7 @@ c_db_my_get_fields_properties(void) {
|
||||
}
|
||||
|
||||
/* c_db_my_get_next_result_set: Connection * NextResSet */
|
||||
static int
|
||||
static Int
|
||||
c_db_my_get_next_result_set(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_next_res_set = Deref(ARG2);
|
||||
@ -673,12 +673,12 @@ c_db_my_get_next_result_set(void) {
|
||||
|
||||
if (mysql_next_result(conn) == 0){
|
||||
res_set = mysql_store_result(conn);
|
||||
Yap_unify(arg_next_res_set, MkIntegerTerm((int) res_set));
|
||||
Yap_unify(arg_next_res_set, MkIntegerTerm((Int) res_set));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_get_database(void) {
|
||||
Term arg_con = Deref(ARG1);
|
||||
Term arg_database = Deref(ARG2);
|
||||
@ -692,7 +692,7 @@ c_db_my_get_database(void) {
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_my_change_database(void) {
|
||||
Term arg_con = Deref(ARG1);
|
||||
Term arg_database = Deref(ARG2);
|
||||
|
@ -27,17 +27,17 @@
|
||||
#include <sql.h>
|
||||
#include <sqlucode.h>
|
||||
|
||||
static int null_id = 0;
|
||||
static Int null_id = 0;
|
||||
|
||||
STATIC_PROTO(int c_db_odbc_connect,(void));
|
||||
STATIC_PROTO(int c_db_odbc_disconnect,(void));
|
||||
STATIC_PROTO(int c_db_odbc_number_of_fields,(void));
|
||||
STATIC_PROTO(int c_db_odbc_get_attributes_types,(void));
|
||||
STATIC_PROTO(int c_db_odbc_query,(void));
|
||||
STATIC_PROTO(int c_db_odbc_row,(void));
|
||||
STATIC_PROTO(int c_db_odbc_row_cut,(void));
|
||||
STATIC_PROTO(int c_db_odbc_get_fields_properties,(void));
|
||||
STATIC_PROTO(int c_db_odbc_number_of_fields_in_query,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_connect,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_disconnect,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_get_attributes_types,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_query,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_row,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_row_cut,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_get_fields_properties,(void));
|
||||
STATIC_PROTO(Int c_db_odbc_number_of_fields_in_query,(void));
|
||||
|
||||
|
||||
#define SQLALLOCHANDLE(A,B,C,print) \
|
||||
@ -248,7 +248,7 @@ STATIC_PROTO(int c_db_odbc_number_of_fields_in_query,(void));
|
||||
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_connect(void) {
|
||||
Term arg_driver = Deref(ARG1);
|
||||
Term arg_user = Deref(ARG2);
|
||||
@ -278,7 +278,7 @@ c_db_odbc_connect(void) {
|
||||
(SQLCHAR*) user, SQL_NTS,
|
||||
(SQLCHAR*) passwd, SQL_NTS, "connect");
|
||||
|
||||
if (!Yap_unify(arg_conn, MkIntegerTerm((int)(hdbc))))
|
||||
if (!Yap_unify(arg_conn, MkIntegerTerm((Int)(hdbc))))
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
@ -294,7 +294,7 @@ c_db_odbc_connect(void) {
|
||||
}
|
||||
|
||||
/* db_query: SQLQuery x ResultSet x Arity x BindList x Connection */
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_query(void) {
|
||||
Term arg_sql_query = Deref(ARG1);
|
||||
Term arg_result_set = Deref(ARG2);
|
||||
@ -314,8 +314,8 @@ c_db_odbc_query(void) {
|
||||
/* Executes the query*/
|
||||
SQLEXECDIRECT(hstmt,sql,SQL_NTS, "db_query");
|
||||
|
||||
int arity;
|
||||
int i;
|
||||
Int arity;
|
||||
Int i;
|
||||
|
||||
if (IsNonVarTerm(arg_arity)){
|
||||
arity = IntegerOfTerm(arg_arity);
|
||||
@ -323,7 +323,8 @@ c_db_odbc_query(void) {
|
||||
|
||||
char *bind_space=NULL;
|
||||
|
||||
const int functor_arity=3;
|
||||
//const Int functor_arity=3;
|
||||
const Short functor_arity=3;
|
||||
Functor functor = Yap_MkFunctor(Yap_LookupAtom("bind"),functor_arity);
|
||||
Term properties[functor_arity];
|
||||
|
||||
@ -344,8 +345,8 @@ c_db_odbc_query(void) {
|
||||
data_info = malloc(sizeof(SQLINTEGER));
|
||||
SQLBINDCOL(hstmt,i,SQL_C_CHAR,bind_space,(ColumnSizePtr+1),data_info,"db_query");
|
||||
|
||||
properties[0] = MkIntegerTerm((int)bind_space);
|
||||
properties[2] = MkIntegerTerm((int)data_info);
|
||||
properties[0] = MkIntegerTerm((Int)bind_space);
|
||||
properties[2] = MkIntegerTerm((Int)data_info);
|
||||
|
||||
if (IS_SQL_INT(type))
|
||||
properties[1]=MkAtomTerm(Yap_LookupAtom("integer"));
|
||||
@ -360,7 +361,7 @@ c_db_odbc_query(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Yap_unify(arg_result_set, MkIntegerTerm((int) hstmt)))
|
||||
if (!Yap_unify(arg_result_set, MkIntegerTerm((Int) hstmt)))
|
||||
{
|
||||
SQLCLOSECURSOR(hstmt,"db_query");
|
||||
SQLFREESTMT(hstmt,SQL_CLOSE,"db_query");
|
||||
@ -369,7 +370,7 @@ c_db_odbc_query(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_number_of_fields(void) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -406,7 +407,7 @@ c_db_odbc_number_of_fields(void) {
|
||||
|
||||
|
||||
/* db_get_attributes_types: RelName x Connection -> TypesList */
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_get_attributes_types(void) {
|
||||
Term arg_relation = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -461,7 +462,7 @@ c_db_odbc_get_attributes_types(void) {
|
||||
}
|
||||
|
||||
/* db_disconnect */
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_disconnect(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
@ -483,7 +484,7 @@ c_db_odbc_disconnect(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_row_cut(void) {
|
||||
|
||||
SQLHSTMT hstmt = (SQLHSTMT) IntegerOfTerm(EXTRA_CBACK_CUT_ARG(Term,1));
|
||||
@ -495,7 +496,7 @@ c_db_odbc_row_cut(void) {
|
||||
}
|
||||
|
||||
/* db_row: ResultSet x BindList x ListOfArgs -> */
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_row(void) {
|
||||
Term arg_result_set = Deref(ARG1);
|
||||
Term arg_bind_list = Deref(ARG2);
|
||||
@ -504,7 +505,7 @@ c_db_odbc_row(void) {
|
||||
SQLHSTMT hstmt = (SQLHSTMT) IntegerOfTerm(arg_result_set);
|
||||
|
||||
/* EXTRA_CBACK_ARG(ARIDADE,LOCAL_ONDE_COLOCAR_VALOR)*/
|
||||
EXTRA_CBACK_ARG(3,1)=(CELL) MkIntegerTerm((int)hstmt);
|
||||
EXTRA_CBACK_ARG(3,1)=(CELL) MkIntegerTerm((Int)hstmt);
|
||||
|
||||
Term head, list, null_atom[1];
|
||||
Term head_bind, list_bind;
|
||||
@ -574,7 +575,7 @@ c_db_odbc_row(void) {
|
||||
|
||||
/* Mudar esta funcao de forma a nao fazer a consulta, pois
|
||||
no predicate db_sql_selet vai fazer duas vezes a mesma consutla*/
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_number_of_fields_in_query(void) {
|
||||
Term arg_query = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -604,7 +605,7 @@ c_db_odbc_number_of_fields_in_query(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_odbc_get_fields_properties(void) {
|
||||
Term nome_relacao = Deref(ARG1);
|
||||
Term arg_conn = Deref(ARG2);
|
||||
@ -614,7 +615,7 @@ c_db_odbc_get_fields_properties(void) {
|
||||
char *relacao = AtomName(AtomOfTerm(nome_relacao));
|
||||
char sql[256];
|
||||
char name[200];
|
||||
int i;
|
||||
Int i;
|
||||
|
||||
|
||||
SQLSMALLINT num_fields=0;
|
||||
@ -643,7 +644,7 @@ c_db_odbc_get_fields_properties(void) {
|
||||
|
||||
SQLSMALLINT bind_prim_key;
|
||||
//por causa de as rows em odbc começam em 1 :)
|
||||
short *null=malloc(sizeof(short)*(1+num_fields));
|
||||
Short *null=malloc(sizeof(Short)*(1+num_fields));
|
||||
|
||||
SQLALLOCHANDLE(SQL_HANDLE_STMT, hdbc, &hstmt2, "db_get_fields_properties");
|
||||
/* Executes the query*/
|
||||
@ -734,7 +735,7 @@ void Yap_InitBackMYDDAS_ODBCPreds(void)
|
||||
{
|
||||
|
||||
/* db_row: ResultSet x ListOfArgs */
|
||||
Yap_InitCPredBackCut("c_db_odbc_row", 3, sizeof(int),
|
||||
Yap_InitCPredBackCut("c_db_odbc_row", 3, sizeof(Int),
|
||||
c_db_odbc_row,
|
||||
c_db_odbc_row,
|
||||
c_db_odbc_row_cut, 0);
|
||||
|
@ -27,21 +27,21 @@
|
||||
#include "myddas_statistics.h"
|
||||
#endif
|
||||
|
||||
//STATIC_PROTO(int c_db_get_new_table_name,(void));
|
||||
STATIC_PROTO(int c_db_connection_type,(void));
|
||||
STATIC_PROTO(int c_db_add_preds,(void));
|
||||
STATIC_PROTO(int c_db_preds_conn_start ,(void));
|
||||
STATIC_PROTO(int c_db_preds_conn_continue ,(void));
|
||||
STATIC_PROTO(int c_db_connection_start ,(void));
|
||||
STATIC_PROTO(int c_db_connection_continue ,(void));
|
||||
STATIC_PROTO(int c_db_check_if_exists_pred,(void));
|
||||
STATIC_PROTO(int c_db_delete_predicate,(void));
|
||||
STATIC_PROTO(int c_db_multi_queries_number,(void));
|
||||
//STATIC_PROTO(Int c_db_get_new_table_name,(void));
|
||||
STATIC_PROTO(Int c_db_connection_type,(void));
|
||||
STATIC_PROTO(Int c_db_add_preds,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_start ,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_start ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_check_if_exists_pred,(void));
|
||||
STATIC_PROTO(Int c_db_delete_predicate,(void));
|
||||
STATIC_PROTO(Int c_db_multi_queries_number,(void));
|
||||
#ifdef MYDDAS_STATS
|
||||
STATIC_PROTO(int c_db_stats,(void));
|
||||
STATIC_PROTO(Int c_db_stats,(void));
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
STATIC_PROTO(int c_db_check,(void));
|
||||
STATIC_PROTO(Int c_db_check,(void));
|
||||
#endif
|
||||
|
||||
void Yap_InitMYDDAS_SharedPreds(void)
|
||||
@ -74,11 +74,11 @@ void Yap_InitMYDDAS_SharedPreds(void)
|
||||
void Yap_InitBackMYDDAS_SharedPreds(void)
|
||||
{
|
||||
/* Gives all the predicates associated to a given connection */
|
||||
Yap_InitCPredBack("c_db_preds_conn", 4, sizeof(int),
|
||||
Yap_InitCPredBack("c_db_preds_conn", 4, sizeof(Int),
|
||||
c_db_preds_conn_start,
|
||||
c_db_preds_conn_continue, 0);
|
||||
/* Gives all the connections stored on the MYDDAS Structure*/
|
||||
Yap_InitCPredBack("c_db_connection", 1, sizeof(int),
|
||||
Yap_InitCPredBack("c_db_connection", 1, sizeof(Int),
|
||||
c_db_connection_start,
|
||||
c_db_connection_continue, 0);
|
||||
|
||||
@ -90,13 +90,13 @@ void Yap_InitBackMYDDAS_SharedPreds(void)
|
||||
|
||||
NOTE: In order to use this predicate, the connection*/
|
||||
/* c_db_connection_type: +Connection * ?Type */
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_type (void){
|
||||
Term arg_con = Deref(ARG1);
|
||||
Term arg_type = Deref(ARG2);
|
||||
|
||||
int *con = (int *) IntegerOfTerm(arg_con);
|
||||
short int type = myddas_util_connection_type(con);
|
||||
Int *con = (Int *) IntegerOfTerm(arg_con);
|
||||
Int type = myddas_util_connection_type(con);
|
||||
|
||||
if (type == 1) /* MYSQL Connection */
|
||||
Yap_unify(arg_type, MkAtomTerm(Yap_LookupAtom("mysql")));
|
||||
@ -109,7 +109,7 @@ c_db_connection_type (void){
|
||||
}
|
||||
|
||||
/* db_add_preds: PredName * Arity * Module * Connection*/
|
||||
static int
|
||||
static Int
|
||||
c_db_add_preds (void){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
@ -118,8 +118,8 @@ c_db_add_preds (void){
|
||||
|
||||
char *nome = AtomName(AtomOfTerm(arg_nome));
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
int aridade = IntegerOfTerm(arg_aridade);
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int aridade = IntegerOfTerm(arg_aridade);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
|
||||
if (myddas_util_add_predicate(nome,aridade,module,conn) == NULL)
|
||||
{
|
||||
@ -133,7 +133,7 @@ c_db_add_preds (void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_check_if_exists_pred (void){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
@ -141,7 +141,7 @@ c_db_check_if_exists_pred (void){
|
||||
|
||||
char *nome = AtomName(AtomOfTerm(arg_nome));
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
int aridade = IntegerOfTerm(arg_aridade);
|
||||
Int aridade = IntegerOfTerm(arg_aridade);
|
||||
|
||||
if (myddas_util_search_predicate(nome,aridade,module) == NULL)
|
||||
return FALSE;
|
||||
@ -150,7 +150,7 @@ c_db_check_if_exists_pred (void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_delete_predicate(void){
|
||||
Term arg_module = Deref(ARG1);
|
||||
Term arg_name = Deref(ARG2);
|
||||
@ -158,7 +158,7 @@ c_db_delete_predicate(void){
|
||||
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
char *name = AtomName(AtomOfTerm(arg_name));
|
||||
int arity = IntegerOfTerm(arg_arity);
|
||||
Int arity = IntegerOfTerm(arg_arity);
|
||||
|
||||
MYDDAS_UTIL_PREDICATE predicate =
|
||||
myddas_util_search_predicate(name,arity,module);
|
||||
@ -171,12 +171,12 @@ c_db_delete_predicate(void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_multi_queries_number(void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_number = Deref(ARG2);
|
||||
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
myddas_util_search_connection(conn);
|
||||
|
||||
@ -184,10 +184,10 @@ c_db_multi_queries_number(void){
|
||||
return FALSE;
|
||||
|
||||
if (IsVarTerm(arg_number)){
|
||||
Yap_unify(arg_number,MkIntegerTerm(((int)myddas_util_get_total_multi_queries_number(node))+1));
|
||||
Yap_unify(arg_number,MkIntegerTerm(((Int)myddas_util_get_total_multi_queries_number(node))+1));
|
||||
}
|
||||
else {
|
||||
int number = IntegerOfTerm(arg_number);
|
||||
Int number = IntegerOfTerm(arg_number);
|
||||
number--;
|
||||
myddas_util_set_total_multi_queries_number(node,number);
|
||||
}
|
||||
@ -196,18 +196,18 @@ c_db_multi_queries_number(void){
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_start(void){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((int)node);
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
|
||||
|
||||
return (c_db_connection_continue());
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_continue(void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
@ -221,19 +221,19 @@ c_db_connection_continue(void){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Yap_unify(arg_conn, MkIntegerTerm((int)(node->connection)));
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((int)(node->next));
|
||||
Yap_unify(arg_conn, MkIntegerTerm((Int)(node->connection)));
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)(node->next));
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
|
||||
static int
|
||||
static Int
|
||||
c_db_preds_conn_start (void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
myddas_util_search_connection(conn);
|
||||
|
||||
@ -245,13 +245,13 @@ c_db_preds_conn_start (void){
|
||||
}
|
||||
|
||||
void *pointer = myddas_util_get_list_pred(node);
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((int)pointer);
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)pointer);
|
||||
|
||||
return (c_db_preds_conn_continue());
|
||||
}
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity*/
|
||||
static int
|
||||
static Int
|
||||
c_db_preds_conn_continue (void){
|
||||
Term module = Deref(ARG2);
|
||||
Term name = Deref(ARG3);
|
||||
@ -262,7 +262,7 @@ c_db_preds_conn_continue (void){
|
||||
|
||||
if (pointer != NULL)
|
||||
{
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((int)myddas_util_get_pred_next(pointer));
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)myddas_util_get_pred_next(pointer));
|
||||
|
||||
if (!Yap_unify(module, MkAtomTerm(Yap_LookupAtom(myddas_util_get_pred_module(pointer))))){
|
||||
return FALSE;
|
||||
@ -270,7 +270,7 @@ c_db_preds_conn_continue (void){
|
||||
if (!Yap_unify(name,MkAtomTerm(Yap_LookupAtom(myddas_util_get_pred_name(pointer))))){
|
||||
return FALSE;
|
||||
}
|
||||
if (!Yap_unify(arity, MkIntegerTerm((int)myddas_util_get_pred_arity(pointer)))){
|
||||
if (!Yap_unify(arity, MkIntegerTerm((Int)myddas_util_get_pred_arity(pointer)))){
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@ -285,7 +285,7 @@ c_db_preds_conn_continue (void){
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static int
|
||||
static Int
|
||||
c_db_check(void){
|
||||
check_int();
|
||||
return TRUE;
|
||||
@ -294,12 +294,12 @@ c_db_check(void){
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
//Returns the stats of this module in a list
|
||||
static int
|
||||
static Int
|
||||
c_db_stats(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_list = Deref(ARG2);
|
||||
|
||||
int *conn = (int *) (IntegerOfTerm(arg_conn));
|
||||
Int *conn = (Int *) (IntegerOfTerm(arg_conn));
|
||||
|
||||
// TODO
|
||||
if (get_myddas_top() == 0 ){ /* We want all the statistics */
|
||||
@ -312,7 +312,7 @@ c_db_stats(void) {
|
||||
list = arg_list;
|
||||
|
||||
MYDDAS_STATS_TIME time;
|
||||
unsigned long number;
|
||||
UInt number;
|
||||
|
||||
|
||||
//[Index 1] -> Total Number of Rows by connection
|
||||
@ -324,7 +324,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Total Number of Rows returned from the Server\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 2] -> Total of Time Spent by the DB Server
|
||||
@ -332,7 +332,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, on all the SQL Querys\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@ -344,7 +344,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, on the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@ -356,7 +356,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Refence to time Spent by the Server, transfering all the results SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@ -368,7 +368,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, transfering the result of the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@ -380,7 +380,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the db_row_function\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@ -395,7 +395,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Bytes Transfered by the DB Server from all querys\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 8] -> Total of Bytes Transfered by the
|
||||
@ -406,7 +406,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Bytes Transfered by the DB Server on the last query\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 9] -> Number of querys made to the DBserver
|
||||
@ -416,7 +416,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Number of Querys made to the server\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
|
@ -85,7 +85,7 @@ myddas_stats_time_copy_to_final(MYDDAS_STATS_TIME);
|
||||
NODE->total_querys_made = NUMBER;
|
||||
|
||||
#define MYDDAS_STATS_GET_DB_ROW_FUNCTION(TIME) \
|
||||
TIME = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_statistics->total_db_row;
|
||||
TIME = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_statistics->total_db_row;
|
||||
|
||||
#endif /* MYDDAS_STATS */
|
||||
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <sys/times.h>
|
||||
|
||||
|
||||
STATIC_PROTO(int c_db_tl_top_level_mysql,(void));
|
||||
STATIC_PROTO(int c_db_tl_readline,(void));
|
||||
STATIC_PROTO(Int c_db_tl_top_level_mysql,(void));
|
||||
STATIC_PROTO(Int c_db_tl_readline,(void));
|
||||
|
||||
STATIC_PROTO(int com_quit,(char *,char*));
|
||||
STATIC_PROTO(int myddas_top_level_command,(char *,char *));
|
||||
STATIC_PROTO(Int com_quit,(char *,char*));
|
||||
STATIC_PROTO(Int myddas_top_level_command,(char *,char *));
|
||||
STATIC_PROTO(void myddas_top_level_print_time,(MYDDAS_STATS_TIME));
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ void Yap_InitMYDDAS_TopLevelPreds(void)
|
||||
typedef struct {
|
||||
const char *name; /* User printable name of the function. */
|
||||
char cmd_char; /* msql command character */
|
||||
int (*func)(char *str,char *); /* Function to call to do the job. */
|
||||
Int (*func)(char *str,char *); /* Function to call to do the job. */
|
||||
//bool takes_params; /* Max parameters for command */
|
||||
const char *doc; /* Documentation for this function. */
|
||||
} COMMANDS;
|
||||
@ -66,7 +66,7 @@ static COMMANDS commands[] = {
|
||||
{ (char *)NULL, 0, 0, ""}
|
||||
};
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_tl_readline(void) {
|
||||
Term arg_prompt = Deref(ARG1);
|
||||
Term arg_line = Deref(ARG2);
|
||||
@ -88,7 +88,7 @@ c_db_tl_readline(void) {
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_tl_top_level_mysql(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_res_set_mode = Deref(ARG2);
|
||||
@ -96,9 +96,9 @@ c_db_tl_top_level_mysql(void) {
|
||||
MYSQL *con = (MYSQL *) IntegerOfTerm(arg_conn);
|
||||
char *res_set_mode = AtomName(AtomOfTerm(arg_res_set_mode));
|
||||
char *line;
|
||||
int quit;
|
||||
Int quit;
|
||||
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_level_connection = myddas_util_search_connection(con);
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_level_connection = myddas_util_search_connection(con);
|
||||
|
||||
printf ("\n");
|
||||
for (;;) {
|
||||
@ -115,10 +115,10 @@ c_db_tl_top_level_mysql(void) {
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
myddas_top_level_command(char *line,char *res_set_mode){
|
||||
|
||||
int i;
|
||||
Int i;
|
||||
MYSQL *conn;
|
||||
MYSQL_RES *res_set;
|
||||
|
||||
@ -131,13 +131,13 @@ myddas_top_level_command(char *line,char *res_set_mode){
|
||||
for (i=0;commands[i].name!=NULL;i++)
|
||||
if (!strcmp(commands[i].name,line))
|
||||
{
|
||||
int quit = (*(commands[i].func))(NULL,NULL);
|
||||
Int quit = (*(commands[i].func))(NULL,NULL);
|
||||
return quit;
|
||||
}
|
||||
|
||||
int length=strlen(line);
|
||||
Int length=strlen(line);
|
||||
|
||||
conn = (MYSQL *) (Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_level_connection->connection);
|
||||
conn = (MYSQL *) (Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_level_connection->connection);
|
||||
|
||||
MYDDAS_STATS_TIME start = myddas_stats_walltime();
|
||||
if (mysql_real_query(conn, line, length) != 0){
|
||||
@ -167,8 +167,8 @@ myddas_top_level_command(char *line,char *res_set_mode){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int com_quit(char *nill,char *null){
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_level_connection = NULL;
|
||||
Int com_quit(char *nill,char *null){
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_level_connection = NULL;
|
||||
printf ("Bye\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifdef CUT_C
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
|
||||
#include "Yap.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "cut_c.h"
|
||||
@ -16,29 +17,29 @@
|
||||
#ifdef MYDDAS_MYSQL
|
||||
#include <mysql/mysql.h>
|
||||
#endif /*MYDDAS_MYSQL*/
|
||||
#include "Yap.h"
|
||||
|
||||
|
||||
|
||||
/* Search for the predicate in the given predicate list*/
|
||||
static MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_find_predicate(char *, int , char *, MYDDAS_UTIL_PREDICATE);
|
||||
myddas_util_find_predicate(char *, Int , char *, MYDDAS_UTIL_PREDICATE);
|
||||
/* Deletes a predicate list */
|
||||
static void
|
||||
myddas_util_delete_predicate_list(MYDDAS_UTIL_PREDICATE);
|
||||
|
||||
/* Prints a error message */
|
||||
static void
|
||||
myddas_util_error_message(char *,int,char *);
|
||||
myddas_util_error_message(char *,Int,char *);
|
||||
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
/* Auxilary function to table_write*/
|
||||
static void
|
||||
n_print(int , char );
|
||||
n_print(Int , char );
|
||||
#endif
|
||||
|
||||
/* Type: MYSQL->1 ODBC->2*/
|
||||
short int
|
||||
Short
|
||||
myddas_util_connection_type(void *con){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION con_node =
|
||||
@ -55,10 +56,10 @@ myddas_util_connection_type(void *con){
|
||||
|
||||
|
||||
MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_search_predicate(char *pred_name, int pred_arity,
|
||||
myddas_util_search_predicate(char *pred_name, Int pred_arity,
|
||||
char *pred_module){
|
||||
MYDDAS_UTIL_PREDICATE pred=NULL;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
for (;top!=NULL;top=top->next)
|
||||
{
|
||||
@ -71,7 +72,7 @@ myddas_util_search_predicate(char *pred_name, int pred_arity,
|
||||
/* When using this function, we must guarante that this predicate
|
||||
it's unique */
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_add_predicate(char *pred_name, int pred_arity,
|
||||
myddas_util_add_predicate(char *pred_name, Int pred_arity,
|
||||
char *pred_module, void *con){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION node_con =
|
||||
@ -99,7 +100,7 @@ myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE to_delete){
|
||||
to_delete->previous->next = to_delete->next;
|
||||
else //First predicate of the predicate list
|
||||
{
|
||||
MYDDAS_UTIL_CONNECTION con_node = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
MYDDAS_UTIL_CONNECTION con_node = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
for(;con_node != NULL; con_node = con_node->next)
|
||||
if (con_node->predicates == to_delete)
|
||||
break;
|
||||
@ -127,8 +128,8 @@ myddas_util_delete_connection(void *conn){
|
||||
to_delete->next->previous = to_delete->previous;
|
||||
|
||||
/* Is the first element of the list */
|
||||
if (to_delete == (Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections))
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections = to_delete->next;
|
||||
if (to_delete == (Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections))
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections = to_delete->next;
|
||||
else
|
||||
to_delete->previous->next=to_delete->next;
|
||||
|
||||
@ -139,7 +140,7 @@ myddas_util_delete_connection(void *conn){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_search_connection(void *conn){
|
||||
MYDDAS_UTIL_CONNECTION list = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
MYDDAS_UTIL_CONNECTION list = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
if (conn == 0) { /* We want all the statistics */
|
||||
@ -164,7 +165,7 @@ myddas_util_add_connection(void *conn, void *enviromment){
|
||||
return node;
|
||||
}
|
||||
//put the new connection node on the top of the list
|
||||
temp = myddas_util_initialize_connection(conn,enviromment,Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections);
|
||||
temp = myddas_util_initialize_connection(conn,enviromment,Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections);
|
||||
if (temp == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -172,8 +173,8 @@ myddas_util_add_connection(void *conn, void *enviromment){
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections = temp;
|
||||
return Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections = temp;
|
||||
return Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
}
|
||||
|
||||
#ifdef MYDDAS_ODBC
|
||||
@ -182,7 +183,7 @@ myddas_util_add_connection(void *conn, void *enviromment){
|
||||
if there is any odbc connections left on the list*/
|
||||
SQLHENV
|
||||
myddas_util_get_odbc_enviromment(SQLHDBC connection){
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
for (;top != NULL;top=top->next)
|
||||
if (top->connection == ((void *)connection))
|
||||
@ -192,37 +193,37 @@ myddas_util_get_odbc_enviromment(SQLHDBC connection){
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned long
|
||||
UInt
|
||||
myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con){
|
||||
return con->total_number_queries;
|
||||
}
|
||||
|
||||
void
|
||||
myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION con,
|
||||
unsigned long number){
|
||||
UInt number){
|
||||
con->total_number_queries = number;
|
||||
}
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
/* Auxilary function to table_write*/
|
||||
static void
|
||||
n_print(int n, char c)
|
||||
n_print(Int n, char c)
|
||||
{
|
||||
for(;n>0;n--) printf("%c",c);
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
void myddas_util_error_message(char *message,int line,char *file){
|
||||
void myddas_util_error_message(char *message ,Int line,char *file){
|
||||
#ifdef DEBUG
|
||||
printf ("ERROR: %s at line %d in file %s\n",message,line,file);
|
||||
printf ("ERROR: %s at line %d in file %s\n",message,(int)line,file);
|
||||
#else
|
||||
printf ("ERROR: %s\n",message);
|
||||
#endif
|
||||
}
|
||||
|
||||
static MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_find_predicate(char *pred_name, int pred_arity,
|
||||
myddas_util_find_predicate(char *pred_name, Int pred_arity,
|
||||
char *pred_module, MYDDAS_UTIL_PREDICATE list){
|
||||
|
||||
for(;list != NULL ; list = list->next)
|
||||
@ -255,7 +256,7 @@ myddas_util_table_write(MYSQL_RES *res_set){
|
||||
|
||||
MYSQL_ROW row;
|
||||
MYSQL_FIELD *fields;
|
||||
int i,f;
|
||||
Int i,f;
|
||||
|
||||
if (mysql_num_rows(res_set) == 0)
|
||||
{
|
||||
@ -319,11 +320,11 @@ myddas_util_table_write(MYSQL_RES *res_set){
|
||||
#endif
|
||||
|
||||
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
||||
int
|
||||
Int
|
||||
get_myddas_top(){
|
||||
if (Yap_regp->MYDDAS_GLOBAL_POINTER == NULL)
|
||||
if (Yap_REGS.MYDDAS_GLOBAL_POINTER == NULL)
|
||||
return 0;
|
||||
return (int)Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
return (Int)Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
}
|
||||
|
||||
void *
|
||||
@ -332,7 +333,7 @@ myddas_util_get_pred_next(void *pointer){
|
||||
return (void *) (temp->next);
|
||||
}
|
||||
|
||||
int
|
||||
Int
|
||||
myddas_util_get_pred_arity(void *pointer){
|
||||
MYDDAS_UTIL_PREDICATE temp = (MYDDAS_UTIL_PREDICATE) pointer;
|
||||
return temp->pred_arity;
|
||||
@ -357,9 +358,9 @@ myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION node){
|
||||
|
||||
#ifdef DEBUG
|
||||
void check_int(){
|
||||
int i;
|
||||
Int i;
|
||||
MYDDAS_UTIL_PREDICATE pred = NULL;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
MYDDAS_UTIL_CONNECTION top = Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
for (i=1 ; top!=NULL ; top=top->next)
|
||||
{
|
||||
printf ("***************\n");
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef __MYDDAS_UTIL_H__
|
||||
#define __MYDDAS_UTIL_H__
|
||||
|
||||
//#include "Yap.h"
|
||||
#include <stdio.h>
|
||||
#ifdef MYDDAS_ODBC
|
||||
#include <sql.h>
|
||||
@ -28,68 +29,4 @@ typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
|
||||
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;
|
||||
#endif
|
||||
|
||||
MYDDAS_GLOBAL
|
||||
myddas_util_initialize_myddas(void);
|
||||
|
||||
#ifdef MYDDAS_MYSQL
|
||||
void
|
||||
myddas_util_table_write(MYSQL_RES *);
|
||||
#endif
|
||||
|
||||
/* Returns the connection type (mysql -> 1 or odbc -> 2) */
|
||||
short int
|
||||
myddas_util_connection_type(void *);
|
||||
/* Adds a connection identifier to the MYDDAS connections list*/
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_add_connection(void *,void *);
|
||||
/* Search for the node of the specified connection*/
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_search_connection(void *);
|
||||
/* Deletes a connection node from the MYDDAS connections list*/
|
||||
void
|
||||
myddas_util_delete_connection(void *);
|
||||
|
||||
/* Adds a new predicate to it's connection node list*/
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_add_predicate(char *,int , char *,void *);
|
||||
/* Search for a predicate node*/
|
||||
MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_search_predicate(char *,int , char *);
|
||||
/* Deletes predicate from the prediate list */
|
||||
void
|
||||
myddas_util_delete_predicate(MYDDAS_UTIL_PREDICATE);
|
||||
|
||||
/* Get's the number of queries to save */
|
||||
unsigned long
|
||||
myddas_util_get_total_multi_queries_number(MYDDAS_UTIL_CONNECTION);
|
||||
void
|
||||
myddas_util_set_total_multi_queries_number(MYDDAS_UTIL_CONNECTION,unsigned long);
|
||||
|
||||
#ifdef MYDDAS_ODBC
|
||||
/* Return enviromment identifier*/
|
||||
SQLHENV
|
||||
myddas_util_get_odbc_enviromment(SQLHDBC);
|
||||
#endif
|
||||
|
||||
void *
|
||||
myddas_util_get_list_pred(MYDDAS_UTIL_CONNECTION);
|
||||
void *
|
||||
myddas_util_get_pred_next(void *);
|
||||
char *
|
||||
myddas_util_get_pred_module(void *);
|
||||
char *
|
||||
myddas_util_get_pred_name(void *);
|
||||
int
|
||||
myddas_util_get_pred_arity(void *);
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void check_int(void);
|
||||
#endif
|
||||
|
||||
|
||||
//DELETE THIS WHEN DB_STATS IS COMPLETED
|
||||
int
|
||||
get_myddas_top(void);
|
||||
|
||||
#endif /*__MYDDAS_UTIL_H__*/
|
||||
|
@ -273,7 +273,7 @@ db_stats(Connection,List):-
|
||||
|
||||
%compatibility
|
||||
db_sql_select(Connection,SQL,LA):-
|
||||
db_sql(Connection,SQL.LA).
|
||||
db_sql(Connection,SQL,LA).
|
||||
|
||||
db_sql(SQL,LA):-
|
||||
db_sql(myddas,SQL,LA).
|
||||
|
@ -138,7 +138,7 @@ db_view(Connection,PredName,DbGoal) :-
|
||||
% get arity of projection term
|
||||
functor(PredName,ViewName,Arity),
|
||||
db_module(Module),
|
||||
%not c_db_check_if_exists_pred(ViewName,Arity,Module),
|
||||
not c_db_check_if_exists_pred(ViewName,Arity,Module),
|
||||
|
||||
% This copy_term is done to prevent the unification
|
||||
% with top-level variables A='var('A')' error
|
||||
|
@ -21,12 +21,13 @@
|
||||
|
||||
:- use_module(myddas_util_predicates,[
|
||||
'$make_a_list'/2,
|
||||
'$check_fields'/2
|
||||
'$check_fields'/2,
|
||||
'$check_list_on_list'/2
|
||||
]).
|
||||
|
||||
:- use_module(lists,[
|
||||
is_list/1
|
||||
]).
|
||||
]).
|
||||
|
||||
|
||||
'$error_checks'(db_abolish(ModulePredName,Arity)):-!,
|
||||
@ -104,10 +105,14 @@
|
||||
nonvar(Password),
|
||||
atom(Connection),
|
||||
get_value(Connection,[]). % Nao pode ter nenhum valor atribuido
|
||||
'$error_checks'(db_view(Connection,PredName,DbGoal)) :- !,
|
||||
'$error_checks'(db_view(Connection,Pred,DbGoal)) :- !,
|
||||
atom(Connection),
|
||||
nonvar(DbGoal),
|
||||
nonvar(PredName).
|
||||
nonvar(Pred),
|
||||
nonvar(DbGoal),
|
||||
Pred =.. [_|PredArgs],
|
||||
DbGoal =.. [_|DbGoalArgs],
|
||||
'$check_list_on_list'(PredArgs,DbGoalArgs).
|
||||
'$error_checks'(db_import(Connection,RelationName,PredName)) :- !,
|
||||
atom(Connection),
|
||||
atom(RelationName),
|
||||
|
@ -15,6 +15,8 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifdef MYDDAS_TOP_LEVEL
|
||||
|
||||
:- module(myddas_top_level,[
|
||||
db_top_level/5,
|
||||
db_datalog_select/3
|
||||
@ -107,3 +109,5 @@ db_datalog_select(Connection,LA,DbGoal):-
|
||||
% set_value(Connection,Con),
|
||||
% db_my_result_set(Mode),
|
||||
% c_db_top_level(Con,Mode).
|
||||
|
||||
#endif MYDDAS_TOP_LEVEL
|
@ -37,7 +37,8 @@
|
||||
'$where_exists'/2,
|
||||
'$build_query'/5,
|
||||
'$assert_facts'/2,
|
||||
'$lenght'/2
|
||||
'$lenght'/2,
|
||||
'$check_list_on_list'/2
|
||||
]).
|
||||
|
||||
:- use_module(myddas,[
|
||||
@ -408,3 +409,13 @@
|
||||
'$lenght'([_|T],Sum):-
|
||||
'$lenght'(T,Num),
|
||||
Sum is Num + 1.
|
||||
|
||||
'$check_list_on_list'([],_).
|
||||
'$check_list_on_list'([H|T],DbGoalArgs) :-
|
||||
'$member_strick'(H,DbGoalArgs),
|
||||
'$check_list_on_list'(T,DbGoalArgs).
|
||||
|
||||
'$member_strick'(Element1, [Element2|_]) :-
|
||||
Element1 == Element2,!.
|
||||
'$member_strick'(Element, [_|Rest]) :-
|
||||
'$member_strick'(Element, Rest).
|
Reference in New Issue
Block a user