Changeset: 17e2c46e5d22 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=17e2c46e5d22
Added Files:
sql/jdbc/tests/Tests/Test_CallableStmt.SQL.bat
sql/jdbc/tests/Tests/Test_CallableStmt.SQL.sh
sql/jdbc/tests/Tests/Test_CallableStmt.stable.err
sql/jdbc/tests/Tests/Test_CallableStmt.stable.out
Modified Files:
clients/Tests/exports.stable.out
configure.ag
gdk/gdk_posix.c
gdk/gdk_system.h
monetdb5/mal/mal_interpreter.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/remote.h
sql/backends/monet5/UDF/pyapi/pyapi.c
sql/backends/monet5/UDF/pyapi/pyapi.h
sql/jdbc/tests/Tests/All
Branch: default
Log Message:
Merge with Apr2019 branch.
diffs (truncated from 764 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1721,7 +1721,6 @@ str RMTisalive(int *ret, str *conn);
str RMTprelude(void *ret);
str RMTput(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str RMTregister(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str RMTregisterInternal(Client cntxt, str conn, str mod, str fcn);
str RMTregisterSupervisor(int *ret, str *sup_uuid, str *query_uuid);
str RMTresolve(bat *ret, str *pat);
str RUNadder(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2564,6 +2564,7 @@ AC_CHECK_FUNCS([\
lockf \
madvise \
mremap \
+ nanosleep \
nl_langinfo \
_NSGetExecutablePath \
pipe2 \
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -1099,11 +1099,15 @@ win_mkdir(const char *pathname, const in
void
MT_sleep_ms(unsigned int ms)
{
- struct timeval tv;
-
- tv.tv_sec = ms / 1000;
- tv.tv_usec = 1000 * (ms % 1000);
- (void) select(0, NULL, NULL, NULL, &tv);
+#ifdef HAVE_NANOSLEEP
+ (void) nanosleep(&(struct timespec) {.tv_sec = ms / 1000,
+ .tv_nsec = ms == 1 ? 1000 : (long) (ms % 1000)
* 1000000,},
+ NULL);
+#else
+ (void) select(0, NULL, NULL, NULL,
+ &(struct timeval) {.tv_sec = ms / 1000,
+ .tv_usec = ms == 1 ? 1 : (ms % 1000) *
1000,});
+#endif
}
#else /* WIN32 */
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -199,12 +199,7 @@ gdk_export int MT_join_thread(MT_Id t);
(void) ATOMIC_INC(&(l)->contention); \
} while (0)
-#define _DBG_LOCK_SLEEP(l) \
- do { \
- if (_spincnt == 1024) \
- (void) ATOMIC_INC(&GDKlocksleepcnt); \
- (void) ATOMIC_INC(&(l)->sleep); \
- } while (0)
+#define _DBG_LOCK_SLEEP(l) ((void) ATOMIC_INC(&(l)->sleep))
#define _DBG_LOCK_COUNT_2(l) \
do { \
@@ -328,9 +323,10 @@ MT_lock_try(MT_Lock *l)
if (!MT_lock_try(l)) { \
_DBG_LOCK_CONTENTION(l); \
MT_thread_setlockwait(l); \
+ do \
+ _DBG_LOCK_SLEEP(l); \
while (WaitForSingleObject( \
- (l)->lock, INFINITE) != WAIT_OBJECT_0) \
- ; \
+ (l)->lock, INFINITE) != WAIT_OBJECT_0); \
MT_thread_setlockwait(NULL); \
} \
_DBG_LOCK_LOCKER(l); \
@@ -389,8 +385,9 @@ typedef struct MT_Lock {
if (!MT_lock_try(l)) { \
_DBG_LOCK_CONTENTION(l); \
MT_thread_setlockwait(l); \
- while (pthread_mutex_lock(&(l)->lock) != 0) \
- ; \
+ do \
+ _DBG_LOCK_SLEEP(l); \
+ while (pthread_mutex_lock(&(l)->lock) != 0); \
MT_thread_setlockwait(NULL); \
} \
_DBG_LOCK_LOCKER(l); \
@@ -441,15 +438,12 @@ typedef struct MT_Lock {
_DBG_LOCK_COUNT_0(l); \
if (!MT_lock_try(l)) { \
/* we didn't get the lock */ \
- int _spincnt = GDKnr_threads > 1 ? 0 : 1023; \
_DBG_LOCK_CONTENTION(l); \
MT_thread_setlockwait(l); \
do { \
- if (++_spincnt >= 1024) { \
- _DBG_LOCK_SLEEP(l); \
- MT_sleep_ms(1); \
- } \
- } while (ATOMIC_TAS(&(l)->lock) != 0); \
+ _DBG_LOCK_SLEEP(l); \
+ MT_sleep_ms(1); \
+ } while (!MT_lock_try(l)); \
MT_thread_setlockwait(NULL); \
} \
_DBG_LOCK_LOCKER(l); \
@@ -464,10 +458,12 @@ typedef struct MT_Lock {
_DBG_LOCK_INIT(l); \
} while (0)
-#define MT_lock_unset(l) \
- do { \
- _DBG_LOCK_UNLOCKER(l); \
- ATOMIC_CLEAR(&(l)->lock); \
+#define MT_lock_unset(l) \
+ do { \
+ /* lock should be locked */ \
+ assert(ATOMIC_TAS(&(l)->lock) != 0); \
+ _DBG_LOCK_UNLOCKER(l); \
+ ATOMIC_CLEAR(&(l)->lock); \
} while (0)
#define MT_lock_destroy(l) _DBG_LOCK_DESTROY(l)
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -644,6 +644,34 @@ str runMALsequence(Client cntxt, MalBlkP
} else {
ret = (*pci->fcn)(cntxt, mb, stk, pci);
#ifndef NDEBUG
+ if (ret == MAL_SUCCEED) {
+ /* check that the types of actual
results match
+ * expected results */
+ for (i = 0; i < pci->retc; i++) {
+ int a = getArg(pci, i);
+ int t = getArgType(mb, pci, i);
+
+ if (isaBatType(t)) {
+ bat bid =
stk->stk[a].val.bval;
+ BAT *_b =
BATdescriptor(bid);
+ t = getBatType(t);
+
assert(stk->stk[a].vtype == TYPE_bat);
+ assert(is_bat_nil(bid)
||
+ t ==
TYPE_any ||
+
ATOMtype(_b->ttype) == ATOMtype(t));
+ if(_b) BBPunfix(bid);
+ } else {
+ assert(t ==
stk->stk[a].vtype);
+ }
+ }
+ }
+#endif
+ }
+ break;
+ case CMDcall:
+ ret = malCommandCall(stk, pci);
+#ifndef NDEBUG
+ if (ret == MAL_SUCCEED) {
/* check that the types of actual results match
* expected results */
for (i = 0; i < pci->retc; i++) {
@@ -652,39 +680,15 @@ str runMALsequence(Client cntxt, MalBlkP
if (isaBatType(t)) {
bat bid = stk->stk[a].val.bval;
- BAT *_b = BATdescriptor(bid);
t = getBatType(t);
assert(stk->stk[a].vtype ==
TYPE_bat);
assert(is_bat_nil(bid) ||
t == TYPE_any ||
- ATOMtype(_b->ttype)
== ATOMtype(t));
- if(_b) BBPunfix(bid);
+
ATOMtype(BBP_desc(bid)->ttype) == ATOMtype(t));
} else {
assert(t == stk->stk[a].vtype);
}
}
-#endif
- }
- break;
- case CMDcall:
- ret = malCommandCall(stk, pci);
-#ifndef NDEBUG
- /* check that the types of actual results match
- * expected results */
- for (i = 0; i < pci->retc; i++) {
- int a = getArg(pci, i);
- int t = getArgType(mb, pci, i);
-
- if (isaBatType(t)) {
- bat bid = stk->stk[a].val.bval;
- t = getBatType(t);
- assert(stk->stk[a].vtype == TYPE_bat);
- assert(is_bat_nil(bid) ||
- t == TYPE_any ||
-
ATOMtype(BBP_desc(bid)->ttype) == ATOMtype(t));
- } else {
- assert(t == stk->stk[a].vtype);
- }
}
#endif
break;
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -74,7 +74,7 @@
static connection conns = NULL;
static unsigned char localtype = 0177;
-static inline str RMTquery(MapiHdl *ret, str func, Mapi conn, str query);
+static inline str RMTquery(MapiHdl *ret, const char *func, Mapi conn, const
char *query);
static inline str RMTinternalcopyfrom(BAT **ret, char *hdr, stream *in);
/**
@@ -220,6 +220,7 @@ str RMTconnectScen(
}
c->mconn = m;
c->nextid = 0;
+ MT_lock_init(&c->lock, c->name);
c->next = conns;
conns = c;
@@ -234,8 +235,6 @@ str RMTconnectScen(
c->type = 0;
}
- MT_lock_init(&c->lock, "remconlock");
-
#ifdef _DEBUG_MAPI_
mapi_trace(c->mconn, true);
#endif
@@ -368,7 +367,7 @@ str RMTdisconnect(void *ret, str *conn)
* NOTE: this function acquires the mal_remoteLock before accessing conns
*/
static inline str
-RMTfindconn(connection *ret, str conn) {
+RMTfindconn(connection *ret, const char *conn) {
connection c;
/* just make sure the return isn't garbage */
@@ -431,7 +430,7 @@ RMTgetId(char *buf, MalBlkPtr mb, InstrP
* NOTE: this function assumes a lock for conn is set
*/
static inline str
-RMTquery(MapiHdl *ret, str func, Mapi conn, str query) {
+RMTquery(MapiHdl *ret, const char *func, Mapi conn, const char *query) {
MapiHdl mhdl;
*ret = NULL;
@@ -524,6 +523,7 @@ str RMTget(Client cntxt, MalBlkPtr mb, M
ValPtr v;
(void)mb;
+ (void) cntxt;
conn = *getArgReference_str(stk, pci, 1);
if (conn == NULL || strcmp(conn, (str)str_nil) == 0)
@@ -572,8 +572,6 @@ str RMTget(Client cntxt, MalBlkPtr mb, M
snprintf(qbuf, BUFSIZ, "io.print(%s);", ident);
#ifdef _DEBUG_REMOTE
fprintf(stderr, "#remote.get:%s\n", qbuf);
-#else
- (void) cntxt;
#endif
/* this call should be a single transaction over the channel*/
MT_lock_set(&c->lock);
@@ -587,19 +585,24 @@ str RMTget(Client cntxt, MalBlkPtr mb, M
#endif
MT_lock_unset(&c->lock);
var = createException(MAL, "remote.get", "%s", tmp);
- GDKfree(tmp);
+ freeException(tmp);
return var;
}
t = getBatType(rtype);
b = COLnew(0, t, 0, TRANSIENT);
- if (b == NULL)
+ if (b == NULL) {
+ mapi_close_handle(mhdl);
+ MT_lock_unset(&c->lock);
throw(MAL, "remote.get", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+ }
if (ATOMvarsized(t)) {
while (mapi_fetch_row(mhdl)) {
var = mapi_fetch_field(mhdl, 1);
if (BUNappend(b, var == NULL ? str_nil : var,
false) != GDK_SUCCEED) {
BBPreclaim(b);
+ mapi_close_handle(mhdl);
+ MT_lock_unset(&c->lock);
throw(MAL, "remote.get",
SQLSTATE(HY001) MAL_MALLOC_FAIL);
}
}
@@ -614,6 +617,8 @@ str RMTget(Client cntxt, MalBlkPtr mb, M
BUNappend(b, r, false) != GDK_SUCCEED) {
BBPreclaim(b);
GDKfree(r);
+ mapi_close_handle(mhdl);
+ MT_lock_unset(&c->lock);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list