Changeset: cb613d10da50 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cb613d10da50
Modified Files:
        sql/backends/monet5/UDF/pyapi/connection.c
        sql/backends/monet5/UDF/pyapi/pyapi.c
        sql/backends/monet5/UDF/pyapi/pyapi.h
Branch: default
Log Message:

No longer need to do dynamic function lookup.


diffs (171 lines):

diff --git a/sql/backends/monet5/UDF/pyapi/connection.c 
b/sql/backends/monet5/UDF/pyapi/connection.c
--- a/sql/backends/monet5/UDF/pyapi/connection.c
+++ b/sql/backends/monet5/UDF/pyapi/connection.c
@@ -9,9 +9,6 @@
 #define PyString_FromString PyUnicode_FromString
 #endif
 
-CREATE_SQL_FUNCTION_PTR(void,SQLdestroyResult,(res_table*));
-CREATE_SQL_FUNCTION_PTR(str,SQLstatementIntern,(Client, str *, str, int, bit, 
res_table **));
-
 static PyObject *
 _connection_execute(Py_ConnectionObject *self, PyObject *args)
 {
@@ -210,13 +207,13 @@ PyTypeObject Py_ConnectionType = {
 
 void _connection_cleanup_result(void* output) 
 {
-    (*SQLdestroyResult_ptr)((res_table*) output);
+    SQLdestroyResult((res_table*) output);
 }
 
 char* _connection_query(Client cntxt, char* query, res_table** result) {
     str res = MAL_SUCCEED;
     Client c = cntxt;
-    res = (*SQLstatementIntern_ptr)(c, &query, "name", 1, 0, result);
+    res = SQLstatementIntern(c, &query, "name", 1, 0, result);
     return res;
 }
 
@@ -247,9 +244,6 @@ str _connection_init(void)
     str msg = MAL_SUCCEED;
     _connection_import_array();
 
-    LOAD_SQL_FUNCTION_PTR(SQLdestroyResult, "lib_sql.dll");
-    LOAD_SQL_FUNCTION_PTR(SQLstatementIntern, "lib_sql.dll");
-
     if (msg != MAL_SUCCEED) {
         return msg;
     }
diff --git a/sql/backends/monet5/UDF/pyapi/pyapi.c 
b/sql/backends/monet5/UDF/pyapi/pyapi.c
--- a/sql/backends/monet5/UDF/pyapi/pyapi.c
+++ b/sql/backends/monet5/UDF/pyapi/pyapi.c
@@ -96,17 +96,6 @@ static char* FunctionBasePath(void) {
     return basepath;
 }
 
-CREATE_SQL_FUNCTION_PTR(str,batbte_dec2_dbl,(bat*, int*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,batsht_dec2_dbl,(bat*, int*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,batint_dec2_dbl,(bat*, int*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,batlng_dec2_dbl,(bat*, int*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,bathge_dec2_dbl,(bat*, int*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,batstr_2time_timestamp,(bat*, bat*, int*));
-CREATE_SQL_FUNCTION_PTR(str,batstr_2time_daytime,(bat*, bat*, int*));
-CREATE_SQL_FUNCTION_PTR(str,batstr_2_date,(bat*, bat*));
-CREATE_SQL_FUNCTION_PTR(str,batdbl_num2dec_lng,(bat*, bat*, int*,int*));
-CREATE_SQL_FUNCTION_PTR(str,SQLbatstr_cast,(Client, MalBlkPtr, MalStkPtr, 
InstrPtr));
-
 static MT_Lock pyapiLock;
 static MT_Lock queryLock;
 static int pyapiInitialized = FALSE;
@@ -1585,19 +1574,6 @@ str
                 return createException(MAL, "pyapi.eval", "Failed to load 
function \"loads\" from Marshal module.");
             }
             PyEval_SaveThread();
-            LOAD_SQL_FUNCTION_PTR(batbte_dec2_dbl, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batsht_dec2_dbl, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batint_dec2_dbl, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batlng_dec2_dbl, "lib_sql.dll");
-#ifdef HAVE_HGE
-            LOAD_SQL_FUNCTION_PTR(bathge_dec2_dbl, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(bathge_dec2_dbl, "lib_sql.dll");
-#endif
-            LOAD_SQL_FUNCTION_PTR(batstr_2time_timestamp, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batstr_2time_daytime, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batstr_2_date, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(batdbl_num2dec_lng, "lib_sql.dll");
-            LOAD_SQL_FUNCTION_PTR(SQLbatstr_cast, "lib_sql.dll");
             if (msg != MAL_SUCCEED) {
                 MT_lock_unset(&pyapiLock);
                 return msg;
@@ -2651,7 +2627,7 @@ str ConvertFromSQLType(Client cntxt, BAT
         stk->stk[6].val.ival = digits;
         stk->stk[6].vtype = TYPE_int;
 
-        res = (*SQLbatstr_cast_ptr)(cntxt, &mb, stk, pci);
+        res = SQLbatstr_cast(cntxt, &mb, stk, pci);
 
         if (res == MAL_SUCCEED) {
             *ret_bat = BATdescriptor(stk->stk[0].val.bval);
@@ -2673,20 +2649,20 @@ str ConvertFromSQLType(Client cntxt, BAT
         switch(bat_type) 
         {
             case TYPE_bte:
-                res = (*batbte_dec2_dbl_ptr)(&result, &hpos, &b->batCacheid);
+                res = batbte_dec2_dbl(&result, &hpos, &b->batCacheid);
                 break;
             case TYPE_sht:
-                res = (*batsht_dec2_dbl_ptr)(&result, &hpos, &b->batCacheid);
+                res = batsht_dec2_dbl(&result, &hpos, &b->batCacheid);
                 break;
             case TYPE_int:
-                res = (*batint_dec2_dbl_ptr)(&result, &hpos, &b->batCacheid);
+                res = batint_dec2_dbl(&result, &hpos, &b->batCacheid);
                 break;
             case TYPE_lng:
-                res = (*batlng_dec2_dbl_ptr)(&result, &hpos, &b->batCacheid);
+                res = batlng_dec2_dbl(&result, &hpos, &b->batCacheid);
                 break;
 #ifdef HAVE_HGE
             case TYPE_hge:
-                res = (*bathge_dec2_dbl_ptr)(&result, &hpos, &b->batCacheid);
+                res = bathge_dec2_dbl(&result, &hpos, &b->batCacheid);
                 break;
 #endif
             default: 
@@ -2718,16 +2694,16 @@ ConvertToSQLType(Client cntxt, BAT *b, s
     switch(sql_subtype->type->eclass)
     {
         case EC_TIMESTAMP:
-            res = (*batstr_2time_timestamp_ptr)(&result_bat, &b->batCacheid, 
&digits);
+            res = batstr_2time_timestamp(&result_bat, &b->batCacheid, &digits);
             break;
         case EC_TIME:
-            res = (*batstr_2time_daytime_ptr)(&result_bat, &b->batCacheid, 
&digits);
+            res = batstr_2time_daytime(&result_bat, &b->batCacheid, &digits);
             break;
         case EC_DATE:
-            res = (*batstr_2_date_ptr)(&result_bat, &b->batCacheid);
+            res = batstr_2_date(&result_bat, &b->batCacheid);
             break;
         case EC_DEC:
-            res = (*batdbl_num2dec_lng_ptr)(&result_bat, &b->batCacheid, 
&digits, &scale);
+            res = batdbl_num2dec_lng(&result_bat, &b->batCacheid, &digits, 
&scale);
             break;
         default: 
             return createException(MAL, "pyapi.eval", "Convert To SQL Type: 
Unrecognized SQL type %s (%d).", sql_subtype->type->sqlname, 
sql_subtype->type->eclass);
@@ -2872,14 +2848,4 @@ bool Python_ReleaseGIL(bool state)
     return 0;
 }
 
-void* lookup_function(char *func, char* library) {
-    void *dl, *fun;
-    dl = mdlopen(library, RTLD_NOW | RTLD_GLOBAL);
-    if (dl == NULL) {
-        return NULL;
-    }
-    fun = dlsym(dl, func);
-    dlclose(dl);
-    return fun;
-}
 
diff --git a/sql/backends/monet5/UDF/pyapi/pyapi.h 
b/sql/backends/monet5/UDF/pyapi/pyapi.h
--- a/sql/backends/monet5/UDF/pyapi/pyapi.h
+++ b/sql/backends/monet5/UDF/pyapi/pyapi.h
@@ -101,16 +101,4 @@ pyapi_export str PyAPIprelude(void *ret)
 
 int PyAPIEnabled(void);
 
-pyapi_export void* lookup_function(char *func, char* library);
-
-#define CREATE_SQL_FUNCTION_PTR(retval, fcnname, params) \
-    typedef retval (*fcnname##_ptr_tpe)params;                   \
-    fcnname##_ptr_tpe fcnname##_ptr = NULL;
-
-#define LOAD_SQL_FUNCTION_PTR(fcnname,libname)                                 
  \
-    fcnname##_ptr = (fcnname##_ptr_tpe) lookup_function(#fcnname, libname);    
    \
-    if (fcnname##_ptr == NULL) {                                         \
-        msg = createException(MAL, "pyapi.eval", "Failed to load function %s", 
#fcnname); \
-    }
-
 #endif /* _PYPI_LIB_ */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to