Changeset: a360342f2919 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a360342f2919
Modified Files:
        NT/monetdb_config.h.in
        clients/mapiclient/mclient.c
        configure.ag
        gdk/gdk_storage.c
Branch: default
Log Message:

Merge with Jan2014 branch.


diffs (truncated from 561 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
@@ -171,7 +171,7 @@
 
 /* Define to 1 if you have the `ftruncate' function. */
 #define HAVE_FTRUNCATE 1
-#define ftruncate(fd, sz)      (_chsize_s((fd), (__int64) (sz)) == 0 ? 0 : -1)
+#define ftruncate(fd, sz)      (-(_chsize_s((fd), (__int64) (sz)) != 0))
 
 /* Does your compiler support function attributes (__attribute__)? */
 /* #undef HAVE_FUNCTION_ATTRIBUTES */
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -419,8 +419,7 @@ SQLrow(int *len, int *numeric, char **re
        if (trim == 1) {
                for (i = 0; i < fields; i++) {
                        if ((t = rest[i]) != NULL &&
-                           utf8strlen(t, NULL) > (size_t) len[i])
-                       {
+                           utf8strlen(t, NULL) > (size_t) len[i]) {
                                /* eat leading whitespace */
                                while (*t != 0 && isascii((int) *t) && 
isspace((int) *t))
                                        t++;
@@ -443,9 +442,12 @@ SQLrow(int *len, int *numeric, char **re
                                ulen = utf8strlen(rest[i], NULL);
 
                                if (first && trim == 2) {
-                                       /* calculate the height of this field 
according to
-                                        * the golden ratio, with a correction 
for a
-                                        * terminal screen (1.62 * 2 -> 3 : 
9.72~10) */
+                                       /* calculate the height of
+                                        * this field according to the
+                                        * golden ratio, with a
+                                        * correction for a terminal
+                                        * screen (1.62 * 2 -> 3 :
+                                        * 9.72~10) */
                                        if (ulen > (size_t) len[i])
                                                cutafter[i] = 3 * len[i] / 10;
                                }
@@ -476,8 +478,11 @@ SQLrow(int *len, int *numeric, char **re
                                                             "");
 
                                        if (!numeric[i]) {
-                                               /* replace tabs with a single 
space to avoid
-                                                * screwup the width 
calculations */
+                                               /* replace tabs with a
+                                                * single space to
+                                                * avoid screwup the
+                                                * width
+                                                * calculations */
                                                for (s = rest[i]; *s != *t; s++)
                                                        if (*s == '\t')
                                                                *s = ' ';
@@ -507,8 +512,8 @@ SQLrow(int *len, int *numeric, char **re
                                                croppedfields++;
                                        } else {
                                                mnstr_printf(toConsole, " %.*s 
",
-                                                                 (int) (t - 
rest[i]),
-                                                                 rest[i]);
+                                                            (int) (t - 
rest[i]),
+                                                            rest[i]);
                                                if (!numeric[i])
                                                        mnstr_printf(toConsole, 
"%*s",
                                                                     (int) 
(len[i] - (ulen - utf8strlen(t, NULL))),
@@ -516,8 +521,10 @@ SQLrow(int *len, int *numeric, char **re
                                        }
                                        rest[i] = *s ? s : 0;
                                        if (rest[i] == NULL) {
-                                               /* avoid > as border marker if 
everything
-                                                * actually just fits */
+                                               /* avoid > as border
+                                                * marker if
+                                                * everything actually
+                                                * just fits */
                                                cutafter[i] = -1;
                                        }
                                        if (cutafter[i] == 0)
@@ -529,27 +536,31 @@ SQLrow(int *len, int *numeric, char **re
                                                        first ? '|' : i > 0 && 
cutafter[i - 1] == 0 ? '>' : ':');
                                        if (numeric[i]) {
                                                mnstr_printf(toConsole, "%*s",
-                                                             (int) (len[i] - 
ulen),
-                                                             "");
+                                                            (int) (len[i] - 
ulen),
+                                                            "");
                                                mnstr_printf(toConsole, " %s ",
-                                                                 rest[i]);
+                                                            rest[i]);
                                        }
                                        if (!numeric[i]) {
                                                char *p;
-                                               /* replace tabs with a single 
space to avoid
-                                                * screwup the width 
calculations */
+                                               /* replace tabs with a
+                                                * single space to
+                                                * avoid screwup the
+                                                * width
+                                                * calculations */
                                                for (p = rest[i]; *p != '\0'; 
p++)
                                                        if (*p == '\t')
                                                                *p = ' ';
                                                mnstr_printf(toConsole, " %s ",
-                                                                 rest[i]);
+                                                            rest[i]);
                                                mnstr_printf(toConsole, "%*s",
-                                                             (int) (len[i] - 
ulen),
-                                                             "");
+                                                            (int) (len[i] - 
ulen),
+                                                            "");
                                        }
                                        rest[i] = 0;
-                                       /* avoid > as border marker if 
everything
-                                        * actually just fits */
+                                       /* avoid > as border marker if
+                                        * everything actually just
+                                        * fits */
                                        if (cutafter[i] == 0)
                                                cutafter[i] = -1;
                                }
@@ -617,13 +628,13 @@ XMLrenderer(MapiHdl hdl)
        mnstr_flush(toConsole);
        mnstr_printf(toConsole_raw, "<?xml version='1.0' encoding='UTF-8'?>\n");
        mnstr_printf(toConsole_raw,
-                     "<!DOCTYPE table [\n"
-                     " <!ELEMENT table (row)*>\n" /* a table consists of zero 
or more rows */
-                     " <!ELEMENT row (column)+>\n"     /* a row consists of 
one or more columns */
-                     " <!ELEMENT column (#PCDATA)>\n"
-                     " <!ATTLIST table name CDATA #IMPLIED>\n" /* a table may 
have a name */
-                     " <!ATTLIST column name CDATA #IMPLIED\n" /* a column may 
have a name */
-                     "                  isnull (true|false) 'false'>]>\n");
+                    "<!DOCTYPE table [\n"
+                    " <!ELEMENT table (row)*>\n" /* a table consists of zero 
or more rows */
+                    " <!ELEMENT row (column)+>\n"      /* a row consists of 
one or more columns */
+                    " <!ELEMENT column (#PCDATA)>\n"
+                    " <!ATTLIST table name CDATA #IMPLIED>\n"  /* a table may 
have a name */
+                    " <!ATTLIST column name CDATA #IMPLIED\n"  /* a column may 
have a name */
+                    "                  isnull (true|false) 'false'>]>\n");
        mnstr_printf(toConsole_raw, "<table");
        name = mapi_get_table(hdl, 0);
        if (name != NULL && *name != 0)
@@ -681,7 +692,7 @@ CSVrenderer(MapiHdl hdl)
                            strchr(s, '\n') != NULL ||
                            strchr(s, '"') != NULL) {
                                mnstr_printf(toConsole, "%s\"",
-                                             i == 0 ? "" : sep);
+                                            i == 0 ? "" : sep);
                                while (*s) {
                                        switch (*s) {
                                        case '\n':
@@ -708,7 +719,7 @@ CSVrenderer(MapiHdl hdl)
                                mnstr_write(toConsole, "\"", 1, 1);
                        } else
                                mnstr_printf(toConsole, "%s%s",
-                                             i == 0 ? "" : sep, s);
+                                            i == 0 ? "" : sep, s);
                }
                mnstr_printf(toConsole, "\n");
        }
@@ -768,20 +779,20 @@ static char *
 classify(const char *s, size_t l)
 {
        /* state is the current state of the state machine:
-          0 - initial state, no input seen
-          1 - initial sign
-          2 - valid integer (with optionally a sign)
-          3 - valid integer, followed by a decimal point
-          4 - fixed point number of the form [sign] digits period digits
-          5 - exponent marker after integer or fixed point number
-          6 - sign after exponent marker
-          7 - valid floating point number with exponent
-          8 - integer followed by single 'L'
-          9 - integer followed by 'LL' (lng)
-          10 - fixed or floating point number followed by single 'L'
-          11 - fixed or floating point number followed by 'LL' (dbl)
-          12 - integer followed by '@'
-          13 - valid OID (integer followed by '@0')
+        * 0 - initial state, no input seen
+        * 1 - initial sign
+        * 2 - valid integer (with optionally a sign)
+        * 3 - valid integer, followed by a decimal point
+        * 4 - fixed point number of the form [sign] digits period digits
+        * 5 - exponent marker after integer or fixed point number
+        * 6 - sign after exponent marker
+        * 7 - valid floating point number with exponent
+        * 8 - integer followed by single 'L'
+        * 9 - integer followed by 'LL' (lng)
+        * 10 - fixed or floating point number followed by single 'L'
+        * 11 - fixed or floating point number followed by 'LL' (dbl)
+        * 12 - integer followed by '@'
+        * 13 - valid OID (integer followed by '@0')
         */
        int state = 0;
 
@@ -971,8 +982,8 @@ TESTrenderer(MapiHdl hdl)
                                        default:
                                                if ((unsigned char) *s < ' ')
                                                        mnstr_printf(toConsole,
-                                                                     "\\%03o",
-                                                                     (int) 
(unsigned char) *s);
+                                                                    "\\%03o",
+                                                                    (int) 
(unsigned char) *s);
                                                else
                                                        mnstr_write(toConsole, 
s, 1, 1);
                                                break;
@@ -1186,9 +1197,8 @@ SQLrenderer(MapiHdl hdl, char singleinst
                /* do a very pessimistic calculation to determine if more
                 * columns would actually fit on the screen */
                if (pagewidth > 0 &&
-                               ((((printfields + 1) * 3) - 1) + 2) + /* 
graphwaste */
-                               (total - vartotal) + minvartotal > pagewidth)
-               {
+                   ((((printfields + 1) * 3) - 1) + 2) + /* graphwaste */
+                   (total - vartotal) + minvartotal > pagewidth) {
                        /* this last column was too much */
                        total -= len[i];
                        if (!numeric[i])
@@ -1480,6 +1490,7 @@ format_result(Mapi mid, MapiHdl hdl, cha
                        continue;
                }
 
+               timerHumanStop();
                switch (mapi_get_querytype(hdl)) {
                case Q_BLOCK:
                case Q_PARSE:
@@ -1490,74 +1501,75 @@ format_result(Mapi mid, MapiHdl hdl, cha
                        if (formatter == RAWformatter ||
                            formatter == TESTformatter)
                                mnstr_printf(toConsole, "[ " LLFMT "\t]\n", 
mapi_rows_affected(hdl));
+                       else if (formatter == TIMERformatter)
+                               printf("%s\n", timerHuman());
                        else {
-                               timerHumanStop();
                                aff = mapi_rows_affected(hdl);
                                lid = mapi_get_last_id(hdl);
+                               mnstr_printf(toConsole,
+                                            LLFMT " affected row%s",
+                                            aff,
+                                            aff == 1 ? "s" : "");
                                if (lid != -1) {
                                        mnstr_printf(toConsole,
-                                                       LLFMT " affected row%s, 
"
-                                                       "last generated key: " 
LLFMT "%s%s%s\n",
-                                                       aff,
-                                                       (aff == 1 ? "" : "s"),
-                                                       lid,
-                                                       singleinstr ? " (" : "",
-                                                       singleinstr && 
formatter != TESTformatter ? timerHuman() : "",
-                                                       singleinstr ? ")" : "");
-                               } else {
-                                       mnstr_printf(toConsole,
-                                                       LLFMT " affected 
row%s%s%s%s\n",
-                                                       aff,
-                                                       (aff == 1 ? "" : "s"),
-                                                       singleinstr ? " (" : "",
-                                                       singleinstr && 
formatter != TESTformatter ? timerHuman() : "",
-                                                       singleinstr ? ")" : "");
+                                                    ", last generated key: "
+                                                    LLFMT,
+                                                    lid);
                                }
+                               if (singleinstr && formatter != TESTformatter)
+                                       mnstr_printf(toConsole, " (%s)",
+                                                    timerHuman());
+                               mnstr_printf(toConsole, "\n");
                        }
                        continue;
                case Q_SCHEMA:
                        SQLqueryEcho(hdl);
-                       timerHumanStop();
-                       if (formatter == TABLEformatter)
-                               mnstr_printf(toConsole,
-                                             "operation successful%s%s%s\n",
-                                             singleinstr ? " (" : "",
-                                             singleinstr && formatter != 
TESTformatter ? timerHuman() : "",
-                                             singleinstr ? ")" : "");
+                       if (formatter == TABLEformatter) {
+                               mnstr_printf(toConsole, "operation successful");
+                               if (singleinstr)
+                                       mnstr_printf(toConsole, " (%s)",
+                                                    timerHuman());
+                               mnstr_printf(toConsole, "\n");
+                       } else if (formatter == TIMERformatter)
+                               printf("%s\n", timerHuman());
                        continue;
                case Q_TRANS:
                        SQLqueryEcho(hdl);
                        if (formatter == TABLEformatter)
                                mnstr_printf(toConsole,
-                                             "auto commit mode: %s\n",
-                                             mapi_get_autocommit(mid) ? "on" : 
"off");
+                                            "auto commit mode: %s\n",
+                                            mapi_get_autocommit(mid) ? "on" : 
"off");
                        continue;
                case Q_PREPARE:
                        SQLqueryEcho(hdl);
                        if (formatter == TABLEformatter)
                                mnstr_printf(toConsole,
-                                             "execute prepared statement "
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to