Changeset: 02edbfac0bef for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/02edbfac0bef Modified Files: gdk/gdk_bat.c gdk/gdk_bbp.c monetdb5/mal/mal_runtime.c sql/server/rel_schema.c Branch: default Log Message:
Merged with Jul2021 diffs (truncated from 1119 to 300 lines): diff --git a/clients/examples/python/basics.py b/clients/examples/python/basics.py --- a/clients/examples/python/basics.py +++ b/clients/examples/python/basics.py @@ -21,3 +21,6 @@ c.execute('select * from tables') results = c.fetchall() x.commit() print(results) + +c.close() +x.close() diff --git a/clients/examples/python/perf.py b/clients/examples/python/perf.py --- a/clients/examples/python/perf.py +++ b/clients/examples/python/perf.py @@ -20,3 +20,5 @@ c = x.cursor() c.arraysize=10000 c.execute('select * from tables, tables') results = c.fetchall() +c.close() +x.close() diff --git a/clients/examples/python/sqlsample.py b/clients/examples/python/sqlsample.py --- a/clients/examples/python/sqlsample.py +++ b/clients/examples/python/sqlsample.py @@ -41,3 +41,5 @@ if cursor.executemany("insert into pytho sys.stderr.write("2 rows inserted expected") cursor.execute('drop table python_table;') +cursor.close() +dbh.close() diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -2553,7 +2553,7 @@ dump_database(Mapi mid, stream *toConsol squoted_print(toConsole, fullname, '\'', false); mnstr_printf(toConsole, " SCHEMA "); dquoted_print(toConsole, describe ? sname : "sys", NULL); - if (spath) { + if (spath && strcmp(spath, "\"sys\"") != 0) { mnstr_printf(toConsole, " SCHEMA PATH "); squoted_print(toConsole, spath, '\'', false); } diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2181,9 +2181,9 @@ BATsetaccess(BAT *b, restrict_t newmode) BATcheck(b, NULL); if ((isVIEW(b) || b->batSharecnt) && newmode != BAT_READ) { BAT *bn = COLcopy(b, b->ttype, true, TRANSIENT); + BBPunfix(b->batCacheid); if (bn == NULL) return NULL; - BBPunfix(b->batCacheid); b = bn; } bakmode = (restrict_t) b->batRestricted; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -2793,14 +2793,15 @@ BBPkeepref(bat i) bool lock = locked_by == 0 || locked_by != MT_getpid(); BAT *b; + incref(i, true, lock); if ((b = BBPdescriptor(i)) != NULL) { - b = BATsetaccess(b, BAT_READ); BATsettrivprop(b); if (GDKdebug & (CHECKMASK | PROPMASK)) BATassertProps(b); + if (BATsetaccess(b, BAT_READ) == NULL) + return; /* already decreffed */ } - incref(i, true, lock); assert(BBP_refs(i)); decref(i, false, false, lock, "BBPkeepref"); } diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -2329,9 +2329,12 @@ log_constant(logger *lg, int type, ptr v if (LOG_DISABLED(lg) || !nr) { /* logging is switched off */ - if (nr) - return la_bat_update_count(lg, id, offset+cnt); - return GDK_SUCCEED; + if (nr) { + logger_lock(lg); + ok = la_bat_update_count(lg, id, offset+cnt); + logger_unlock(lg); + } + return ok; } gdk_return (*wt) (const void *, stream *, size_t) = BATatoms[type].atomWrite; diff --git a/monetdb5/mal/mal_resource.h b/monetdb5/mal/mal_resource.h --- a/monetdb5/mal/mal_resource.h +++ b/monetdb5/mal/mal_resource.h @@ -18,7 +18,7 @@ #define MAX_DELAYS 1000 /* never wait more then 2000 ms */ //#define heapinfo(X,Id) (((X) && (X)->base && ((X)->parentid == 0 || (X)->parentid == Id)) ? (X)->free : 0) -#define heapinfo(X,Id) (((X) && (X)->base ) ? (X)->free : 0) +#define heapinfo(X,Id) ((X) ? (X)->free : 0) #define hashinfo(X,Id) ((X) && (X) != (Hash *) 1 ? heapinfo(&(X)->heaplink, Id) + heapinfo(&(X)->heapbckt, Id) : 0) mal_export int MALadmission_claim(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, lng argclaim); diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c --- a/monetdb5/mal/mal_runtime.c +++ b/monetdb5/mal/mal_runtime.c @@ -385,7 +385,8 @@ runtimeProfileBegin(Client cntxt, MalBlk assert(pci); /* keep track on the instructions taken in progress for stethoscope*/ - if( tid < THREADS){ + if( tid > 0 && tid <= THREADS){ + tid--; if( malProfileMode) { MT_lock_set(&mal_profileLock); workingset[tid].cntxt = cntxt; @@ -416,7 +417,8 @@ runtimeProfileExit(Client cntxt, MalBlkP lng ticks = GDKusec(); /* keep track on the instructions in progress*/ - if ( tid < THREADS) { + if ( tid > 0 && tid <= THREADS) { + tid--; if( malProfileMode) { MT_lock_set(&mal_profileLock); workingset[tid].cntxt = 0; diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c --- a/monetdb5/modules/mal/mat.c +++ b/monetdb5/modules/mal/mat.c @@ -118,7 +118,7 @@ MATpackIncrement(Client cntxt, MalBlkPtr { bat *ret = getArgReference_bat(stk,p,0); int pieces; - BAT *b, *bb, *bn, *nb; + BAT *b, *bb, *bn; size_t newsize; (void) cntxt; @@ -198,13 +198,8 @@ MATpackIncrement(Client cntxt, MalBlkPtr } BBPunfix(bb->batCacheid); b->unused--; - if (b->unused == 0) { - if (!(nb = BATsetaccess(b, BAT_READ))) { - BBPunfix(b->batCacheid); - throw(MAL, "mat.pack", GDK_EXCEPTION); - } - b = nb; - } + if (b->unused == 0 && (b = BATsetaccess(b, BAT_READ)) == NULL) + throw(MAL, "mat.pack", GDK_EXCEPTION); if (b->tnil && b->tnonil) { BBPunfix(b->batCacheid); throw(MAL, "mat.pack", "INTERNAL ERROR" " b->tnil or b->tnonil fails "); diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c --- a/monetdb5/modules/mal/tablet.c +++ b/monetdb5/modules/mal/tablet.c @@ -18,7 +18,7 @@ * that should preferable be maintained. * * The code below consists of a file reader, which breaks up the - * file into chunks of distinct lines. Then multiple parallel threads + * file into chunks of distinct rows. Then multiple parallel threads * grab them, and break them on the field boundaries. * After all fields are identified this way, the columns are converted * and stored in the BATs. @@ -572,7 +572,7 @@ TABLEToutput_file(Tablet *as, BAT *order * that should preferable be maintained. * * The code below consists of a file reader, which breaks up the - * file into chunks of distinct lines. Then multiple parallel threads + * file into chunks of distinct rows. Then multiple parallel threads * grab them, and break them on the field boundaries. * After all fields are identified this way, the columns are converted * and stored in the BATs. @@ -591,7 +591,7 @@ TABLEToutput_file(Tablet *as, BAT *order /* #define MLOCK_TST did not make a difference on sf10 */ -#define BREAKLINE 1 +#define BREAKROW 1 #define UPDATEBAT 2 #define SYNCBAT 3 #define ENDOFCOPY 4 @@ -599,9 +599,9 @@ TABLEToutput_file(Tablet *as, BAT *order typedef struct { Client cntxt; int id; /* for self reference */ - int state; /* line break=1 , 2 = update bat */ + int state; /* row break=1 , 2 = update bat */ int workers; /* how many concurrent ones */ - int error; /* error during line break */ + int error; /* error during row break */ int next; int limit; BUN cnt, maxrow; /* first row in file chunk. */ @@ -624,10 +624,11 @@ typedef struct { size_t seplen, rseplen; char quote; - char *base[MAXBUFFERS], *input[MAXBUFFERS]; /* buffers for line splitter and tokenizer */ + char *base[MAXBUFFERS], *input[MAXBUFFERS]; /* buffers for row splitter and tokenizer */ size_t rowlimit[MAXBUFFERS]; /* determines maximal record length buffer */ - char **lines[MAXBUFFERS]; - int top[MAXBUFFERS]; /* number of lines in this buffer */ + char **rows[MAXBUFFERS]; + lng *startlineno[MAXBUFFERS]; + int top[MAXBUFFERS]; /* number of rows in this buffer */ int cur; /* current buffer used by splitter and update threads */ int *cols; /* columns to handle */ @@ -638,11 +639,11 @@ typedef struct { } READERtask; static void -tablet_error(READERtask *task, lng row, int col, const char *msg, const char *fcn) +tablet_error(READERtask *task, lng row, lng lineno, int col, const char *msg, const char *fcn) { MT_lock_set(&errorlock); if (task->cntxt->error_row != NULL) { - if (BUNappend(task->cntxt->error_row, &row, false) != GDK_SUCCEED || + if (BUNappend(task->cntxt->error_row, &(lng){(lng)task->cnt + row + 1}, false) != GDK_SUCCEED || BUNappend(task->cntxt->error_fld, &col, false) != GDK_SUCCEED || BUNappend(task->cntxt->error_msg, msg, false) != GDK_SUCCEED || BUNappend(task->cntxt->error_input, fcn, false) != GDK_SUCCEED) @@ -653,11 +654,11 @@ tablet_error(READERtask *task, lng row, if (task->as->error == NULL) { if (msg == NULL) task->besteffort = 0; - else if (!is_lng_nil(row)) { + else if (!is_lng_nil(lineno)) { if (!is_int_nil(col)) - task->as->error = createException(MAL, "sql.copy_from", "line " LLFMT ": column %d: %s", row + 1, col + 1, msg); + task->as->error = createException(MAL, "sql.copy_from", "line " LLFMT ": column %d: %s", lineno, col + 1, msg); else - task->as->error = createException(MAL, "sql.copy_from", "line " LLFMT ": %s", row + 1, msg); + task->as->error = createException(MAL, "sql.copy_from", "line " LLFMT ": %s", lineno, msg); } else task->as->error = createException(MAL, "sql.copy_from", "%s", msg); } @@ -666,7 +667,7 @@ tablet_error(READERtask *task, lng row, } /* - * The line is broken into pieces directly on their field separators. It assumes that we have + * The row is broken into pieces directly on their field separators. It assumes that we have * the record in the cache already, so we can do most work quickly. * Furthermore, it assume a uniform (SQL) pattern, without whitespace skipping, but with quote and separator. */ @@ -780,7 +781,7 @@ SQLload_error(READERtask *task, lng idx, s = line = GDKmalloc(sz + task->rseplen + 1); if (line == 0) { - tablet_error(task, idx, int_nil, "SQLload malloc error", "SQLload_error"); + tablet_error(task, idx, lng_nil, int_nil, "SQLload malloc error", "SQLload_error"); return 0; } for (i = 0; i < attrs; i++) { @@ -865,7 +866,7 @@ SQLinsert_val(READERtask *task, int col, MT_lock_set(&errorlock); snprintf(buf, sizeof(buf), "line " LLFMT " field %s '%s' expected%s%s%s", - row, fmt->name ? fmt->name : "", fmt->type, + task->startlineno[task->cur][idx], fmt->name ? fmt->name : "", fmt->type, s ? " in '" : "", s ? s : "", s ? "'" : ""); GDKfree(s); if (task->as->error == NULL && (task->as->error = GDKstrdup(buf)) == NULL) @@ -927,7 +928,7 @@ SQLworker_column(READERtask *task, int c MT_lock_set(&mal_copyLock); if (!fmt[col].skip && BATcapacity(fmt[col].c) < BATcount(fmt[col].c) + task->next) { if (BATextend(fmt[col].c, BATgrows(fmt[col].c) + task->limit) != GDK_SUCCEED) { - tablet_error(task, lng_nil, col, "Failed to extend the BAT\n", "SQLworker_column"); + tablet_error(task, lng_nil, lng_nil, col, "Failed to extend the BAT\n", "SQLworker_column"); MT_lock_unset(&mal_copyLock); return -1; } @@ -947,64 +948,65 @@ SQLworker_column(READERtask *task, int c } /* - * The lines are broken on the column separator. Any error is shown and reflected with + * The rows are broken on the column separator. Any error is shown and reflected with * setting the reference of the offending row fields to NULL. * This allows the loading to continue, skipping the minimal number of rows. * The details about the locations can be inspected from the error table. * We also trim the quotes around strings. */ static int -SQLload_parse_line(READERtask *task, int idx) +SQLload_parse_row(READERtask *task, int idx) { BUN i; char errmsg[BUFSIZ]; char ch = *task->csep; - char *line = task->lines[task->cur][idx]; + char *row = task->rows[task->cur][idx]; + lng startlineno = task->startlineno[task->cur][idx]; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list