Changeset: 9595a5fa57eb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9595a5fa57eb
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_bat.c
gdk/gdk_utils.c
gdk/gdk_utils.h
monetdb5/mal/mal_client.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_session.c
monetdb5/modules/mal/inspect.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/mdb.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/UDF/pyapi/pyapi.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_scenario.c
tools/mserver/mserver5.c
tools/mserver/shutdowntest.c
Branch: mdbl-mal
Log Message:
Merge with default.
diffs (truncated from 555 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
@@ -232,6 +232,7 @@ size_t GDKbatread(char *src, BAT **bat,
gdk_return GDKchangesemval(int sem_id, int number, int change);
gdk_return GDKchangesemval_timeout(int sem_id, int number, int change, int
timeout_mseconds, bool *succeed);
void GDKclrerr(void);
+gdk_return GDKcopyenv(BAT **key, BAT **val, bool writable);
gdk_return GDKcreatedir(const char *nme);
gdk_return GDKcreatesem(int id, int count, int *semid);
int GDKdebug;
@@ -247,7 +248,7 @@ bit GDKfataljumpenable;
str GDKfatalmsg;
char *GDKfilepath(int farmid, const char *dir, const char *nme, const char
*ext);
void GDKfree(void *blk);
-char *GDKgetenv(const char *name);
+const char *GDKgetenv(const char *name);
int GDKgetenv_int(const char *name, int def);
bool GDKgetenv_istext(const char *name, const char *text);
bool GDKgetenv_istrue(const char *name);
@@ -256,7 +257,6 @@ gdk_return GDKgetsem(int sem_id, int cou
gdk_return GDKgetsemval(int sem_id, int number, int *semval);
gdk_return GDKinit(opt *set, int setlen);
void *GDKinitmmap(size_t id, size_t size, size_t *return_size);
-BAT *GDKkey;
ATOMIC_TYPE volatile GDKlockcnt;
ATOMIC_TYPE volatile GDKlockcontentioncnt;
MT_Lock *volatile GDKlocklist;
@@ -286,7 +286,6 @@ void GDKsyserror(_In_z_ _Printf_format_s
size_t GDKuniqueid(size_t offset);
gdk_return GDKupgradevarheap(BAT *b, var_t v, bool copyall, bool mayshare)
__attribute__((__warn_unused_result__));
lng GDKusec(void);
-BAT *GDKval;
const char *GDKversion(void);
size_t GDKvm_cursize(void);
void *GDKzalloc(size_t size) __attribute__((__malloc__))
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1475,7 +1475,7 @@ BUNfnd(BAT *b, const void *v)
BUN r = BUN_NONE;
BATiter bi;
- BATcheck(b, "BUNfnd", 0);
+ BATcheck(b, "BUNfnd", BUN_NONE);
if (!v)
return r;
if (BATtvoid(b))
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -20,8 +20,8 @@
#include "gdk_private.h"
#include "mutils.h"
-BAT *GDKkey = NULL;
-BAT *GDKval = NULL;
+static BAT *GDKkey = NULL;
+static BAT *GDKval = NULL;
int GDKdebug = 0;
static char THRprintbuf[BUFSIZ];
@@ -92,14 +92,16 @@ GDKenvironment(const char *dbpath)
return true;
}
-char *
+const char *
GDKgetenv(const char *name)
{
- BUN b = BUNfnd(GDKkey, (ptr) name);
+ if (GDKkey && GDKval) {
+ BUN b = BUNfnd(GDKkey, (ptr) name);
- if (b != BUN_NONE) {
- BATiter GDKenvi = bat_iterator(GDKval);
- return BUNtvar(GDKenvi, b);
+ if (b != BUN_NONE) {
+ BATiter GDKenvi = bat_iterator(GDKval);
+ return BUNtvar(GDKenvi, b);
+ }
}
return NULL;
}
@@ -127,7 +129,7 @@ GDKgetenv_istrue(const char *name)
int
GDKgetenv_int(const char *name, int def)
{
- char *val = GDKgetenv(name);
+ const char *val = GDKgetenv(name);
if (val)
return atoi(val);
@@ -143,6 +145,27 @@ GDKsetenv(const char *name, const char *
return GDK_SUCCEED;
}
+gdk_return
+GDKcopyenv(BAT **key, BAT **val, bool writable)
+{
+ BAT *k, *v;
+
+ if (key == NULL || val == NULL) {
+ GDKerror("GDKcopyenv: called incorrectly.\n");
+ return GDK_FAIL;
+ }
+ k = COLcopy(GDKkey, GDKkey->ttype, writable, TRANSIENT);
+ v = COLcopy(GDKval, GDKval->ttype, writable, TRANSIENT);
+ if (k == NULL || v == NULL) {
+ BBPreclaim(k);
+ BBPreclaim(v);
+ return GDK_FAIL;
+ }
+ *key = k;
+ *val = v;
+ return GDK_SUCCEED;
+}
+
/*
* @+ System logging
@@ -407,28 +430,38 @@ gdk_return
GDKinit(opt *set, int setlen)
{
char *dbpath = mo_find_option(set, setlen, "gdk_dbpath");
- char *p;
+ const char *p;
opt *n;
int i, nlen = 0;
int farmid;
char buf[16];
/* some sanity checks (should also find if symbols are not defined) */
- static_assert(sizeof(char) == SIZEOF_CHAR, "error in configure: bad
value for SIZEOF_CHAR");
- static_assert(sizeof(short) == SIZEOF_SHORT, "error in configure: bad
value for SIZEOF_SHORT");
- static_assert(sizeof(int) == SIZEOF_INT, "error in configure: bad value
for SIZEOF_INT");
- static_assert(sizeof(long) == SIZEOF_LONG, "error in configure: bad
value for SIZEOF_LONG");
- static_assert(sizeof(lng) == SIZEOF_LNG, "error in configure: bad value
for SIZEOF_LNG");
+ static_assert(sizeof(char) == SIZEOF_CHAR,
+ "error in configure: bad value for SIZEOF_CHAR");
+ static_assert(sizeof(short) == SIZEOF_SHORT,
+ "error in configure: bad value for SIZEOF_SHORT");
+ static_assert(sizeof(int) == SIZEOF_INT,
+ "error in configure: bad value for SIZEOF_INT");
+ static_assert(sizeof(long) == SIZEOF_LONG,
+ "error in configure: bad value for SIZEOF_LONG");
+ static_assert(sizeof(lng) == SIZEOF_LNG,
+ "error in configure: bad value for SIZEOF_LNG");
#ifdef HAVE_HGE
- static_assert(sizeof(hge) == SIZEOF_HGE, "error in configure: bad value
for SIZEOF_HGE");
+ static_assert(sizeof(hge) == SIZEOF_HGE,
+ "error in configure: bad value for SIZEOF_HGE");
#endif
- static_assert(sizeof(oid) == SIZEOF_OID, "error in configure: bad value
for SIZEOF_OID");
- static_assert(sizeof(void *) == SIZEOF_VOID_P, "error in configure: bad
value for SIZEOF_VOID_P");
- static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "error in configure: bad
value for SIZEOF_SIZE_T");
- static_assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG,
"SIZEOF_OID should be equal to SIZEOF_INT or SIZEOF_LNG");
+ static_assert(sizeof(oid) == SIZEOF_OID,
+ "error in configure: bad value for SIZEOF_OID");
+ static_assert(sizeof(void *) == SIZEOF_VOID_P,
+ "error in configure: bad value for SIZEOF_VOID_P");
+ static_assert(sizeof(size_t) == SIZEOF_SIZE_T,
+ "error in configure: bad value for SIZEOF_SIZE_T");
+ static_assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG,
+ "SIZEOF_OID should be equal to SIZEOF_INT or SIZEOF_LNG");
#ifdef NEED_MT_LOCK_INIT
- MT_lock_init(&MT_system_lock,"MT_system_lock");
+ MT_lock_init(&MT_system_lock, "MT_system_lock");
ATOMIC_INIT(GDKstoppedLock);
ATOMIC_INIT(mbyteslock);
MT_lock_init(&GDKnameLock, "GDKnameLock");
@@ -712,25 +745,27 @@ GDKreset(int status)
{
MT_Id pid = MT_getpid();
Thread t, s;
- struct serverthread *st;
int farmid;
int i;
- if( GDKkey){
+ assert(GDKexiting());
+
+ if (GDKkey) {
BBPunfix(GDKkey->batCacheid);
- GDKkey = 0;
+ GDKkey = NULL;
}
- if( GDKval){
+ if (GDKval) {
BBPunfix(GDKval->batCacheid);
- GDKval = 0;
+ GDKval = NULL;
}
MT_lock_set(&GDKthreadLock);
- for (st = serverthread; st; st = serverthread) {
+ while (serverthread != NULL) {
+ struct serverthread *st = serverthread;
+ serverthread = st->next;
MT_lock_unset(&GDKthreadLock);
MT_join_thread(st->pid);
MT_lock_set(&GDKthreadLock);
- serverthread = st->next;
GDKfree(st);
}
MT_lock_unset(&GDKthreadLock);
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -12,10 +12,7 @@
#include "monet_options.h"
#include <setjmp.h>
-gdk_export BAT *GDKkey;
-gdk_export BAT *GDKval;
-
-gdk_export char *GDKgetenv(const char *name);
+gdk_export const char *GDKgetenv(const char *name);
gdk_export bool GDKgetenv_istext(const char *name, const char* text);
gdk_export bool GDKgetenv_isyes(const char *name);
@@ -24,6 +21,7 @@ gdk_export bool GDKgetenv_istrue(const c
gdk_export int GDKgetenv_int(const char *name, int def);
gdk_export gdk_return GDKsetenv(const char *name, const char *value);
+gdk_export gdk_return GDKcopyenv(BAT **key, BAT **val, bool writable);
/*
* @+ Memory management
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -64,7 +64,7 @@ mal_client_reset(void)
void
MCinit(void)
{
- char *max_clients = GDKgetenv("max_clients");
+ const char *max_clients = GDKgetenv("max_clients");
int maxclients = 0;
if (max_clients != NULL)
@@ -201,7 +201,7 @@ MCexitClient(Client c)
Client
MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout)
{
- str prompt;
+ const char *prompt;
c->user = user;
c->username = 0;
diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -148,7 +148,7 @@ loadLibrary(str filename, int flag)
void *handle = NULL;
str s;
int idx;
- char *mod_path = GDKgetenv("monet_mod_path");
+ const char *mod_path = GDKgetenv("monet_mod_path");
/* AIX requires RTLD_MEMBER to load a module that is a member of an
* archive. */
@@ -179,7 +179,7 @@ loadLibrary(str filename, int flag)
}
while (*mod_path) {
- char *p;
+ const char *p;
for (p = mod_path; *p && *p != PATH_SEP; p++)
;
@@ -305,7 +305,7 @@ cmpstr(const void *_p1, const void *_p2)
char *
locate_file(const char *basename, const char *ext, bit recurse)
{
- char *mod_path = GDKgetenv("monet_mod_path");
+ const char *mod_path = GDKgetenv("monet_mod_path");
char *fullname;
size_t fullnamelen;
size_t filelen = strlen(basename) + strlen(ext);
@@ -325,7 +325,7 @@ locate_file(const char *basename, const
return NULL;
while (*mod_path) {
size_t i;
- char *p;
+ const char *p;
int fd;
DIR *rdir;
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -200,7 +200,8 @@ void
MSscheduleClient(str command, str challenge, bstream *fin, stream *fout,
protocol_version protocol, size_t blocksize)
{
char *user = command, *algo = NULL, *passwd = NULL, *lang = NULL;
- char *database = NULL, *s, *dbname;
+ char *database = NULL, *s;
+ const char *dbname;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list