Changeset: 3ddb3892012b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ddb3892012b
Modified Files:
clients/mapiclient/eventparser.h
clients/mapiclient/tachograph.c
clients/mapiclient/tomograph.c
gdk/gdk_atoms.c
gdk/gdk_select.c
sql/test/pg_regress/Tests/timestamptz.stable.out
Branch: resultset
Log Message:
Merge with default
diffs (281 lines):
diff --git a/clients/mapiclient/eventparser.h b/clients/mapiclient/eventparser.h
--- a/clients/mapiclient/eventparser.h
+++ b/clients/mapiclient/eventparser.h
@@ -55,9 +55,6 @@
#define US_HH (US_MM * 60)
#define US_DD (US_HH * 24)
-#define MAXTHREADS 1048
-#define MAXBOX 32678 /* should be > MAXTHREADS */
-
#define MDB_START 1
#define MDB_DONE 2
#define MDB_PING 3
diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -888,7 +888,8 @@ main(int argc, char **argv)
#else
snprintf(cachebuf,BUFSIZ,"%s/",cache);
#endif
- if(dbname == NULL){
+ if ( dbname == NULL){
+ fprintf(stderr,"Database name missing\n");
usageTachograph();
exit(-1);
}
@@ -959,10 +960,13 @@ main(int argc, char **argv)
doQ(buf);
if( cache){
#ifdef NATIVE_WIN32
- _mkdir(cache);
+ if( access(cache,F_OK) && _mkdir(cache)){
#else
- mkdir(cache,0755);
+ if( access(cache,F_OK) && mkdir(cache,0755) ) {
#endif
+ fprintf(stderr,"Failed to create cache '%s'\n",cache);
+ exit(-1);
+ }
}
snprintf(buf,BUFSIZ,"%s%s_%s.trace", cachebuf, basefilename,dbname);
// keep a trace of the events received
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -469,7 +469,7 @@ stopListening(int i)
#define BSIZE 64*1024
char buf[BSIZE + BUFSIZ]={0};
char pages[BSIZE]={0};
- int error =0, plen =0;
+ int j, error =0, plen =0;
if( i)
fprintf(stderr,"signal %d received\n",i);
if( dbh)
@@ -479,10 +479,17 @@ stop_disconnect:
createTomogram();
// show follow up action only once
if(atlaspage >= 1){
- for (i = 0; systemcall && error == 0 && i< atlaspage; i++){
+ for (i = 0; systemcall && i< atlaspage; i++){
snprintf(buf, BUFSIZ, "gnuplot %s%s_%s_%02d.gpl;",
cachebuf, basefilename, dbname, i);
- fprintf(stderr,"-- exec:%s\n",buf);
- error = system(buf);
+ if( error == 0){
+ fprintf(stderr,"-- exec:%s\n",buf);
+ error = system(buf);
+ if( error){
+ fprintf(stderr, "To finish the atlas
make sure gnuplot is available and run:\n");
+ for (j=i; j< atlaspage; j++)
+ fprintf(stderr, "gnuplot
%s%s_%s_%02d.gpl\n", cachebuf, basefilename, dbname,j);
+ }
+ }
snprintf(buf, BUFSIZ, "%s%s_%s_%02d.pdf ", cachebuf,
basefilename, dbname, i);
plen += snprintf(pages + plen, BSIZE -plen,"%s",buf);
@@ -492,10 +499,6 @@ stop_disconnect:
}
}
- if( i < atlaspage)
- fprintf(stderr, "To finish the atlas run:\n");
- for (; i< atlaspage; i++)
- fprintf(stderr, "gnuplot %s%s_%s_%02d.gpl;", cachebuf,
basefilename, dbname,i);
if( systemcall && error == 0) {
snprintf(buf, BSIZE, "gs -q -dNOPAUSE -sDEVICE=pdfwrite
-sOUTPUTFILE=%s%s_%s.pdf -dBATCH %s",cachebuf,basefilename,dbname,pages);
@@ -531,8 +534,9 @@ typedef struct BOX {
int threads[MAXTHREADS];
lng lastclk[MAXTHREADS];
-Box box[MAXBOX];
+Box *box= 0;
int topbox = 0;
+int maxbox = 0;
int events = 0;
lng totalclkticks = 0; /* number of clock ticks reported */
@@ -568,7 +572,7 @@ static void resetTomograph(void){
events = 0;
for (i = 0; i < MAXTHREADS; i++)
threads[i] = topbox++;
- memset((char*) box, 0, sizeof(Box) * MAXBOX);
+ memset((char*) box, 0, sizeof(Box) * maxbox);
totalclkticks = 0;
totalexecticks = 0;
@@ -1331,10 +1335,18 @@ update(char *line, EventRecord *ev)
char *s;
int uid = 0,qid = 0;
- if (topbox == MAXBOX) {
- fprintf(stderr, "Out of space for trace");
- createTomogram();
- exit(0);
+ if (topbox == maxbox || maxbox < topbox) {
+
+ if( box == 0)
+ box = (Box*) malloc(MAXBOX * sizeof(Box));
+ else
+ box = (Box*) realloc((void*)box, (maxbox + MAXBOX) *
sizeof(Box));
+ if( box == NULL){
+ fprintf(stderr, "Out of space for trace, exceeds max
entries %d\n", maxbox);
+ fprintf(stderr, "Restart with a slower beat might help,
e.g. --beat=5000 or --beat=0\n");
+ exit(0);
+ }
+ maxbox += MAXBOX;
}
/* handle a ping event, keep the current instruction in focus */
if (ev->state >= MDB_PING ) {
@@ -1570,6 +1582,10 @@ main(int argc, char **argv)
/* parse config file first, command line options override */
parse_dotmonetdb(&user, &password, NULL, NULL, NULL, NULL);
+ if( argc == 1){
+ usageTomograph();
+ exit(-1);
+ }
while (1) {
int option_index = 0;
int c = getopt_long(argc, argv,
"d:u:p:P:h:?T:i:r:s:q:o:c:Db:A:m",
@@ -1670,6 +1686,16 @@ main(int argc, char **argv)
}
}
+ if ( dbname == NULL && inputfile == NULL){
+ fprintf(stderr,"Database name and inputfile missing\n");
+ usageTomograph();
+ exit(-1);
+ }
+ if (dbname != NULL && strncmp(dbname, "mapi:monetdb://", 15) == 0) {
+ uri = dbname;
+ dbname = NULL;
+ }
+
fprintf(stderr,"-- Stop capturing with <cntrl-c> or after %d
pages\n",atlas);
if (cache)
#ifdef NATIVE_WIN32
@@ -1687,11 +1713,6 @@ main(int argc, char **argv)
printf("tomograph --input=%s
--output=%s\n",inputfile,basefilename);
}
- if (dbname != NULL && strncmp(dbname, "mapi:monetdb://", 15) == 0) {
- uri = dbname;
- dbname = NULL;
- }
-
if (colormap) {
showcolormap(basefilename, 1);
printf("Color map file generated\n");
@@ -1714,10 +1735,13 @@ main(int argc, char **argv)
/* reprocess an existing profiler trace, possibly producing the trace
split */
if (cache) {
#ifdef NATIVE_WIN32
- _mkdir(cache);
+ if( access(cache, F_OK) && _mkdir(cache)){
#else
- mkdir(cache,0755);
+ if( access(cache, F_OK) && mkdir(cache,0755) ) {
#endif
+ fprintf(stderr,"Failed to create cache '%s'\n",cache);
+ exit(-1);
+ }
}
snprintf(buf,BUFSIZ,"%s%s_%s_%02d.trace", cachebuf, basefilename,
dbname, atlaspage);
if (inputfile==0 || strcmp(buf, inputfile) ){
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1254,6 +1254,50 @@ strPut(Heap *h, var_t *dst, const char *
/* insert string */
pos = h->free + pad + extralen;
*dst = (var_t) (pos >> GDK_VARSHIFT);
+#ifndef NDEBUG
+ /* just before inserting into the heap, make sure that the
+ * string is actually UTF-8 (if we encountered a return
+ * statement before this, the string was already in the heap,
+ * and hence already checked) */
+ if (v[0] != '\200' || v[1] != '\0') {
+ /* not str_nil, must be UTF-8 */
+ size_t i;
+
+ for (i = 0; v[i] != '\0'; i++) {
+ /* check that v[i] is the start of a validly
+ * coded UTF-8 sequence: this involves
+ * checking that the first byte is a valid
+ * start byte and is followed by the correct
+ * number of follow-up bytes, but also that
+ * the sequence cannot be shorter */
+ if ((v[i] & 0x80) == 0) {
+ /* 0aaaaaaa */
+ continue;
+ } else if ((v[i] & 0xE0) == 0xC0) {
+ /* 110bbbba 10aaaaaa
+ * one of the b's must be set*/
+ assert(v[i] & 0x4D);
+ assert((v[++i] & 0xC0) == 0x80);
+ } else if ((v[i] & 0xF0) == 0xE0) {
+ /* 1110cccc 10cbbbba 10aaaaaa
+ * one of the c's must be set*/
+ assert(v[i] & 0x0F || v[i + 1] & 0x20);
+ assert((v[++i] & 0xC0) == 0x80);
+ assert((v[++i] & 0xC0) == 0x80);
+ } else if ((v[i] & 0xF8) == 0xF0) {
+ /* 11110ddd 10ddcccc 10cbbbba 10aaaaaa
+ * one of the d's must be set */
+ assert(v[i] & 0x07 || v[i + 1] & 0x30);
+ assert((v[++i] & 0xC0) == 0x80);
+ assert((v[++i] & 0xC0) == 0x80);
+ assert((v[++i] & 0xC0) == 0x80);
+ } else {
+ /* this will fail */
+ assert((v[i] & 0x80) == 0);
+ }
+ }
+ }
+#endif
memcpy(h->base + pos, v, len);
if (h->hashash) {
((BUN *) (h->base + pos))[-1] = strhash;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -156,9 +156,9 @@ doubleslice(BAT *b, BUN l1, BUN h1, BUN
for (hb = HASHget(h, HASHprobe((h), v)); \
hb != HASHnil(h); \
hb = HASHgetlink(h,hb)) \
- if (misses += hb >= (hi), (hb >= (lo) && hb < (hi) && \
+ if (hb >= (lo) && hb < (hi) && \
(cmp == NULL || \
- (*cmp)(v, BUNtail(bi, hb)) == 0)))
+ (*cmp)(v, BUNtail(bi, hb)) == 0))
static BAT *
BAT_hashselect(BAT *b, BAT *s, BAT *bn, const void *tl, BUN maximum)
@@ -169,7 +169,6 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn,
BUN l, h;
oid seq;
int (*cmp)(const void *, const void *);
- BUN misses = 0;
assert(bn->htype == TYPE_void);
assert(bn->ttype == TYPE_oid);
@@ -231,7 +230,6 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn,
cnt++;
}
}
- fprintf(stderr, "#BAT_hashselect: misses = "BUNFMT"\n", misses);
BATsetcount(bn, cnt);
bn->tkey = 1;
if (cnt > 1) {
diff --git a/sql/test/pg_regress/Tests/timestamptz.stable.out
b/sql/test/pg_regress/Tests/timestamptz.stable.out
--- a/sql/test/pg_regress/Tests/timestamptz.stable.out
+++ b/sql/test/pg_regress/Tests/timestamptz.stable.out
@@ -181,7 +181,6 @@ Ready.
[ "", 1997-06-11 01:32:01.00+01:00 ]
[ "", 2001-09-22 19:19:20.00+01:00 ]
[ "", 1997-02-11 02:32:01.00+01:00 ]
-[ "", NULL ]
#SELECT '' AS "16", d1 FROM TIMESTAMPTZ_TBL
# WHERE d1 <= cast('1997-01-02' as timestamptz);
% .L1, sys.timestamptz_tbl # table_name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list