Changeset: 380fec712a3d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=380fec712a3d
Modified Files:
        sql/server/rel_select.c
        sql/test/BugTracker-2015/Tests/outerjoin_project.Bug-3725.stable.out
        
sql/test/BugTracker-2018/Tests/multi-column-hash-wrongly-NIL.Bug-6638.stable.out
        
sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
        sql/test/BugTracker/Tests/full_join_crash.SF-1841754.stable.out
        sql/test/SQLancer/Tests/sqlancer04.sql
        sql/test/SQLancer/Tests/sqlancer04.stable.err
        sql/test/SQLancer/Tests/sqlancer04.stable.out
        sql/test/bugs/Tests/subselect_single_value-bug-sf-962099.stable.out
Branch: default
Log Message:

Making SQLancer happy. Keep relation names while referencing them, so later 
their columns can be found on a natural join


diffs (truncated from 382 to 300 lines):

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
@@ -197,15 +197,14 @@ rel_table_optname(mvc *sql, sql_rel *sq,
                        ne = sq->exps->h;
                        for (; ne; ne = ne->next) {
                                sql_exp *e = ne->data;
-
-                               /*
-                               if (exp_name(e) && exps_bind_column2(l, tname, 
exp_name(e)))
-                                       return sql_error(sql, ERR_AMBIGUOUS, 
SQLSTATE(42000) "SELECT: Duplicate column name '%s.%s'", tname, exp_name(e));
-                                       */
-                               noninternexp_setname(sql->sa, e, tname, NULL );
-                               if (!is_intern(e))
+                               char *name = NULL;
+
+                               if (!is_intern(e)) {
+                                       if (!exp_name(e))
+                                               name = make_label(sql->sa, 
++sql->label);
+                                       noninternexp_setname(sql->sa, e, tname, 
name);
                                        set_basecol(e);
-                               append(l, e);
+                               }
                        }
                }
        } else {
@@ -252,19 +251,19 @@ rel_with_query(sql_query *query, symbol 
        for (d = d->data.lval->h; d; d = d->next) {
                symbol *sym = d->data.sym;
                dnode *dn = sym->data.lval->h;
-               char *name = qname_schema_object(dn->data.lval);
+               char *rname = qname_schema_object(dn->data.lval);
                sql_rel *nrel;
 
-               if (frame_find_rel_view(sql, name)) {
+               if (frame_find_rel_view(sql, rname)) {
                        stack_pop_frame(sql);
-                       return sql_error(sql, 01, SQLSTATE(42000) "View '%s' 
already declared", name);
+                       return sql_error(sql, 01, SQLSTATE(42000) "View '%s' 
already declared", rname);
                }
                nrel = rel_semantic(query, sym);
                if (!nrel) {
                        stack_pop_frame(sql);
                        return NULL;
                }
-               if (!stack_push_rel_view(sql, name, nrel)) {
+               if (!stack_push_rel_view(sql, rname, nrel)) {
                        stack_pop_frame(sql);
                        return sql_error(sql, 02, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                }
@@ -282,10 +281,14 @@ rel_with_query(sql_query *query, symbol 
 
                        for (; ne; ne = ne->next) {
                                sql_exp *e = ne->data;
-
-                               noninternexp_setname(sql->sa, e, name, NULL );
-                               if (!is_intern(e))
+                               char *name = NULL;
+
+                               if (!is_intern(e)) {
+                                       if (!exp_name(e))
+                                               name = make_label(sql->sa, 
++sql->label);
+                                       noninternexp_setname(sql->sa, e, rname, 
name);
                                        set_basecol(e);
+                               }
                        }
                }
        }
@@ -5402,20 +5405,17 @@ static sql_rel *
 join_on_column_name(sql_query *query, sql_rel *rel, sql_rel *t1, sql_rel *t2, 
int op, int l_nil, int r_nil)
 {
        mvc *sql = query->sql;
-       int nr = ++sql->label, found = 0, full = (op != op_join);
-       char name[16], *nme;
+       int found = 0, full = (op != op_join);
        list *exps = rel_projections(sql, t1, NULL, 1, 0);
        list *r_exps = rel_projections(sql, t2, NULL, 1, 0);
        list *outexps = new_exp_list(sql->sa);
-       node *n;
-
-       nme = number2name(name, sizeof(name), nr);
+
        if (!exps || !r_exps)
                return NULL;
-       for (n = exps->h; n; n = n->next) {
+       for (node *n = exps->h; n; n = n->next) {
                sql_exp *le = n->data;
-               const char *nm = exp_name(le);
-               sql_exp *re = exps_bind_column(r_exps, nm, NULL, 0);
+               const char *rname = exp_relname(le), *name = exp_name(le);
+               sql_exp *re = exps_bind_column(r_exps, name, NULL, 0);
 
                if (re) {
                        found = 1;
@@ -5429,7 +5429,7 @@ join_on_column_name(sql_query *query, sq
                                if (!(le = rel_nop_(sql, rel, cond, re, le, 
NULL, NULL, "ifthenelse", card_value)))
                                        return NULL;
                        }
-                       exp_setname(sql->sa, le, nme, sa_strdup(sql->sa, nm));
+                       exp_setname(sql->sa, le, rname, name);
                        append(outexps, le);
                        list_remove_data(r_exps, re);
                } else {
@@ -5440,7 +5440,7 @@ join_on_column_name(sql_query *query, sq
        }
        if (!found)
                return sql_error(sql, 02, SQLSTATE(42000) "JOIN: no columns of 
tables '%s' and '%s' match", rel_name(t1)?rel_name(t1):"", 
rel_name(t2)?rel_name(t2):"");
-       for (n = r_exps->h; n; n = n->next) {
+       for (node *n = r_exps->h; n; n = n->next) {
                sql_exp *re = n->data;
                if (r_nil)
                        set_has_nil(re);
diff --git 
a/sql/test/BugTracker-2015/Tests/outerjoin_project.Bug-3725.stable.out 
b/sql/test/BugTracker-2015/Tests/outerjoin_project.Bug-3725.stable.out
--- a/sql/test/BugTracker-2015/Tests/outerjoin_project.Bug-3725.stable.out
+++ b/sql/test/BugTracker-2015/Tests/outerjoin_project.Bug-3725.stable.out
@@ -30,8 +30,8 @@ stdout of test 'outerjoin_project.Bug-37
 #insert into a values (1);
 [ 1    ]
 #select * from a left join (select a, 20 from b) as x using (a);
-% .%1, .%4 # table_name
-% a,   %4 # name
+% .%2, .x # table_name
+% a,   %1 # name
 % int, tinyint # type
 % 1,   1 # length
 [ 1,   NULL    ]
diff --git 
a/sql/test/BugTracker-2018/Tests/multi-column-hash-wrongly-NIL.Bug-6638.stable.out
 
b/sql/test/BugTracker-2018/Tests/multi-column-hash-wrongly-NIL.Bug-6638.stable.out
--- 
a/sql/test/BugTracker-2018/Tests/multi-column-hash-wrongly-NIL.Bug-6638.stable.out
+++ 
b/sql/test/BugTracker-2018/Tests/multi-column-hash-wrongly-NIL.Bug-6638.stable.out
@@ -106,7 +106,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     -2      ]
 [ 11,  21,     -1      ]
 #select * from r2 natural join s2 order by x,y;
-% sys.%1,      sys.%1, sys.r2, sys.s2 # table_name
+% sys.r2,      sys.r2, sys.r2, sys.s2 # table_name
 % a,   b,      x,      y # name
 % bigint,      bigint, bigint, bigint # type
 % 20,  20,     2,      3 # length
@@ -124,7 +124,7 @@ stdout of test 'multi-column-hash-wrongl
 [ -1,  9223372036854775807,    12,     -12     ]
 [ 9223372036854775807, -1,     13,     -13     ]
 #select * from s2 natural join r2 order by x,y;
-% sys.%1,      sys.%1, sys.s2, sys.r2 # table_name
+% sys.s2,      sys.s2, sys.s2, sys.r2 # table_name
 % a,   b,      y,      x # name
 % bigint,      bigint, bigint, bigint # type
 % 20,  20,     3,      2 # length
@@ -174,7 +174,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     -2      ]
 [ 11,  21,     31,     -1      ]
 #select * from r3 natural join s3 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.r3, sys.s3 # table_name
+% sys.r3,      sys.r3, sys.r3, sys.r3, sys.s3 # table_name
 % a,   b,      c,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint # type
 % 15,  15,     15,     1,      2 # length
@@ -188,7 +188,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   140737488355328,        0,      8,      -8      ]
 [ 0,   0,      140737488355328,        9,      -9      ]
 #select * from s3 natural join r3 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.s3, sys.r3 # table_name
+% sys.s3,      sys.s3, sys.s3, sys.s3, sys.r3 # table_name
 % a,   b,      c,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint # type
 % 15,  15,     15,     2,      1 # length
@@ -238,7 +238,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     -2      ]
 [ 11,  21,     31,     41,     -1      ]
 #select * from r4 natural join s4 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.r4, sys.s4 # table_name
+% sys.r4,      sys.r4, sys.r4, sys.r4, sys.r4, sys.s4 # table_name
 % a,   b,      c,      d,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     2,      3 # length
@@ -254,7 +254,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      1125899906842624,       0,      10,     -10     ]
 [ 0,   0,      0,      1125899906842624,       11,     -11     ]
 #select * from s4 natural join r4 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.s4, sys.r4 # table_name
+% sys.s4,      sys.s4, sys.s4, sys.s4, sys.s4, sys.r4 # table_name
 % a,   b,      c,      d,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     3,      2 # length
@@ -310,7 +310,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     52,     -2      ]
 [ 11,  21,     31,     41,     51,     -1      ]
 #select * from r5 natural join s5 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.r5, sys.s5 # table_name
+% sys.r5,      sys.r5, sys.r5, sys.r5, sys.r5, sys.r5, sys.s5 # table_name
 % a,   b,      c,      d,      e,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     16,     2,      3 # length
@@ -328,7 +328,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      0,      4503599627370496,       0,      12,     -12     ]
 [ 0,   0,      0,      0,      4503599627370496,       13,     -13     ]
 #select * from s5 natural join r5 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.s5, sys.r5 # table_name
+% sys.s5,      sys.s5, sys.s5, sys.s5, sys.s5, sys.s5, sys.r5 # table_name
 % a,   b,      c,      d,      e,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     16,     3,      2 # length
@@ -390,7 +390,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     52,     62,     -2      ]
 [ 11,  21,     31,     41,     51,     61,     -1      ]
 #select * from r6 natural join s6 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.r6, sys.s6 # 
table_name
+% sys.r6,      sys.r6, sys.r6, sys.r6, sys.r6, sys.r6, sys.r6, sys.s6 # 
table_name
 % a,   b,      c,      d,      e,      f,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     16,     16,     2,      3 # length
@@ -410,7 +410,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      0,      0,      9007199254740992,       0,      14,     -14     
]
 [ 0,   0,      0,      0,      0,      9007199254740992,       15,     -15     
]
 #select * from s6 natural join r6 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.s6, sys.r6 # 
table_name
+% sys.s6,      sys.s6, sys.s6, sys.s6, sys.s6, sys.s6, sys.s6, sys.r6 # 
table_name
 % a,   b,      c,      d,      e,      f,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint # type
 % 16,  16,     16,     16,     16,     16,     3,      2 # length
@@ -478,7 +478,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     52,     62,     72,     -2      ]
 [ 11,  21,     31,     41,     51,     61,     71,     -1      ]
 #select * from r7 natural join s7 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.r7, sys.s7 
# table_name
+% sys.r7,      sys.r7, sys.r7, sys.r7, sys.r7, sys.r7, sys.r7, sys.r7, sys.s7 
# table_name
 % a,   b,      c,      d,      e,      f,      g,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint 
# type
 % 17,  17,     17,     17,     17,     17,     17,     2,      3 # length
@@ -500,7 +500,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      0,      0,      0,      36028797018963968,      0,      16,     
-16     ]
 [ 0,   0,      0,      0,      0,      0,      36028797018963968,      17,     
-17     ]
 #select * from s7 natural join r7 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.s7, sys.r7 
# table_name
+% sys.s7,      sys.s7, sys.s7, sys.s7, sys.s7, sys.s7, sys.s7, sys.s7, sys.r7 
# table_name
 % a,   b,      c,      d,      e,      f,      g,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint 
# type
 % 17,  17,     17,     17,     17,     17,     17,     3,      2 # length
@@ -574,7 +574,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     52,     62,     72,     82,     -2      ]
 [ 11,  21,     31,     41,     51,     61,     71,     81,     -1      ]
 #select * from r8 natural join s8 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.r8, 
sys.s8 # table_name
+% sys.r8,      sys.r8, sys.r8, sys.r8, sys.r8, sys.r8, sys.r8, sys.r8, sys.r8, 
sys.s8 # table_name
 % a,   b,      c,      d,      e,      f,      g,      h,      x,      y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, 
bigint # type
 % 17,  17,     17,     17,     17,     17,     17,     17,     2,      3 # 
length
@@ -598,7 +598,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      0,      0,      0,      0,      36028797018963968,      0,      
18,     -18     ]
 [ 0,   0,      0,      0,      0,      0,      0,      36028797018963968,      
19,     -19     ]
 #select * from s8 natural join r8 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.s8, 
sys.r8 # table_name
+% sys.s8,      sys.s8, sys.s8, sys.s8, sys.s8, sys.s8, sys.s8, sys.s8, sys.s8, 
sys.r8 # table_name
 % a,   b,      c,      d,      e,      f,      g,      h,      y,      x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, 
bigint # type
 % 17,  17,     17,     17,     17,     17,     17,     17,     3,      2 # 
length
@@ -678,7 +678,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 12,  22,     32,     42,     52,     62,     72,     82,     92,     -2      
]
 [ 11,  21,     31,     41,     51,     61,     71,     81,     91,     -1      
]
 #select * from r9 natural join s9 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, 
sys.r9, sys.s9 # table_name
+% sys.r9,      sys.r9, sys.r9, sys.r9, sys.r9, sys.r9, sys.r9, sys.r9, sys.r9, 
sys.r9, sys.s9 # table_name
 % a,   b,      c,      d,      e,      f,      g,      h,      i,      x,      
y # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, 
bigint, bigint # type
 % 17,  17,     17,     17,     17,     17,     17,     17,     17,     2,      
3 # length
@@ -704,7 +704,7 @@ stdout of test 'multi-column-hash-wrongl
 [ 0,   0,      0,      0,      0,      0,      0,      72057594037927936,      
0,      20,     -20     ]
 [ 0,   0,      0,      0,      0,      0,      0,      0,      
72057594037927936,      21,     -21     ]
 #select * from s9 natural join r9 order by x,y;
-% sys.%1,      sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, sys.%1, 
sys.s9, sys.r9 # table_name
+% sys.s9,      sys.s9, sys.s9, sys.s9, sys.s9, sys.s9, sys.s9, sys.s9, sys.s9, 
sys.s9, sys.r9 # table_name
 % a,   b,      c,      d,      e,      f,      g,      h,      i,      y,      
x # name
 % bigint,      bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, 
bigint, bigint # type
 % 17,  17,     17,     17,     17,     17,     17,     17,     17,     3,      
2 # length
diff --git 
a/sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
 
b/sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
--- 
a/sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
+++ 
b/sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
@@ -47,13 +47,13 @@ stdout of test 'disallow_duplicate_colum
 % 1,   1,      1 # length
 [ 1,   2,      3       ]
 #select a.* from (select 1,2,3 as "L2") a;
-% .%1, .%2,    .a # table_name
+% .a,  .a,     .a # table_name
 % %1,  %2,     L2 # name
 % tinyint,     tinyint,        tinyint # type
 % 1,   1,      1 # length
 [ 1,   2,      3       ]
 #with wa as (select 1,2,3 as "L2") select wa.* from wa;
-% .%1, .%2,    .wa # table_name
+% .wa, .wa,    .wa # table_name
 % %1,  %2,     L2 # name
 % tinyint,     tinyint,        tinyint # type
 % 1,   1,      1 # length
diff --git a/sql/test/BugTracker/Tests/full_join_crash.SF-1841754.stable.out 
b/sql/test/BugTracker/Tests/full_join_crash.SF-1841754.stable.out
--- a/sql/test/BugTracker/Tests/full_join_crash.SF-1841754.stable.out
+++ b/sql/test/BugTracker/Tests/full_join_crash.SF-1841754.stable.out
@@ -53,7 +53,7 @@ stdout of test 'full_join_crash.SF-18417
 [ "dd",        NULL,   42,     NULL    ]
 [ "cc",        NULL,   NULL,   33      ]
 #SELECT * FROM t1841754a natural FULL JOIN t1841754b ;
-% .%1, .%1 # table_name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to