Changeset: c80772560aa0 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c80772560aa0 Added Files: sql/test/BugTracker-2015/Tests/concurrent-queries.Bug-3848.SQL.py sql/test/BugTracker-2015/Tests/concurrent-queries.Bug-3848.stable.err sql/test/BugTracker-2015/Tests/concurrent-queries.Bug-3848.stable.out sql/test/BugTracker-2015/Tests/concurrent-queries.Bug-3848.timeout sql/test/BugTracker-2015/Tests/concurrent-schema.Bug-3826.SQL.py sql/test/BugTracker-2015/Tests/concurrent-schema.Bug-3826.stable.err sql/test/BugTracker-2015/Tests/concurrent-schema.Bug-3826.stable.out sql/test/BugTracker-2015/Tests/schema-trigger.Bug-3710.sql Removed Files: sql/storage/restrict/Makefile.ag Modified Files: NT/monetdb_config.h.in clients/mapilib/mapi.c clients/python2/monetdb/control.py clients/python3/monetdb/control.py gdk/gdk_align.c gdk/gdk_atomic.h gdk/gdk_atoms.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_imprints.c gdk/gdk_search.c gdk/gdk_system.c gdk/gdk_system.h gdk/gdk_tm.c gdk/gdk_utils.c monetdb5/extras/rapi/rapi.c monetdb5/mal/mal_client.c monetdb5/mal/mal_dataflow.c monetdb5/mal/mal_debugger.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_linker.c monetdb5/mal/mal_namespace.c monetdb5/mal/mal_profiler.c monetdb5/mal/mal_recycle.c monetdb5/mal/mal_resource.c monetdb5/mal/mal_runtime.c monetdb5/mal/mal_scenario.c monetdb5/mal/mal_session.c monetdb5/modules/kernel/alarm.c monetdb5/modules/mal/clients.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/querylog.c monetdb5/modules/mal/remote.c monetdb5/modules/mal/sysmon.c monetdb5/modules/mal/tablet.c monetdb5/modules/mal/tokenizer.c monetdb5/optimizer/opt_mergetable.c monetdb5/optimizer/opt_pipes.c monetdb5/optimizer/opt_statistics.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_scenario.c sql/backends/monet5/vaults/bam/bam_loader.c sql/backends/monet5/vaults/lidar/lidar.c sql/benchmarks/ssbm/Tests/04-explain.stable.out sql/benchmarks/ssbm/Tests/05-explain.stable.out sql/benchmarks/ssbm/Tests/06-explain.stable.out sql/benchmarks/ssbm/Tests/07-explain.stable.out sql/benchmarks/ssbm/Tests/08-explain.stable.out sql/benchmarks/ssbm/Tests/09-explain.stable.out sql/benchmarks/ssbm/Tests/10-explain.stable.out sql/benchmarks/ssbm/Tests/11-explain.stable.out sql/benchmarks/ssbm/Tests/12-explain.stable.out sql/benchmarks/ssbm/Tests/13-explain.stable.out sql/benchmarks/tpch/Tests/01-explain.stable.out sql/benchmarks/tpch/Tests/01-explain.stable.out.32bit sql/benchmarks/tpch/Tests/03-explain.stable.out sql/benchmarks/tpch/Tests/04-explain.stable.out.32bit sql/benchmarks/tpch/Tests/05-explain.stable.out sql/benchmarks/tpch/Tests/05-explain.stable.out.32bit sql/benchmarks/tpch/Tests/07-explain.stable.out sql/benchmarks/tpch/Tests/08-explain.stable.out sql/benchmarks/tpch/Tests/09-explain.stable.out sql/benchmarks/tpch/Tests/10-explain.stable.out sql/benchmarks/tpch/Tests/11-explain.stable.out sql/benchmarks/tpch/Tests/12-explain.stable.out sql/benchmarks/tpch/Tests/14-explain.stable.out sql/benchmarks/tpch/Tests/15-explain.stable.out sql/benchmarks/tpch/Tests/16-explain.stable.out.32bit sql/benchmarks/tpch/Tests/17-explain.stable.out sql/benchmarks/tpch/Tests/18-explain.stable.out sql/benchmarks/tpch/Tests/19-explain.stable.out sql/benchmarks/tpch/Tests/20-explain.stable.out sql/benchmarks/tpch/Tests/20-explain.stable.out.32bit sql/benchmarks/tpch/Tests/22-explain.stable.out sql/benchmarks/tpch/Tests/22-explain.stable.out.32bit sql/common/sql_list.c sql/common/sql_types.c sql/server/rel_exp.c sql/server/rel_optimizer.c sql/server/rel_planner.c sql/server/rel_select.c sql/server/rel_updates.c sql/storage/sql_catalog.c sql/storage/store.c sql/test/BugTracker-2015/Tests/All sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.err sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out sql/test/BugTracker-2015/Tests/date_comparison_incorrect_results.Bug-3834.stable.out sql/test/BugTracker-2015/Tests/update_with_without_parenthesis.Bug-3838.stable.out sql/test/SQLite_regress/sqllogictest/Tests/select2.test.sql sql/test/SQLite_regress/sqllogictest/Tests/select2.test.stable.out sql/test/SQLite_regress/sqllogictest/Tests/select2.test.stable.out.int128 sql/test/SQLite_regress/sqllogictest/Tests/select5.test.timeout sql/test/mergetables/Tests/singlekeyconstraint.sql sql/test/mergetables/Tests/singlekeyconstraint.stable.err sql/test/mergetables/Tests/singlekeyconstraint.stable.out Branch: mosaic Log Message:
Merge with default diffs (truncated from 86103 to 300 lines): diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in --- a/NT/monetdb_config.h.in +++ b/NT/monetdb_config.h.in @@ -57,6 +57,8 @@ #include <assert.h> +#define __func__ __FUNCTION__ + /* indicate to sqltypes.h that windows.h has already been included and that it doesn't have to define Windows constants */ #define ALREADY_HAVE_WINDOWS_TYPE 1 diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1006,18 +1006,13 @@ struct MapiStatement { mapi_clrError((X)->mid); \ } while (0) -static Mapi mapi_new(void); static int mapi_extend_bindings(MapiHdl hdl, int minbindings); static int mapi_extend_params(MapiHdl hdl, int minparams); -static MapiMsg mapi_setError(Mapi mid, const char *msg, const char *action, MapiMsg error); static void close_connection(Mapi mid); static MapiMsg read_into_cache(MapiHdl hdl, int lookahead); static int unquote(const char *msg, char **start, const char **next, int endchar, size_t *lenp); static int mapi_slice_row(struct MapiResultSet *result, int cr); static void mapi_store_bind(struct MapiResultSet *result, int cr); -static void parse_uri_query(Mapi mid, char *uri); -static void set_uri(Mapi mid); -static MapiMsg connect_to_server(Mapi mid); static int mapi_initialized = 0; @@ -1872,9 +1867,9 @@ mapi_new(void) mid->index = index++; /* for distinctions in log records */ mid->auto_commit = 1; mid->error = MOK; - mid->hostname = strdup("localhost"); + mid->hostname = NULL; mid->server = NULL; - mid->language = strdup("sql"); + mid->language = NULL; mid->languageId = LANG_SQL; mid->noexplain = NULL; @@ -1901,376 +1896,9 @@ mapi_new(void) mid->first = NULL; - if (mid->hostname == NULL || mid->language == NULL) { - /* strdup failed, give up */ - mapi_destroy(mid); - return NULL; - } - return mid; } -Mapi -mapi_mapiuri(const char *url, const char *user, const char *pass, const char *lang) -{ - char *uri; - char *host; - int port; - char *dbname; - char *p; - Mapi mid; - - if (!mapi_initialized) { - mapi_initialized = 1; - if (mnstr_init() < 0) - return NULL; - } - - mid = mapi_new(); - if (mid == NULL) - return NULL; - - if (url == NULL) { - mapi_setError(mid, "url is null", "mapi_mapiuri", MERROR); - return mid; - } - if (user == NULL) { - mapi_setError(mid, "user is null", "mapi_mapiuri", MERROR); - return mid; - } - if (pass == NULL) { - mapi_setError(mid, "pass is null", "mapi_mapiuri", MERROR); - return mid; - } - if (lang == NULL) { - mapi_setError(mid, "lang is null", "mapi_mapiuri", MERROR); - return mid; - } - - if (strncmp(url, "mapi:monetdb://", sizeof("mapi:monetdb://") - 1) != 0) { - mapi_setError(mid, - "url has unsupported scheme, " - "expecting mapi:monetdb://...", - "mapi_mapiuri", MERROR); - return mid; - } - - /* copy to a writable working buffer */ - uri = strdup(url + sizeof("mapi:monetdb://") - 1); - - if (uri[0] != '/') { - if ((p = strchr(uri, ':')) == NULL) { - mapi_setError(mid, "URI must contain a port number after " - "the hostname", "mapi_mapiuri", MERROR); - free(uri); - return mid; - } - *p++ = '\0'; - dbname = p; /* temp misuse */ - host = uri; - if ((p = strchr(dbname, '/')) == NULL) { - p = dbname; - dbname = NULL; - } else { - *p++ = '\0'; - if (*p == '\0') { - p = dbname; - dbname = NULL; - } else { - char *t = dbname; - dbname = p; - p = t; - } - } - port = atoi(p); - if (port <= 0) { - mapi_setError(mid, "URI contains invalid port", - "mapi_mapiuri", MERROR); - free(uri); - return mid; - } - } else { - host = uri; - port = 0; - dbname = NULL; - } - - mid->port = port; - if (mid->username != NULL) - free(mid->username); - mid->username = strdup(user); - if (mid->password) - free(mid->password); - mid->password = strdup(pass); - free(mid->language); - mid->language = strdup(lang); - if (strcmp(lang, "mal") == 0 || strcmp(lang, "msql") == 0) - mid->languageId = LANG_MAL; - else if (strstr(lang, "sql") == lang) - mid->languageId = LANG_SQL; - if (mid->database) - free(mid->database); - mid->database = NULL; - - /* this is in particular important for unix sockets */ - parse_uri_query(mid, uri); - - /* doing this here, because parse_uri_query will terminate the - * string if a ? is in place */ - if (mid->hostname) - free(mid->hostname); - mid->hostname = strdup(host); - if (mid->database == NULL && dbname != NULL) - mid->database = strdup(dbname); - - set_uri(mid); - free(uri); - - return mid; -} - -/* Allocate a new connection handle and fill in the information needed - to connect to a server, but don't connect yet. */ -Mapi -mapi_mapi(const char *host, int port, const char *username, - const char *password, const char *lang, const char *dbname) -{ - Mapi mid; -#ifdef HAVE_SYS_UN_H - char buf[1024]; -#endif - - if (!mapi_initialized) { - mapi_initialized = 1; - if (mnstr_init() < 0) - return NULL; - } - - mid = mapi_new(); - if (mid == NULL) - return NULL; - - /* connection searching strategy: - * 0) if host and port are given, resort to those - * 1) if no dbname given, make TCP connection (merovingian will - * complain regardless, so it is more likely an mserver is - * meant to be directly addressed) - * a) resort to default (hardwired) port 50000, unless port given, then - * b) resort to port given - * 2) a dbname is given - * a) if a port is given, open unix socket for that port, resort - * to TCP connection if not found - * b) no port given, start looking for a matching merovingian, by - * searching through socket files, attempting connect to given - * dbname - * I) try available sockets that have a matching owner with - * the current user - * II) try other sockets - * III) resort to TCP connection on hardwired port - * (localhost:50000) - */ - if (host != NULL && port != 0) { - /* case 0), just do what the user told us */ -#ifdef HAVE_SYS_UN_H - if (*host == '/') { - /* don't stat or anything, the connect_to_server will return - * the error if it doesn't exists, falling back to TCP with - * a hostname like '/var/sockets' won't work anyway */ - snprintf(buf, sizeof(buf), "%s/.s.monetdb.%d", host, port); - host = buf; - } -#endif - } else if (dbname == NULL) { - /* case 1) */ - if (port == 0) - port = 50000; /* case 1a), hardwired default */ - if (host == NULL) - host = "localhost"; - } else { - /* case 2), dbname is given */ - if (port != 0) { - /* case 2a), if unix socket found, use it, otherwise TCP */ -#ifdef HAVE_SYS_UN_H - struct stat st; - snprintf(buf, sizeof(buf), "/tmp/.s.monetdb.%d", port); - if (stat(buf, &st) != -1 && S_ISSOCK(st.st_mode)) - host = buf; - else -#endif - host = "localhost"; - } else if (host != NULL) { -#ifdef HAVE_SYS_UN_H - if (*host == '/') { - /* see comment above for why we don't stat */ - snprintf(buf, sizeof(buf), "%s/.s.monetdb.50000", host); - host = buf; - } -#endif - port = 50000; - } else { - /* case 2b), no host, no port, but a dbname, search for meros */ -#ifdef HAVE_SYS_UN_H - DIR *d; - struct dirent *e; - struct stat st; - char found = 0; - struct { - int port; - uid_t owner; - } socks[24]; - int i = 0; - int len; - uid_t me = getuid(); - - d = opendir("/tmp"); - if (d != NULL) { - while ((e = readdir(d)) != NULL) { - if (strncmp(e->d_name, ".s.monetdb.", 11) != 0) - continue; - if (snprintf(buf, sizeof(buf), "/tmp/%s", e->d_name) >= (int) sizeof(buf)) - continue; /* ignore long name */ - if (stat(buf, &st) != -1 && S_ISSOCK(st.st_mode)) { - socks[i].owner = st.st_uid; - socks[i++].port = atoi(e->d_name + 11); - } - if (i == sizeof(socks) / sizeof(socks[0])) - break; - } - closedir(d); - len = i; - /* case 2bI) first those with a matching owner */ - for (i = 0; found == 0 && i < len; i++) { - if (socks[i].port != 0 && - socks[i].owner == me) { - Mapi tmid; - /* try this server for the database */ - tmid = mapi_mapi("/tmp", socks[i].port, "mero", "mero", - lang, dbname); - tmid->redirmax = 0; - if (connect_to_server(tmid) == MOK && - (mapi_start_talking(tmid) == MOK || - *tmid->redirects != NULL || - (tmid->errorstr != NULL && _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list