Changeset: cf540fc6d1e6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cf540fc6d1e6
Modified Files:
        sql/server/rel_select.c
Branch: label
Log Message:

merged with default


diffs (123 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -409,7 +409,11 @@ utf8strlenmax(char *s, char *e, size_t m
                                        return len0;
                                }
                                if (len == max) {
-                                       *t = s;
+                                       /* add any following combining (zero 
width) characters */
+                                       do {
+                                               *t = s;
+                                               s = nextcharn(s, e == NULL ? 4 
: (size_t) (e - s), &codepoint);
+                                       } while (codepoint > 0 && 
charwidth(codepoint) == 0);
                                        return len;
                                }
                        }
diff --git a/common/utils/mutf8.h b/common/utils/mutf8.h
--- a/common/utils/mutf8.h
+++ b/common/utils/mutf8.h
@@ -63,3 +63,24 @@ nextchar(const char *s, uint32_t *c)
        *c = 0;
        return NULL;
 }
+
+/* like the above, but s is at most n bytes long */
+static inline char *
+nextcharn(const char *s, size_t n, uint32_t *c)
+{
+       uint32_t codepoint = 0, state = 0;
+       while (n-- > 0 && *s) {
+               switch (decode(&state, &codepoint, (uint8_t) *s++)) {
+               case UTF8_ACCEPT:
+                       *c = codepoint;
+                       return (char *) s;
+               case UTF8_REJECT:
+                       *c = 0;
+                       return NULL;
+               default:
+                       break;
+               }
+       }
+       *c = 0;
+       return NULL;
+}
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
@@ -5580,7 +5580,7 @@ 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 found = 0, full = (op != op_join);
+       int found = 0, full = (op == op_full), right = (op == op_right);
        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);
@@ -5604,18 +5604,22 @@ join_on_column_name(sql_query *query, sq
                        found = 1;
                        if (!(rel = rel_compare_exp(query, rel, le, re, "=", 
TRUE, 0, 0, 0, 0)))
                                return NULL;
+                       list_remove_data(r_exps, NULL, re);
                        if (full) {
                                sql_exp *cond = rel_unop_(sql, rel, le, "sys", 
"isnull", card_value);
                                if (!cond)
                                        return NULL;
                                set_has_no_nil(cond);
+                               if (rel_convert_types(sql, NULL, NULL, &le, 
&re, 1, type_equal_no_any) < 0)
+                                       return NULL;
                                if (!(le = rel_nop_(sql, rel, cond, re, le, 
NULL, "sys", "ifthenelse", card_value)))
                                        return NULL;
+                       } else if (right) {
+                               le = re;
                        }
                        exp_setname(sql, le, rname, name);
                        set_not_unique(le);
                        append(outexps, le);
-                       list_remove_data(r_exps, NULL, re);
                } else {
                        if (l_nil)
                                set_has_nil(le);
diff --git a/sql/test/BugTracker-2024/Tests/7524-right-outer-join.test 
b/sql/test/BugTracker-2024/Tests/7524-right-outer-join.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7524-right-outer-join.test
@@ -0,0 +1,30 @@
+
+statement ok
+CREATE TABLE t0(c0 INT)
+
+statement ok
+CREATE TABLE t1(c0 VARCHAR)
+
+query II
+SELECT * FROM t1 LEFT JOIN t0 ON t1.c0 = t0.c0
+----
+
+query II
+SELECT * FROM t1 RIGHT JOIN t0 ON t1.c0 = t0.c0
+----
+
+query II
+SELECT * FROM t1 FULL JOIN t0 ON t1.c0 = t0.c0
+----
+
+query I
+SELECT * FROM t1 NATURAL LEFT JOIN t0
+----
+
+query I
+SELECT * FROM t1 NATURAL RIGHT JOIN t0
+----
+
+query I
+SELECT * FROM t1 NATURAL FULL JOIN t0
+----
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -59,3 +59,4 @@ 7511-password-hash-missing-error
 7512-concurrent-globaltmp-instantiate-crash
 7513-uri-authority-parse-issue
 7514-wrong-window-function
+7524-right-outer-join
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to