Update cleri compat
authorJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 2 Dec 2019 14:11:59 +0000 (15:11 +0100)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 2 Dec 2019 14:11:59 +0000 (15:11 +0100)
include/siri/grammar/gramp.h
include/siri/version.h
src/cexpr/cexpr.c
src/siri/db/aggregate.c
src/siri/db/listener.c
src/siri/db/query.c
src/siri/net/stream.c

index 931fb0b44bd14646c00a89e9511b4990e2311851..dbea871138f94552fad137ff8bd83845ca6a2e6e 100644 (file)
 #define HELP_OFFSET CLERI_GID_HELP_ACCESS
 #define HELP_COUNT CLERI_GID_HELP_TIMEZONES + 1 - HELP_OFFSET
 
+
+
+#if CLERI_VERSION_MINOR >= 12
+#define CLERI_NODE_DATA(__node) ((intptr_t)(__node)->data)
+#define CLERI_NODE_DATA_ADDR(__node) ((intptr_t *) &(__node)->data)
+#else
+#define CLERI_NODE_DATA(__node) ((intptr_t *)(__node)->result)
+#define CLERI_NODE_DATA_ADDR(__node) ((intptr_t *) &(__node)->result)
+#endif
+
 #endif  /* SIRI_GRAMP_H_ */
index d92e3cb6762dfbac0c9ad1e5d91103d027287bf8..c1ff0cac1c61b2abfb60111a0d6288a0ba6febec 100644 (file)
@@ -15,7 +15,7 @@
  * Note that debian alpha packages should use versions like this:
  *   2.0.34-0alpha0
  */
-#define SIRIDB_VERSION_PRE_RELEASE "-alpha-0"
+#define SIRIDB_VERSION_PRE_RELEASE "-alpha-1"
 
 #ifndef NDEBUG
 #define SIRIDB_VERSION_BUILD_RELEASE "+debug"
index 0de7e2c11a46707d528c3054604bf56d8634355b..81b82d5fbcf23c164ef57bb8b50e0c340f90ac30 100644 (file)
@@ -6,6 +6,7 @@
 #include <stddef.h>
 #include <math.h>
 #include <siri/grammar/grammar.h>
+#include <siri/grammar/gramp.h>
 #include <logger/logger.h>
 #include <siri/db/series.h>
 #include <siri/db/shard.h>
@@ -383,7 +384,7 @@ static cexpr_t * CEXPR_walk_node(
             /* this is an integer or time expression, we can set the result
              * and the condition.
              */
-            (*condition)->int64 = node->result;
+            (*condition)->int64 = CLERI_NODE_DATA(node);
             SET_CONDITION_AND_RETURN
         case CLERI_TP_CHOICE:
             /* in case of a string, set the value and return */
index a3578e393daf17669ae47b4d6b2651eadd44db72..dd4c5bb0e1c12674f53acc0a30a0e37d3e9f2cbb 100644 (file)
@@ -217,8 +217,8 @@ vec_t * siridb_aggregate_list(cleri_children_t * children, char * err_msg)
         case CLERI_GID_F_LIMIT:
             AGGR_NEW
             {
-                int64_t limit = children->node->children->node->
-                    children->next->next->node->result;
+                int64_t limit = CLERI_NODE_DATA(children->node->children->node->
+                    children->next->next->node);
 
                 if (limit <= 0)
                 {
@@ -344,7 +344,7 @@ vec_t * siridb_aggregate_list(cleri_children_t * children, char * err_msg)
                 {
                     /* result is at least positive, checked earlier */
                     aggr->timespan =
-                            (double) dlist->children->node->result;
+                            (double) CLERI_NODE_DATA(dlist->children->node);
 
                     if (!aggr->timespan)
                     {
@@ -359,8 +359,8 @@ vec_t * siridb_aggregate_list(cleri_children_t * children, char * err_msg)
                     if (dlist->children->next != NULL)
                     {
                         /* result is always positive */
-                        aggr->group_by = dlist->children->next->next->
-                                node->result;
+                        aggr->group_by = CLERI_NODE_DATA(
+                                dlist->children->next->next->node);
 
                         if (!aggr->group_by)
                         {
@@ -400,9 +400,10 @@ vec_t * siridb_aggregate_list(cleri_children_t * children, char * err_msg)
                         next->next->next != NULL)
             {
                 /* result is always positive, checked earlier */
-                aggr->group_by = children->node->children->node->
+                aggr->group_by = CLERI_NODE_DATA(
+                        children->node->children->node->
                         children->next->next->node->children->
-                        node->result;
+                        node);
 
                 if (!aggr->group_by)
                 {
index 2835b0526b1c7af88304bb8603371824e31ca32e..9f300fbe89beb950151a27cbbbccd73a802c38c4 100644 (file)
@@ -870,7 +870,7 @@ static void enter_limit_expr(uv_async_t * handle)
     siridb_query_t * query = handle->data;
     siridb_t * siridb = query->client->siridb;
     query_list_t * qlist = (query_list_t *) query->data;
-    int64_t limit = query->nodes->node->children->next->node->result;
+    int64_t limit = CLERI_NODE_DATA(query->nodes->node->children->next->node);
 
     if (limit <= 0 || limit > siridb->list_limit)
     {
@@ -1589,7 +1589,8 @@ static void exit_after_expr(uv_async_t * handle)
 {
     siridb_query_t * query = handle->data;
     ((query_select_t *) query->data)->start_ts =
-            (uint64_t *) &query->nodes->node->children->next->node->result;
+            (uint64_t *) CLERI_NODE_DATA_ADDR(
+                    query->nodes->node->children->next->node);
 
     SIRIPARSER_NEXT_NODE
 }
@@ -1657,7 +1658,8 @@ static void exit_before_expr(uv_async_t * handle)
     siridb_query_t * query = handle->data;
 
     ((query_select_t *) query->data)->end_ts =
-            (uint64_t *) &query->nodes->node->children->next->node->result;
+            (uint64_t *) CLERI_NODE_DATA_ADDR(
+                    query->nodes->node->children->next->node);
 
     SIRIPARSER_NEXT_NODE
 }
@@ -1667,11 +1669,11 @@ static void exit_between_expr(uv_async_t * handle)
     siridb_query_t * query = handle->data;
     query_select_t * q_select = query->data;
 
-    q_select->start_ts = (uint64_t *)
-            &query->nodes->node->children->next->node->result;
+    q_select->start_ts = (uint64_t *) CLERI_NODE_DATA_ADDR(
+            query->nodes->node->children->next->node);
 
-    q_select->end_ts = (uint64_t *)
-            &query->nodes->node->children->next->next->next->node->result;
+    q_select->end_ts = (uint64_t *) CLERI_NODE_DATA_ADDR(
+            query->nodes->node->children->next->next->next->node);
 
     if (*q_select->start_ts > *q_select->end_ts)
     {
@@ -1708,12 +1710,14 @@ static void exit_calc_stmt(uv_async_t * handle)
 
     if (!query->factor)
     {
-        qp_add_int64(query->packer, calc_node->result);
+        qp_add_int64(query->packer, CLERI_NODE_DATA(calc_node));
     }
     else
     {
         double factor = (double) query->factor;
-        qp_add_int64(query->packer, (int64_t) (calc_node->result * factor));
+        qp_add_int64(
+                query->packer,
+                (int64_t) ((CLERI_NODE_DATA(calc_node) * factor)));
     }
 
     SIRIPARSER_ASYNC_NEXT_NODE
index 49d53357532535ce818f8ad87ad6d9d1feb3db97..779b20fdb88dc740e40950c68fe1ee79fe7d9a81 100644 (file)
@@ -19,6 +19,7 @@
 #include <siri/net/pkg.h>
 #include <siri/net/clserver.h>
 #include <siri/siri.h>
+#include <siri/grammar/gramp.h>
 #include <xstr/xstr.h>
 #include <string.h>
 #include <sys/time.h>
@@ -722,13 +723,13 @@ static int QUERY_walk(cleri_node_t * node, siridb_walker_t * walker)
         buffer[EXPR_MAX_SIZE - size] = 0;
 
         /* evaluate the expression */
-        if ((rc = expr_parse(&node->result, buffer)))
+        if ((rc = expr_parse(CLERI_NODE_DATA_ADDR(node), buffer)))
         {
             return rc;
         }
 
         /* check if timestamp is valid */
-        if (!siridb_int64_valid_ts(walker->siridb->time, node->result))
+        if (!siridb_int64_valid_ts(walker->siridb->time, CLERI_NODE_DATA(node)))
         {
             return EXPR_TIME_OUT_OF_RANGE;
         }
@@ -750,7 +751,7 @@ static int QUERY_walk(cleri_node_t * node, siridb_walker_t * walker)
         buffer[EXPR_MAX_SIZE - size] = 0;
 
         /* evaluate the expression */
-        if ((rc = expr_parse(&node->result, buffer)))
+        if ((rc = expr_parse(CLERI_NODE_DATA_ADDR(node), buffer)))
         {
             return rc;
         }
@@ -1004,7 +1005,7 @@ static int QUERY_rebuild(
                         buf + max_size - *size,
                         *size,
                         "%" PRId64 " ",
-                        node->result);
+                        CLERI_NODE_DATA(node));
                 if (n >= (ssize_t) *size)
                 {
                     return QUERY_TOO_LONG;
index cbcf1e80b9b4d18739bf6e0d8166c9ec48ea3d60..f5d5a5c85d3263b78c64a0ca18d87ea9c8785d97 100644 (file)
@@ -246,6 +246,7 @@ void sirinet__stream_free(uv_stream_t * uvclient)
     {
     case STREAM_PIPE_CLIENT:
     case STREAM_TCP_CLIENT:  /* listens to client connections  */
+        log_debug("client connection lost");
         if (client->origin != NULL)
         {
             siridb_user_t * user = client->origin;