Changeset: 7d0255bee8b3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7d0255bee8b3
Modified Files:
        
Branch: default
Log Message:

Merge with Dec2011 branch.


diffs (truncated from 645 to 300 lines):

diff --git a/clients/ChangeLog.Aug2011 b/clients/ChangeLog.Aug2011
--- a/clients/ChangeLog.Aug2011
+++ b/clients/ChangeLog.Aug2011
@@ -1,6 +1,11 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Mon Oct 17 2011 Fabian Groffen <fab...@cwi.nl>
+- Small improvement to mclient's table rendering for tables without
+  any rows.  Previously, the column names in the header could be
+  squeezed to very small widths, degrading readability.
+
 * Wed Oct 12 2011 Fabian Groffen <fab...@cwi.nl>
 - Python DB API connect() function now supports PEP 249-style arguments
   user and host, bug #2901
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1108,12 +1108,11 @@ SQLrenderer(MapiHdl hdl, char singleinst
                         strcmp(s, "decimal") == 0);
 
                if (rows == 0) {
-                       vartotal += len[i];
-                       minvartotal += MINCOLSIZE;
+                       minvartotal += len[i]; /* don't wrap column headers if 
no data */
                } else if (!numeric[i]) {
-                       vartotal += len[i];
                        minvartotal += len[i] > MINVARCOLSIZE ? MINVARCOLSIZE : 
len[i];
                }
+               vartotal += len[i];
                total += len[i];
 
                /* do a very pessimistic calculation to determine if more
diff --git a/gdk/gdk_bat.mx b/gdk/gdk_bat.mx
--- a/gdk/gdk_bat.mx
+++ b/gdk/gdk_bat.mx
@@ -2005,24 +2005,24 @@ BUNfnd(BAT *b, ptr v)
        return r;
 }
 
-@= swap
-       {
-               int (*_cmp) (ptr, ptr);
-               ptr _p;
-
-               _cmp = hcmp;
-               hcmp = tcmp;
-               tcmp = _cmp;
-               _p = x;
-               x = y;
-               y = _p;
-               bi.b = b = BATmirror(b);
-       }       
-                           
-@= dohash
-        ATOMstorage(@1->@2->type) != TYPE_chr && (ATOMstorage(@1->@2->type) != 
TYPE_str || !GDK_ELIMDOUBLES(@1->@2->vheap)) 
-@
-@c
+#define usemirror()                            \
+       do {                                    \
+               int (*_cmp) (ptr, ptr);         \
+               ptr _p;                         \
+                                               \
+               _cmp = hcmp;                    \
+               hcmp = tcmp;                    \
+               tcmp = _cmp;                    \
+               _p = x;                         \
+               x = y;                          \
+               y = _p;                         \
+               bi.b = b = BATmirror(b);        \
+       } while (0)
+
+#define dohash(hp)        (ATOMstorage(hp->type) != TYPE_chr &&                
\
+                          (ATOMstorage(hp->type) != TYPE_str ||        \
+                           !GDK_ELIMDOUBLES(hp->vheap)))
+
 BUN
 BUNlocate(BAT *b, ptr x, ptr y)
 {
@@ -2051,7 +2051,7 @@ BUNlocate(BAT *b, ptr x, ptr y)
            ((BAThordered(b) & 1) &&
             (*hcmp) (x, BUNhead(bi, p)) == 0 &&
             (*hcmp) (x, BUNhead(bi, q - 1)) == 0))
-               @:swap()@
+               usemirror();
        if (y == NULL ||
            ((BATtordered(b) & 1) &&
             (*tcmp) (y, BUNtail(bi, p)) == 0 &&
@@ -2061,7 +2061,7 @@ BUNlocate(BAT *b, ptr x, ptr y)
 
        /* positional lookup is always the best choice */
        if (BATtdense(b))
-               @:swap()@
+               usemirror();
        if (BAThdense(b)) {
                BUN i = (BUN) (*(oid *) x - b->hseqbase);
 
@@ -2093,19 +2093,22 @@ BUNlocate(BAT *b, ptr x, ptr y)
 
        /* if the range is still larger than 32 BUNs, consider investing in a 
hash table */
        if ((q - p) > (1 << 5)) {
-               /* regrettably MonetDB support only single-column hashes 
-                * strategy: create a hash on both columns, and select the 
column with the best distribution
+               /* regrettably MonetDB support only single-column hashes
+                * strategy: create a hash on both columns, and select
+                * the column with the best distribution
                 */
-               if ((b->T->hash && b->H->hash == NULL) || !(@:dohash(b,H)@))
-                       @:swap()@
+               if ((b->T->hash && b->H->hash == NULL) || !dohash(b->H))
+                       usemirror();
                if (b->H->hash == NULL && (v = VIEWcreate_(b, b, TRUE)) != 
NULL) {
-                       /* As we are going to remove the worst hash table 
later, we must do everything 
-                        * in a view, as it is not permitted to remove a hash 
table from a read-only 
-                        * operation (like BUNlocate). Other threads might then 
crash. 
+                       /* As we are going to remove the worst hash
+                        * table later, we must do everything in a
+                        * view, as it is not permitted to remove a
+                        * hash table from a read-only operation (like
+                        * BUNlocate). Other threads might then crash.
                         */
-                       if (@:dohash(v,H)@)
+                       if (dohash(v->H))
                                (void) BATprepareHash(v);
-                       if (@:dohash(v,T)@)
+                       if (dohash(v->T))
                                (void) BATprepareHash(BATmirror(v));
                        if (v->H->hash && v->T->hash) { /* we can choose 
between two hash tables */
                                BUN hcnt = 0, tcnt = 0;
@@ -2116,14 +2119,14 @@ BUNlocate(BAT *b, ptr x, ptr y)
                                for (i = 0; i <= v->T->hash->mask; i++)
                                        tcnt += (v->T->hash->hash[i] != 
BUN_NONE);
                                if (hcnt < tcnt) {
-                                       @:swap()@
+                                       usemirror();
                                        v = BATmirror(v);
                                }
                                /* remove the least selective hash table */
                                HASHremove(BATmirror(v));
                        }
                        if (v->H->hash == NULL) {
-                               @:swap()@
+                               usemirror();
                                v = BATmirror(v);
                        }
                        if (v->H->hash) {
diff --git a/sql/test/BugTracker-2011/Tests/All 
b/sql/test/BugTracker-2011/Tests/All
--- a/sql/test/BugTracker-2011/Tests/All
+++ b/sql/test/BugTracker-2011/Tests/All
@@ -48,4 +48,5 @@ HAVE_PERL?perl-short-read-bug.Bug-2897
 device-self-ref-fk
 missing_refine_reverse.Bug-2898
 rand-with-seed.Bug-2900
+many-connects-cache.Bug-2904
 alter-table-set-read-only.bug-2906
diff --git a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py 
b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
@@ -0,0 +1,68 @@
+import os, sys
+try:
+    from MonetDBtesting import process
+except ImportError:
+    import process
+
+c = process.client('sql',
+                   args = ['-s', '''CREATE USER "testuser" WITH ENCRYPTED 
PASSWORD 
\'e9e633097ab9ceb3e48ec3f70ee2beba41d05d5420efee5da85f97d97005727587fda33ef4ff2322088f4c79e8133cc9cd9f3512f4d3a303cbdb5bc585415a00\'
 NAME \'Test User\' SCHEMA "sys";
+CREATE SCHEMA "testschema" AUTHORIZATION "testuser";
+ALTER USER "testuser" SET SCHEMA "testschema"'''],
+                   stdout = process.PIPE,
+                   stderr = process.PIPE)
+out, err = c.communicate()
+if out:
+    sys.stdout.write(out)
+if err:
+    sys.stderr.write(err)
+
+c = process.client('sql',
+                   args = ['-s', 'CREATE FUNCTION rad(d DOUBLE) RETURNS DOUBLE 
BEGIN RETURN d * PI() / 180; END'],
+                   user = 'testuser', passwd = 'testpassword',
+                   stdout = process.PIPE,
+                   stderr = process.PIPE)
+out, err = c.communicate()
+if out:
+    sys.stdout.write(out)
+if err:
+    sys.stderr.write(err)
+
+clients = []
+for i in range(50):
+    c = process.client('sql', args = ['-s', 'SELECT rad(55.81689)'],
+                       user = 'testuser', passwd = 'testpassword',
+#                       stdout = process.PIPE,
+#                       stderr = process.PIPE
+                       )
+    clients.append(c)
+
+for c in clients:
+    out, err = c.communicate()
+    if out:
+        sys.stdout.write(out)
+    if err:
+        sys.stderr.write(err)
+
+c = process.client('sql',
+                   args = ['-s', 'DROP FUNCTION rad'],
+                   user = 'testuser', passwd = 'testpassword',
+                   stdout = process.PIPE,
+                   stderr = process.PIPE)
+out, err = c.communicate()
+if out:
+    sys.stdout.write(out)
+if err:
+    sys.stderr.write(err)
+
+# undo damage
+c = process.client('sql',
+                   args = ['-s', '''ALTER USER "testuser" SET SCHEMA "sys";
+DROP SCHEMA "testschema";
+DROP USER "testuser"'''],
+                   stdout = process.PIPE,
+                   stderr = process.PIPE)
+out, err = c.communicate()
+if out:
+    sys.stdout.write(out)
+if err:
+    sys.stderr.write(err)
diff --git 
a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.err 
b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'many-connects-cache.Bug-2904` in directory 
'test/BugTracker-2011` itself:
+
+
+# 14:18:16 >  
+# 14:18:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/ufs/sjoerd/Monet-stable/var/MonetDB" "--set" "mapi_open=true" 
"--set" "mapi_port=33580" "--set" "monet_prompt=" "--trace" "--forcemito" 
"--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2011" "--set" 
"mal_listing=0"
+# 14:18:16 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = /ufs/sjoerd/Monet-stable/var/monetdb5/dbfarm
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_alloc_map = no
+# builtin opt  gdk_vmtrim = yes
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  gdk_dbfarm = /ufs/sjoerd/Monet-stable/var/MonetDB
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 33580
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_test_BugTracker-2011
+# cmdline opt  mal_listing = 0
+
+# 14:18:16 >  
+# 14:18:16 >  "/usr/bin/python" "many-connects-cache.Bug-2904.SQL.py" 
"many-connects-cache.Bug-2904"
+# 14:18:16 >  
+
+
+# 14:18:17 >  
+# 14:18:17 >  "Done."
+# 14:18:17 >  
+
diff --git 
a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out 
b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
@@ -0,0 +1,370 @@
+stdout of test 'many-connects-cache.Bug-2904` in directory 
'test/BugTracker-2011` itself:
+
+
+# 14:18:16 >  
+# 14:18:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/ufs/sjoerd/Monet-stable/var/MonetDB" "--set" "mapi_open=true" 
"--set" "mapi_port=33580" "--set" "monet_prompt=" "--trace" "--forcemito" 
"--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2011" "--set" 
"mal_listing=0"
+# 14:18:16 >  
+
+# MonetDB 5 server v11.5.4
+# This is an unreleased version
+# Serving database 'mTests_test_BugTracker-2011', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 7.749 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2011 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://ottar.ins.cwi.nl:33580/
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+# SQL catalog created, loading sql scripts once
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to