diff --git a/debian/.pbuilderrc b/debian/.pbuilderrc index 34e88f696..a6fe1a129 100644 --- a/debian/.pbuilderrc +++ b/debian/.pbuilderrc @@ -3,10 +3,13 @@ # # ubuntu: # prepare old (trusty or earlier) host system: + +# sudo ln -s gutsy /usr/share/debootstrap/scripts/eoan # sudo ln -s gutsy /usr/share/debootstrap/scripts/disco # sudo ln -s gutsy /usr/share/debootstrap/scripts/cosmic # sudo ln -s gutsy /usr/share/debootstrap/scripts/artful # sudo ln -s gutsy /usr/share/debootstrap/scripts/bionic +# sudo ln -s sid /usr/share/debootstrap/scripts/buster # build ubuntu: # sudo DIST=trusty pbuilder create --configfile debian/.pbuilderrc && DIST=trusty pdebuild --configfile debian/.pbuilderrc # sudo DIST=xenial pbuilder create --configfile debian/.pbuilderrc && DIST=xenial pdebuild --configfile debian/.pbuilderrc @@ -56,7 +59,7 @@ DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME $STABLE_BAC "experimental" "unstable" "testing" "stable") # List of Ubuntu suites. Update these when needed. -UBUNTU_SUITES=("disco" "cosmic" "bionic" "artful" "zesty" "xenial" "trusty" "devel") +UBUNTU_SUITES=("eoan" "disco" "cosmic" "bionic" "artful" "zesty" "xenial" "trusty" "devel") # Set a default distribution if none is used. Note that you can set your own default (i.e. ${DIST:="unstable"}). HOST_DIST=`lsb_release --short --codename` diff --git a/driver/connection.cpp b/driver/connection.cpp index 6c8930863..11415b9fb 100644 --- a/driver/connection.cpp +++ b/driver/connection.cpp @@ -203,9 +203,13 @@ void Connection::loadConfiguration() { auto str = stringFromMYTCHAR(ci.trace); if (!str.empty()) log_enabled = !(str == "0" || str == "No" || str == "no"); - if (log_enabled && !tracefile.empty() && tracefile != log_file) { + if (log_enabled && !tracefile.empty() && (tracefile != log_file || !log_stream.is_open())) { log_file = tracefile; log_stream = std::ofstream(log_file, std::ios::out | std::ios::app); + if (!log_header.empty()) { + LOG(log_header); + log_header.clear(); + } } } if (url.empty()) diff --git a/driver/environment.cpp b/driver/environment.cpp index 20e6cd3b6..e4f30cdde 100644 --- a/driver/environment.cpp +++ b/driver/environment.cpp @@ -79,46 +79,49 @@ Environment::Environment() { LOG(std::endl << mbstr); } - std::string report; - report += " VERSION=" + std::string {VERSION_STRING}; + log_header = " === Driver started ==="; + log_header += " VERSION=" + std::string {VERSION_STRING}; #if defined(_win64_) - report += " WIN64"; + log_header += " WIN64"; #elif defined(_win32_) - report += " WIN32"; + log_header += " WIN32"; #endif #if ODBC_IODBC - report += " ODBC_IODBC"; + log_header += " ODBC_IODBC"; #endif #if ODBC_CHAR16 - report += " ODBC_CHAR16"; + log_header += " ODBC_CHAR16"; #endif #if ODBC_UNIXODBC - report += " ODBC_UNIXODBC"; + log_header += " ODBC_UNIXODBC"; #endif #if defined(UNICODE) - report += " UNICODE=" + std::to_string(UNICODE); + log_header += " UNICODE=" + std::to_string(UNICODE); # if defined(ODBC_WCHAR) - report += " ODBC_WCHAR=" + std::to_string(ODBC_WCHAR); + log_header += " ODBC_WCHAR=" + std::to_string(ODBC_WCHAR); # endif - report += " sizeof(SQLTCHAR)=" + std::to_string(sizeof(SQLTCHAR)) + " sizeof(wchar_t)=" + std::to_string(sizeof(wchar_t)); + log_header += " sizeof(SQLTCHAR)=" + std::to_string(sizeof(SQLTCHAR)) + " sizeof(wchar_t)=" + std::to_string(sizeof(wchar_t)); #endif #if defined(SQL_WCHART_CONVERT) - report += " SQL_WCHART_CONVERT"; + log_header += " SQL_WCHART_CONVERT"; #endif #if ODBCVER std::stringstream strm; strm << " ODBCVER=" << std::hex << ODBCVER << std::dec; - report += strm.str(); + log_header += strm.str(); #endif #if defined(ODBC_LIBRARIES) - report += " ODBC_LIBRARIES=" + std::string {ODBC_LIBRARIES}; + log_header += " ODBC_LIBRARIES=" + std::string {ODBC_LIBRARIES}; #endif #if defined(ODBC_INCLUDE_DIRECTORIES) - report += " ODBC_INCLUDE_DIRECTORIES=" + std::string {ODBC_INCLUDE_DIRECTORIES}; + log_header += " ODBC_INCLUDE_DIRECTORIES=" + std::string {ODBC_INCLUDE_DIRECTORIES}; #endif - LOG(" === Driver started ===" << report); + if (log_stream.is_open()) { + LOG(log_header); + log_header.clear(); + } } } diff --git a/driver/log/log.cpp b/driver/log/log.cpp index 104a6bd26..0b27e079f 100644 --- a/driver/log/log.cpp +++ b/driver/log/log.cpp @@ -12,7 +12,8 @@ bool log_enabled = ; std::string log_file = LOG_DEFAULT_FILE; -std::ofstream log_stream(log_file, std::ios::out | std::ios::app); +std::ofstream log_stream = log_enabled ? std::ofstream(log_file, std::ios::out | std::ios::app) : std::ofstream(); +std::string log_header; std::chrono::high_resolution_clock hr_clock; diff --git a/driver/log/log.h b/driver/log/log.h index 2dbc45080..4e2586773 100644 --- a/driver/log/log.h +++ b/driver/log/log.h @@ -24,12 +24,14 @@ extern bool log_enabled; extern std::ofstream log_stream; extern std::string log_file; +extern std::string log_header; std::ostream & log_prefix(std::ofstream & stream); #define LOG(message) \ do { \ - if (log_enabled) \ + if (log_enabled) { \ log_prefix(log_stream); \ - log_stream << __FILE__ << ":" << __LINE__ << " " << message << std::endl; \ + log_stream << __FILE__ << ":" << __LINE__ << " " << message << std::endl; \ + } \ } while (false) diff --git a/driver/read_helpers.cpp b/driver/read_helpers.cpp index 58cae1479..8d276ec6e 100644 --- a/driver/read_helpers.cpp +++ b/driver/read_helpers.cpp @@ -1,4 +1,5 @@ #include "read_helpers.h" + #include void readSize(std::istream & istr, int32_t & res) { @@ -20,5 +21,5 @@ void readString(std::istream & istr, std::string & res, bool * is_null) { } if (!istr.good()) - throw std::runtime_error("Incomplete result received."); + throw std::runtime_error("Incomplete result received. Want size=" + std::to_string(size) + "."); } diff --git a/driver/result_set.cpp b/driver/result_set.cpp index 3572d876f..3b714c7e3 100644 --- a/driver/result_set.cpp +++ b/driver/result_set.cpp @@ -246,7 +246,3 @@ bool ResultSet::readNextBlock() { iterator = current_block.data.begin(); return !current_block.data.empty(); } - -void ResultSet::throwIncompleteResult() const { - throw std::runtime_error("Incomplete result received."); -} diff --git a/driver/result_set.h b/driver/result_set.h index 91258bf5b..7bc052490 100644 --- a/driver/result_set.h +++ b/driver/result_set.h @@ -82,8 +82,6 @@ class ResultSet { private: std::istream & in(); - void throwIncompleteResult() const; - bool readNextBlock(); bool readNextBlockCache(); diff --git a/driver/utils.h b/driver/utils.h index 0ca9d0db5..33180c81b 100644 --- a/driver/utils.h +++ b/driver/utils.h @@ -182,9 +182,6 @@ RETCODE fillOutputStringImpl( *out_value_length = symbols; } -LOG("fillOutputStringImpl: " << symbols << " = " /* << value*/ ); - - if (out_value_max_length < 0) return SQL_ERROR; diff --git a/test/test_all.sh b/test/test_all.sh index c02e8f01d..87dd162b4 100755 --- a/test/test_all.sh +++ b/test/test_all.sh @@ -6,14 +6,14 @@ set -x cd .. -for compiler in "" _gcc _clang; do +for compiler in ${USE_COMPILER=_gcc _clang}; do if [ "$compiler" = "_clang" ]; then - CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which clang++-7 clang++-6.0 clang++-5.0 clang++60 clang++50 clang++ | head -n1` -DCMAKE_C_COMPILER=`which clang-7 clang-6.0 clang-5.0 clang60 clang50 clang | head -n1`" + CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which clang++-8 clang++-7 clang++-6.0 clang++-5.0 clang++60 clang++50 clang++ | head -n1` -DCMAKE_C_COMPILER=`which clang-8 clang-7 clang-6.0 clang-5.0 clang60 clang50 clang | head -n1`" fi if [ "$compiler" = "_gcc" ]; then - CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which g++-8 g++-7 g++8 g++7 g++ | head -n1` -DCMAKE_C_COMPILER=`which gcc-8 gcc-7 gcc8 gcc7 gcc | head -n1`" + CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which g++-9 g++-8 g++-7 g++9 g++8 g++7 g++ | head -n1` -DCMAKE_C_COMPILER=`which gcc-9 gcc-8 gcc-7 gcc9 gcc8 gcc7 gcc | head -n1`" fi - for type in ${USE_TYPES=debug asan tsan ubsan release relwithdebinfo}; do + for type in ${USE_TYPE=debug asan tsan ubsan release relwithdebinfo}; do for option in ""; do CTEST_ENV0="" if [ "$type" = "asan" ]; then diff --git a/test/test_unicode.sh b/test/test_unicode.sh index a808ca32f..16ced2d2a 100755 --- a/test/test_unicode.sh +++ b/test/test_unicode.sh @@ -42,15 +42,14 @@ elif [ `which apt` ]; then sudo apt install -y unixodbc-dev unixodbc fi fi - for compiler in ""; do if [ "$compiler" = "_clang" ]; then - CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which clang++-6.0 clang++-5.0 clang++60 clang++50 clang++ | head -n1` -DCMAKE_C_COMPILER=`which clang-6.0 clang-5.0 clang60 clang50 clang | head -n1`" + CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which clang++-8 clang++-7 clang++-6.0 clang++-5.0 clang++60 clang++50 clang++ | head -n1` -DCMAKE_C_COMPILER=`which clang-8 clang-7 clang-6.0 clang-5.0 clang60 clang50 clang | head -n1`" fi if [ "$compiler" = "_gcc" ]; then - CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which g++-8 g++-7 g++8 g++7 g++ | head -n1` -DCMAKE_C_COMPILER=`which gcc-7 gcc-8 gcc8 gcc7 gcc | head -n1`" + CMAKE_COMPILER_FLAGS="-DCMAKE_CXX_COMPILER=`which g++-9 g++-8 g++-7 g++9 g++8 g++7 g++ | head -n1` -DCMAKE_C_COMPILER=`which gcc-9 gcc-8 gcc-7 gcc9 gcc8 gcc7 gcc | head -n1`" fi - for type in debug; do + for type in ${USE_TYPE=debug}; do for option in ""; do build_dir=build${compiler}_$type$option echo build $compiler $type $option in ${build_dir}