Changeset: 8436d13becf4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8436d13becf4 Added Files: sql/test/BugTracker-2019/Tests/json-text-empty-separator.Bug-6798.sql sql/test/BugTracker-2019/Tests/json-text-empty-separator.Bug-6798.stable.err sql/test/BugTracker-2019/Tests/json-text-empty-separator.Bug-6798.stable.out sql/test/mergetables/Tests/transaction-conflict.py Modified Files: common/utils/msabaoth.c monetdb5/modules/atoms/json.c sql/backends/monet5/sql_cat.c sql/include/sql_catalog.h sql/server/sql_partition.c sql/storage/store.c sql/test/BugTracker-2019/Tests/All sql/test/mergetables/Tests/All tools/merovingian/client/monetdb.c Branch: default Log Message:
Merge with Nov2019 branch. diffs (truncated from 2360 to 300 lines): diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -848,8 +848,7 @@ msab_getUplogInfo(sabuplog *ret, const s start = stop = up = 0; p = data; while ((c = getc(f)) != EOF) { - *p = (char)c; - switch (*p) { + switch (c) { case '\t': /* start attempt */ ret->startcntr++; @@ -879,7 +878,7 @@ msab_getUplogInfo(sabuplog *ret, const s break; default: /* timestamp */ - p++; + *p++ = c; break; } } 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 @@ -1183,7 +1183,7 @@ JSONjson2textSeparator(str *ret, json *j } JSONplaintext(s, &l, jt, 0, **sep); l = strlen(s); - if (l) + if (l && **sep) s[l - 1] = 0; *ret = s; JSONfree(jt); diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c --- a/sql/backends/monet5/sql_cat.c +++ b/sql/backends/monet5/sql_cat.c @@ -38,21 +38,21 @@ #include "orderidx.h" #define initcontext() \ - if ((msg = getSQLContext(cntxt, mb, &sql, NULL)) != NULL)\ - return msg;\ - if ((msg = checkSQLContext(cntxt)) != NULL)\ - return msg;\ - if (STORE_READONLY)\ - throw(SQL,"sql.cat",SQLSTATE(25006) "Schema statements cannot be executed on a readonly database."); + if ((msg = getSQLContext(cntxt, mb, &sql, NULL)) != NULL)\ + return msg;\ + if ((msg = checkSQLContext(cntxt)) != NULL)\ + return msg;\ + if (STORE_READONLY)\ + throw(SQL,"sql.cat",SQLSTATE(25006) "Schema statements cannot be executed on a readonly database."); static char * SaveArgReference(MalStkPtr stk, InstrPtr pci, int arg) -{ - char *val = *getArgReference_str(stk, pci, arg); - - if (val && strcmp(val, str_nil) == 0) - val = NULL; - return val; +{ + char *val = *getArgReference_str(stk, pci, arg); + + if (val && strcmp(val, str_nil) == 0) + val = NULL; + return val; } static int @@ -88,14 +88,14 @@ rel_check_tables(sql_table *nt, sql_tabl if (subtype_cmp(&nc->type, &mc->type) != 0) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table column type doesn't match %s definition", errtable, errtable); - if(isRangePartitionTable(nt) || isListPartitionTable(nt)) { + if (isRangePartitionTable(nt) || isListPartitionTable(nt)) { if (nc->null != mc->null) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table column NULL check doesn't match %s definition", errtable, errtable); if ((!nc->def && mc->def) || (nc->def && !mc->def) || (nc->def && mc->def && strcmp(nc->def, mc->def) != 0)) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table column DEFAULT value doesn't match %s definition", errtable, errtable); } } - if(isNonPartitionedTable(nt)) { + if (isNonPartitionedTable(nt)) { if (cs_size(&nt->idxs) != cs_size(&nnt->idxs)) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table index doesn't match %s definition", errtable, errtable); if (cs_size(&nt->idxs)) @@ -128,8 +128,8 @@ rel_check_tables(sql_table *nt, sql_tabl } } - for(sql_table *up = nt->p ; up ; up = up->p) { - if(!strcmp(up->s->base.name, nnt->s->base.name) && !strcmp(up->base.name, nnt->base.name)) + for (sql_table *up = nt->p ; up ; up = up->p) { + if (!strcmp(up->s->base.name, nnt->s->base.name) && !strcmp(up->base.name, nnt->base.name)) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table is a parent of the %s", errtable, errtable); } return MAL_SUCCEED; @@ -179,7 +179,7 @@ alter_table_add_table(mvc *sql, char *ms sql_table *mt = NULL, *pt = NULL; str msg = validate_alter_table_add_table(sql, "sql.alter_table_add_table", msname, mtname, psname, ptname, &mt, &pt, 0); - if(msg == MAL_SUCCEED) + if (msg == MAL_SUCCEED) sql_trans_add_table(sql->session->tr, mt, pt); return msg; @@ -197,15 +197,15 @@ alter_table_add_range_partition(mvc *sql ssize_t (*atomtostr)(str *, size_t *, const void *, bool); sql_subtype tpe; - if((msg = validate_alter_table_add_table(sql, "sql.alter_table_add_range_partition", msname, mtname, psname, ptname, + if ((msg = validate_alter_table_add_table(sql, "sql.alter_table_add_range_partition", msname, mtname, psname, ptname, &mt, &pt, update))) { return msg; - } else if(!isRangePartitionTable(mt)) { + } else if (!isRangePartitionTable(mt)) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: cannot add range partition into a %s table", (mt->type == tt_merge_table)?"merge":"list partition"); goto finish; - } else if(!update && pt->p) { + } else if (!update && pt->p) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: table %s.%s is already part of another range partition table", psname, ptname); @@ -217,16 +217,16 @@ alter_table_add_range_partition(mvc *sql min_null = ATOMcmp(tp1, min, ATOMnilptr(tp1)) == 0; max_null = ATOMcmp(tp1, max, ATOMnilptr(tp1)) == 0; - if(max_null && min_null && !with_nills) { + if (max_null && min_null && !with_nills) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: range bound cannot be null"); goto finish; - } else if(!min_null && !max_null && ATOMcmp(tp1, min, max) > 0) { + } else if (!min_null && !max_null && ATOMcmp(tp1, min, max) > 0) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: minimum value is higher than maximum value"); goto finish; } errcode = sql_trans_add_range_partition(sql->session->tr, mt, pt, tpe, min, max, with_nills, update, &err); - switch(errcode) { + switch (errcode) { case 0: break; case -1: @@ -242,19 +242,19 @@ alter_table_add_range_partition(mvc *sql break; case -4: assert(err); - if(with_nills && err->with_nills) { + if (with_nills && err->with_nills) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(42000) "ALTER TABLE: conflicting partitions: table %s.%s stores null values and only " - "one partition can store null values at the time", err->t->s->base.name, err->t->base.name); + "one partition can store null values at the time", err->t->s->base.name, err->base.name); } else { atomtostr = BATatoms[tp1].atomToStr; - if(atomtostr(&conflict_err_min, &length, err->part.range.minvalue, true) < 0) { + if (atomtostr(&conflict_err_min, &length, err->part.range.minvalue, true) < 0) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(HY001) MAL_MALLOC_FAIL); - } else if(atomtostr(&conflict_err_max, &length, err->part.range.maxvalue, true) < 0) { + } else if (atomtostr(&conflict_err_max, &length, err->part.range.maxvalue, true) < 0) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(HY001) MAL_MALLOC_FAIL); - } else if(atomtostr(&err_min, &length, min, true) < 0) { + } else if (atomtostr(&err_min, &length, min, true) < 0) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(HY001) MAL_MALLOC_FAIL); - } else if(atomtostr(&err_max, &length, max, true) < 0) { + } else if (atomtostr(&err_max, &length, max, true) < 0) { msg = createException(SQL,"sql.alter_table_add_range_partition",SQLSTATE(HY001) MAL_MALLOC_FAIL); } else { sql_table *errt = mvc_bind_table(sql, mt->s, err->base.name); @@ -269,15 +269,15 @@ alter_table_add_range_partition(mvc *sql } finish: - if(err_min) + if (err_min) GDKfree(err_min); - if(err_max) + if (err_max) GDKfree(err_max); - if(conflict_err_min) + if (conflict_err_min) GDKfree(conflict_err_min); - if(conflict_err_max) + if (conflict_err_max) GDKfree(conflict_err_max); - if(msg != MAL_SUCCEED) + if (msg != MAL_SUCCEED) pt->p = NULL; return msg; } @@ -293,15 +293,15 @@ alter_table_add_value_partition(mvc *sql list *values = list_new(sql->session->tr->sa, (fdestroy) NULL); sql_subtype tpe; - if((msg = validate_alter_table_add_table(sql, "sql.alter_table_add_value_partition", msname, mtname, psname, ptname, + if ((msg = validate_alter_table_add_table(sql, "sql.alter_table_add_value_partition", msname, mtname, psname, ptname, &mt, &pt, update))) { return msg; - } else if(!isListPartitionTable(mt)) { + } else if (!isListPartitionTable(mt)) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: cannot add value partition into a %s table", (mt->type == tt_merge_table)?"merge":"range partition"); goto finish; - } else if(!update && pt->p) { + } else if (!update && pt->p) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: table %s.%s is already part of another list partition table", psname, ptname); @@ -310,17 +310,17 @@ alter_table_add_value_partition(mvc *sql find_partition_type(&tpe, mt); ninserts = pci->argc - pci->retc - 6; - if(ninserts <= 0 && !with_nills) { + if (ninserts <= 0 && !with_nills) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: no values in the list"); goto finish; } - for( i = pci->retc+6; i < pci->argc; i++){ + for ( i = pci->retc+6; i < pci->argc; i++){ sql_part_value *nextv = NULL; ValRecord *vnext = &(stk)->stk[(pci)->argv[i]]; ptr pnext = VALget(vnext); size_t len = ATOMlen(vnext->vtype, pnext); - if(VALisnil(vnext)) { /* check for an eventual null value which cannot be */ + if (VALisnil(vnext)) { /* check for an eventual null value which cannot be */ msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: list value cannot be null"); goto finish; @@ -332,7 +332,7 @@ alter_table_add_value_partition(mvc *sql memcpy(nextv->value, pnext, len); nextv->length = len; - if(list_append_sorted(values, nextv, sql_values_list_element_validate_and_insert) != NULL) { + if (list_append_sorted(values, nextv, sql_values_list_element_validate_and_insert) != NULL) { msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: there are duplicated values in the list"); goto finish; @@ -340,13 +340,13 @@ alter_table_add_value_partition(mvc *sql } errcode = sql_trans_add_value_partition(sql->session->tr, mt, pt, tpe, values, with_nills, update, &err); - switch(errcode) { + switch (errcode) { case 0: break; case -1: msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) "ALTER TABLE: the new partition is conflicting with the existing partition %s.%s", - err->t->s->base.name, err->t->base.name); + err->t->s->base.name, err->base.name); break; default: msg = createException(SQL,"sql.alter_table_add_value_partition",SQLSTATE(42000) @@ -356,7 +356,7 @@ alter_table_add_value_partition(mvc *sql } finish: - if(msg != MAL_SUCCEED) + if (msg != MAL_SUCCEED) pt->p = NULL; return msg; } @@ -440,10 +440,10 @@ create_trigger(mvc *sql, char *sname, ch sql_allocator *sa = sql->sa; sql->sa = sa_create(); - if(!sql->sa) + if (!sql->sa) throw(SQL, "sql.catalog",SQLSTATE(HY001) MAL_MALLOC_FAIL); buf = sa_strdup(sql->sa, query); - if(!buf) + if (!buf) throw(SQL, "sql.catalog",SQLSTATE(HY001) MAL_MALLOC_FAIL); r = rel_parse(sql, s, buf, m_deps); if (r) @@ -473,11 +473,11 @@ drop_trigger(mvc *sql, char *sname, char throw(SQL,"sql.drop_trigger",SQLSTATE(3F000) "DROP TRIGGER: access denied for %s to schema '%s'", stack_get_string(sql, "current_user"), s->base.name); if ((tri = mvc_bind_trigger(sql, s, tname)) == NULL) { - if(if_exists) + if (if_exists) return MAL_SUCCEED; throw(SQL,"sql.drop_trigger", SQLSTATE(3F000) "DROP TRIGGER: unknown trigger %s\n", tname); } - if(mvc_drop_trigger(sql, s, tri)) + if (mvc_drop_trigger(sql, s, tri)) throw(SQL,"sql.drop_trigger", SQLSTATE(HY001) MAL_MALLOC_FAIL); return MAL_SUCCEED; } @@ -552,7 +552,7 @@ drop_view(mvc *sql, char *sname, char *t if (!mvc_schema_privs(sql, ss) && !(isTempSchema(ss) && t && t->persistence == SQL_LOCAL_TEMP)) { throw(SQL,"sql.dropview", SQLSTATE(42000) "DROP VIEW: access denied for %s to schema '%s'", stack_get_string(sql, "current_user"), ss->base.name); } else if (!t) { - if(if_exists){ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list