Changeset: 9092c719d493 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9092c719d493
Modified Files:
        monetdb_config.h.in
Branch: samloader
Log Message:

Merge with default branch.


diffs (truncated from 6379 to 300 lines):

diff --git a/ChangeLog.Dec2025 b/ChangeLog.Dec2025
--- a/ChangeLog.Dec2025
+++ b/ChangeLog.Dec2025
@@ -1,3 +1,7 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Fri Oct 23 2026 Sjoerd Mullender <[email protected]>
+- Added an option --relative-dir to mclient to specify the directory
+  for relative path names when using the ON CLIENT option in SQL queries.
+
diff --git a/clients/examples/C/bincopydata.h b/clients/examples/C/bincopydata.h
--- a/clients/examples/C/bincopydata.h
+++ b/clients/examples/C/bincopydata.h
@@ -13,7 +13,7 @@
 #include "copybinary_support.h"
 
 _Noreturn void croak(int status, _In_z_ _Printf_format_string_ const char 
*msg, ...)
-       __attribute__((__format__(__printf__, 2, 3)));
+       ATTR_FORMAT(__printf__, 2, 3);
 
 void gen_decimal_tinyints(FILE *f, bool byteswap, long nrecs, char *arg);
 void gen_decimal_smallints(FILE *f, bool byteswap, long nrecs, char *arg);
diff --git a/clients/examples/C/streamcat.c b/clients/examples/C/streamcat.c
--- a/clients/examples/C/streamcat.c
+++ b/clients/examples/C/streamcat.c
@@ -78,7 +78,7 @@ static void copy_file_to_stream(FILE *in
 /* Format the message and write it to stderr. Then exit with the given status.
  * If status is 1, include USAGE in the message.
  */
-__attribute__((__format__(__printf__, 2, 3)))
+ATTR_FORMAT(__printf__, 2, 3)
 _Noreturn static void
 croak(int status, _In_z_ _Printf_format_string_ const char *msg, ...)
 {
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -342,6 +342,14 @@ dumping the data of a table.
 This option can be used when trying to load data from MonetDB into
 another database, or when e.g. JDBC applications are used to reload
 the dump.
+.TP
+\fB\-\-relative\-dir=\fP\fIdirectory\fP (\fB\-/\fP \fIdirectory\fP)
+Directory used to find files specified using a relative path name when
+using the \fBON CLIENT\fP option in SQL queries that support them.
+Normally when a file is given as command line argument, such files are
+located relative to the directory of the input file.
+This option overrides that, and also specifies a directory for when
+queries are read from standard input.
 .SH BACKSLASH COMMANDS
 .SS
 General Commands
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -69,6 +69,7 @@ static bool echoquery = false;
 static bool errseen = false;
 static bool allow_remote = false;
 static const char *curfile = NULL;
+static const char *reldir = NULL;
 
 #define setPrompt() snprintf(promptbuf, sizeof(promptbuf), "%.*s>", (int) 
sizeof(promptbuf) - 2, language)
 #define debugMode() (strncmp(promptbuf, "mdb", 3) == 0)
@@ -3238,7 +3239,13 @@ getfile(void *data, const char *filename
 #endif
                }
                if (f == NULL) {
-                       if (curfile != NULL) {
+                       if (reldir != NULL) {
+                               size_t x = strlen(reldir) + strlen(fname) + 2;
+                               char *b = malloc(x);
+                               snprintf(b, x, "%s/%s", reldir, fname);
+                               f = binary ? open_rstream(b) : open_rastream(b);
+                               free(b);
+                       } else if (curfile != NULL) {
                                const char *p = strrchr(curfile, '/');
 #ifdef _MSC_VER
                                const char *q = strrchr(curfile, '\\');
@@ -3367,9 +3374,7 @@ putfile(void *data, const char *filename
        return NULL;            /* success */
 }
 
-static _Noreturn void usage(const char *prog, int xit);
-
-static void
+static _Noreturn void
 usage(const char *prog, int xit)
 {
        mnstr_printf(stderr_stream, "Usage: %s [ options ] [ file or database [ 
file ... ] ]\n", prog);
@@ -3399,6 +3404,7 @@ usage(const char *prog, int xit)
 #ifdef HAVE_POPEN
        mnstr_printf(stderr_stream, " -| cmd      | --pager=cmd        for 
pagination\n");
 #endif
+       mnstr_printf(stderr_stream, " -/ dir      | --relative-dir=dir 
directory for relative paths in ON CLIENT\n");
        mnstr_printf(stderr_stream, " -v          | --version          show 
version information and exit\n");
        mnstr_printf(stderr_stream, " -q          | --quiet            don't 
print welcome message\n");
        mnstr_printf(stderr_stream, " -?          | --help             show 
this usage message\n");
@@ -3518,6 +3524,7 @@ main(int argc, char **argv)
                {"Xdebug", 0, 0, 'X'},
                {"timezone", 0, 0, 'z'},
                {"allow-remote", 0, 0, 'R'},
+               {"relative-dir", 1, 0, '/'},
                {0, 0, 0, 0}
        };
 
@@ -3596,7 +3603,7 @@ main(int argc, char **argv)
 #ifdef HAVE_POPEN
                                "|:"
 #endif
-                               "?",
+                               "/:?",
                                long_options, &option_index)) != -1) {
                switch (c) {
                case 0:
@@ -3757,6 +3764,10 @@ main(int argc, char **argv)
                        pager = optarg;
                        break;
 #endif
+               case '/':
+                       assert(optarg);
+                       reldir = optarg;
+                       break;
                case '?':
                        /* a bit of a hack: look at the option that the
                         * current `c' is based on and see if we recognize
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -68,29 +68,35 @@ extern "C" {
 #endif
 
 /* Does your compiler support `__attribute__' extension? */
-#if !defined(__has_attribute)
-#ifndef __attribute__
-#define __attribute__(...)
+#if defined(__has_attribute)
+#if __has_attribute(__const__)
+#define ATTR_CONST                     __attribute__((__const__))
+#endif
+#if __has_attribute(__nonnull__)
+#define ATTR_NONNULL(...)              
__attribute__((__nonnull__(__VA_ARGS__)))
 #endif
-#else
-#if !__has_attribute(__nonnull__)
-#define __nonnull__(...)
 #endif
+
+#ifndef ATTR_CONST
+#define ATTR_CONST
+#endif
+#ifndef ATTR_NONNULL
+#define ATTR_NONNULL(...)
 #endif
 
 /* connection-oriented functions */
 mapi_export Mapi mapi_mapi(const char *host, int port, const char *username, 
const char *password, const char *lang, const char *dbname);
 mapi_export Mapi mapi_mapiuri(const char *url, const char *user, const char 
*pass, const char *lang);
 mapi_export MapiMsg mapi_destroy(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export Mapi mapi_connect(const char *host, int port, const char 
*username, const char *password, const char *lang, const char *dbname);
 mapi_export char **mapi_resolve(const char *host, int port, const char 
*pattern);
 mapi_export MapiMsg mapi_disconnect(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_reconnect(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_ping(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_setfilecallback2(
        Mapi mid,
        char *(*getfunc)(void *priv, const char *filename,
@@ -98,7 +104,7 @@ mapi_export void mapi_setfilecallback2(
        char *(*putfunc)(void *priv, const char *filename, bool binary,
                         const void *data, size_t size),
        void *priv)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_setfilecallback(
        Mapi mid,
        char *(*getfunc)(void *priv, const char *filename,
@@ -106,187 +112,187 @@ mapi_export void mapi_setfilecallback(
        char *(*putfunc)(void *priv, const char *filename,
                         const void *data, size_t size),
        void *priv)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_setclientprefix(Mapi mid, const char *prefix);
 
 mapi_export MapiMsg mapi_error(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export const char *mapi_error_str(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_noexplain(Mapi mid, const char *errorprefix)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_explain(Mapi mid, FILE *fd)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_explain_query(MapiHdl hdl, FILE *fd)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export void mapi_explain_result(MapiHdl hdl, FILE *fd);
 mapi_export void mapi_trace(Mapi mid, bool flag)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 #ifdef _STREAM_H_              /* if stream.h was included */
 mapi_export stream *mapi_get_from(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export stream *mapi_get_to(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 #endif
 mapi_export bool mapi_get_trace(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export int mapi_get_time_zone(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export bool mapi_get_autocommit(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export bool mapi_get_columnar_protocol(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_log(Mapi mid, const char *nme)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_set_time_zone(Mapi mid, int seconds_east_of_utc)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_set_columnar_protocol(Mapi mid, bool 
columnar_protocol)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_set_size_header(Mapi mid, bool value)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_release_id(Mapi mid, int id)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export const char *mapi_result_error(MapiHdl hdl);
 mapi_export const char *mapi_result_errorcode(MapiHdl hdl);
 mapi_export MapiMsg mapi_next_result(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_needmore(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export bool mapi_more_results(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiHdl mapi_new_handle(Mapi mid)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_close_handle(MapiHdl hdl);
 mapi_export MapiMsg mapi_bind(MapiHdl hdl, int fnr, char **ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_bind_var(MapiHdl hdl, int fnr, int type, void *ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_bind_numeric(MapiHdl hdl, int fnr, int scale, int 
precision, void *ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_clear_bindings(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_param_type(MapiHdl hdl, int fnr, int ctype, int 
sqltype, void *ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_param_string(MapiHdl hdl, int fnr, int sqltype, char 
*ptr, int *sizeptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_param(MapiHdl hdl, int fnr, char **ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_param_numeric(MapiHdl hdl, int fnr, int scale, int 
precision, void *ptr)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_clear_params(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiHdl mapi_prepare(Mapi mid, const char *cmd)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_prepare_handle(MapiHdl hdl, const char *cmd)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
 mapi_export MapiMsg mapi_execute(MapiHdl hdl)
-       __attribute__((__nonnull__(1)));
+       ATTR_NONNULL(1);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to