Changeset: ace143d049ce for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ace143d049ce
Modified Files:
        gdk/gdk_firstn.c
        sql/server/sql_scan.c
        sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.sql
        sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.stable.out
        sql/test/Dependencies/Tests/Dependencies.stable.err
        sql/test/Dependencies/Tests/Dependencies.stable.out
        sql/test/testdb/Tests/testdb-dump.stable.out.Windows
Branch: default
Log Message:

Merge with Oct2014 branch.


diffs (truncated from 489 to 300 lines):

diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c
--- a/gdk/gdk_firstn.c
+++ b/gdk/gdk_firstn.c
@@ -113,7 +113,7 @@
 
 #define shuffle_unique(TYPE, OP)                                       \
        do {                                                            \
-               const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
+               const TYPE *restrict vals = (const TYPE *) Tloc(b, 
BUNfirst(b)); \
                heapify(OP##fix, SWAP1);                                \
                while (cand ? cand < candend : start < end) {           \
                        i = cand ? *cand++ : start++ + b->hseqbase;     \
@@ -136,7 +136,7 @@ BATfirstn_unique(BAT *b, BAT *s, BUN n, 
 {
        BAT *bn;
        BATiter bi = bat_iterator(b);
-       oid *oids;
+       oid *restrict oids;
        BUN i, cnt, start, end;
        const oid *cand, *candend;
        int tpe = b->ttype;
@@ -357,7 +357,7 @@ BATfirstn_unique(BAT *b, BAT *s, BUN n, 
 
 #define shuffle_unique_with_groups(TYPE, OP)                           \
        do {                                                            \
-               const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
+               const TYPE *restrict vals = (const TYPE *) Tloc(b, 
BUNfirst(b));        \
                heapify(OP##fixgrp, SWAP2);                             \
                while (cand ? cand < candend : start < end) {           \
                        i = cand ? *cand++ : start++ + b->hseqbase;     \
@@ -378,8 +378,8 @@ BATfirstn_unique_with_groups(BAT *b, BAT
 {
        BAT *bn;
        BATiter bi = bat_iterator(b);
-       oid *oids, *goids;
-       const oid *gv;
+       oid *restrict oids, *restrict goids;
+       const oid *restrict gv;
        BUN i, cnt, start, end, ci;
        const oid *cand, *candend;
        int tpe = b->ttype;
@@ -601,14 +601,14 @@ BATfirstn_unique_with_groups(BAT *b, BAT
 
 #define shuffle_grouped1(TYPE, OPER)                                   \
        do {                                                            \
-               const TYPE *v = (const TYPE *) Tloc(b, BUNfirst(b));    \
+               const TYPE *restrict v = (const TYPE *) Tloc(b, BUNfirst(b)); \
                shuffle_grouped1_body(OPER(v[i], v[groups[j].bun]),     \
                                      v[i] == v[groups[j].bun]);        \
        } while (0)
 
 #define shuffle_grouped2(TYPE)                                         \
        do {                                                            \
-               const TYPE *v = (const TYPE *) Tloc(b, BUNfirst(b));    \
+               const TYPE *restrict v = (const TYPE *) Tloc(b, BUNfirst(b)); \
                TYPE lastval = v[groups[top - 1].bun];                  \
                for (i = cand ? *cand++ - b->hseqbase : start;          \
                     i < end;                                           \
@@ -631,7 +631,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids
 {
        BAT *bn, *gn;
        BATiter bi = bat_iterator(b);
-       oid *bp, *gp;
+       oid *restrict bp, *restrict gp;
        BUN top, i, j, k, cnt, start, end;
        const oid *cand, *candend, *oldcand;
        int tpe = b->ttype;
@@ -641,7 +641,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids
        struct group {
                BUN bun;
                BUN cnt;
-       } *groups;
+       } *restrict groups;
 
        assert(topn);
 
@@ -898,14 +898,14 @@ BATfirstn_grouped(BAT **topn, BAT **gids
 
 #define shuffle_grouped_with_groups1(TYPE, OPER)                       \
        do {                                                            \
-               const TYPE *v = (const TYPE *) Tloc(b, BUNfirst(b));    \
+               const TYPE *restrict v = (const TYPE *) Tloc(b, BUNfirst(b)); \
                shuffle_grouped_with_groups1_body(OPER(v[i], v[groups[j].bun]), 
\
                                                  v[i] == v[groups[j].bun]); \
        } while (0)
 
 #define shuffle_grouped_with_groups2(TYPE)                             \
        do {                                                            \
-               const TYPE *v = (const TYPE *) Tloc(b, BUNfirst(b));    \
+               const TYPE *restrict v = (const TYPE *) Tloc(b, BUNfirst(b)); \
                for (ci = 0, i = cand ? *cand++ - b->hseqbase : start;  \
                     i < end;                                           \
                     ci++, cand < candend ? (i = *cand++ - b->hseqbase) : i++) 
{ \
@@ -926,9 +926,9 @@ BATfirstn_grouped_with_groups(BAT **topn
 {
        BAT *bn, *gn;
        BATiter bi = bat_iterator(b);
-       oid *bp, *gp;
+       oid *restrict bp, *restrict gp;
        BUN top, i, j, k, cnt, start, end, ci;
-       const oid *cand, *candend, *oldcand, *gv;
+       const oid *cand, *candend, *oldcand, *restrict gv;
        int tpe = b->ttype;
        int c;
        int (*cmp)(const void *, const void *);
@@ -937,7 +937,7 @@ BATfirstn_grouped_with_groups(BAT **topn
                BUN bun;
                BUN cnt;
                oid grp;
-       } *groups;
+       } *restrict groups;
 
        assert(topn);
 
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -18,6 +18,7 @@
  */
 
 #include "monetdb_config.h"
+#include <wctype.h>
 #include <sql_mem.h>
 #include "sql_scan.h"
 #include "sql_types.h"
@@ -410,7 +411,7 @@ scanner_query_processed(struct scanner *
        s->rs->pos += s->yycur;
        /* completely eat the query including white space after the ; */
        while (s->rs->pos < s->rs->len &&
-              (cur = s->rs->buf[s->rs->pos], isascii(cur) && isspace(cur))) {
+              (cur = s->rs->buf[s->rs->pos], iswspace(cur))) {
                s->rs->pos++;
        }
        /*assert(s->rs->pos <= s->rs->len);*/
@@ -435,7 +436,10 @@ scanner_error(mvc *lc, int cur)
                (void) sql_error(lc, 1, "unexpected end of input");
                return -1;      /* EOF needs -1 result */
        default:
-               (void) sql_error(lc, 1, "unexpected%s character (U+%04X)", 
iscntrl(cur) ? " control" : "", cur);
+               /* on Windows at least, U+FEFF returns TRUE for
+                * iswcntrl, but we just want consistent error
+                * messages */
+               (void) sql_error(lc, 1, "unexpected%s character (U+%04X)", 
iswcntrl(cur) && cur != 0xFEFF ? " control" : "", cur);
        }
        return LEX_ERROR;
 }
@@ -682,7 +686,7 @@ keyword_or_ident(mvc * c, int cur)
        s = lc->yycur;
        lc->yyval = IDENT;
        while ((cur = scanner_getc(lc)) != EOF) {
-               if ((isascii(cur) && !isalnum(cur)) && cur != '_') {
+               if (!iswalnum(cur) && cur != '_') {
                        utf8_putchar(lc, cur);
                        (void)scanner_token(lc, IDENT);
                        k = find_keyword_bs(lc,s);
@@ -710,7 +714,7 @@ skip_white_space(struct scanner * lc)
        int cur;
 
        lc->yysval = lc->yycur;
-       while ((cur = scanner_getc(lc)) != EOF && isspace(cur))
+       while ((cur = scanner_getc(lc)) != EOF && iswspace(cur))
                lc->yysval = lc->yycur;
        return cur;
 }
@@ -761,15 +765,15 @@ number(mvc * c, int cur)
        lc->started = 1;
        if (cur == '0' && (cur = scanner_getc(lc)) == 'x') {
                while ((cur = scanner_getc(lc)) != EOF && 
-                               (isdigit(cur) || 
+                      (iswdigit(cur) || 
                                 (cur >= 'A' && cur <= 'F') || 
                                 (cur >= 'a' && cur <= 'f')))
                        token = HEXADECIMAL; 
                if (token == sqlINT)
                        before_cur = 'x';
        } else {
-               if (isdigit(cur))
-                       while ((cur = scanner_getc(lc)) != EOF && isdigit(cur)) 
+               if (iswdigit(cur))
+                       while ((cur = scanner_getc(lc)) != EOF && 
iswdigit(cur)) 
                                ;
                if (cur == '@') {
                        token = OIDNUM;
@@ -781,7 +785,7 @@ number(mvc * c, int cur)
                if (cur == '.') {
                        token = INTNUM;
        
-                       while ((cur = scanner_getc(lc)) != EOF && isdigit(cur)) 
+                       while ((cur = scanner_getc(lc)) != EOF && 
iswdigit(cur)) 
                                ;
                }
                if (cur == 'e' || cur == 'E') {
@@ -789,7 +793,7 @@ number(mvc * c, int cur)
                        cur = scanner_getc(lc);
                        if (cur == '-' || cur == '+') 
                                token = 0;
-                       while ((cur = scanner_getc(lc)) != EOF && isdigit(cur)) 
+                       while ((cur = scanner_getc(lc)) != EOF && 
iswdigit(cur)) 
                                token = APPROXNUM;
                }
        }
@@ -804,7 +808,7 @@ number(mvc * c, int cur)
                        utf8_putchar(lc, before_cur);
                return scanner_token(lc, token);
        } else {
-               (void)sql_error( c, 2, "unexpected symbol %c", cur);
+               (void)sql_error( c, 2, "unexpected symbol %lc", (wint_t) cur);
                return LEX_ERROR;
        }
 }
@@ -910,7 +914,7 @@ int scanner_symbol(mvc * c, int cur)
        case '.':
                lc->started = 1;
                cur = scanner_getc(lc);
-               if (!isdigit(cur)) {
+               if (!iswdigit(cur)) {
                        utf8_putchar(lc, cur); 
                        return scanner_token( lc, '.');
                } else {
@@ -928,7 +932,7 @@ int scanner_symbol(mvc * c, int cur)
                        return scanner_token(lc, '|');
                }
        }
-       (void)sql_error( c, 3, "unexpected symbol (%c)", cur);
+       (void)sql_error( c, 3, "unexpected symbol (%lc)", (wint_t) cur);
        return LEX_ERROR;
 }
 
@@ -937,15 +941,21 @@ tokenize(mvc * c, int cur)
 {
        struct scanner *lc = &c->scanner;
        while (1) {
-               if (isspace(cur)) {
+               if (cur == 0xFEFF) {
+                       /* on Linux at least, U+FEFF returns TRUE for
+                        * iswpunct, but we don't want that, we just
+                        * want to go to the scanner_error case
+                        * below */
+                       ;
+               } else if (iswspace(cur)) {
                        if ((cur = skip_white_space(lc)) == EOF)
                                return cur;
                        continue;  /* try again */
-               } else if (isdigit(cur)) {
+               } else if (iswdigit(cur)) {
                        return number(c, cur);
-               } else if (isalpha(cur) || cur == '_') {
+               } else if (iswalpha(cur) || cur == '_') {
                        return keyword_or_ident(c, cur);
-               } else if (ispunct(cur)) {
+               } else if (iswpunct(cur)) {
                        return scanner_symbol(c, cur);
                }
                if (cur == EOF) {
diff --git a/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.sql 
b/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.sql
--- a/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.sql
+++ b/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.sql
@@ -4,7 +4,7 @@ BEGIN
        RETURN 1;
 END;
 
-CREATE TABLE "bam"."alignments_2" (
+CREATE TABLE "alignments_2" (
        "virtual_offset" BIGINT        NOT NULL,
        "qname"          CHARACTER LARGE OBJECT NOT NULL,
        "flag"           SMALLINT      NOT NULL,
@@ -20,12 +20,12 @@ CREATE TABLE "bam"."alignments_2" (
        "qual"           CHARACTER LARGE OBJECT NOT NULL,
        CONSTRAINT "alignments_2_pkey_virtual_offset" PRIMARY KEY 
("virtual_offset")
 );
-ALTER TABLE bam.alignments_2 SET READ ONLY;
+ALTER TABLE alignments_2 SET READ ONLY;
 SELECT s.value AS refpos, COUNT(*) AS cnt
        FROM 
            generate_series(128, 18960) AS s
        JOIN (
-           SELECT epos, pos, seq, cigar FROM bam.alignments_2 WHERE pos > 0 ) 
AS al 
+           SELECT epos, pos, seq, cigar FROM alignments_2 WHERE pos > 0 ) AS 
al 
        ON (
                s.value >= al.pos AND s.value <= al."epos"
                AND seq_char(s.value, al.seq, al.pos, al.cigar) IS NOT NULL
@@ -34,5 +34,5 @@ GROUP BY refpos
 ORDER BY cnt DESC
 LIMIT 10;
 
-DROP TABLE bam.alignments_2;
+DROP TABLE alignments_2;
 DROP FUNCTION seq_char;
diff --git a/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.stable.out 
b/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.stable.out
--- a/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.stable.out
+++ b/sql/test/BugTracker-2014/Tests/type_resolution.Bug-3622.stable.out
@@ -30,7 +30,7 @@ Ready.
 #BEGIN
 #      RETURN 1;
 #END;
-#CREATE TABLE "bam"."alignments_2" (
+#CREATE TABLE "alignments_2" (
 #      "virtual_offset" BIGINT        NOT NULL,
 #      "qname"          CHARACTER LARGE OBJECT NOT NULL,
 #      "flag"           SMALLINT      NOT NULL,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to