Changeset: 63b16d9f430f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=63b16d9f430f
Modified Files:
        gdk/gdk_logger.c
        gdk/gdk_logger.h
        sql/storage/bat/bat_logger.c
        sql/storage/sql_storage.h
        sql/storage/store.c
Branch: default
Log Message:

Cosmetics: use bool, use const, proper indent.
I really dislike a for loop as the body of an if without the indent.


diffs (220 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -97,7 +97,7 @@
 
 #define NAME(name,tpe,id) (name?name:"tpe id")
 
-static char *log_commands[] = {
+static const char *log_commands[] = {
        NULL,
        "LOG_START",
        "LOG_END",
@@ -1560,7 +1560,7 @@ bm_subcommit(logger *lg, BAT *list_bid, 
  */
 static int
 logger_set_logdir_path(char *filename, const char *fn,
-                      const char *logdir, int shared)
+                      const char *logdir, bool shared)
 {
        int role = PERSISTENT; /* default role is persistent, i.e. the default 
dbfarm */
 
@@ -1804,7 +1804,7 @@ logger_load(int debug, const char *fn, c
                                if (BUNappend(t, &zero, false) != GDK_SUCCEED)
                                        goto error;
                        }
-                       lg->with_ids = 0;
+                       lg->with_ids = false;
                }
 
                snprintf(bak, sizeof(bak), "%s_catalog_oid", fn);
@@ -1827,7 +1827,7 @@ logger_load(int debug, const char *fn, c
                                if (BUNappend(o, &zero, false) != GDK_SUCCEED)
                                        goto error;
                        }
-                       lg->with_ids = 0;
+                       lg->with_ids = false;
                }
 
                snprintf(bak, sizeof(bak), "%s_dcatalog", fn);
@@ -1972,7 +1972,7 @@ logger_load(int debug, const char *fn, c
                bat seqs_val = logger_find_bat(lg, "seqs_val", 0, 0);
                bat snapshots_tid = logger_find_bat(lg, "snapshots_tid", 0, 0);
                bat dsnapshots = logger_find_bat(lg, "dsnapshots", 0, 0);
-               int needcommit = 0;
+               bool needcommit = false;
                int dbg = GDKdebug;
 
                if (seqs_id) {
@@ -2044,7 +2044,7 @@ logger_load(int debug, const char *fn, c
                                         "%s failed", bak);
                                goto error;
                        }
-                       needcommit = 1;
+                       needcommit = true;
                }
                GDKdebug &= ~CHECKMASK;
                if (needcommit && bm_commit(lg) != GDK_SUCCEED) {
@@ -2138,7 +2138,7 @@ logger_load(int debug, const char *fn, c
                                        goto error;
                                }
                                /* set the flag that we need to convert */
-                               lg->convert_nil_nan = 1;
+                               lg->convert_nil_nan = true;
                        } else if ((fp1 = GDKfileopen(farmid, NULL, cvfile, 
NULL, "r")) != NULL) {
                                /* the versioned conversion file
                                 * exists: check version */
@@ -2148,7 +2148,7 @@ logger_load(int debug, const char *fn, c
                                    newid == curid) {
                                        /* versions match, we need to
                                         * convert */
-                                       lg->convert_nil_nan = 1;
+                                       lg->convert_nil_nan = true;
                                }
                                fclose(fp1);
                                if (!lg->convert_nil_nan) {
@@ -2170,7 +2170,7 @@ logger_load(int debug, const char *fn, c
                        /* we converted, remove versioned file and
                         * reset conversion flag */
                        GDKunlink(0, NULL, cvfile, NULL);
-                       lg->convert_nil_nan = 0;
+                       lg->convert_nil_nan = false;
                }
 #endif
                if (lg->postfuncp && (*lg->postfuncp)(lg) != GDK_SUCCEED)
@@ -2207,7 +2207,7 @@ logger_load(int debug, const char *fn, c
 /* Initialize a new logger
  * It will load any data in the logdir and persist it in the BATs*/
 static logger *
-logger_new(int debug, const char *fn, const char *logdir, int version, 
preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, int shared, const 
char *local_logdir)
+logger_new(int debug, const char *fn, const char *logdir, int version, 
preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, bool shared, const 
char *local_logdir)
 {
        logger *lg = GDKmalloc(sizeof(struct logger));
        char filename[FILENAME_MAX];
@@ -2224,12 +2224,12 @@ logger_new(int debug, const char *fn, co
 
        lg->changes = 0;
        lg->version = version;
-       lg->with_ids = 1;
+       lg->with_ids = true;
        lg->id = 1;
 
        lg->tid = 0;
 #ifdef GDKLIBRARY_NIL_NAN
-       lg->convert_nil_nan = 0;
+       lg->convert_nil_nan = false;
 #endif
 
        lg->dbfarm_role = logger_set_logdir_path(filename, fn, logdir, shared);;
@@ -2335,7 +2335,7 @@ logger *
 logger_create(int debug, const char *fn, const char *logdir, int version, 
preversionfix_fptr prefuncp, postversionfix_fptr postfuncp, int 
keep_persisted_log_files)
 {
        logger *lg;
-       lg = logger_new(debug, fn, logdir, version, prefuncp, postfuncp, 0, 
NULL);
+       lg = logger_new(debug, fn, logdir, version, prefuncp, postfuncp, false, 
NULL);
        if (lg == NULL)
                return NULL;
        if (lg->debug & 1) {
@@ -2369,7 +2369,7 @@ logger *
 logger_create_shared(int debug, const char *fn, const char *logdir, const char 
*local_logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr 
postfuncp)
 {
        logger *lg;
-       lg = logger_new(debug, fn, logdir, version, prefuncp, postfuncp, 1, 
local_logdir);
+       lg = logger_new(debug, fn, logdir, version, prefuncp, postfuncp, true, 
local_logdir);
        if (lg && lg->debug & 1) {
                printf("# Started processing logs %s/%s version 
%d\n",fn,logdir,version);
                fflush(stdout);
@@ -2616,7 +2616,7 @@ logger_cleanup(logger *lg, int keep_pers
 void
 logger_with_ids(logger *lg)
 {
-       lg->with_ids = 1;
+       lg->with_ids = true;
 }
 
 /* Clean-up write-ahead log files already persisted in the BATs, leaving only 
the most recent one.
diff --git a/gdk/gdk_logger.h b/gdk/gdk_logger.h
--- a/gdk/gdk_logger.h
+++ b/gdk/gdk_logger.h
@@ -41,21 +41,21 @@ typedef gdk_return (*postversionfix_fptr
 
 typedef struct logger {
        int debug;
+       int version;
        lng changes;
-       int version;
-       int with_ids;
        lng id;
        int tid;
+       bool with_ids;
 #ifdef GDKLIBRARY_NIL_NAN
        /* convert old style floating point NIL values to NaN */
-       int convert_nil_nan;
+       bool convert_nil_nan;
 #endif
+       bool shared; /* a flag to indicate if the logger is a shared on 
(usually read-only) */
        char *fn;
        char *dir;
        char *local_dir; /* the directory in which the non-shared log is 
written */
-       int shared; /* a flag to indicate if the logger is a shared on (usually 
read-only) */
-       int dbfarm_role; /* role for the dbram used for the logdir, PERSISTENT 
by default */
-       int local_dbfarm_role; /* role for the dbram used for the logdir, 
PERSISTENT by default */
+       int dbfarm_role; /* role for the dbfarm used for the logdir, PERSISTENT 
by default */
+       int local_dbfarm_role; /* role for the dbfarm used for the logdir, 
PERSISTENT by default */
        preversionfix_fptr prefuncp;
        postversionfix_fptr postfuncp;
        stream *log;
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -1022,13 +1022,10 @@ bl_log_isnew(void)
        return 1;
 }
 
-static int
+static bool
 bl_log_needs_update(void)
 {
-       if (bat_logger->with_ids) {
-               return 0;
-       }
-       return 1;
+       return !bat_logger->with_ids;
 }
 
 static int
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -306,7 +306,7 @@ typedef lng (*logger_get_transaction_dri
 typedef int (*logger_reload_fptr) (void);
 
 typedef int (*log_isnew_fptr)(void);
-typedef int (*log_needs_update_fptr)(void);
+typedef bool (*log_needs_update_fptr)(void);
 typedef int (*log_tstart_fptr) (void);
 typedef int (*log_tend_fptr) (void);
 typedef int (*log_sequence_fptr) (int seq, lng id);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1285,7 +1285,8 @@ store_upgrade_ids(sql_trans* tr)
 
                if (isDeclaredSchema(s))
                        continue;
-               if (s->tables.set)
+               if (s->tables.set == NULL)
+                       continue;
                for (m = s->tables.set->h; m; m = m->next) {
                        sql_table *t = m->data;
 
@@ -1299,7 +1300,8 @@ store_upgrade_ids(sql_trans* tr)
                                if (store_funcs.upgrade_col(c) != LOG_OK)
                                        return SQL_ERR;
                        }
-                       if (t->idxs.set)
+                       if (t->idxs.set == NULL)
+                               continue;
                        for (o = t->idxs.set->h; o; o = o->next) {
                                sql_idx *i = o->data;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to