Changeset: 4808d50956de for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4808d50956de
Modified Files:
        testing/Mz.py.in
Branch: default
Log Message:

Merge with Jul2021 branch.


diffs (truncated from 317 to 300 lines):

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
@@ -146,14 +146,13 @@ validate_alter_table_add_table(mvc *sql,
        if (!mvc_schema_privs(sql, ps))
                throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: access denied for 
%s to schema '%s'", get_string_global_var(sql, "current_user"), ps->base.name);
        if (!(rmt = mvc_bind_table(sql, ms, mtname)))
-               throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: no such table '%s' 
in schema '%s'", ms->base.name, mtname);
+               throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: no such table '%s' 
in schema '%s'", mtname, ms->base.name);
        if (!(rpt = mvc_bind_table(sql, ps, ptname)))
-               throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: no such table '%s' 
in schema '%s'", ps->base.name, ptname);
+               throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: no such table '%s' 
in schema '%s'", ptname, ps->base.name);
 
        const char *errtable = TABLE_TYPE_DESCRIPTION(rmt->type, 
rmt->properties);
        if (!update && (!isMergeTable(rmt) && !isReplicaTable(rmt)))
                throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: cannot add table 
'%s.%s' to %s '%s.%s'", psname, ptname, errtable, msname, mtname);
-       node *n = members_find_child_id(rmt->members, rpt->base.id);
        if (isView(rpt))
                throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: can't add a view 
into a %s", errtable);
        if (isDeclaredTable(rpt))
@@ -162,6 +161,9 @@ validate_alter_table_add_table(mvc *sql,
                throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: can't add a 
temporary table into a %s", errtable);
        if (ms->base.id != ps->base.id)
                throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: all children 
tables of '%s.%s' must be part of schema '%s'", msname, mtname, msname);
+       if (strcmp(rmt->base.name, rpt->base.name) == 0)
+               throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: a %s can't be a 
child of itself", errtable);
+       node *n = members_find_child_id(rmt->members, rpt->base.id);
        if (n && !update)
                throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: table '%s.%s' is 
already part of %s '%s.%s'", psname, ptname, errtable, msname, mtname);
        if (!n && update)
@@ -439,9 +441,9 @@ alter_table_del_table(mvc *sql, char *ms
        if (!mvc_schema_privs(sql, ps))
                throw(SQL,"sql.alter_table_del_table",SQLSTATE(42000) "ALTER 
TABLE: access denied for %s to schema '%s'", get_string_global_var(sql, 
"current_user"), ps->base.name);
        if (!(mt = mvc_bind_table(sql, ms, mtname)))
-               throw(SQL,"sql.alter_table_del_table",SQLSTATE(42S02) "ALTER 
TABLE: no such table '%s' in schema '%s'", ms->base.name, mtname);
+               throw(SQL,"sql.alter_table_del_table",SQLSTATE(42S02) "ALTER 
TABLE: no such table '%s' in schema '%s'", mtname, ms->base.name);
        if (!(pt = mvc_bind_table(sql, ps, ptname)))
-               throw(SQL,"sql.alter_table_del_table",SQLSTATE(42S02) "ALTER 
TABLE: no such table '%s' in schema '%s'", ps->base.name, ptname);
+               throw(SQL,"sql.alter_table_del_table",SQLSTATE(42S02) "ALTER 
TABLE: no such table '%s' in schema '%s'", ptname, ps->base.name);
        const char *errtable = TABLE_TYPE_DESCRIPTION(mt->type, mt->properties);
        if (!isMergeTable(mt) && !isReplicaTable(mt))
                throw(SQL,"sql.alter_table_del_table",SQLSTATE(42S02) "ALTER 
TABLE: cannot drop table '%s.%s' to %s '%s.%s'", psname, ptname, errtable, 
msname, mtname);
diff --git a/sql/test/transactions/Tests/transaction_isolation5.SQL.py 
b/sql/test/transactions/Tests/transaction_isolation5.SQL.py
--- a/sql/test/transactions/Tests/transaction_isolation5.SQL.py
+++ b/sql/test/transactions/Tests/transaction_isolation5.SQL.py
@@ -32,6 +32,23 @@ with SQLTestCase() as mdb1:
         mdb1.execute('commit;').assertSucceeded()
         mdb2.execute('commit;').assertSucceeded()
 
+        mdb1.execute('create merge table parent2(a int, b 
int);').assertSucceeded()
+        mdb1.execute('create table child2(a int, b int);').assertSucceeded()
+        mdb1.execute('start transaction;').assertSucceeded()
+        mdb2.execute('start transaction;').assertSucceeded()
+        mdb1.execute("drop table child2;").assertSucceeded()
+        mdb2.execute("ALTER TABLE parent2 ADD TABLE child2;").assertSucceeded()
+        mdb1.execute('commit;').assertSucceeded()
+        mdb2.execute('commit;').assertFailed(err_code="40000", 
err_message="COMMIT: transaction is aborted because of concurrency conflicts, 
will ROLLBACK instead")
+
+        mdb1.execute('create merge table parent3(a int, b 
int);').assertSucceeded()
+        mdb1.execute('start transaction;').assertSucceeded()
+        mdb2.execute('start transaction;').assertSucceeded()
+        mdb1.execute("drop table parent3;").assertSucceeded()
+        mdb2.execute("ALTER TABLE parent3 ADD TABLE 
parent2;").assertFailed(err_code="42000", err_message="ALTER TABLE: transaction 
conflict detected")
+        mdb1.execute('commit;').assertSucceeded()
+        mdb2.execute('rollback;').assertSucceeded()
+
         mdb1.execute('CREATE ROLE myrole;').assertSucceeded()
         mdb1.execute('start transaction;').assertSucceeded()
         mdb2.execute('start transaction;').assertSucceeded()
@@ -44,6 +61,7 @@ with SQLTestCase() as mdb1:
         mdb1.execute('alter table parent1 drop table 
child1;').assertSucceeded()
         mdb1.execute('drop table parent1;').assertSucceeded()
         mdb1.execute('drop table child1;').assertSucceeded()
+        mdb1.execute('drop table parent2;').assertSucceeded()
         mdb1.execute('drop schema mysch;').assertSucceeded()
         mdb1.execute('drop role myrole;').assertSucceeded()
         mdb1.execute('commit;').assertSucceeded()
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1634,63 +1634,63 @@ def GetBitsAndModsAndThreads(env) :
     if procdebug:
         print('GetBitsAndModsAndThreads: starting process "%s" (inpipe, 
outpipe, errpipe)\n' % '" "'.join(cmd))
     setpgrp = True
-    proc = process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE,
-                         stderr=process.PIPE, text=True)
-    proc.stdout = process._BufferedPipe(proc.stdout)
-    proc.stderr = process._BufferedPipe(proc.stderr)
-    proc.killed = False
-    proc.onechild = True
-    t = Timer(float(par['TIMEOUT']), killProc, args = [proc, proc.stderr, cmd])
-    qOut = qErr = None
-    try:
-        t.start()
-        while True:
-            proc.poll()
-            if proc.returncode is not None:
-                break
-            if os.path.exists(os.path.join(dbpath, '.started')):
-                break
-            time.sleep(0.001)
-        if proc.returncode is None:
-            connurl = open(os.path.join(dbpath, '.conn')).read()
-            res = mapiportre.search(connurl)
-            cmd = splitcommand(env['exe']['MAL_Client'][1].replace('${PORT}', 
res.group('port')))
+    with process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE,
+                       stderr=process.PIPE, text=True) as proc:
+        proc.stdout = process._BufferedPipe(proc.stdout)
+        proc.stderr = process._BufferedPipe(proc.stderr)
+        proc.killed = False
+        proc.onechild = True
+        t = Timer(float(par['TIMEOUT']), killProc, args = [proc, proc.stderr, 
cmd])
+        qOut = qErr = None
+        try:
+            t.start()
+            while True:
+                proc.poll()
+                if proc.returncode is not None:
+                    break
+                if os.path.exists(os.path.join(dbpath, '.started')):
+                    break
+                time.sleep(0.001)
+            if proc.returncode is None:
+                connurl = open(os.path.join(dbpath, '.conn')).read()
+                res = mapiportre.search(connurl)
+                cmd = 
splitcommand(env['exe']['MAL_Client'][1].replace('${PORT}', res.group('port')))
+                if procdebug:
+                    print('GetBitsAndModsAndThreads: starting process "%s" 
(inpipe, outpipe, errpipe)\n' % '" "'.join(cmd))
+                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()
+                proc.wait()
+                qOut = sOut + qOut
+                qErr = sErr + qErr
+        finally:
+            t.cancel()
+            if proc.returncode is None:
+                killProc(proc, proc.stderr, cmd)
+                proc.wait()
             if procdebug:
-                print('GetBitsAndModsAndThreads: starting process "%s" 
(inpipe, outpipe, errpipe)\n' % '" "'.join(cmd))
-            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()
-            proc.wait()
-            qOut = sOut + qOut
-            qErr = sErr + qErr
-    finally:
-        t.cancel()
-        if proc.returncode is None:
-            killProc(proc, proc.stderr, cmd)
-            proc.wait()
-        if procdebug:
-            print('GetBitsAndModsAndThreads: process exited "%s" (%s)\n' % ('" 
"'.join(cmd), proc.returncode))
+                print('GetBitsAndModsAndThreads: process exited "%s" (%s)\n' % 
('" "'.join(cmd), proc.returncode))
     env['TST_MODS'] = []
     env['TST_BITS'] = ""
     env['TST_INT128'] = ""
@@ -3484,21 +3484,14 @@ def main(argv) :
     # hence, we set them at runtime.
     # X == true   =>  @X_TRUE@='',  @X_FALSE@='#'
     # X == false  =>  @X_TRUE@='#', @X_FALSE@=''
-    python_version = ''
-    if CheckExec('python'):
-        with process.Popen(['python', '-c', 'import sys; 
print(sys.version[:1])'],
-                           stdout=process.PIPE, stderr=process.PIPE,
-                           text=True) as proc:
-            pyout, pyerr = proc.communicate()
-        if proc.returncode == 0 and pyout:
-            python_version = pyout.strip()
-            os.environ['PYTHON' + python_version] = 'python'
     try:
         import pymonetdb
     except ImportError:
-        print('Python available, but pymonetdb package not available')
+        print('pymonetdb package not available')
+        CONDITIONALS['HAVE_PYMONETDB'] = False
     else:
         CONDITIONALS['HAVE_PYMONETDB'] = True
+
     try:
         import lz4
     except ImportError:
@@ -3513,21 +3506,16 @@ def main(argv) :
     else:
         CONDITIONALS['HAVE_MONETDBE'] = True
 
-    if 'PYTHON3' in os.environ:
-        with process.Popen([os.environ['PYTHON3'], '-c', 'import scipy'],
-                           stdout=process.PIPE, stderr=process.PIPE,
-                           text=True) as proc:
-            pyout, pyerr = proc.communicate()
-        if proc.returncode == 0:
-            CONDITIONALS['HAVE_LIBSCIPY3'] = True
-        # with process.Popen([os.environ['PYTHON3'], '-c', 'import pandas'],
-        #                    stdout=process.PIPE, stderr=process.PIPE,
-        #                    text=True) as proc:
-        #     pyout, pyerr = proc.communicate()
-        # if proc.returncode == 0:
-        #     CONDITIONALS['HAVE_LIBPANDAS3'] = True
+    try:
+        import scipy
+    except ImportError:
+        CONDITIONALS['HAVE_LIBSCIPY3'] = False
+    else:
+        CONDITIONALS['HAVE_LIBSCIPY3'] = True
+
     if env.get('TSTDATAPATH'):
         CONDITIONALS['HAVE_DATA_PATH'] = True
+
     if CheckExec('perl'):
         with process.Popen(['perl', '-e', 'use MonetDB::CLI::MapiPP; use 
DBI;'],
                            stdout=process.PIPE, stderr=process.PIPE,
@@ -3754,8 +3742,8 @@ def main(argv) :
         if SOCK:
             # we cannot put the UNIX socket in the mtest root, because that
             # makes the UNIX socket too long on most platforms, so use
-            # /var/tmp/mtest and try not to forget to clean that up
-            sockdir = "/var/tmp/mtest-%d" % os.getpid()
+            # /tmp/mtest and try not to forget to clean that up
+            sockdir = "/tmp/mtest-%d" % os.getpid()
             try:
                 os.mkdir(sockdir)
                 SOCK = "--set mapi_usock=%s/.s.monetdb.${PORT}" % sockdir
diff --git a/testing/Mz.py.in b/testing/Mz.py.in
--- a/testing/Mz.py.in
+++ b/testing/Mz.py.in
@@ -2342,15 +2342,6 @@ def main(argv) :
             print("%s = %s" % (v, str(par[v])))
     STDOUT.flush()
 
-    python_version = ''
-    if CheckExec('python'):
-        with process.Popen(['python', '-c', 'import sys; 
print(sys.version[:1])'],
-                           stdout=process.PIPE, stderr=process.PIPE,
-                           text=True) as proc:
-            pyout, pyerr = proc.communicate()
-        if proc.returncode == 0 and pyout:
-            python_version = pyout.strip()
-            os.environ['PYTHON' + python_version] = 'python'
     try:
         import lz4
     except ImportError:
@@ -2365,13 +2356,13 @@ def main(argv) :
     else:
         CONDITIONALS['HAVE_MONETDBE'] = True
 
-    if 'PYTHON3' in os.environ:
-        with process.Popen([os.environ['PYTHON3'], '-c', 'import scipy'],
-                           stdout=process.PIPE, stderr=process.PIPE,
-                           text=True) as proc:
-            pyout, pyerr = proc.communicate()
-        if proc.returncode == 0:
-            CONDITIONALS['HAVE_LIBSCIPY3'] = '#'
+    try:
+        import scipy
+    except ImportError:
+        CONDITIONALS['HAVE_LIBSCIPY3'] = False
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to