Changeset: 497cf791babb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=497cf791babb
Modified Files:
        monetdb5/extras/jaql/jaql.c
Branch: jacqueline
Log Message:

jaql: make sure constructed pairs have a valid name

return an error when a variable was given that is not a key (from a
record)
let the error from make_pair fall through till the top


diffs (50 lines):

diff --git a/monetdb5/extras/jaql/jaql.c b/monetdb5/extras/jaql/jaql.c
--- a/monetdb5/extras/jaql/jaql.c
+++ b/monetdb5/extras/jaql/jaql.c
@@ -69,9 +69,16 @@ make_json(char *s)
 tree *
 make_json_object(tree *obj)
 {
-       tree *res = GDKzalloc(sizeof(tree));
+       tree *res;
 
-       assert(obj != NULL && obj->type == j_pair);
+       assert(obj != NULL);
+       
+       if (obj->type == j_error)
+               return obj;
+
+       assert(obj->type == j_pair);
+
+       res = GDKzalloc(sizeof(tree));
        res->type = j_json_obj;
        res->tval1 = obj;
 
@@ -172,6 +179,11 @@ make_jaql_transform(tree *var, tree *tmp
        assert(var != NULL && var->type == j_var);
        assert(tmpl != NULL);
 
+       if (tmpl->type == j_error) {
+               freetree(var);
+               return tmpl;
+       }
+
        /* traverse down tmpl, searching for all variable references to
         * check if they refer to var */
        if ((res = _check_exp_var(var->sval, tmpl)) != NULL) {
@@ -393,6 +405,15 @@ make_pair(char *name, tree *val)
 
        if (name == NULL) {
                tree *w;
+
+               if (val->tval1 == NULL) {
+                       /* we can't do arithmetic with these */
+                       res->type = j_error;
+                       res->sval = GDKstrdup("a pair needs a name");
+                       freetree(val);
+                       return res;
+               }
+
                /* find last var in val */
                for (w = val; w->tval1 != NULL; w = w->tval1)
                        ;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to