Changeset: a9c95d2d4caa for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9c95d2d4caa Branch: octbugs Log Message:
Merge with Oct2020 branch. diffs (truncated from 310 to 300 lines): diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py --- a/NT/mksqlwxs.py +++ b/NT/mksqlwxs.py @@ -151,6 +151,7 @@ def main(): vcpkg.format(r'bin\libcharset.dll'), # for libiconv.dll vcpkg.format(r'bin\libcrypto-1_1{}.dll'.format(libcrypto)), vcpkg.format(r'bin\libxml2.dll'), + vcpkg.format(r'bin\lz4.dll'), vcpkg.format(r'bin\lzma.dll'), vcpkg.format(r'bin\pcre.dll'), vcpkg.format(r'bin\zlib1.dll')]) @@ -200,8 +201,12 @@ def main(): r'lib\stream.lib', vcpkg.format(r'lib\libiconv.lib'), vcpkg.format(r'lib\bz2.lib'), + vcpkg.format(r'lib\getopt.lib'), + vcpkg.format(r'lib\libcharset.lib'), vcpkg.format(r'lib\libcrypto.lib'), vcpkg.format(r'lib\libxml2.lib'), + vcpkg.format(r'lib\lz4.lib'), + vcpkg.format(r'lib\lzma.lib'), vcpkg.format(r'lib\pcre.lib'), vcpkg.format(r'lib\zlib.lib')]) print(r' </Directory>') diff --git a/common/stream/stdio_stream.c b/common/stream/stdio_stream.c --- a/common/stream/stdio_stream.c +++ b/common/stream/stdio_stream.c @@ -165,6 +165,7 @@ file_fsetpos(stream *restrict s, fpos_t /* convert a string from UTF-8 to wide characters; the return value is * freshly allocated */ +#ifdef HAVE__WFOPEN static wchar_t * utf8towchar(const char *src) { @@ -246,6 +247,8 @@ utf8towchar(const char *src) return dest; } +#else + static char * cvfilename(const char *filename) { @@ -281,6 +284,7 @@ cvfilename(const char *filename) * locale's encoding is not UTF-8) */ return strdup(filename); } +#endif stream * @@ -297,7 +301,6 @@ open_stream(const char *restrict filenam { wchar_t *wfname = utf8towchar(filename); wchar_t *wflags = utf8towchar(flags); - (void)cvfilename; if (wfname != NULL && wflags != NULL) fp = _wfopen(wfname, wflags); else @@ -310,7 +313,6 @@ open_stream(const char *restrict filenam #else { char *fname = cvfilename(filename); - (void)utf8towchar; if (fname) { fp = fopen(fname, flags); free(fname); @@ -498,3 +500,24 @@ getFileSize(stream *s) return (size_t) stb.st_size; return 0; /* unknown */ } + +int +file_remove(const char *filename) +{ + int rc = -1; + +#ifdef HAVE__WFOPEN + wchar_t *wfname = utf8towchar(filename); + if (wfname != NULL) { + rc = _wremove(wfname); + free(wfname); + } +#else + char *fname = cvfilename(filename); + if (fname) { + rc = remove(fname); + free(fname); + } +#endif + return rc; +} diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -851,7 +851,7 @@ open_rstream(const char *filename) stream *c = compressed_stream(s, 0); if (c == NULL) - mnstr_close(s); + mnstr_destroy(s); return c; } @@ -870,8 +870,10 @@ open_wstream(const char *filename) return NULL; stream *c = compressed_stream(s, 0); - if (c == NULL) - mnstr_close(s); + if (c == NULL) { + mnstr_destroy(s); + file_remove(filename); + } return c; } @@ -890,7 +892,7 @@ open_rastream(const char *filename) stream *t = create_text_stream(s); if (t == NULL) - mnstr_close(s); + mnstr_destroy(s); return t; } @@ -908,8 +910,10 @@ open_wastream(const char *filename) return NULL; stream *t = create_text_stream(s); - if (t == NULL) - mnstr_close(s); + if (t == NULL) { + mnstr_destroy(s); + file_remove(filename); + } return t; } diff --git a/common/stream/stream_internal.h b/common/stream/stream_internal.h --- a/common/stream/stream_internal.h +++ b/common/stream/stream_internal.h @@ -207,6 +207,9 @@ stream *open_stream(const char *restrict stream *file_stream(const char *name) __attribute__((__visibility__("hidden"))); +int file_remove(const char *filename) + __attribute__((__visibility__("hidden"))); + /* implementation detail of stdio_stream.c which must be public because * for example bstream() special cases on it to provide a fast path for file * i/o. diff --git a/debian/control b/debian/control --- a/debian/control +++ b/debian/control @@ -158,7 +158,7 @@ Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, monetdb5-server (= ${source:Version}) -Description: MonetDB5 SQL GIS support module +Description: MonetDB5 add on module for FITS files MonetDB is a database management system that is developed from a main-memory perspective with use of a fully decomposed storage model, automatic index management, extensibility of data types and search @@ -190,7 +190,7 @@ Package: monetdb5-server-dev Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, monetdb5-server (= ${source:Version}), libmonetdb-dev (= ${source:Version}) -Description: MonetDB database server version 5 +Description: MonetDB database server version 5 development files MonetDB is a database management system that is developed from a main-memory perspective with use of a fully decomposed storage model, automatic index management, extensibility of data types and search diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c --- a/monetdb5/mal/mal_exception.c +++ b/monetdb5/mal/mal_exception.c @@ -61,22 +61,39 @@ dupError(const char *err) static str __attribute__((__format__(__printf__, 3, 0), __returns_nonnull__)) createExceptionInternal(enum malexception type, const char *fcn, const char *format, va_list ap) { - char local[GDKMAXERRLEN]; + size_t msglen; int len; + char *msg; + va_list ap2; #ifndef NDEBUG // if there is an error we allow memory allocation once again GDKsetmallocsuccesscount(-1); #endif - len = snprintf(local, GDKMAXERRLEN, "%s:%s:", exceptionNames[type], fcn); - len = vsnprintf(local + len, GDKMAXERRLEN - len, format, ap); - if (len < 0) + va_copy(ap2, ap); /* we need to use it twice */ + msglen = strlen(exceptionNames[type]) + strlen(fcn) + 2; + len = vsnprintf(NULL, 0, format, ap); /* count necessary length */ + if (len < 0) { TRC_CRITICAL(MAL_SERVER, "called with bad arguments"); - char *q = local; - for (char *p = strchr(q, '\n'); p; q = p + 1, p = strchr(q, '\n')) - TRC_ERROR(MAL_SERVER, "%.*s\n", (int) (p - q), q); - if (*q) - TRC_ERROR(MAL_SERVER, "%s\n", q); - return dupError(local); + len = 0; + } + msg = GDKmalloc(msglen + len + 1); + if (msg != NULL) { + /* the calls below succeed: the arguments have already been checked */ + (void) strconcat_len(msg, msglen + 1, + exceptionNames[type], ":", fcn, ":", NULL); + if (len > 0) + (void) vsnprintf(msg + msglen, len + 1, format, ap2); + va_end(ap2); + char *q = msg; + for (char *p = strchr(msg, '\n'); p; q = p + 1, p = strchr(q, '\n')) + TRC_ERROR(MAL_SERVER, "%.*s\n", (int) (p - q), q); + if (*q) + TRC_ERROR(MAL_SERVER, "%s\n", q); + } else { + msg = M5OutOfMemory; + } + va_end(ap2); + return msg; } /** @@ -145,38 +162,52 @@ freeException(str msg) static str __attribute__((__format__(__printf__, 5, 0), __returns_nonnull__)) createMalExceptionInternal(MalBlkPtr mb, int pc, enum malexception type, char *prev, const char *format, va_list ap) { - char buf[GDKMAXERRLEN]; - size_t i; - str s, fcn; + bool addnl = false; + const char *s = mb ? getModName(mb) : "unknown"; + const char *fcn = mb ? getFcnName(mb) : "unknown"; + size_t msglen; - s = mb ? getModName(mb) : "unknown"; - fcn = mb ? getFcnName(mb) : "unknown"; - i = 0; - - if (prev){ - if( *prev){ - i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s", prev); - if( buf[i-1] != '\n') - buf[i++]= '\n'; + if (prev) { + msglen = strlen(prev); + if (msglen > 0 && prev[msglen - 1] != '\n') { + addnl = true; + msglen++; } - i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "!%s:%s.%s[%d]:", - exceptionNames[type], s, fcn, pc); - freeException(prev); - } else if( type == SYNTAX) - i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s:", - exceptionNames[type]); - else - i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s:%s.%s[%d]:", - exceptionNames[type], s, fcn, pc); - i += vsnprintf(buf + i, GDKMAXERRLEN - 1 - i, format, ap); - if( buf[i-1] != '\n') - buf[i++]= '\n'; - buf[i] = '\0'; - - s = GDKstrdup(buf); - if (s == NULL) /* make sure we always return something */ - s = M5OutOfMemory; - return s; + msglen += snprintf(NULL, 0, "!%s:%s.%s[%d]:", + exceptionNames[type], s, fcn, pc); + } else if (type == SYNTAX) { + msglen = strlen(exceptionNames[type]) + 1; + } else { + msglen = snprintf(NULL, 0, "%s:%s.%s[%d]:", + exceptionNames[type], s, fcn, pc); + } + va_list ap2; + va_copy(ap2, ap); + int len = vsnprintf(NULL, 0, format, ap); + if (len < 0) + len = 0; + char *msg = GDKmalloc(msglen + len + 1); + if (msg != NULL) { + /* the calls below succeed: the arguments have already been checked */ + if (prev) { + (void) snprintf(msg, msglen + 1, "%s%s!%s:%s.%s[%d]:", + prev, addnl ? "\n" : "", + exceptionNames[type], s, fcn, pc); + } else if (type == SYNTAX) { + (void) strconcat_len(msg, msglen + 1, + exceptionNames[type], ":", NULL); + } else { + (void) snprintf(msg, msglen + 1, "%s:%s.%s[%d]:", + exceptionNames[type], s, fcn, pc); + } + if (len > 0) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list