Changeset: 60c4208b7605 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60c4208b7605
Branch: Oct2020
Log Message:

merged


diffs (truncated from 673 to 300 lines):

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
@@ -576,98 +576,97 @@ int win_unlink(const char *);
 int winerror(int);
 
 # mapi
-MapiMsg mapi_bind(MapiHdl hdl, int fnr, char **ptr);
-MapiMsg mapi_bind_numeric(MapiHdl hdl, int fnr, int scale, int precision, void 
*ptr);
-MapiMsg mapi_bind_var(MapiHdl hdl, int fnr, int type, void *ptr);
-MapiMsg mapi_cache_freeup(MapiHdl hdl, int percentage);
-MapiMsg mapi_cache_limit(Mapi mid, int limit);
-MapiMsg mapi_clear_bindings(MapiHdl hdl);
-MapiMsg mapi_clear_params(MapiHdl hdl);
+MapiMsg mapi_bind(MapiHdl hdl, int fnr, char **ptr) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_bind_numeric(MapiHdl hdl, int fnr, int scale, int precision, void 
*ptr) __attribute__((__nonnull__(1)));
+MapiMsg mapi_bind_var(MapiHdl hdl, int fnr, int type, void *ptr) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_cache_freeup(MapiHdl hdl, int percentage) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_cache_limit(Mapi mid, int limit) __attribute__((__nonnull__(1)));
+MapiMsg mapi_clear_bindings(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_clear_params(MapiHdl hdl) __attribute__((__nonnull__(1)));
 MapiMsg mapi_close_handle(MapiHdl hdl);
 Mapi mapi_connect(const char *host, int port, const char *username, const char 
*password, const char *lang, const char *dbname);
-MapiMsg mapi_destroy(Mapi mid);
-MapiMsg mapi_disconnect(Mapi mid);
-MapiMsg mapi_error(Mapi mid);
-const char *mapi_error_str(Mapi mid);
-MapiMsg mapi_execute(MapiHdl hdl);
-void mapi_explain(Mapi mid, FILE *fd);
-void mapi_explain_query(MapiHdl hdl, FILE *fd);
+MapiMsg mapi_destroy(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_disconnect(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_error(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_error_str(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_execute(MapiHdl hdl) __attribute__((__nonnull__(1)));
+void mapi_explain(Mapi mid, FILE *fd) __attribute__((__nonnull__(1)));
+void mapi_explain_query(MapiHdl hdl, FILE *fd) __attribute__((__nonnull__(1)));
 void mapi_explain_result(MapiHdl hdl, FILE *fd);
-int64_t mapi_fetch_all_rows(MapiHdl hdl);
-char *mapi_fetch_field(MapiHdl hdl, int fnr);
-size_t mapi_fetch_field_len(MapiHdl hdl, int fnr);
-char *mapi_fetch_line(MapiHdl hdl);
-MapiMsg mapi_fetch_reset(MapiHdl hdl);
-int mapi_fetch_row(MapiHdl hdl);
-MapiMsg mapi_finish(MapiHdl hdl);
-MapiHdl mapi_get_active(Mapi mid);
-bool mapi_get_autocommit(Mapi mid);
-const char *mapi_get_dbname(Mapi mid);
-int mapi_get_digits(MapiHdl hdl, int fnr);
-int mapi_get_field_count(MapiHdl hdl);
-stream *mapi_get_from(Mapi mid);
-const char *mapi_get_host(Mapi mid);
-const char *mapi_get_lang(Mapi mid);
-int64_t mapi_get_last_id(MapiHdl hdl);
-int mapi_get_len(MapiHdl hdl, int fnr);
-int64_t mapi_get_maloptimizertime(MapiHdl hdl);
-const char *mapi_get_mapi_version(Mapi mid);
-const char *mapi_get_monet_version(Mapi mid);
-const char *mapi_get_motd(Mapi mid);
-char *mapi_get_name(MapiHdl hdl, int fnr);
-char *mapi_get_query(MapiHdl hdl);
-int64_t mapi_get_querytime(MapiHdl hdl);
-int mapi_get_querytype(MapiHdl hdl);
-int64_t mapi_get_row_count(MapiHdl hdl);
-int mapi_get_scale(MapiHdl hdl, int fnr);
-int64_t mapi_get_sqloptimizertime(MapiHdl hdl);
-char *mapi_get_table(MapiHdl hdl, int fnr);
-int mapi_get_tableid(MapiHdl hdl);
-stream *mapi_get_to(Mapi mid);
-bool mapi_get_trace(Mapi mid);
-char *mapi_get_type(MapiHdl hdl, int fnr);
-const char *mapi_get_uri(Mapi mid);
-const char *mapi_get_user(Mapi mid);
-bool mapi_is_connected(Mapi mid);
-MapiMsg mapi_log(Mapi mid, const char *nme);
+int64_t mapi_fetch_all_rows(MapiHdl hdl) __attribute__((__nonnull__(1)));
+char *mapi_fetch_field(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+size_t mapi_fetch_field_len(MapiHdl hdl, int fnr) 
__attribute__((__nonnull__(1)));
+char *mapi_fetch_line(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_fetch_reset(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int mapi_fetch_row(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_finish(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiHdl mapi_get_active(Mapi mid) __attribute__((__nonnull__(1)));
+bool mapi_get_autocommit(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_dbname(Mapi mid) __attribute__((__nonnull__(1)));
+int mapi_get_digits(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+int mapi_get_field_count(MapiHdl hdl) __attribute__((__nonnull__(1)));
+stream *mapi_get_from(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_host(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_lang(Mapi mid) __attribute__((__nonnull__(1)));
+int64_t mapi_get_last_id(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int mapi_get_len(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+int64_t mapi_get_maloptimizertime(MapiHdl hdl) __attribute__((__nonnull__(1)));
+const char *mapi_get_mapi_version(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_monet_version(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_motd(Mapi mid) __attribute__((__nonnull__(1)));
+char *mapi_get_name(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+char *mapi_get_query(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int64_t mapi_get_querytime(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int mapi_get_querytype(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int64_t mapi_get_row_count(MapiHdl hdl) __attribute__((__nonnull__(1)));
+int mapi_get_scale(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+int64_t mapi_get_sqloptimizertime(MapiHdl hdl) __attribute__((__nonnull__(1)));
+char *mapi_get_table(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+int mapi_get_tableid(MapiHdl hdl) __attribute__((__nonnull__(1)));
+stream *mapi_get_to(Mapi mid) __attribute__((__nonnull__(1)));
+bool mapi_get_trace(Mapi mid) __attribute__((__nonnull__(1)));
+char *mapi_get_type(MapiHdl hdl, int fnr) __attribute__((__nonnull__(1)));
+const char *mapi_get_uri(Mapi mid) __attribute__((__nonnull__(1)));
+const char *mapi_get_user(Mapi mid) __attribute__((__nonnull__(1)));
+bool mapi_is_connected(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_log(Mapi mid, const char *nme) __attribute__((__nonnull__(1)));
 Mapi mapi_mapi(const char *host, int port, const char *username, const char 
*password, const char *lang, const char *dbname);
 Mapi mapi_mapiuri(const char *url, const char *user, const char *pass, const 
char *lang);
-bool mapi_more_results(MapiHdl hdl);
-MapiMsg mapi_needmore(MapiHdl hdl);
-MapiHdl mapi_new_handle(Mapi mid);
-MapiMsg mapi_next_result(MapiHdl hdl);
-void mapi_noexplain(Mapi mid, const char *errorprefix);
-MapiMsg mapi_param(MapiHdl hdl, int fnr, char **ptr);
-MapiMsg mapi_param_numeric(MapiHdl hdl, int fnr, int scale, int precision, 
void *ptr);
-MapiMsg mapi_param_string(MapiHdl hdl, int fnr, int sqltype, char *ptr, int 
*sizeptr);
-MapiMsg mapi_param_type(MapiHdl hdl, int fnr, int ctype, int sqltype, void 
*ptr);
-MapiMsg mapi_ping(Mapi mid);
-MapiHdl mapi_prepare(Mapi mid, const char *cmd);
-MapiMsg mapi_prepare_handle(MapiHdl hdl, const char *cmd);
-MapiHdl mapi_query(Mapi mid, const char *cmd);
-MapiMsg mapi_query_done(MapiHdl hdl);
-MapiMsg mapi_query_handle(MapiHdl hdl, const char *cmd);
-MapiMsg mapi_query_part(MapiHdl hdl, const char *cmd, size_t size);
-MapiHdl mapi_query_prep(Mapi mid);
-char *mapi_quote(const char *msg, int size);
-MapiMsg mapi_read_response(MapiHdl hdl);
-MapiMsg mapi_reconnect(Mapi mid);
-MapiMsg mapi_release_id(Mapi mid, int id);
+bool mapi_more_results(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_needmore(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiHdl mapi_new_handle(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_next_result(MapiHdl hdl) __attribute__((__nonnull__(1)));
+void mapi_noexplain(Mapi mid, const char *errorprefix) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_param(MapiHdl hdl, int fnr, char **ptr) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_param_numeric(MapiHdl hdl, int fnr, int scale, int precision, 
void *ptr) __attribute__((__nonnull__(1)));
+MapiMsg mapi_param_string(MapiHdl hdl, int fnr, int sqltype, char *ptr, int 
*sizeptr) __attribute__((__nonnull__(1)));
+MapiMsg mapi_param_type(MapiHdl hdl, int fnr, int ctype, int sqltype, void 
*ptr) __attribute__((__nonnull__(1)));
+MapiMsg mapi_ping(Mapi mid) __attribute__((__nonnull__(1)));
+MapiHdl mapi_prepare(Mapi mid, const char *cmd) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_prepare_handle(MapiHdl hdl, const char *cmd) 
__attribute__((__nonnull__(1)));
+MapiHdl mapi_query(Mapi mid, const char *cmd) __attribute__((__nonnull__(1)));
+MapiMsg mapi_query_done(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_query_handle(MapiHdl hdl, const char *cmd) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_query_part(MapiHdl hdl, const char *cmd, size_t size) 
__attribute__((__nonnull__(1)));
+MapiHdl mapi_query_prep(Mapi mid) __attribute__((__nonnull__(1)));
+char *mapi_quote(const char *msg, int size) __attribute__((__nonnull__(1)));
+MapiMsg mapi_read_response(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_reconnect(Mapi mid) __attribute__((__nonnull__(1)));
+MapiMsg mapi_release_id(Mapi mid, int id) __attribute__((__nonnull__(1)));
 char **mapi_resolve(const char *host, int port, const char *pattern);
 const char *mapi_result_error(MapiHdl hdl);
 const char *mapi_result_errorcode(MapiHdl hdl);
-int64_t mapi_rows_affected(MapiHdl hdl);
-MapiMsg mapi_seek_row(MapiHdl hdl, int64_t rowne, int whence);
-MapiHdl mapi_send(Mapi mid, const char *cmd);
-MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit);
-MapiMsg mapi_set_size_header(Mapi mid, bool value);
-void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, const void *data, size_t size), void *priv);
-int mapi_split_line(MapiHdl hdl);
-MapiMsg mapi_start_talking(Mapi mid);
-MapiMsg mapi_store_field(MapiHdl hdl, int fnr, int outtype, void *outparam);
-MapiMsg mapi_timeout(Mapi mid, unsigned int time);
-void mapi_trace(Mapi mid, bool flag);
-char *mapi_unquote(char *msg);
+int64_t mapi_rows_affected(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_seek_row(MapiHdl hdl, int64_t rowne, int whence) 
__attribute__((__nonnull__(1)));
+MapiHdl mapi_send(Mapi mid, const char *cmd) __attribute__((__nonnull__(1)));
+MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_set_size_header(Mapi mid, bool value) 
__attribute__((__nonnull__(1)));
+void mapi_setfilecallback(Mapi mid, char *(*getfunc)(void *priv, const char 
*filename, bool binary, uint64_t offset, size_t *size), char *(*putfunc)(void 
*priv, const char *filename, const void *data, size_t size), void *priv) 
__attribute__((__nonnull__(1)));
+int mapi_split_line(MapiHdl hdl) __attribute__((__nonnull__(1)));
+MapiMsg mapi_store_field(MapiHdl hdl, int fnr, int outtype, void *outparam) 
__attribute__((__nonnull__(1)));
+MapiMsg mapi_timeout(Mapi mid, unsigned int time) 
__attribute__((__nonnull__(1)));
+void mapi_trace(Mapi mid, bool flag) __attribute__((__nonnull__(1)));
+char *mapi_unquote(char *msg) __attribute__((__nonnull__(1)));
 char *mcrypt_BackendSum(const char *string, size_t len);
 char *mcrypt_MD5Sum(const char *string, size_t len);
 char *mcrypt_RIPEMD160Sum(const char *string, size_t len);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1045,6 +1045,10 @@ static char nomem[] = "Memory allocation
 
 static void
 mapi_clrError(Mapi mid)
+       __attribute__((__nonnull__));
+
+static void
+mapi_clrError(Mapi mid)
 {
        assert(mid);
        if (mid->errorstr && mid->errorstr != nomem)
@@ -1056,6 +1060,10 @@ mapi_clrError(Mapi mid)
 
 static MapiMsg
 mapi_setError(Mapi mid, const char *msg, const char *action, MapiMsg error)
+       __attribute__((__nonnull__(2, 3)));
+
+static MapiMsg
+mapi_setError(Mapi mid, const char *msg, const char *action, MapiMsg error)
 {
        assert(msg);
        REALLOC(mid->errorstr, strlen(msg) + 1);
@@ -1801,6 +1809,8 @@ finish_handle(MapiHdl hdl)
 MapiMsg
 mapi_close_handle(MapiHdl hdl)
 {
+       if (hdl == NULL)
+               return MOK;
        debugprint("entering %s\n", "mapi_close_handle");
 
        /* don't use mapi_check_hdl: it's ok if we're not connected */
@@ -2512,10 +2522,10 @@ mapi_reconnect(Mapi mid)
 
        if (!isa_block_stream(mid->to)) {
                mid->to = block_stream(mid->to);
-               check_stream(mid, mid->to, NULL, mid->error);
+               check_stream(mid, mid->to, "not a block stream", mid->error);
 
                mid->from = block_stream(mid->from);
-               check_stream(mid, mid->from, NULL, mid->error);
+               check_stream(mid, mid->from, "not a block stream", mid->error);
        }
 
   try_again_after_redirect:
@@ -4676,7 +4686,7 @@ mapi_fetch_line(MapiHdl hdl)
                                  result->tableid,
                                  result->cache.first + 
result->cache.tuplecount) < 0 ||
                    mnstr_flush(hdl->mid->to, MNSTR_FLUSH_DATA))
-                       check_stream(hdl->mid, hdl->mid->to, NULL, NULL);
+                       check_stream(hdl->mid, hdl->mid->to, "sending export 
command", NULL);
                reply = mapi_fetch_line_internal(hdl);
        }
        return reply;
@@ -5201,7 +5211,7 @@ mapi_fetch_all_rows(MapiHdl hdl)
                        if (mnstr_printf(mid->to, "X" "export %d %" PRId64 "\n",
                                          result->tableid, result->cache.first 
+ result->cache.tuplecount) < 0 ||
                            mnstr_flush(mid->to, MNSTR_FLUSH_DATA))
-                               check_stream(mid, mid->to, NULL, 0);
+                               check_stream(mid, mid->to, "sending export 
command", 0);
                }
                if (mid->active)
                        read_into_cache(mid->active, 0);
diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h
--- a/clients/mapilib/mapi.h
+++ b/clients/mapilib/mapi.h
@@ -53,110 +53,199 @@ extern "C" {
 #define mapi_export extern
 #endif
 
+#ifndef __GNUC__
+/* This feature is available in gcc versions 2.5 and later.  */
+# ifndef __attribute__
+#  define __attribute__(Spec)  /* empty */
+# endif
+#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);
-mapi_export MapiMsg mapi_start_talking(Mapi mid);
+mapi_export MapiMsg mapi_destroy(Mapi mid)
+       __attribute__((__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);
-mapi_export MapiMsg mapi_reconnect(Mapi mid);
-mapi_export MapiMsg mapi_ping(Mapi mid);
+mapi_export MapiMsg mapi_disconnect(Mapi mid)
+       __attribute__((__nonnull__(1)));
+mapi_export MapiMsg mapi_reconnect(Mapi mid)
+       __attribute__((__nonnull__(1)));
+mapi_export MapiMsg mapi_ping(Mapi mid)
+       __attribute__((__nonnull__(1)));
 mapi_export void mapi_setfilecallback(
        Mapi mid,
        char *(*getfunc)(void *priv, const char *filename,
                         bool binary, uint64_t offset, size_t *size),
        char *(*putfunc)(void *priv, const char *filename,
                         const void *data, size_t size),
-       void *priv);
+       void *priv)
+       __attribute__((__nonnull__(1)));
 
-mapi_export MapiMsg mapi_error(Mapi mid);
-mapi_export const char *mapi_error_str(Mapi mid);
-mapi_export void mapi_noexplain(Mapi mid, const char *errorprefix);
-mapi_export void mapi_explain(Mapi mid, FILE *fd);
-mapi_export void mapi_explain_query(MapiHdl hdl, FILE *fd);
+mapi_export MapiMsg mapi_error(Mapi mid)
+       __attribute__((__nonnull__(1)));
+mapi_export const char *mapi_error_str(Mapi mid)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to