Changeset: aafd083cd04e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aafd083cd04e
Modified Files:
sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
sql/backends/monet5/UDF/pyapi3/connection3.c
sql/backends/monet5/UDF/pyapi3/conversion3.c
sql/backends/monet5/UDF/pyapi3/pyheader.h
tools/mserver/CMakeLists.txt
tools/mserver/shutdowntest.c
Branch: oscar
Log Message:
Don't use dynamic lookup in shared objects if you can just link.
diffs (282 lines):
diff --git a/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
b/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
--- a/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
+++ b/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
@@ -46,6 +46,7 @@ if(HAVE_LIBPY3)
PRIVATE
Python3::Python
$<$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.14.0>:Python3::NumPy>
+ sql
mutils
stream
gdk
diff --git a/sql/backends/monet5/UDF/pyapi3/connection3.c
b/sql/backends/monet5/UDF/pyapi3/connection3.c
--- a/sql/backends/monet5/UDF/pyapi3/connection3.c
+++ b/sql/backends/monet5/UDF/pyapi3/connection3.c
@@ -13,11 +13,6 @@
#include "type_conversion.h"
#include "gdk_interprocess.h"
-CREATE_SQL_FUNCTION_PTR(void, SQLdestroyResult);
-CREATE_SQL_FUNCTION_PTR(str, SQLstatementIntern);
-CREATE_SQL_FUNCTION_PTR(str, create_table_from_emit);
-CREATE_SQL_FUNCTION_PTR(str, append_to_table_from_emit);
-
static PyObject *_connection_execute(Py_ConnectionObject *self, PyObject *args)
{
char *query = NULL;
@@ -118,26 +113,26 @@ PyTypeObject Py_ConnectionType = {
void _connection_cleanup_result(void *output)
{
- (*SQLdestroyResult_ptr)((res_table *)output);
+ SQLdestroyResult((res_table *)output);
}
str _connection_query(Client cntxt, char *query, res_table **result)
{
str res = MAL_SUCCEED;
- res = (*SQLstatementIntern_ptr)(cntxt, &query, "name", 1, 0, result);
+ res = SQLstatementIntern(cntxt, &query, "name", 1, 0, result);
return res;
}
str _connection_create_table(Client cntxt, char *sname, char *tname,
sql_emit_col *columns,
size_t ncols)
{
- return (*create_table_from_emit_ptr)(cntxt, sname, tname, columns,
ncols);
+ return create_table_from_emit(cntxt, sname, tname, columns, ncols);
}
str _connection_append_to_table(Client cntxt, char *sname, char *tname,
sql_emit_col *columns,
size_t ncols)
{
- return (*append_to_table_from_emit_ptr)(cntxt, sname, tname, columns,
ncols);
+ return append_to_table_from_emit(cntxt, sname, tname, columns, ncols);
}
PyObject *Py_Connection_Create(Client cntxt, bit mapped, QueryStruct
*query_ptr,
@@ -165,11 +160,6 @@ str _connection_init(void)
str msg = MAL_SUCCEED;
_connection_import_array();
- LOAD_SQL_FUNCTION_PTR(SQLdestroyResult);
- LOAD_SQL_FUNCTION_PTR(SQLstatementIntern);
- LOAD_SQL_FUNCTION_PTR(create_table_from_emit);
- LOAD_SQL_FUNCTION_PTR(append_to_table_from_emit);
-
if (msg != MAL_SUCCEED) {
return msg;
}
diff --git a/sql/backends/monet5/UDF/pyapi3/conversion3.c
b/sql/backends/monet5/UDF/pyapi3/conversion3.c
--- a/sql/backends/monet5/UDF/pyapi3/conversion3.c
+++ b/sql/backends/monet5/UDF/pyapi3/conversion3.c
@@ -15,18 +15,6 @@
#include "blob.h"
#include "gdk_interprocess.h"
-CREATE_SQL_FUNCTION_PTR(str, batbte_dec2_dbl);
-CREATE_SQL_FUNCTION_PTR(str, batsht_dec2_dbl);
-CREATE_SQL_FUNCTION_PTR(str, batint_dec2_dbl);
-CREATE_SQL_FUNCTION_PTR(str, batlng_dec2_dbl);
-#ifdef HAVE_HGE
-CREATE_SQL_FUNCTION_PTR(str, bathge_dec2_dbl);
-#endif
-CREATE_SQL_FUNCTION_PTR(str, batstr_2time_timestamp);
-CREATE_SQL_FUNCTION_PTR(str, batstr_2time_daytime);
-CREATE_SQL_FUNCTION_PTR(str, batstr_2_date);
-CREATE_SQL_FUNCTION_PTR(str, batdbl_num2dec_lng);
-
//! Wrapper to get eclass of SQL type
int GetSQLType(sql_subtype *sql_subtype);
@@ -1127,20 +1115,20 @@ str ConvertFromSQLType(BAT *b, sql_subty
// numeric field and convert the one it's actually stored in
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:
@@ -1172,19 +1160,17 @@ str ConvertToSQLType(Client cntxt, BAT *
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(
@@ -1242,16 +1228,5 @@ str _conversion_init(void)
str msg = MAL_SUCCEED;
conversion_import_array();
- LOAD_SQL_FUNCTION_PTR(batbte_dec2_dbl);
- LOAD_SQL_FUNCTION_PTR(batsht_dec2_dbl);
- LOAD_SQL_FUNCTION_PTR(batint_dec2_dbl);
- LOAD_SQL_FUNCTION_PTR(batlng_dec2_dbl);
-#ifdef HAVE_HGE
- LOAD_SQL_FUNCTION_PTR(bathge_dec2_dbl);
-#endif
- LOAD_SQL_FUNCTION_PTR(batstr_2time_timestamp);
- LOAD_SQL_FUNCTION_PTR(batstr_2time_daytime);
- LOAD_SQL_FUNCTION_PTR(batstr_2_date);
- LOAD_SQL_FUNCTION_PTR(batdbl_num2dec_lng);
return msg;
}
diff --git a/sql/backends/monet5/UDF/pyapi3/pyheader.h
b/sql/backends/monet5/UDF/pyapi3/pyheader.h
--- a/sql/backends/monet5/UDF/pyapi3/pyheader.h
+++ b/sql/backends/monet5/UDF/pyapi3/pyheader.h
@@ -77,28 +77,6 @@
#define PythonUnicodeType Py_UNICODE
#define PYFUNCNAME(name) PYAPI3##name
-#if defined(WIN32)
-// 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) {
\
- msg = createException(MAL, "pyapi3.eval", 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
-
#define utf8string_minlength 256
#endif /* _PYHEADER_H_ */
diff --git a/tools/mserver/CMakeLists.txt b/tools/mserver/CMakeLists.txt
--- a/tools/mserver/CMakeLists.txt
+++ b/tools/mserver/CMakeLists.txt
@@ -56,6 +56,7 @@ target_link_libraries(shutdowntest
monetdb_config_header
matomic
moptions
+ sql
mutils
mcrypt
gdk
diff --git a/tools/mserver/shutdowntest.c b/tools/mserver/shutdowntest.c
--- a/tools/mserver/shutdowntest.c
+++ b/tools/mserver/shutdowntest.c
@@ -24,22 +24,6 @@
static char* dbdir = NULL;
-#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(getName("sql"), #fcnname); \
- if (fcnname##_ptr == NULL) {
\
- retval = #fcnname; \
- }
-
-CREATE_SQL_FUNCTION_PTR(int,SQLautocommit);
-CREATE_SQL_FUNCTION_PTR(str,SQLexitClient);
-CREATE_SQL_FUNCTION_PTR(str,SQLinitClient);
-CREATE_SQL_FUNCTION_PTR(str,SQLstatementIntern);
-CREATE_SQL_FUNCTION_PTR(void,SQLdestroyResult);
-
static int monetdb_initialized = 0;
static void* monetdb_connect(void) {
@@ -52,7 +36,7 @@ static void* monetdb_connect(void) {
return NULL;
}
conn->curmodule = conn->usermodule = userModule();
- if ((*SQLinitClient_ptr)(conn) != MAL_SUCCEED) {
+ if (SQLinitClient(conn) != MAL_SUCCEED) {
return NULL;
}
((backend *) conn->sqlcontext)->mvc->session->auto_commit = 1;
@@ -64,11 +48,11 @@ static str monetdb_query(Client c, str q
mvc* m = ((backend *) c->sqlcontext)->mvc;
res_table* res = NULL;
int i;
- retval = (*SQLstatementIntern_ptr)(c,
+ retval = SQLstatementIntern(c,
&query,
"name",
1, 0, &res);
- (*SQLautocommit_ptr)(m);
+ SQLautocommit(m);
if (retval != MAL_SUCCEED) {
printf("Failed to execute SQL query: %s\n", query);
freeException(retval);
@@ -82,7 +66,7 @@ static str monetdb_query(Client c, str q
printf("%s", res->cols[i].name);
printf(i + 1 == res->nr_cols ? ")\n" : ",");
}
- (*SQLdestroyResult_ptr)(res);
+ SQLdestroyResult(res);
}
return MAL_SUCCEED;
}
@@ -91,7 +75,7 @@ static void monetdb_disconnect(void* con
if (!MCvalid((Client) conn)) {
return;
}
- (*SQLexitClient_ptr)((Client) conn);
+ SQLexitClient((Client) conn);
MCcloseClient((Client) conn);
}
@@ -278,12 +262,6 @@ static str monetdb_initialize(void) {
}
GDKfataljumpenable = 0;
- LOAD_SQL_FUNCTION_PTR(SQLautocommit);
- LOAD_SQL_FUNCTION_PTR(SQLexitClient);
- LOAD_SQL_FUNCTION_PTR(SQLinitClient);
- LOAD_SQL_FUNCTION_PTR(SQLstatementIntern);
- LOAD_SQL_FUNCTION_PTR(SQLdestroyResult);
-
if (retval != MAL_SUCCEED) {
printf("Failed to load SQL function: %s\n", retval);
retval = GDKstrdup(retval);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list