Changeset: 2fbbcb60dc63 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2fbbcb60dc63 Added Files: sql/test/copy/Tests/incorrect_columns.sql sql/test/copy/Tests/incorrect_columns.stable.err sql/test/copy/Tests/incorrect_columns.stable.out Modified Files: clients/ChangeLog.Jul2015 clients/R/MonetDB.R/R/dbi.R clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out clients/mapiclient/mclient.c clients/odbc/driver/SQLDriverConnect.c gdk/gdk_heap.c gdk/gdk_logger.c monetdb5/modules/atoms/str.c monetdb5/modules/atoms/str.h monetdb5/modules/atoms/str.mal monetdb5/modules/kernel/algebra.c monetdb5/modules/mal/tablet.c sql/backends/monet5/sql_result.c sql/test/Users/Tests/dropManyUsers.Bug-3764.stable.out sql/test/copy/Tests/All sql/test/copy/Tests/key_copy.sql sql/test/copy/Tests/key_copy.stable.err Branch: profiler Log Message:
merge with default diffs (truncated from 915 to 300 lines): diff --git a/clients/ChangeLog.Jul2015 b/clients/ChangeLog.Jul2015 --- a/clients/ChangeLog.Jul2015 +++ b/clients/ChangeLog.Jul2015 @@ -1,3 +1,7 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Sun Aug 30 2015 Sjoerd Mullender <sjo...@acm.org> +- In the SQL formatter of mclient (the default) we now properly align + East Asian wide characters. + diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R --- a/clients/R/MonetDB.R/R/dbi.R +++ b/clients/R/MonetDB.R/R/dbi.R @@ -291,7 +291,9 @@ quoteIfNeeded <- function(conn, x, warn= message("Identifier(s) ", paste("\"", x[reserved],"\"", collapse=", ", sep=""), " are reserved SQL keywords and need(s) to be quoted in queries.") } qts <- reserved | chars - x[qts] <- dbQuoteIdentifier(conn, x[qts]) + if (any(qts)) { + x[qts] <- dbQuoteIdentifier(conn, x[qts]) + } x } @@ -656,19 +658,11 @@ monet.read.csv <- monetdb.read.csv <- fu delimspec <- paste0("USING DELIMITERS '", delim, "','", newline, "','", quote, "'") - if(header){ - for(i in seq_along(files)) { - thefile <- normalizePath(files[i]) - dbSendUpdate(conn, paste("COPY OFFSET 2 INTO", - tablename, "FROM", paste("'", thefile, "'", sep=""), delimspec, "NULL as", paste("'", - na.strings[1], "'", sep=""), if(locked) "LOCKED")) - } - } else { - for(i in seq_along(files)) { - thefile <- normalizePath(files[i]) - dbSendUpdate(conn, paste0("COPY INTO ", tablename, " FROM ", paste("'", thefile, "'", sep=""), - delimspec, "NULL as ", paste("'", na.strings[1], "'", sep=""), if(locked) " LOCKED ")) - } + for(i in seq_along(files)) { + thefile <- normalizePath(files[i]) + dbSendUpdate(conn, paste("COPY", if(header) "OFFSET 2", "INTO", + tablename, "FROM", paste("'", thefile, "'", sep=""), delimspec, "NULL as", paste("'", + na.strings[1], "'", sep=""), if(locked) "LOCKED")) } dbGetQuery(conn, paste("SELECT COUNT(*) FROM", tablename))[[1]] } diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -41137,7 +41137,7 @@ address STRPrefix; comment Prefix check. command str.stringlength(s:str):int -address STRstringLength; +address STRSQLLength; comment Return the length of a right trimed string (SQL semantics). command str.string(s:str,offset:int,count:int):str diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -52080,7 +52080,7 @@ address STRPrefix; comment Prefix check. command str.stringlength(s:str):int -address STRstringLength; +address STRSQLLength; comment Return the length of a right trimed string (SQL semantics). command str.string(s:str,offset:int,count:int):str diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1936,7 +1936,6 @@ str STRreplace(str *ret, const str *s1, str STRspace(str *ret, const int *l); str STRsplitpart(str *res, str *haystack, str *needle, int *field); str STRstrSearch(int *res, const str *arg1, const str *arg2); -str STRstringLength(int *res, const str *s); str STRsubstring(str *ret, const str *s, const int *start, const int *l); str STRsubstringTail(str *ret, const str *s, const int *start); str STRsuffix(str *ret, const str *s, const int *l); diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -359,36 +359,127 @@ SQLsetSpecial(const char *command) /* return the display length of a UTF-8 string if e is not NULL, return length up to e */ static size_t -utf8strlen(const char *s, const char *e) +utf8strlenmax(char *s, char *e, size_t max, char **t) { - size_t len = 0; + size_t len = 0, len0 = 0; + int c; + int n; + char *t0 = s; + assert(max == 0 || t != NULL); if (s == NULL) return 0; - while (*s && (e == NULL || s < e)) { - /* only count first byte of a sequence */ - if ((*s & 0xC0) != 0x80) + c = 0; + n = 0; + while (*s != 0 && (e == NULL || s < e)) { + if (*s == '\n') { + assert(n == 0); + if (max) { + *t = s; + return len; + } len++; + n = 0; + } else if ((*s & 0x80) == 0) { + assert(n == 0); + len++; + n = 0; + } else if ((*s & 0xC0) == 0x80) { + c = (c << 6) | (*s & 0x3F); + if (--n == 0) { + /* last byte of a multi-byte character */ + len++; + /* the following code points are all East + * Asian Fullwidth and East Asian Wide + * characters as defined in Unicode 8.0 */ + if ((0x1100 <= c && c <= 0x115F) || + c == 0x2329 || + c == 0x232A || + (0x2E80 <= c && c <= 0x2E99) || + (0x2E9B <= c && c <= 0x2EF3) || + (0x2F00 <= c && c <= 0x2FD5) || + (0x2FF0 <= c && c <= 0x2FFB) || + (0x3000 <= c && c <= 0x303E) || + (0x3041 <= c && c <= 0x3096) || + (0x3099 <= c && c <= 0x30FF) || + (0x3105 <= c && c <= 0x312D) || + (0x3131 <= c && c <= 0x318E) || + (0x3190 <= c && c <= 0x31BA) || + (0x31C0 <= c && c <= 0x31E3) || + (0x31F0 <= c && c <= 0x321E) || + (0x3220 <= c && c <= 0x3247) || + (0x3250 <= c && c <= 0x4DBF) || + (0x4E00 <= c && c <= 0xA48C) || + (0xA490 <= c && c <= 0xA4C6) || + (0xA960 <= c && c <= 0xA97C) || + (0xAC00 <= c && c <= 0xD7A3) || + (0xF900 <= c && c <= 0xFAFF) || + (0xFE10 <= c && c <= 0xFE19) || + (0xFE30 <= c && c <= 0xFE52) || + (0xFE54 <= c && c <= 0xFE66) || + (0xFE68 <= c && c <= 0xFE6B) || + (0xFF01 <= c && c <= 0xFFE6) || + (0x1B000 <= c && c <= 0x1B001) || + (0x1F200 <= c && c <= 0x1F202) || + (0x1F210 <= c && c <= 0x1F23A) || + (0x1F240 <= c && c <= 0x1F248) || + (0x1F250 <= c && c <= 0x1F251) || + (0x20000 <= c && c <= 0x2FFFD) || + (0x30000 <= c && c <= 0x3FFFD)) + len++; + } + } else if ((*s & 0xE0) == 0xC0) { + assert(n == 0); + n = 1; + c = *s & 0x1F; + } else if ((*s & 0xF0) == 0xE0) { + assert(n == 0); + n = 2; + c = *s & 0x0F; + } else if ((*s & 0xF8) == 0xF0) { + assert(n == 0); + n = 3; + c = *s & 0x07; + } else if ((*s & 0xFC) == 0xF8) { + assert(n == 0); + n = 4; + c = *s & 0x03; + } else { + assert(0); + n = 0; + } s++; + if (n == 0) { + if (max != 0) { + if (len > max) { + *t = t0; + return len0; + } + if (len == max) { + *t = s; + return len; + } + } + t0 = s; + len0 = len; + } } + if (max != 0) + *t = s; return len; } +static size_t +utf8strlen(char *s, char *e) +{ + return utf8strlenmax(s, e, 0, NULL); +} + /* skip the specified number of UTF-8 characters, but stop at a newline */ static char * utf8skip(char *s, size_t i) { - while (*s && i > 0) { - if ((*s & 0xC0) == 0xC0) { - s++; - while ((*s & 0xC0) == 0x80) - s++; - } else if (*s == '\n') - return s; - else - s++; - i--; - } + utf8strlenmax(s, NULL, i, &s); return s; } @@ -434,8 +525,11 @@ SQLrow(int *len, int *numeric, char **re * correction for a terminal * screen (1.62 * 2 -> 3 : * 9.72~10) */ - if (ulen > (size_t) len[i]) + if (ulen > (size_t) len[i]) { cutafter[i] = 3 * len[i] / 10; + if (cutafter[i] == 1) + cutafter[i]++; + } } /* on each cycle we get closer to the limit */ diff --git a/clients/odbc/driver/SQLDriverConnect.c b/clients/odbc/driver/SQLDriverConnect.c --- a/clients/odbc/driver/SQLDriverConnect.c +++ b/clients/odbc/driver/SQLDriverConnect.c @@ -217,16 +217,17 @@ ODBCConnectionString(SQLRETURN rc, /* calculate how much space was needed */ if (StringLength2Ptr) - *StringLength2Ptr = (int) (strlen(dsn ? dsn : "DEFAULT") + 5 + - (uid ? strlen(uid) + 5 : 0) + - (pwd ? strlen(pwd) + 5 : 0) + - (host ? strlen(host) + 6 : 0) + - (port ? port + 6 : 0) + - (database ? strlen(database) + 10 : 0) + *StringLength2Ptr = (SQLSMALLINT) + (strlen(dsn ? dsn : "DEFAULT") + 5 + + (uid ? strlen(uid) + 5 : 0) + + (pwd ? strlen(pwd) + 5 : 0) + + (host ? strlen(host) + 6 : 0) + + (port ? port + 6 : 0) + + (database ? strlen(database) + 10 : 0) #ifdef ODBCDEBUG - + (ODBCdebug && getenv("ODBCDEBUG") == NULL ? strlen(ODBCdebug) + 9 : 0) + + (ODBCdebug && getenv("ODBCDEBUG") == NULL ? strlen(ODBCdebug) + 9 : 0) #endif - ); + ); #ifdef ODBCDEBUG ODBCLOG("ConnectionString: \"%.*s\" %d\n", buf ? buflen : 6, buf ? (char *) buf : "(null)", buflen); diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -412,12 +412,15 @@ GDKupgradevarheap(COLrec *c, var_t v, in * indicated by the "free" pointer */ n = (copyall ? c->heap.size : c->heap.free) >> c->shift; - /* for memory mapped files, create a backup copy before widening + /* Create a backup copy before widening. * - * this solves a problem that we don't control what's in the - * actual file until the next commit happens, so a crash might - * otherwise leave the file (and the database) in an - * inconsistent state + * If the file is memory-mapped, this solves a problem that we + * don't control what's in the actual file until the next + * commit happens, so a crash might otherwise leave the file + * (and the database) in an inconsistent state. If, on the + * other hand, the heap is allocated, it may happen that later + * on the heap is extended and converted into a memory-mapped + * file. Then the same problem arises. * * also see do_backup in gdk_bbp.c */ filename = strrchr(c->heap.filename, DIR_SEP); @@ -426,9 +429,11 @@ GDKupgradevarheap(COLrec *c, var_t v, in else _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list