Changeset: fce8d8f2af30 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fce8d8f2af30 Modified Files: clients/mapiclient/dump.c testing/Mtest.py.in testing/sqllogictest.py Branch: default Log Message:
Merge with Oct2020 branch. diffs (truncated from 602 to 300 lines): diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -882,6 +882,34 @@ dump_column_definition(Mapi mid, stream mnstr_printf(toConsole, "\t"); space = dquoted_print(toConsole, c_name, " "); mnstr_printf(toConsole, "%*s", CAP(slen - space), ""); + if (s != NULL && t != NULL && + strcmp(c_type, "char") == 0 && strcmp(c_type_digits, "0") == 0) { + /* if the number of characters is not specified (due to a bug), + * calculate a size */ + char *c = descape(c_name); + if (c != NULL) { + size_t qlen = strlen(c) + strlen(s) + strlen(t) + 64; + char *q = malloc(qlen); + if (q != NULL) { + snprintf(q, qlen, "SELECT max(length(\"%s\")) FROM \"%s\".\"%s\"", c, s, t); + MapiHdl h = mapi_query(mid, q); + if (h != NULL) { + if (mapi_fetch_row(h) != 0) { + const char *d = mapi_fetch_field(h, 0); + free(c_type_digits); + /* if NULL, i.e. no non-NULL values, fill in 1 */ + c_type_digits = strdup(d ? d : "1"); + fprintf(stderr, "Warning: fixing size of CHAR column for %s of table %s.%s\n", c_name, schema, tname); + } + mapi_close_handle(h); + } + free(q); + } + free(c); + } + if (c_type_digits == NULL) + goto bailout; + } space = dump_type(mid, toConsole, c_type, c_type_digits, c_type_scale, hashge); if (strcmp(c_null, "false") == 0) { mnstr_printf(toConsole, "%*s NOT NULL", diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in --- a/testing/Mtest.py.in +++ b/testing/Mtest.py.in @@ -1278,6 +1278,8 @@ def PerformDir(env, testdir, testlist, B if not env.get('NOCLEAN') and LogDBdir and os.path.exists(LogDBdir): try: shutil.rmtree(LogDBdir) + except KeyboardInterrupt: + raise except: Warn("database '%s` exists, but destroying it failed; skipping tests in '%s`!" % (TSTDB, TSTSRCDIR)) #TODO: @@ -1302,6 +1304,8 @@ def PerformDir(env, testdir, testlist, B return td, elem, max(FdOut, FdErr), interrupted try: z.extractall(LogDBdir) + except KeyboardInterrupt: + raise except: Warn("initial database '%s` cannot be extracted; skipping tests in '%s`!" % (initdb, TSTSRCDIR)) #TODO: @@ -1446,6 +1450,8 @@ def PerformDir(env, testdir, testlist, B if testweb: try: os.removedirs(TSTTRGDIR) + except KeyboardInterrupt: + raise except: pass @@ -1628,27 +1634,27 @@ def GetBitsAndModsAndThreads(env) : cmd = splitcommand(env['exe']['MAL_Client'][1]) if procdebug: print('GetBitsAndModsAndThreads: starting process "%s" (inpipe, outpipe, errpipe)\n' % '" "'.join(cmd)) - clnt = process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE, - stderr=process.PIPE, text=True) - input = '''\ - c := mdb.modules(); - modsid := algebra.unique(c,nil:bat); - mods := algebra.projection(modsid,c); - s := "\\nModules: "; - sep := ""; - barrier (h:oid,t:str) := iterator.new(mods); - s := s + sep; - s := s + "\'"; - s := s + t; - s := s + "\'"; - sep := ","; - redo (h:oid,t:str) := iterator.next(mods); - exit h; - s := s + "\\n"; - io.printf(s); - ''' - ##module("NoModule"); - qOut, qErr = clnt.communicate(input=input) + with process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE, + stderr=process.PIPE, text=True) as clnt: + input = '''\ + c := mdb.modules(); + modsid := algebra.unique(c,nil:bat); + mods := algebra.projection(modsid,c); + s := "\\nModules: "; + sep := ""; + barrier (h:oid,t:str) := iterator.new(mods); + s := s + sep; + s := s + "\'"; + s := s + t; + s := s + "\'"; + sep := ","; + redo (h:oid,t:str) := iterator.next(mods); + exit h; + s := s + "\\n"; + io.printf(s); + ''' + ##module("NoModule"); + qOut, qErr = clnt.communicate(input=input) proc.terminate() sOut = proc.stdout.read() sErr = proc.stderr.read() @@ -2468,10 +2474,10 @@ def prompt() : def getkids(): # return a dictionary with process IDs as key and a list of child # processes as value - p = process.Popen(['ps', '-lu', os.getenv('USER')], - stdout=process.PIPE, stderr=process.PIPE, - text=True) - out, err = p.communicate() + with process.Popen(['ps', '-lu', os.getenv('USER')], + stdout=process.PIPE, stderr=process.PIPE, + text=True) as p: + out, err = p.communicate() if err: return {} lines = out.split('\n') @@ -2552,26 +2558,28 @@ def killProc(proc, outfile = None, cmd = else: cdb = None if cdb: - p = process.Popen([cdb, '-pv', '-p', str(proc.pid), - '-y', '%scache*;srv*http://msdl.microsoft.com/download/symbols' % sym, '-lines', '-c', '~*kP;!locks;q'], - stdout=process.PIPE, text=True) - out, err = p.communicate() + with process.Popen([cdb, '-pv', '-p', str(proc.pid), + '-y', '%scache*;srv*http://msdl.microsoft.com/download/symbols' % sym, '-lines', '-c', '~*kP;!locks;q'], + stdout=process.PIPE, text=True) as p: + out, err = p.communicate() else: out = '' else: try: - p = process.Popen(['pstack', str(proc.pid)], stdout=process.PIPE, - text=True) - try: - # pstack (gdb) sometimes hangs when trying to get the - # stack trace: kill it mercilessly if it does - t = Timer(60, reallyKill, args = [p]) - t.start() - except AttributeError: - t = None - out, err = p.communicate() + with process.Popen(['pstack', str(proc.pid)], stdout=process.PIPE, + text=True) as p: + try: + # pstack (gdb) sometimes hangs when trying to get the + # stack trace: kill it mercilessly if it does + t = Timer(60, reallyKill, args = [p]) + t.start() + except AttributeError: + t = None + out, err = p.communicate() if t is not None: t.cancel() + except KeyboardInterrupt: + raise except: out = '' if outfile is not None and out: @@ -2588,10 +2596,10 @@ def killProc(proc, outfile = None, cmd = elif os.name == 'nt': if procdebug: print('killProc: starting process "taskkill" "/F" "/T" "/PID" "%s"\n' % str(proc.pid)) - p = process.Popen(['taskkill','/F','/T','/PID',str(proc.pid)], - stdout=process.PIPE, stderr=process.PIPE, - text=True) - out, err = p.communicate() + with process.Popen(['taskkill','/F','/T','/PID',str(proc.pid)], + stdout=process.PIPE, stderr=process.PIPE, + text=True) as p: + out, err = p.communicate() if procdebug: print('killProc: process exited "taskkill" "/F" "/T" "/PID" "%s" (%s)\n' % (str(proc.pid), proc.returncode)) proc.kill() @@ -2710,25 +2718,25 @@ def RunIt(cmd, onechild, TestIn, TestOut if procdebug: print('RunIt: starting process "%s"\n' % '" "'.join(cmd)) setpgrp = True - proc = process.Popen(cmd, stdin=TestIn, stdout=TestOut, - stderr=TestErr, text=True) - proc.killed = False - proc.onechild = onechild - t = Timer(TimeOut, killProc, args = [proc, TestErr, cmd]) - try: - t.start() - # since both stdout and stderr are redirected to files, - # communicate will not return any useful data - proc.communicate(input = TestInput) - t.cancel() - if procdebug: - print('RunIt: process exited "%s" (%s)\n' % ('" "'.join(cmd), proc.returncode)) - except KeyboardInterrupt: - t.cancel() - killProc(proc, TestErr, cmd) - if procdebug: - print('RunIt: process killed "%s"\n' % '" "'.join(cmd)) - raise + with process.Popen(cmd, stdin=TestIn, stdout=TestOut, + stderr=TestErr, text=True) as proc: + proc.killed = False + proc.onechild = onechild + t = Timer(TimeOut, killProc, args = [proc, TestErr, cmd]) + try: + t.start() + # since both stdout and stderr are redirected to files, + # communicate will not return any useful data + proc.communicate(input = TestInput) + t.cancel() + if procdebug: + print('RunIt: process exited "%s" (%s)\n' % ('" "'.join(cmd), proc.returncode)) + except KeyboardInterrupt: + t.cancel() + killProc(proc, TestErr, cmd) + if procdebug: + print('RunIt: process killed "%s"\n' % '" "'.join(cmd)) + raise rc = returnCode(proc, TestErr) if rc == 'interrupt': raise KeyboardInterrupt @@ -2939,12 +2947,16 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te port=int(env['MAPIPORT']), database=TSTDB, language=lang) + except KeyboardInterrupt: + raise except: returncode = 'error' else: if not os.path.exists(TST+'.reqtests'): try: sql.drop() + except KeyboardInterrupt: + raise except: pass try: @@ -3086,23 +3098,23 @@ def Check(command, input) : if procdebug: print('Check: starting process "%s" (inpipe,outpipe,errpipe)\n' % '" "'.join(command)) setpgrp = True - proc = process.Popen(command, stdin=process.PIPE, stdout=process.PIPE, - stderr=process.PIPE, text=True) - proc.killed = False - proc.onechild = True - t = Timer(float(par['TIMEOUT']), killProc, args = [proc]) - try: - t.start() - qOut, qErr = proc.communicate(input = input) - t.cancel() - if procdebug: - print('Check: process exited "%s" (%s)\n' % ('" "'.join(command), proc.returncode)) - except KeyboardInterrupt: - t.cancel() - killProc(proc) - if procdebug: - print('Check: process killed "%s"\n' % '" "'.join(command)) - raise + with process.Popen(command, stdin=process.PIPE, stdout=process.PIPE, + stderr=process.PIPE, text=True) as proc: + proc.killed = False + proc.onechild = True + t = Timer(float(par['TIMEOUT']), killProc, args = [proc]) + try: + t.start() + qOut, qErr = proc.communicate(input = input) + t.cancel() + if procdebug: + print('Check: process exited "%s" (%s)\n' % ('" "'.join(command), proc.returncode)) + except KeyboardInterrupt: + t.cancel() + killProc(proc) + if procdebug: + print('Check: process killed "%s"\n' % '" "'.join(command)) + raise qOut = qOut.split('\n') qErr = qErr.split('\n') failed = False @@ -3272,10 +3284,10 @@ if os.name == "nt": r = re.compile('^Microsoft Windows (.*)\[Version ([0-9]+\.[0-9]+)([^\[0-9].*)\]$') if procdebug: print('starting process "cmd" "/c" "ver" (inpipe,outpipe)\n') - proc = process.Popen('cmd /c ver', stdin=process.PIPE, - stdout=process.PIPE, stderr=process.PIPE, - text=True) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list