Changeset: 3c718fc138cf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3c718fc138cf
Modified Files:
monetdb5/extras/rapi/converters.c.h
monetdb5/extras/rapi/rapi.c
monetdb5/extras/rapi/rapi.h
Branch: cmake-fun
Log Message:
Compiling rapi on Windows.
diffs (94 lines):
diff --git a/monetdb5/extras/rapi/converters.c.h
b/monetdb5/extras/rapi/converters.c.h
--- a/monetdb5/extras/rapi/converters.c.h
+++ b/monetdb5/extras/rapi/converters.c.h
@@ -6,6 +6,11 @@
* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
*/
+//disable warning converting from double to int
+#ifdef _MSC_VER
+#pragma warning (disable:4244)
+#endif
+
#define RSTR(somestr) mkCharCE(somestr, CE_UTF8)
//Element-wise conversion functions, use no-op as passthrough when no
conversion required
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -45,6 +45,9 @@
# undef warning
#endif
+CREATE_SQL_FUNCTION_PTR(str, SQLstatementIntern);
+CREATE_SQL_FUNCTION_PTR(void, res_table_destroy);
+
/* we need the BAT-SEXP-BAT conversion in two places, here and in
tools/embedded */
#include "converters.c.h"
@@ -155,6 +158,14 @@ static char *RAPIinitialize(void) {
// install.packages() uses system2 to call gcc etc., so we cannot
disable it (perhaps store the pointer somewhere just for that?)
//SET_INTERNAL(install("system"), R_NilValue);
+ LOAD_SQL_FUNCTION_PTR(SQLstatementIntern);
+ if (e)
+ return e;
+
+ LOAD_SQL_FUNCTION_PTR(res_table_destroy);
+ if (e)
+ return e;
+
rapiInitialized = true;
return NULL;
}
@@ -482,7 +493,7 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
void* RAPIloopback(void *query) {
res_table* output = NULL;
char* querystr = (char*)CHAR(STRING_ELT(query, 0));
- char* err = SQLstatementIntern(rapiClient, &querystr, "name", 1, 0,
&output);
+ char* err = (*SQLstatementIntern_ptr)(rapiClient, &querystr, "name", 1,
0, &output);
if (err) { // there was an error
return ScalarString(RSTR(err));
@@ -506,12 +517,12 @@ void* RAPIloopback(void *query) {
SET_STRING_ELT(names, i,
RSTR(output->cols[i].name));
SET_VECTOR_ELT(retlist, i, varvalue);
}
- res_table_destroy(output);
+ (*res_table_destroy_ptr)(output);
SET_NAMES(retlist, names);
UNPROTECT(ncols + 2);
return retlist;
}
- res_table_destroy(output);
+ (*res_table_destroy_ptr)(output);
}
return ScalarLogical(1);
}
diff --git a/monetdb5/extras/rapi/rapi.h b/monetdb5/extras/rapi/rapi.h
--- a/monetdb5/extras/rapi/rapi.h
+++ b/monetdb5/extras/rapi/rapi.h
@@ -44,4 +44,23 @@ rapi_export void clearRErrConsole(void);
char* rtypename(int rtypeid);
+#if defined(WIN32) && !defined(HAVE_EMBEDDED)
+// On Windows we need to dynamically load any SQL functions we use
+// For embedded, this is not necessary because we create one large shared
object
+#define CREATE_SQL_FUNCTION_PTR(retval, fcnname)
\
+ typedef retval (*fcnname##_ptr_tpe)();
\
+ fcnname##_ptr_tpe fcnname##_ptr = NULL;
+
+#define LOAD_SQL_FUNCTION_PTR(fcnname)
\
+ fcnname##_ptr = (fcnname##_ptr_tpe)getAddress(#fcnname);
\
+ if (fcnname##_ptr == NULL)
\
+ e = createException(MAL, "rapi.initialize", SQLSTATE(PY000)
"Failed to load function %s", #fcnname);
+#else
+#define CREATE_SQL_FUNCTION_PTR(retval, fcnname)
\
+ typedef retval (*fcnname##_ptr_tpe)();
\
+ fcnname##_ptr_tpe fcnname##_ptr = (fcnname##_ptr_tpe)fcnname;
+
+#define LOAD_SQL_FUNCTION_PTR(fcnname) (void)fcnname
+#endif
+
#endif /* _RAPI_LIB_ */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list