Changeset: 76a7f6c878e7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76a7f6c878e7
Modified Files:
clients/mapiclient/Makefile.ag
clients/mapiclient/stethoscope.c
gdk/gdk_aggr.c
gdk/gdk_calc.c
monetdb5/modules/kernel/bat5.mal
monetdb5/modules/mal/transaction.mal
monetdb5/optimizer/opt_accumulators.c
monetdb5/optimizer/opt_aliases.c
monetdb5/optimizer/opt_coercion.c
monetdb5/optimizer/opt_commonTerms.c
monetdb5/optimizer/opt_constants.c
monetdb5/optimizer/opt_costModel.c
monetdb5/optimizer/opt_dataflow.c
monetdb5/optimizer/opt_deadcode.c
monetdb5/optimizer/opt_emptySet.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_garbageCollector.c
monetdb5/optimizer/opt_groups.c
monetdb5/optimizer/opt_history.c
monetdb5/optimizer/opt_inline.c
monetdb5/optimizer/opt_joinpath.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_mitosis.c
monetdb5/optimizer/opt_multiplex.c
monetdb5/optimizer/opt_origin.c
monetdb5/optimizer/opt_prejoin.c
monetdb5/optimizer/opt_prelude.h
monetdb5/optimizer/opt_reduce.c
monetdb5/optimizer/opt_remap.c
monetdb5/optimizer/opt_wrapper.c
sql/test/BugDay_2005-12-19_2.9.3/Tests/select_from_env.SF-1240701.1242164.stable.err
sql/test/BugDay_2005-12-19_2.9.3/Tests/select_from_env.SF-1240701.1242164.stable.out
sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
testing/Mfilter.py.in
Branch: default
Log Message:
Merged from Feb2013
diffs (truncated from 1819 to 300 lines):
diff --git a/clients/mapiclient/Makefile.ag b/clients/mapiclient/Makefile.ag
--- a/clients/mapiclient/Makefile.ag
+++ b/clients/mapiclient/Makefile.ag
@@ -42,7 +42,7 @@ bin_stethoscope = {
SOURCES = stethoscope.c
LIBS = libmcutil ../mapilib/libmapi \
../../common/stream/libstream \
- $(curl_LIBS) $(MALLOC_LIBS) $(PTHREAD_LIBS) $(SOCKET_LIBS)
+ $(curl_LIBS) $(MALLOC_LIBS) $(SOCKET_LIBS)
}
bin_tomograph = {
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -28,9 +28,7 @@
#include <errno.h>
#include <signal.h>
#include <unistd.h>
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
+#include "mprompt.h"
#include "dotmonetdb.h"
#ifndef HAVE_GETOPT_LONG
@@ -88,35 +86,15 @@ static struct {
/* 3 */ { 0, 0, 0, 0 }
};
-typedef struct _wthread {
-#if !defined(HAVE_PTHREAD_H) && defined(_MSC_VER)
- HANDLE id;
-#else
- pthread_t id;
-#endif
- int tid;
- char *uri;
- char *host;
- char *dbname;
- int port;
- char *user;
- char *pass;
- stream *s;
- size_t argc;
- char **argv;
- struct _wthread *next;
-} wthread;
-
-static wthread *thds = NULL;
+static stream *conn = NULL;
static char hostname[128];
static void
usage(void)
{
- fprintf(stderr, "stethoscope [options] +[trace options]
{<mod>.<fcn>}\n");
+ fprintf(stderr, "stethoscope [options] [dbname] +[trace options]
{<mod>.<fcn>}\n");
fprintf(stderr, " -d | --dbname=<database_name>\n");
fprintf(stderr, " -u | --user=<user>\n");
- fprintf(stderr, " -P | --password=<password>\n");
fprintf(stderr, " -p | --port=<portnr>\n");
fprintf(stderr, " -h | --host=<hostname>\n");
fprintf(stderr, " -? | --help\n");
@@ -148,13 +126,9 @@ usage(void)
static void
stopListening(int i)
{
- wthread *walk;
(void)i;
- /* kill all connections */
- for (walk = thds; walk != NULL; walk = walk->next) {
- if (walk->s != NULL)
- mnstr_close(walk->s);
- }
+ if (conn != NULL)
+ mnstr_close(conn);
}
static int
@@ -174,193 +148,34 @@ setCounter(char *nme)
#define die(dbh, hdl) while (1) {(hdl ? mapi_explain_query(hdl, stderr) : \
dbh ? mapi_explain(dbh, stderr) :
\
- fprintf(stderr, "!! %scommand
failed\n", id)); \
+ fprintf(stderr, "!! command
failed\n")); \
goto stop_disconnect;}
#define doQ(X) \
if ((hdl = mapi_query(dbh, X)) == NULL || mapi_error(dbh) != MOK) \
die(dbh, hdl);
-#if !defined(HAVE_PTHREAD_H) && defined(_MSC_VER)
-static DWORD WINAPI
-#else
-static void *
-#endif
-doProfile(void *d)
+int
+main(int argc, char **argv)
{
- wthread *wthr = (wthread*)d;
- int i;
- size_t a;
+ int i, k;
ssize_t n;
+ char *e;
+ char *host = NULL;
+ int portnr = 0;
+ char *dbname = NULL;
+ char *uri = NULL;
+ char *user = NULL;
+ char *password = NULL;
+ struct stat statb;
char *response, *x;
char buf[BUFSIZ + 1];
- char *e;
char *mod, *fcn;
- char *host = NULL;
- int portnr;
- char id[10];
Mapi dbh;
MapiHdl hdl = NULL;
- /* set up the profiler */
- id[0] = '\0';
- if (wthr->uri)
- dbh = mapi_mapiuri(wthr->uri, wthr->user, wthr->pass, "mal");
- else
- dbh = mapi_mapi(wthr->host, wthr->port, wthr->user, wthr->pass,
"mal", wthr->dbname);
- if (dbh == NULL || mapi_error(dbh))
- die(dbh, hdl);
- mapi_reconnect(dbh);
- if (mapi_error(dbh))
- die(dbh, hdl);
- host = strdup(mapi_get_host(dbh));
- if (*host == '/') {
- fprintf(stderr, "!! UNIX domain socket not supported\n");
- goto stop_disconnect;
- }
- if (wthr->tid > 0) {
- snprintf(id, 10, "[%d] ", wthr->tid);
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- connection with server %s is %s\n", wthr->uri ?
wthr->uri : host, id);
-#endif
- } else {
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- connection with server %s\n", wthr->uri ? wthr->uri
: host);
-#endif
- }
-
- /* set counters */
- x = NULL;
- for (i = 0; profileCounter[i].tag; i++) {
- /* skip duplicates */
- if (x == profileCounter[i].ptag)
- continue;
- /* deactivate any left over counter first */
- snprintf(buf, BUFSIZ, "profiler.deactivate(\"%s\");",
- profileCounter[i].ptag);
- doQ(buf);
- if (profileCounter[i].status) {
- snprintf(buf, BUFSIZ, "profiler.activate(\"%s\");",
- profileCounter[i].ptag);
- doQ(buf);
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- %s%s\n", id, buf);
-#endif
- }
- x = profileCounter[i].ptag;
- }
-
- for (portnr = 50010; portnr < 62010; portnr++) {
- if ((wthr->s = udp_rastream(host, portnr, "profileStream")) !=
NULL)
- break;
- }
- if (wthr->s == NULL) {
- fprintf(stderr, "!! %sopening stream failed: no free ports
available\n",
- id);
- goto stop_cleanup;
- }
-
- printf("-- %sopened UDP profile stream %s:%d for %s\n",
- id, hostname, portnr, host);
-
- snprintf(buf, BUFSIZ, "port := profiler.openStream(\"%s\", %d);",
- hostname, portnr);
- doQ(buf);
-
- /* Set Filters */
- doQ("profiler.setNone();");
-
- if (wthr->argc == 0) {
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- %sprofiler.setAll();\n", id);
-#endif
- doQ("profiler.setAll();");
- } else {
- for (a = 0; a < wthr->argc; a++) {
- char *c;
- char *arg = strdup(wthr->argv[a]);
- c = strchr(arg, '.');
- if (c) {
- mod = arg;
- if (mod == c)
- mod = "*";
- fcn = c + 1;
- if (*fcn == 0)
- fcn = "*";
- *c = 0;
- } else {
- fcn = arg;
- mod = "*";
- }
- snprintf(buf, BUFSIZ,
"profiler.setFilter(\"%s\",\"%s\");", mod, fcn);
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- %s%s\n", id, buf);
-#endif
- doQ(buf);
- free(arg);
- }
- }
-#ifdef _DEBUG_STETHOSCOPE_
- printf("-- %sprofiler.start();\n", id);
-#endif
- doQ("profiler.start();");
- fflush(NULL);
-
- i = 0;
- while ((n = mnstr_read(wthr->s, buf, 1, BUFSIZ)) > 0) {
- buf[n] = 0;
- response = buf;
- while ((e = strchr(response, '\n')) != NULL) {
- *e = 0;
- printf("%s%s\n", id, response);
- response = e + 1;
- }
- /* handle last line in buffer */
- if ( *response)
- printf("%s",response);
- if (++i % 200) {
- i = 0;
- fflush(NULL);
- }
- }
- fflush(NULL);
-
-stop_cleanup:
- doQ("profiler.setNone();");
- doQ("profiler.stop();");
- doQ("profiler.closeStream();");
-stop_disconnect:
- if (dbh) {
- mapi_disconnect(dbh);
- mapi_destroy(dbh);
- }
-
- printf("-- %sconnection with server %s closed\n", id, wthr->uri ?
wthr->uri : host);
-
- free(host);
-
- return(0);
-}
-
-int
-main(int argc, char **argv)
-{
- int a = 1;
- int i, k;
- char *host = NULL;
- int portnr = 0;
- char *dbname = NULL;
- char *user = NULL;
- char *password = NULL;
-
- /* some .monetdb properties are used by mclient, perhaps we need them
as well later */
-
- char **alts, **oalts;
- wthread *walk;
-
- static struct option long_options[8] = {
+ static struct option long_options[6] = {
{ "dbname", 1, 0, 'd' },
{ "user", 1, 0, 'u' },
- { "password", 1, 0, 'P' },
{ "port", 1, 0, 'p' },
{ "host", 1, 0, 'h' },
{ "help", 0, 0, '?' },
@@ -372,7 +187,7 @@ main(int argc, char **argv)
while (1) {
int option_index = 0;
- int c = getopt_long(argc, argv, "d:u:P:p:h:?",
+ int c = getopt_long(argc, argv, "d:u:p:h:?",
long_options, &option_index);
if (c == -1)
break;
@@ -384,11 +199,10 @@ main(int argc, char **argv)
if (user)
free(user);
user = strdup(optarg);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list