Changeset: afca10750710 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=afca10750710
Modified Files:
        clients/Tests/exports.stable.out
        clients/examples/C/sample0.c
        clients/examples/C/sample1.c
        clients/examples/C/sample4.c
        clients/examples/C/smack00.c
        clients/examples/C/smack01.c
        clients/mapiclient/mclient.c
        clients/mapiclient/msqldump.c
        clients/mapilib/mapi.c
        clients/mapilib/mapi.h
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/modules/mal/remote.c
Branch: default
Log Message:

Change some MAPI parameters and return values to type bool.
Also removed defines for MAPI_TRACE and MAPI_TRACE_LANG (the latter
wasn't used).


diffs (truncated from 575 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
@@ -500,7 +500,7 @@ MapiMsg mapi_fetch_reset(MapiHdl hdl);
 int mapi_fetch_row(MapiHdl hdl);
 MapiMsg mapi_finish(MapiHdl hdl);
 MapiHdl mapi_get_active(Mapi mid);
-int mapi_get_autocommit(Mapi mid);
+bool mapi_get_autocommit(Mapi mid);
 char *mapi_get_dbname(Mapi mid);
 int mapi_get_digits(MapiHdl hdl, int fnr);
 int mapi_get_field_count(MapiHdl hdl);
@@ -523,15 +523,15 @@ int64_t mapi_get_sqloptimizertime(MapiHd
 char *mapi_get_table(MapiHdl hdl, int fnr);
 int mapi_get_tableid(MapiHdl hdl);
 stream *mapi_get_to(Mapi mid);
-int mapi_get_trace(Mapi mid);
+bool mapi_get_trace(Mapi mid);
 char *mapi_get_type(MapiHdl hdl, int fnr);
 char *mapi_get_uri(Mapi mid);
 char *mapi_get_user(Mapi mid);
-int mapi_is_connected(Mapi mid);
+bool mapi_is_connected(Mapi mid);
 MapiMsg mapi_log(Mapi mid, const char *nme);
 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);
-int mapi_more_results(MapiHdl hdl);
+bool mapi_more_results(MapiHdl hdl);
 MapiMsg mapi_needmore(MapiHdl hdl);
 MapiHdl mapi_new_handle(Mapi mid);
 MapiMsg mapi_next_result(MapiHdl hdl);
@@ -558,14 +558,14 @@ const char *mapi_result_errorcode(MapiHd
 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, int autocommit);
+MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit);
 MapiMsg mapi_set_size_header(Mapi mid, int value);
 int mapi_split_line(MapiHdl hdl);
 MapiMsg mapi_start_talking(Mapi mid);
 MapiMsg mapi_store_field(MapiHdl hdl, int fnr, int outtype, void *outparam);
 MapiHdl mapi_stream_query(Mapi mid, const char *cmd, int windowsize);
 MapiMsg mapi_timeout(Mapi mid, unsigned int time);
-void mapi_trace(Mapi mid, int flag);
+void mapi_trace(Mapi mid, bool flag);
 char *mapi_unquote(char *msg);
 MapiMsg mapi_virtual_result(MapiHdl hdl, int columns, const char 
**columnnames, const char **columntypes, const int *columnlengths, int 
tuplecount, const char ***tuples);
 char *mcrypt_BackendSum(const char *string, size_t len);
diff --git a/clients/examples/C/sample0.c b/clients/examples/C/sample0.c
--- a/clients/examples/C/sample0.c
+++ b/clients/examples/C/sample0.c
@@ -36,10 +36,10 @@ main(int argc, char **argv)
        if (dbh == NULL || mapi_error(dbh))
                die(dbh, hdl);
 
-       /* mapi_trace(dbh, 1); */
+       /* mapi_trace(dbh, true); */
        if (strcmp(argv[3], "sql") == 0) {
                /* switch of autocommit */
-               if (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh))
+               if (mapi_setAutocommit(dbh, false) != MOK || mapi_error(dbh))
                        die(dbh,NULL);
                if ((hdl = mapi_query(dbh, "create table emp(name varchar(20), 
age int)")) == NULL || mapi_error(dbh))
                        die(dbh, hdl);
diff --git a/clients/examples/C/sample1.c b/clients/examples/C/sample1.c
--- a/clients/examples/C/sample1.c
+++ b/clients/examples/C/sample1.c
@@ -36,11 +36,11 @@ main(int argc, char **argv)
        if (dbh == NULL || mapi_error(dbh))
                die(dbh, hdl);
 
-       /* mapi_trace(dbh, 1); */
+       /* mapi_trace(dbh, true); */
        mapi_cache_limit(dbh, 2);
        if (strcmp(argv[3], "sql") == 0) {
                /* switch of autocommit */
-               if (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh))
+               if (mapi_setAutocommit(dbh, false) != MOK || mapi_error(dbh))
                        die(dbh,NULL);
                if ((hdl = mapi_query(dbh, "create table emp(name varchar(20), 
age int)")) == NULL || mapi_error(dbh))
                        die(dbh, hdl);
diff --git a/clients/examples/C/sample4.c b/clients/examples/C/sample4.c
--- a/clients/examples/C/sample4.c
+++ b/clients/examples/C/sample4.c
@@ -40,10 +40,10 @@ main(int argc, char **argv)
 
        mapi_cache_limit(dbh, 2);
        /* mapi_trace_log(dbh, "/tmp/mapilog"); */
-       /* mapi_trace(dbh, 1); */
+       /* mapi_trace(dbh, true); */
        if (strcmp(argv[3], "sql") == 0) {
                /* switch of autocommit */
-               if (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh))
+               if (mapi_setAutocommit(dbh, false) != MOK || mapi_error(dbh))
                        die(dbh,NULL);
                if ((hdl = mapi_query(dbh, "create table emp(name varchar(20), 
age int)")) == NULL || mapi_error(dbh))
                        die(dbh, hdl);
diff --git a/clients/examples/C/smack00.c b/clients/examples/C/smack00.c
--- a/clients/examples/C/smack00.c
+++ b/clients/examples/C/smack00.c
@@ -60,7 +60,7 @@ main(int argc, char **argv)
                die(dbh, hdl);
 
        /* switch of autocommit */
-       if (lang==1 && (mapi_setAutocommit(dbh, 0) != MOK || mapi_error(dbh)))
+       if (lang==1 && (mapi_setAutocommit(dbh, false) != MOK || 
mapi_error(dbh)))
                die(dbh,NULL);
 
        for (i = 0; i < n; i++) {
diff --git a/clients/examples/C/smack01.c b/clients/examples/C/smack01.c
--- a/clients/examples/C/smack01.c
+++ b/clients/examples/C/smack01.c
@@ -66,7 +66,7 @@ main(int argc, char **argv)
                        die(dbh, hdl);
 
                /* switch of autocommit */
-               if (lang==1 && (mapi_setAutocommit(dbh, 0) != MOK || 
mapi_error(dbh)))
+               if (lang==1 && (mapi_setAutocommit(dbh, false) != MOK || 
mapi_error(dbh)))
                        die(dbh,NULL);
 
                if (lang==1)
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2438,12 +2438,12 @@ doFile(Mapi mid, stream *fp, bool useins
                                case 'A':
                                        if (mode != SQL)
                                                break;
-                                       mapi_setAutocommit(mid, 1);
+                                       mapi_setAutocommit(mid, true);
                                        continue;
                                case 'a':
                                        if (mode != SQL)
                                                break;
-                                       mapi_setAutocommit(mid, 0);
+                                       mapi_setAutocommit(mid, false);
                                        continue;
                                case 'w':
                                        pagewidth = atoi(line + 2);
@@ -3088,7 +3088,7 @@ main(int argc, char **argv)
        char *dbname = NULL;
        char *output = NULL;    /* output format as string */
        FILE *fp = NULL;
-       int trace = 0;
+       bool trace = false;
        bool dump = false;
        bool useinserts = false;
        int c = 0;
@@ -3321,7 +3321,7 @@ main(int argc, char **argv)
                        pagewidthset = pagewidth != 0;
                        break;
                case 'X':
-                       trace = MAPI_TRACE;
+                       trace = true;
                        break;
                case 'z':
                        settz = false;
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -56,7 +56,7 @@ main(int argc, char **argv)
        char *passwd = NULL;
        char *host = NULL;
        char *dbname = NULL;
-       int trace = 0;
+       bool trace = false;
        bool describe = false;
        bool functions = false;
        bool useinserts = false;
@@ -123,7 +123,7 @@ main(int argc, char **argv)
                        quiet = true;
                        break;
                case 'X':
-                       trace = MAPI_TRACE;
+                       trace = true;
                        break;
                case '?':
                        /* a bit of a hack: look at the option that the
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -636,7 +636,7 @@
  *
  * @subsection Miscellaneous
  * @itemize
- * @item MapiMsg mapi_setAutocommit(Mapi mid, int autocommit)
+ * @item MapiMsg mapi_setAutocommit(Mapi mid, bool autocommit)
  *
  * Set the autocommit flag (default is on).  This only has an effect
  * when the language is SQL.  In that case, the server commits after each
@@ -678,7 +678,7 @@
  * representation into a C-representation. The storage space is
  * dynamically created and should be freed after use.
  *
- * @item MapiMsg  mapi_trace(Mapi mid, int flag)
+ * @item MapiMsg  mapi_trace(Mapi mid, bool flag)
  *
  * Set the trace flag to monitor interaction of the client
  * with the library. It is primarilly used for debugging
@@ -843,15 +843,15 @@ struct MapiStruct {
        int languageId;
        char *motd;             /* welcome message from server */
 
-       int trace;              /* Trace Mapi interaction */
-       int auto_commit;
        char *noexplain;        /* on error, don't explain, only print result */
        MapiMsg error;          /* Error occurred */
        char *errorstr;         /* error from server */
        const char *action;     /* pointer to constant string */
 
        struct BlockCache blk;
-       int connected;
+       bool connected;
+       bool trace;             /* Trace Mapi interaction */
+       bool auto_commit;
        MapiHdl first;          /* start of doubly-linked list */
        MapiHdl active;         /* set when not all rows have been received */
 
@@ -920,7 +920,7 @@ struct MapiStatement {
        do {                                                            \
                debugprint("entering %s\n", (C));                       \
                assert(X);                                              \
-               if ((X)->connected == 0) {                              \
+               if (!(X)->connected) {                                  \
                        mapi_setError((X), "Connection lost", (C), MERROR); \
                        return (X)->error;                              \
                }                                                       \
@@ -930,7 +930,7 @@ struct MapiStatement {
        do {                                                            \
                debugprint("entering %s\n", (C));                       \
                assert(X);                                              \
-               if ((X)->connected == 0) {                              \
+               if (!(X)->connected) {                                  \
                        mapi_setError((X), "Connection lost", (C), MERROR); \
                        return 0;                                       \
                }                                                       \
@@ -941,7 +941,7 @@ struct MapiStatement {
                debugprint("entering %s\n", (C));                       \
                assert(X);                                              \
                assert((X)->mid);                                       \
-               if ((X)->mid->connected == 0) {                         \
+               if (!(X)->mid->connected) {                             \
                        mapi_setError((X)->mid, "Connection lost", (C), 
MERROR); \
                        return (X)->mid->error;                         \
                }                                                       \
@@ -952,7 +952,7 @@ struct MapiStatement {
                debugprint("entering %s\n", (C));                       \
                assert(X);                                              \
                assert((X)->mid);                                       \
-               if ((X)->mid->connected == 0) {                         \
+               if (!(X)->mid->connected) {                             \
                        mapi_setError((X)->mid, "Connection lost", (C), 
MERROR); \
                        return 0;                                       \
                }                                                       \
@@ -1315,14 +1315,14 @@ mapi_get_from(Mapi mid)
        return mid->from;
 }
 
-int
+bool
 mapi_get_trace(Mapi mid)
 {
        mapi_check0(mid, "mapi_get_trace");
        return mid->trace;
 }
 
-int
+bool
 mapi_get_autocommit(Mapi mid)
 {
        mapi_check0(mid, "mapi_get_autocommit");
@@ -1420,7 +1420,7 @@ new_result(MapiHdl hdl)
        assert((hdl->lastresult == NULL && hdl->result == NULL) ||
               (hdl->result != NULL && hdl->lastresult != NULL && 
hdl->lastresult->next == NULL));
 
-       if (hdl->mid->trace == MAPI_TRACE)
+       if (hdl->mid->trace)
                printf("allocating new result set\n");
        /* append a newly allocated struct to the end of the linked list */
        result = malloc(sizeof(*result));
@@ -1478,7 +1478,7 @@ close_result(MapiHdl hdl)
                return MERROR;
        mid = hdl->mid;
        assert(mid != NULL);
-       if (mid->trace == MAPI_TRACE)
+       if (mid->trace)
                printf("closing result set\n");
        if (result->tableid >= 0 && result->querytype != Q_PREPARE) {
                if (mid->active &&
@@ -1666,7 +1666,7 @@ mapi_needmore(MapiHdl hdl)
        return hdl->needmore ? MMORE : MOK;
 }
 
-int
+bool
 mapi_more_results(MapiHdl hdl)
 {
        struct MapiResultSet *result;
@@ -1675,7 +1675,7 @@ mapi_more_results(MapiHdl hdl)
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to