Changeset: fefd216dc972 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fefd216dc972 Modified Files: configure.ag monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_parser.c monetdb5/modules/atoms/json.c monetdb5/modules/atoms/str.c monetdb5/modules/atoms/url.c sql/backends/monet5/rel_bin.c Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 527 to 300 lines): diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -627,7 +627,7 @@ AS_VAR_IF([enable_strict], [yes], [ MCHECK_ADD_FLAG([-Wduplicated-branches]) MCHECK_ADD_FLAG([-Wlogical-op]) MCHECK_ADD_FLAG([-Wrestrict]) - MCHECK_ADD_FLAG([-Wnull-dereference]) +dnl MCHECK_ADD_FLAG([-Wnull-dereference]) MCHECK_ADD_FLAG([-Wjump-misses-init]) dnl MCHECK_ADD_FLAG([-Wshadow]) MCHECK_ADD_FLAG([-Wformat=2]) diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c --- a/monetdb5/mal/mal_interpreter.c +++ b/monetdb5/mal/mal_interpreter.c @@ -816,8 +816,10 @@ str runMALsequence(Client cntxt, MalBlkP continue; } b = BATdescriptor(stk->stk[getArg(pci, i)].val.bval); - BATassertProps(b); - BBPunfix(b->batCacheid); + if (b) { + BATassertProps(b); + BBPunfix(b->batCacheid); + } } } } diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c --- a/monetdb5/mal/mal_parser.c +++ b/monetdb5/mal/mal_parser.c @@ -39,7 +39,7 @@ lastline(Client cntxt) str s = CURRENT(cntxt); if (NL(*s)) s++; - while (s && s > cntxt->fdin->buf && !NL(*s)) + while (s > cntxt->fdin->buf && !NL(*s)) s--; if (NL(*s)) s++; diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -28,12 +28,14 @@ break; \ } while (0) -#define hex(J) \ - do { \ - if ((*(J) >='0' && *(J) <='9') || \ - (*(J) >='a' && *(J) <='f') || \ - (*(J) >='A' && *(J) <='F')) \ - (J)++; \ +#define hex(J) \ + do { \ + if ((*(J) >='0' && *(J) <='9') || \ + (*(J) >='a' && *(J) <='f') || \ + (*(J) >='A' && *(J) <='F')) \ + (J)++; \ + else \ + throw(MAL, "json.parser", "illegal escape char"); \ } while (0) #define CHECK_JSON(jt) \ @@ -57,24 +59,22 @@ int TYPE_json; /* Internal constructors. */ static int jsonhint = 8; -static JSON *JSONparse(const char *j, int silent); +static JSON *JSONparse(const char *j); static JSON * -JSONnewtree(int size) +JSONnewtree(void) { JSON *js; - if (size == 0) - size = jsonhint; js = (JSON *) GDKzalloc(sizeof(JSON)); if (js == NULL) return NULL; - js->elm = (JSONterm *) GDKzalloc(sizeof(JSONterm) * size); + js->elm = (JSONterm *) GDKzalloc(sizeof(JSONterm) * jsonhint); if (js->elm == NULL) { GDKfree(js); return NULL; } - js->size = size; + js->size = jsonhint; return js; } @@ -104,6 +104,7 @@ JSONfree(JSON *c) { if (c == 0) return; + freeException(c->error); GDKfree(c->elm); GDKfree(c); } @@ -125,7 +126,7 @@ JSONfromString(const char *src, size_t * return 1; } - if ((jt = JSONparse(src, FALSE)) == NULL) + if ((jt = JSONparse(src)) == NULL) return -1; if (jt->error) { GDKerror("%s", getExceptionMessageAndState(jt->error)); @@ -271,7 +272,7 @@ JSONdumpInternal(JSON *jt, int depth) str JSONdump(void *ret, json *val) { - JSON *jt = JSONparse(*val, FALSE); + JSON *jt = JSONparse(*val); CHECK_JSON(jt); (void) ret; @@ -300,7 +301,7 @@ JSONjson2str(str *ret, json *j) str JSONstr2json(json *ret, str *j) { - JSON *jt = JSONparse(*j, FALSE); + JSON *jt = JSONparse(*j); CHECK_JSON(jt); JSONfree(jt); @@ -312,12 +313,11 @@ JSONstr2json(json *ret, str *j) str JSONisvalid(bit *ret, json *j) { - JSON *jt = JSONparse(*j, FALSE); + JSON *jt = JSONparse(*j); if (jt == NULL) throw(MAL, "json.isvalid", SQLSTATE(HY001) MAL_MALLOC_FAIL); *ret = jt->error == MAL_SUCCEED; - GDKfree(jt->error); JSONfree(jt); return MAL_SUCCEED; } @@ -383,11 +383,13 @@ JSONappend(JSON *jt, int idx, int nxt) } /* - * The JSON filter operation takes a path expression which is purposely kept simple, - * It provides step (.), multistep (..) and indexed ([nr]) access to the JSON elements. - * A wildcard * can be used as placeholder for a step identifier. + * The JSON filter operation takes a path expression which is + * purposely kept simple, It provides step (.), multistep (..) and + * indexed ([nr]) access to the JSON elements. A wildcard * can be + * used as placeholder for a step identifier. * - * A path expression is always validated upfront and can only be applied to valid json strings. + * A path expression is always validated upfront and can only be + * applied to valid json strings. * Path samples: * .store.book * .store.book[0] @@ -653,7 +655,7 @@ JSONfilterInternal(json *ret, json *js, throw(MAL,"JSONfilterInternal", SQLSTATE(HY001) MAL_MALLOC_FAIL); return MAL_SUCCEED; } - jt = JSONparse(j, FALSE); + jt = JSONparse(j); CHECK_JSON(jt); memset(terms, 0, sizeof(terms)); msg = JSONcompile(*expr, terms); @@ -700,10 +702,10 @@ JSONfilterInternal(json *ret, json *js, static str -JSONstringParser(const char *j, const char **next, int silent) +JSONstringParser(const char *j, const char **next) { - if (*j == '"') - j++; + assert(*j == '"'); + j++; for (; *j; j++) { switch (*j) { case '\\': @@ -728,9 +730,6 @@ JSONstringParser(const char *j, const ch break; default: *next = j; - if (silent) { - return MAL_SUCCEED; - } throw(MAL, "json.parser", "illegal escape char"); } break; @@ -741,13 +740,11 @@ JSONstringParser(const char *j, const ch } } *next = j; - if (!silent) - throw(MAL, "json.parser", "Nonterminated string"); - return MAL_SUCCEED; + throw(MAL, "json.parser", "Nonterminated string"); } static str -JSONnumberParser(const char *j, const char **next, int silent) +JSONnumberParser(const char *j, const char **next) { const char *backup = j; @@ -756,9 +753,7 @@ JSONnumberParser(const char *j, const ch skipblancs(j); if (*j < '0' || *j > '9') { *next = j; - if (!silent) - throw(MAL, "json.parser", "Number expected"); - return MAL_SUCCEED; + throw(MAL, "json.parser", "Number expected"); } for (; *j; j++) if (*j < '0' || *j > '9') @@ -791,12 +786,11 @@ JSONnumberParser(const char *j, const ch } static int -JSONtoken(JSON *jt, const char *j, const char **next, int silent) +JSONtoken(JSON *jt, const char *j, const char **next) { str msg; int nxt, idx = JSONnew(jt); - assert(silent==0); if (jt->error) return idx; skipblancs(j); @@ -809,12 +803,11 @@ JSONtoken(JSON *jt, const char *j, const skipblancs(j); if (*j == '}') break; - nxt = JSONtoken(jt, j, next, silent); + nxt = JSONtoken(jt, j, next); if (jt->error) return idx; if (jt->elm[nxt].kind != JSON_ELEMENT) { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : element expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : element expected"); return idx; } JSONappend(jt, idx, nxt); @@ -825,15 +818,13 @@ JSONtoken(JSON *jt, const char *j, const if (*j == '}') break; if (*j != '}' && *j != ',') { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : ',' or '}' expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : ',' or '}' expected"); return idx; } j++; } if (*j != '}') { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : '}' expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : '}' expected"); return idx; } else j++; @@ -848,7 +839,7 @@ JSONtoken(JSON *jt, const char *j, const skipblancs(j); if (*j == ']') break; - nxt = JSONtoken(jt, j, next, silent); + nxt = JSONtoken(jt, j, next); if (jt->error) return idx; switch (jt->elm[nxt].kind) { @@ -884,33 +875,29 @@ JSONtoken(JSON *jt, const char *j, const if (*j == ']') break; if (jt->elm[nxt].kind == JSON_ELEMENT) { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : Array value expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : Array value expected"); return idx; } if (*j != ']' && *j != ',') { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : ',' or ']' expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : ',' or ']' expected"); return idx; } j++; skipblancs(j); } if (*j != ']') { - if (!silent) - jt->error = createException(MAL, "json.parser", "Syntax error : ']' expected"); + jt->error = createException(MAL, "json.parser", "Syntax error : ']' expected"); } else j++; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list