Changeset: 129da86e9686 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/129da86e9686 Modified Files: gdk/gdk.h gdk/gdk_bbp.c gdk/gdk_private.h monetdb5/modules/mal/batExtensions.c sql/backends/monet5/sql.c Branch: string_imprints Log Message:
Merge with default diffs (truncated from 126951 to 300 lines): diff --git a/clients/ChangeLog b/clients/ChangeLog --- a/clients/ChangeLog +++ b/clients/ChangeLog @@ -1,3 +1,10 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Wed Aug 11 2021 Sjoerd Mullender <sjo...@acm.org> +- A new output formatting mode was added to mclient. Use -fcsv-noquote + to produce a CSV (comma-separated values) output where the quote + characters have not been escapes. This can be useful when producing + a single column string output that should be saved as is, e.g. when + using the sys.dump_database() function. + 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 @@ -344,7 +344,7 @@ void HASHdestroy(BAT *b); BUN HASHlist(Hash *h, BUN i); BUN HASHprobe(const Hash *h, const void *v); void HEAP_free(Heap *heap, var_t block); -void HEAP_initialize(Heap *heap, size_t nbytes, size_t nprivate, int alignment); +gdk_return HEAP_initialize(Heap *heap, size_t nbytes, size_t nprivate, int alignment); var_t HEAP_malloc(BAT *b, size_t nbytes); void HEAPdecref(Heap *h, bool remove); gdk_return HEAPextend(Heap *h, size_t size, bool mayshare) __attribute__((__warn_unused_result__)); diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1 --- a/clients/mapiclient/mclient.1 +++ b/clients/mapiclient/mclient.1 @@ -204,6 +204,7 @@ The possible values are .BR expanded , .BR x , .BR csv , +.BR csv-noquote , .BR tab , .BR raw , .BR xml , @@ -212,6 +213,8 @@ and .BR rowcount . .B csv is comma-separated values; +.B csv-noquote +is comma-separated values without escaping any quotes; .B tab is tab-separated values; .B raw @@ -235,6 +238,10 @@ and is a variation on .B trash where only the number of affected rows is printed. +Normal \fBcsv\fP and \fBtab\fP formatting will use double quotes +around any fields that contain double quotes, white space or the +separator. The \fBcsv-noquote\fP format will prevent that and dump +the contents of the field without any interpretation. In addition to plain \fBcsv\fP, two other forms are possible. \fBcsv=\fP\fIc\fP uses \fIc\fP as column separator; \fBcsv+\fP\fIc\fP uses \fIc\fP as column separator and produces a single header line in diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -95,6 +95,7 @@ enum formatters { static enum formatters formatter = NOformatter; char *separator = NULL; /* column separator for CSV/TAB format */ bool csvheader = false; /* include header line in CSV format */ +bool noquote = false; /* don't use quotes in CSV format */ #define DEFWIDTH 80 @@ -942,7 +943,7 @@ CSVrenderer(MapiHdl hdl) while (!mnstr_errnr(toConsole) && (fields = fetch_row(hdl)) != 0) { for (i = 0; i < fields; i++) { s = mapi_fetch_field(hdl, i); - if (s != NULL && s[strcspn(s, specials)] != '\0') { + if (!noquote && s != NULL && s[strcspn(s, specials)] != '\0') { mnstr_printf(toConsole, "%s\"", i == 0 ? "" : separator); while (*s) { @@ -1647,6 +1648,7 @@ setFormatter(const char *s) free(separator); separator = NULL; csvheader = false; + noquote = false; #ifdef _TWO_DIGIT_EXPONENT if (formatter == TESTformatter) _set_output_format(0); @@ -1673,6 +1675,29 @@ setFormatter(const char *s) } else separator = strdup(s + 4); csvheader = true; + } else if (strcmp(s, "csv-noquote") == 0) { + noquote = true; + formatter = CSVformatter; + separator = strdup(","); + } else if (strncmp(s, "csv-noquote=", 12) == 0) { + noquote = true; + formatter = CSVformatter; + if (s[12] == '"') { + separator = strdup(s + 13); + if (separator[strlen(separator) - 1] == '"') + separator[strlen(separator) - 1] = 0; + } else + separator = strdup(s + 12); + } else if (strncmp(s, "csv-noquote+", 12) == 0) { + noquote = true; + formatter = CSVformatter; + if (s[12] == '"') { + separator = strdup(s + 13); + if (separator[strlen(separator) - 1] == '"') + separator[strlen(separator) - 1] = 0; + } else + separator = strdup(s + 12); + csvheader = true; } else if (strcmp(s, "tab") == 0) { formatter = CSVformatter; separator = strdup("\t"); @@ -1808,7 +1833,7 @@ format_result(Mapi mid, MapiHdl hdl, boo if (formatter == RAWformatter || formatter == TESTformatter) { mnstr_printf(toConsole, "[ %" PRId64 "\t]\n", mapi_rows_affected(hdl)); - } else if (formatter != TRASHformatter) { + } else if (formatter != TRASHformatter && formatter != CSVformatter) { aff = mapi_rows_affected(hdl); lid = mapi_get_last_id(hdl); mnstr_printf(toConsole, diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -3113,6 +3113,10 @@ close_connection(Mapi mid) } mid->redircnt = 0; mapi_log_record(mid, "Connection closed\n"); + if (mid->tracelog) { + close_stream(mid->tracelog); + mid->tracelog = 0; + } } MapiMsg diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake --- a/cmake/monetdb-defines.cmake +++ b/cmake/monetdb-defines.cmake @@ -297,7 +297,7 @@ macro(monetdb_configure_misc) CACHE STRING "Password hash algorithm, one of MD5, SHA1, RIPEMD160, SHA224, SHA256, SHA384, SHA512, defaults to SHA512") - if(NOT ${PASSWORD_BACKEND} MATCHES "^MD5|SHA1|RIPEMD160|SHA224|SHA256|SHA384|SHA512$") + if(NOT ${PASSWORD_BACKEND} MATCHES "^(MD5|SHA1|RIPEMD160|SHA224|SHA256|SHA384|SHA512)$") message(FATAL_ERROR "PASSWORD_BACKEND invalid, choose one of MD5, SHA1, RIPEMD160, SHA224, SHA256, SHA384, SHA512") endif() diff --git a/cmake/monetdb-options.cmake b/cmake/monetdb-options.cmake --- a/cmake/monetdb-options.cmake +++ b/cmake/monetdb-options.cmake @@ -39,6 +39,10 @@ option(FITS "Enable support for FITS (default=ON)" ON) +option(FORCE_COLORED_OUTPUT + "Force colored compiler output (GCC and Clang only; default=OFF)" + OFF) + option(GEOM "Enable support for geom module (default=ON)" ON) diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake --- a/cmake/monetdb-toolchain.cmake +++ b/cmake/monetdb-toolchain.cmake @@ -7,6 +7,14 @@ #]] function(monetdb_default_toolchain) + if (${FORCE_COLORED_OUTPUT}) + if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + MT_addCompilerFlag("-fdiagnostics-color=always" "-fdiagnostics-color=always" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) + elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "^(Clang|AppleClang)$") + MT_addCompilerFlag("-fcolor-diagnostics" "-fcolor-diagnostics" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) + endif () + endif () + if(SANITIZER) if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") MT_addCompilerFlag("-fsanitize=address" "-fsanitize=address" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) @@ -18,7 +26,7 @@ function(monetdb_default_toolchain) endif() if(STRICT) - if(${CMAKE_C_COMPILER_ID} MATCHES "^GNU|Clang|AppleClang$") + if(${CMAKE_C_COMPILER_ID} MATCHES "^(GNU|Clang|AppleClang)$") MT_addCompilerFlag("-Werror" "-Werror" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) MT_addCompilerFlag("-Wall" "-Wall" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) MT_addCompilerFlag("-Wextra" "-Wextra" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) @@ -101,6 +109,14 @@ function(monetdb_default_toolchain) endfunction() function(monetdb_default_compiler_options) + if (${FORCE_COLORED_OUTPUT}) + if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + add_compile_options("-fdiagnostics-color=always") + elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "^(Clang|AppleClang)$") + add_compile_options("-fcolor-diagnostics") + endif () + endif () + if(SANITIZER) if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") add_compile_options("-fsanitize=address") @@ -112,7 +128,7 @@ function(monetdb_default_compiler_option endif() if(STRICT) - if(${CMAKE_C_COMPILER_ID} MATCHES "^GNU|Clang|AppleClang$") + if(${CMAKE_C_COMPILER_ID} MATCHES "^(GNU|Clang|AppleClang)$") add_compile_options("-Werror") add_compile_options("-Wall") add_compile_options("-Wextra") @@ -149,10 +165,14 @@ function(monetdb_default_compiler_option add_option_if_available("-Wduplicated-branches") add_option_if_available("-Wrestrict") add_option_if_available("-Wnested-externs") + add_option_if_available("-Wmissing-noreturn") + add_option_if_available("-Wuninitialized") + # since we use values of type "int8_t" as subscript, # and int8_t may be defined as plain "char", we cannot # allow this warning (part of -Wall) add_option_if_available("-Wno-char-subscripts") + add_option_if_available("-Wunreachable-code") elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel") if(WIN32) diff --git a/common/stream/bs2.c b/common/stream/bs2.c --- a/common/stream/bs2.c +++ b/common/stream/bs2.c @@ -351,7 +351,7 @@ bs2_read(stream *restrict ss, void *rest return -1; } #ifdef BSTREAM_DEBUG - fprintf(stderr, "R1 '%s' length: %lld, final: %s\n", ss->name, blksize >> 1, blksize & 1 ? "true" : "false"); + fprintf(stderr, "R1 '%s' length: %" PRId64 ", final: %s\n", ss->name, blksize >> 1, blksize & 1 ? "true" : "false"); #endif s->itotal = (size_t) (blksize >> 1); /* amount readable */ /* store whether this was the last block or not */ @@ -431,7 +431,7 @@ bs2_read(stream *restrict ss, void *rest return -1; } #ifdef BSTREAM_DEBUG - fprintf(stderr, "R3 '%s' length: %lld, final: %s\n", ss->name, blksize >> 1, blksize & 1 ? "true" : "false"); + fprintf(stderr, "R3 '%s' length: %" PRId64 ", final: %s\n", ss->name, blksize >> 1, blksize & 1 ? "true" : "false"); #endif diff --git a/common/utils/ripemd160.c b/common/utils/ripemd160.c --- a/common/utils/ripemd160.c +++ b/common/utils/ripemd160.c @@ -39,7 +39,7 @@ RIPEMD160Input(RIPEMD160Context *ctxt, c bytecount -= ctxt->noverflow; bytes += ctxt->noverflow; ctxt->noverflow = 0; - compress(ctxt->digest, X); + MDcompress(ctxt->digest, X); } while (bytecount >= 64) { for (int i = 0; i < 16; i++) { @@ -47,7 +47,7 @@ RIPEMD160Input(RIPEMD160Context *ctxt, c bytes += 4; } bytecount -= 64; - compress(ctxt->digest, X); + MDcompress(ctxt->digest, X); } if (bytecount > 0) memcpy(ctxt->overflow, bytes, bytecount); diff --git a/common/utils/rmd160.c b/common/utils/rmd160.c --- a/common/utils/rmd160.c +++ b/common/utils/rmd160.c @@ -12,32 +12,30 @@ * * Copyright (c) 1996 Katholieke Universiteit Leuven * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * - * The above copyright notice and this permission notice shall be + * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list