Changeset: ec0a3ea4be34 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ec0a3ea4be34
Modified Files:
        clients/python2/test/capabilities.py
        clients/python3/test/capabilities.py
        sql/server/rel_select.c
Branch: Jan2014
Log Message:

fix for bug 3482, ie return an error on abiguous table names


diffs (65 lines):

diff --git a/clients/python2/test/capabilities.py 
b/clients/python2/test/capabilities.py
--- a/clients/python2/test/capabilities.py
+++ b/clients/python2/test/capabilities.py
@@ -361,7 +361,7 @@ class DatabaseTest(unittest.TestCase):
         r = self.cursor.fetchone()
         n = r[0]
         self.cursor.arraysize=100000
-        self.cursor.execute('select * from tables, tables')
+        self.cursor.execute('select * from tables, tables t')
         r = self.cursor.fetchall()
         self.assertEqual(len(r), n**2)
 
diff --git a/clients/python3/test/capabilities.py 
b/clients/python3/test/capabilities.py
--- a/clients/python3/test/capabilities.py
+++ b/clients/python3/test/capabilities.py
@@ -361,7 +361,7 @@ class DatabaseTest(unittest.TestCase):
         r = self.cursor.fetchone()
         n = r[0]
         self.cursor.arraysize=100000
-        self.cursor.execute('select * from tables, tables')
+        self.cursor.execute('select * from tables, tables t')
         r = self.cursor.fetchall()
         self.assertEqual(len(r), n**2)
 
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -5060,7 +5060,6 @@ rel_select_exp(mvc *sql, sql_rel *rel, S
        return rel;
 }
 
-
 static sql_rel *
 rel_query(mvc *sql, sql_rel *rel, symbol *sq, int toplevel, exp_kind ek, int 
apply)
 {
@@ -5083,10 +5082,11 @@ rel_query(mvc *sql, sql_rel *rel, symbol
 
 
        sql->use_views = 1;
-       if (sn->from) {         /* keep variable list with tables and names */
+       if (sn->from) { 
                dlist *fl = sn->from->data.lval;
                dnode *n = NULL;
                sql_rel *fnd = NULL;
+               list *aliases =  sa_list(sql->sa);
 
                for (n = fl->h; n ; n = n->next) {
                        fnd = table_ref(sql, NULL, n->data.sym);
@@ -5112,10 +5112,14 @@ rel_query(mvc *sql, sql_rel *rel, symbol
 
                        if (!fnd)
                                break;
-                       if (res)
+                       if (res && list_find(aliases, rel_name(fnd), 
(fcmp)&strcmp)) 
+                               return sql_error(sql, ERR_AMBIGUOUS, "SELECT: 
identifier '%s' ambiguous", rel_name(fnd));
+                       else if (res)
                                res = rel_crossproduct(sql->sa, res, fnd, 
op_join);
-                       else
+                       else 
                                res = fnd;
+                       if (rel_name(fnd))
+                               list_append(aliases, rel_name(fnd));
                }
                if (!fnd) {
                        if (res)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to