Changeset: 211b59dc8eae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/211b59dc8eae
Branch: default
Log Message:
merged with Aug2024
diffs (275 lines):
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -84,6 +84,7 @@ function(monetdb_configure_defines)
check_function_exists("getuid" HAVE_GETUID)
check_symbol_exists("gmtime_r" "time.h" HAVE_GMTIME_R)
check_symbol_exists("localtime_r" "time.h" HAVE_LOCALTIME_R)
+ check_symbol_exists("strerror_s" "string.h" HAVE_STRERROR_S)
check_symbol_exists("strerror_r" "string.h" HAVE_STRERROR_R)
check_function_exists("lockf" HAVE_LOCKF)
check_symbol_exists("madvise" "sys/mman.h" HAVE_MADVISE)
@@ -100,6 +101,7 @@ function(monetdb_configure_defines)
check_symbol_exists("posix_fallocate" "fcntl.h" HAVE_POSIX_FALLOCATE)
check_symbol_exists("posix_madvise" "sys/mman.h" HAVE_POSIX_MADVISE)
check_function_exists("setsid" HAVE_SETSID)
+ check_function_exists("sockatmark" HAVE_SOCKATMARK)
check_function_exists("shutdown" HAVE_SHUTDOWN)
check_function_exists("sigaction" HAVE_SIGACTION)
check_function_exists("siglongjmp" HAVE_SIGLONGJMP)
diff --git a/common/stream/socket_stream.c b/common/stream/socket_stream.c
--- a/common/stream/socket_stream.c
+++ b/common/stream/socket_stream.c
@@ -73,10 +73,17 @@ socket_getoob(const stream *s)
for (;;) {
int atmark = 0;
char flush[100];
+#ifdef HAVE_SOCKATMARK
+ if ((atmark = sockatmark(fd)) < 0) {
+ perror("sockatmark");
+ break;
+ }
+#else
if (ioctlsocket(fd, SIOCATMARK, &atmark) < 0) {
perror("ioctl");
break;
}
+#endif
if (atmark)
break;
if (recv(fd, flush, sizeof(flush), 0) < 0) {
@@ -306,10 +313,17 @@ socket_read(stream *restrict s, void *re
for (;;) {
int atmark = 0;
char flush[100];
+#ifdef HAVE_SOCKATMARK
+ if ((atmark =
sockatmark(s->stream_data.s)) < 0) {
+ perror("sockatmark");
+ break;
+ }
+#else
if
(ioctlsocket(s->stream_data.s, SIOCATMARK, &atmark) < 0) {
perror("ioctl");
break;
}
+#endif
if (atmark)
break;
if (recv(s->stream_data.s,
flush, sizeof(flush), 0) < 0) {
@@ -362,10 +376,17 @@ socket_read(stream *restrict s, void *re
for (;;) {
int atmark = 0;
char flush[100];
+#ifdef HAVE_SOCKATMARK
+ if ((atmark =
sockatmark(s->stream_data.s)) < 0) {
+ perror("sockatmark");
+ break;
+ }
+#else
if (ioctlsocket(s->stream_data.s,
SIOCATMARK, &atmark) < 0) {
perror("ioctl");
break;
}
+#endif
if (atmark)
break;
if (recv(s->stream_data.s, flush,
sizeof(flush), 0) < 0) {
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -426,24 +426,32 @@ mnstr_set_open_error(const char *name, i
static size_t
my_strerror_r(int error_nr, char *buf, size_t buflen)
{
- // Three cases:
- // 1. no strerror_r
+ // Four cases:
+ // 1. strerror_s
// 2. gnu strerror_r (returns char* and does not always fill buffer)
// 3. xsi strerror_r (returns int and always fills the buffer)
+ // 4. no strerror_r and no strerror_s
char *to_move;
-#ifndef HAVE_STRERROR_R
- // Hope for the best
- to_move = strerror(error_nr);
-#elif !defined(_GNU_SOURCE) || !_GNU_SOURCE
- // standard strerror_r always writes to buf
+#ifdef HAVE_STRERROR_S
+ int result_code = strerror_s(buf, buflen, error_nr);
+ if (result_code == 0)
+ to_move = NULL;
+ else
+ to_move = "<failed to retrieve error message>";
+#elif defined(HAVE_STRERROR_R)
+#ifdef STRERROR_R_CHARP
+ // gnu strerror_r sometimes only returns static string, needs copy
+ to_move = strerror_r(error_nr, buf, buflen);
+#else
int result_code = strerror_r(error_nr, buf, buflen);
if (result_code == 0)
to_move = NULL;
else
to_move = "<failed to retrieve error message>";
+#endif
#else
- // gnu strerror_r sometimes only returns static string, needs copy
- to_move = strerror_r(error_nr, buf, buflen);
+ // Hope for the best
+ to_move = strerror(error_nr);
#endif
if (to_move != NULL) {
// move to buffer
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -23,22 +23,6 @@
#define mutils_export extern
#endif
-#ifndef S_IWGRP
-/* if one doesn't exist, presumably they all don't exist - Not so on MinGW */
-#define S_IRUSR 0000400 /* read permission, owner */
-#define S_IWUSR 0000200 /* write permission, owner */
-#define S_IXUSR 0000100 /* execute permission, owner */
-#define S_IRGRP 0000040 /* read permission, group */
-#define S_IWGRP 0000020 /* write permission, group */
-#define S_IXGRP 0000010 /* execute permission, group */
-#define S_IROTH 0000004 /* read permission, other */
-#define S_IWOTH 0000002 /* write permission, other */
-#define S_IXOTH 0000001 /* execute permission, other */
-#endif
-
-#define MONETDB_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH)
-#define MONETDB_DIRMODE (MONETDB_MODE | S_IXUSR | S_IXGRP |
S_IXOTH)
-
#ifdef NATIVE_WIN32
#include <stdio.h>
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -1013,7 +1013,7 @@ ctime_r(const time_t *restrict t, char *
}
#endif
-#ifndef HAVE_STRERROR_R
+#if !defined(HAVE_STRERROR_R) && !defined(HAVE_STRERROR_S)
static MT_Lock strerrlock = MT_LOCK_INITIALIZER(strerrlock);
int
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -175,20 +175,25 @@ gdk_export char *asctime_r(const struct
#ifndef HAVE_CTIME_R
gdk_export char *ctime_r(const time_t *restrict, char *restrict);
#endif
-#ifndef HAVE_STRERROR_R
+#if !defined(HAVE_STRERROR_R) && !defined(HAVE_STRERROR_S)
gdk_export int strerror_r(int errnum, char *buf, size_t buflen);
#endif
static inline const char *
GDKstrerror(int errnum, char *buf, size_t buflen)
{
-#if !defined(_GNU_SOURCE) || ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE)
+#ifdef HAVE_STRERROR_S
+ if (strerror_s(buf, buflen, errnum) == 0)
+ return buf;
+ snprintf(buf, buflen, "Unknown error %d", errnum);
+ return buf;
+#elif defined(STRERROR_R_CHARP)
+ return strerror_r(errnum, buf, buflen);
+#else
if (strerror_r(errnum, buf, buflen) == 0)
return buf;
snprintf(buf, buflen, "Unknown error %d", errnum);
return buf;
-#else
- return strerror_r(errnum, buf, buflen);
#endif
}
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -138,6 +138,7 @@
#cmakedefine HAVE_GETUID 1
#cmakedefine HAVE_GMTIME_R 1
#cmakedefine HAVE_LOCALTIME_R 1
+#cmakedefine HAVE_STRERROR_S 1
#cmakedefine HAVE_STRERROR_R 1
#cmakedefine HAVE_LOCKF 1
#cmakedefine HAVE_MADVISE 1
@@ -153,6 +154,7 @@
#cmakedefine HAVE_POSIX_MADVISE 1
#cmakedefine HAVE_SETTHREADDESCRIPTION 1
#cmakedefine HAVE_SETSID 1
+#cmakedefine HAVE_SOCKATMARK 1
#cmakedefine HAVE_SHUTDOWN 1
#cmakedefine HAVE_SIGACTION 1
#cmakedefine HAVE_SIGLONGJMP 1
@@ -366,6 +368,18 @@ typedef __uint128_t uhge;
#include <strings.h> /* strcasecmp */
#endif
+/* The GNU C library has two variants of strerror_r, the XSI compliant
+ * one which returns int and a GNU specific one which returns char *.
+ * According to the manual, we should check for _GNU_SOURCE to find out
+ * which is used (if defined, it's the char * version), but MUSL C (used
+ * on Alpine Linux) also defined _GNU_SOURCE but only defines the int
+ * version, so that won't fly. Instead we look at __USE_GNU which only
+ * the GNU library defines (if _GNU_SOURCE is defined) and is the one
+ * actually used in the GNU header file to make the distinction. */
+#if defined(__USE_GNU) && defined(HAVE_STRERROR_R)
+#define STRERROR_R_CHARP 1
+#endif
+
#ifdef _MSC_VER
#define strdup(s) _strdup(s)
diff --git
a/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
b/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
--- a/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
+++ b/sql/test/BugTracker-2024/Tests/7465-fwf-block-boundary-error.test.in
@@ -50,7 +50,7 @@ denial_reason_2,
denial_reason_3,
edit_status,
sequence_number)
-FROM '$TSTSRCDIR/l30000.gz' ON CLIENT
+FROM r'$TSTSRCDIR/l30000.gz' ON CLIENT
FWF(
4,
10,
diff --git a/testing/test_docker.sh b/testing/test_docker.sh
new file mode 100644
--- /dev/null
+++ b/testing/test_docker.sh
@@ -0,0 +1,16 @@
+TEST="python3 -m venv /monetdb/build/venv && .
/monetdb/build/venv/bin/activate && pip install --upgrade pip && pip install
pymonetdb && cmake -Bbuild -S . -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/monetdb/build/install -DASSERT=OFF -DSTRICT=ON && cmake
--build build && cmake --install build && cmake --build build --target test &&
PATH=/monetdb/build/install/bin:$PATH /monetdb/build/install/bin/Mtest.py"
+
+rm -rf build/*
+podman run -i --rm --volume $(pwd):/monetdb:z --workdir /monetdb alpine:latest
<<<"apk add --no-cache bison cmake pkgconf python3 openssl-dev bzip2-dev
libbz2 lz4-dev lz4-libs pcre-dev readline-dev xz-dev xz-libs zlib-dev
build-base gcc py3-pip py3-cryptography && $TEST"
+rm -rf build/*
+podman run -i --platform linux/arm64 --rm --volume $(pwd):/monetdb:z --workdir
/monetdb alpine:latest <<<"apk add --no-cache bison cmake pkgconf python3
openssl-dev bzip2-dev libbz2 lz4-dev lz4-libs pcre-dev readline-dev xz-dev
xz-libs zlib-dev build-base gcc py3-pip py3-cryptography && $TEST"
+rm -rf build/*
+podman run -i --platform linux/s390x --rm --volume $(pwd):/monetdb:z --workdir
/monetdb alpine:latest <<<"apk add --no-cache bison cmake pkgconf python3
openssl-dev bzip2-dev libbz2 lz4-dev lz4-libs pcre-dev readline-dev xz-dev
xz-libs zlib-dev build-base gcc py3-pip py3-cryptography && $TEST"
+rm -rf build/*
+podman run -i --rm --volume $(pwd):/monetdb:z --workdir /monetdb amazonlinux:2
<<<"dnf -y install bison cmake python3 openssl-devel bzip2-devel bzip2-libs
lz4-devel lz4-libs pcre-devel readline-devel xz-devel xz-libs zlib-devel gcc
pip python3-cryptography && $TEST"
+rm -rf build/*
+podman run -i --rm --volume $(pwd):/monetdb:z --workdir /monetdb
amazonlinux:latest <<<"dnf -y install bison cmake python3 openssl-devel
bzip2-devel bzip2-libs lz4-devel lz4-libs pcre-devel readline-devel xz-devel
xz-libs zlib-devel gcc pip python3-cryptography && $TEST"
+rm -rf build/*
+podman run -i --rm --volume $(pwd):/monetdb:z --workdir /monetdb centos
<<<"sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && sed -i
's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g'
/etc/yum.repos.d/CentOS-* && dnf -y install bison cmake python3 openssl-devel
bzip2-devel bzip2-libs lz4-devel lz4-libs pcre-devel readline-devel xz-devel
xz-libs zlib-devel gcc python3-pip python3-cryptography libarchive && $TEST"
+rm -rf build/*
+podman run -i --rm --volume $(pwd):/monetdb:z --workdir /monetdb fedora
<<<"dnf -y install bison cmake python3 openssl-devel bzip2-devel bzip2-libs
lz4-devel lz4-libs pcre-devel readline-devel xz-devel xz-libs zlib-devel gcc
pip python3-cryptography && $TEST"
diff --git a/tools/merovingian/daemon/snapshot.c
b/tools/merovingian/daemon/snapshot.c
--- a/tools/merovingian/daemon/snapshot.c
+++ b/tools/merovingian/daemon/snapshot.c
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]