Changeset: f38ad73ae620 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f38ad73ae620
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        clients/odbc/tests/ODBCmetadata.c
        monetdb5/modules/mal/tablet.c
        monetdb5/optimizer/opt_support.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_upgrades.c
        sql/server/rel_dump.c
        sql/server/rel_optimizer.c
        sql/server/rel_propagate.c
        sql/server/rel_rel.h
        sql/server/rel_schema.c
        sql/server/rel_select.c
        sql/server/sql_mvc.c
        sql/server/sql_mvc.h
        sql/server/sql_parser.y
        sql/server/sql_scan.c
        sql/storage/bat/bat_storage.c
        sql/storage/sql_catalog.c
        sql/storage/store.c
        sql/test/BugTracker-2025/Tests/7614_join_reordering.test
        sql/test/BugTracker-2025/Tests/7615_join_reordering_2.test
        sql/test/BugTracker-2025/Tests/7616_join_reordering_3.test
        sql/test/SQLancer/Tests/sqlancer10.test
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
        tools/mserver/mserver5.c
Branch: nested
Log Message:

Merge with default branch


diffs (truncated from 22500 to 300 lines):

diff --git a/.editorconfig b/.editorconfig
--- a/.editorconfig
+++ b/.editorconfig
@@ -5,7 +5,7 @@ root = true
 end_of_line = lf
 insert_final_newline = true
 
-[*.{c,h}{,.in}]
+[*.{c,h,y}{,.in}]
 indent_style = tab
 tab_width = 4
 indent_size = tab
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2559,7 +2559,7 @@ doFile(Mapi mid, stream *fp, bool useins
                                                        " 
''''||replace(rp.minimum, '''', '''''')||'''' as minimum,"
                                                        " 
''''||replace(rp.maximum, '''', '''''')||'''' as maximum,"
                                                        " rp.with_nulls,"
-                                                       " 
'('||group_concat(''''||replace(vp.value, '''', '''''')||'''', ',' order by 
vp.value)||')' as values,"
+                                                       " 
'('||group_concat(''''||replace(vp.value, '''', '''''')||'''', ','%s)||')' as 
\"values\","
                                                        " count(vp.value) <> 
count(*) as has_nulls"
                                                        " from sys.schemas as 
s1,"
                                                        " sys._tables as t1 
left outer join sys.table_partitions as tp on t1.id = tp.table_id left outer 
join sys._columns as c1 on tp.column_id = c1.id,"
@@ -2574,10 +2574,25 @@ doFile(Mapi mid, stream *fp, bool useins
                                                        " d.id = t2.id"
                                                        " group by s1.name, 
t1.name, s2.name, t2.name, c1.name, tp.expression, tp.type, rp.minimum, 
rp.maximum, rp.with_nulls"
                                                        " order by s1.name, 
t1.name, s2.name, t2.name";
+                                               const char *ordering = "";
                                                char *squery = NULL;
                                                size_t squerylen = 0;
                                                char *tquery = NULL;
                                                size_t tquerylen = 0;
+                                               hdl = mapi_query(mid, "select 
value from sys.env() where name = 'monet_version'");
+                                               CHECK_RESULT(mid, hdl, buf, fp);
+                                               if (fetch_row(hdl) > 0) {
+                                                       const char *version = 
mapi_fetch_field(hdl, 0);
+                                                       int major, minor, patch;
+                                                       if (version &&
+                                                               sscanf(version, 
"%d.%d.%d",
+                                                                          
&major, &minor, &patch) == 3 &&
+                                                               major == 11 &&
+                                                               minor >= 53)
+                                                               ordering = " 
order by vp.value";
+                                               }
+                                               mapi_close_handle(hdl);
+                                               hdl = NULL;
                                                if (sname) {
                                                        sname = sescape(sname);
                                                        squerylen = 
strlen(sname) + 21;
@@ -2604,9 +2619,9 @@ doFile(Mapi mid, stream *fp, bool useins
                                                        free(tname);
                                                        tname = NULL;
                                                }
-                                               size_t qlen = sizeof(mquery) + 
squerylen + tquerylen;
+                                               size_t qlen = sizeof(mquery) + 
strlen(ordering) + squerylen + tquerylen;
                                                char *query = malloc(qlen);
-                                               snprintf(query, qlen, mquery, 
squery ? squery : "", tquery ? tquery : "");
+                                               snprintf(query, qlen, mquery, 
ordering, squery ? squery : "", tquery ? tquery : "");
                                                free(squery);
                                                free(tquery);
                                                hdl = mapi_query(mid, query);
diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -410,9 +410,16 @@ SQLhelp sqlhelp1[] = {
         NULL,
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-manipulation/prepare-statement/"},
        {"EXPLAIN",
-        "Give MAL execution plan for the SQL statement",
-        "EXPLAIN statement",
+        "Display logical or physical execution plan for the SQL statement.",
+        "EXPLAIN [BEFORE|AFTER] [step] [SHOW DETAILS] statement\n"
+        "step [REL_UNNEST|REL_REWRITE|PHYSICAL]",
         NULL,
+        "Plain EXPLAIN defaults to logical execution plan.\n"
+        "Use REL_UNNEST|REL_REWRITE|PHYSICAL to specify compilation step to 
show.\n"
+        "Use BEFORE|AFTER to specify moment of compilation step\n"
+        "to output. The default is AFTER.\n"
+        "SHOW DETAILS displays column properties, rewriter number of changes\n"
+        "and time spent.\n"
         "See also 
https://www.monetdb.org/documentation/admin-guide/debugging-features/explain-sql-stmt/"},
        {"EXTRACT",
         "Built-in function",
@@ -446,11 +453,6 @@ SQLhelp sqlhelp1[] = {
         "[ WITH cte_list ] MERGE INTO qname [ [AS] ident ] USING table_ref [ 
[AS] ident ] ON search_condition merge_list",
         "cte_list,table_ref,search_condition,merge_list",
         "See also: 
https://www.monetdb.org/documentation/user-guide/blog-archive/merge-statements/"},
-       {"PLAN",
-        "Give relational execution plan for the SQL statement",
-        "PLAN statement",
-        NULL,
-        "See also 
https://www.monetdb.org/documentation/admin-guide/debugging-features/plan-sql-stmt/"},
        {"PREPARE",
         "Prepare a SQL DML statement with optional question-mark parameter 
markers",
         "PREPARE statement",
@@ -551,7 +553,7 @@ SQLhelp sqlhelp1[] = {
         "joined_table,join_type",
         "See also 
https://www.monetdb.org/documentation/user-guide/sql-manual/data-manipulation/table-expressions/"},
        {"TRACE",
-        "Give execution trace for the SQL statement",
+        "Trace engine execution for the SQL statement. Output can be accessed 
via tracelog view.",
         "TRACE statement",
         NULL,
         "See also 
https://www.monetdb.org/documentation/admin-guide/debugging-features/trace-sql-stmt/"},
diff --git a/clients/odbc/tests/ODBCgetInfo.c b/clients/odbc/tests/ODBCgetInfo.c
--- a/clients/odbc/tests/ODBCgetInfo.c
+++ b/clients/odbc/tests/ODBCgetInfo.c
@@ -663,7 +663,7 @@ const struct {
                        "MATCHED,MAXVALUE,MEDIUMINT,MERGE,MINVALUE,"
                        "NAME,NATIVE,NEW,NOW,NULLS,"
                        "OBJECT,OFFSET,OLD,OPTIONS,ORDERED,OTHERS,OVER,"
-                       "PARTITION,PASSWORD,PATH,PLAN,PRECEDING,PREP,QUARTER,"
+                       "PARTITION,PASSWORD,PATH,PRECEDING,PREP,QUARTER,"
                        
"RANGE,RECORDS,REFERENCING,RELEASE,REMOTE,RENAME,REPEATABLE,"
                        
"REPLACE,REPLICA,RESTART,RETURN,RETURNS,ROLE,ROLLUP,ROW,"
                        "SAMPLE,SAVEPOINT,SEED,SEQUENCE,SERIAL,SERIALIZABLE,"
diff --git a/clients/odbc/tests/ODBCmetadata.c 
b/clients/odbc/tests/ODBCmetadata.c
--- a/clients/odbc/tests/ODBCmetadata.c
+++ b/clients/odbc/tests/ODBCmetadata.c
@@ -324,7 +324,7 @@ compareResultOptClose(SQLHANDLE stmt, SQ
 
 /*
  * Utility function to query the gdk_nr_threads value from the server.
- * The output of some queries (EXPLAIN, TRACE) differ when the server
+ * The output of some queries (EXPLAIN PHYSICAL, TRACE) differ when the server
  * is started with 1 thread, as is done in our testweb.
  */
 static int
@@ -1519,9 +1519,9 @@ main(int argc, char **argv)
                "ORDERID        LINES   PARTID  QUANTITY\n"
                "INTEGER        INTEGER INTEGER DECIMAL(9,3)\n");
 
-       // test PLAN SELECT query
-       ret = SQLExecDirect(stmt, (SQLCHAR *) "PLAN SELECT * from 
odbctst.\"LINES\";", SQL_NTS);
-       compareResult(stmt, ret, "PLAN SELECT * from odbctst.\"LINES\"",
+       // test EXPLAIN SHOW DETAILS SELECT query
+       ret = SQLExecDirect(stmt, (SQLCHAR *) "EXPLAIN SHOW DETAILS SELECT * 
from odbctst.\"LINES\";", SQL_NTS);
+       compareResult(stmt, ret, "EXPLAIN SHOW DETAILS SELECT * from 
odbctst.\"LINES\"",
                "Resultset with 1 columns\n"
                "Resultset with 3 rows\n"
                "rel\n"
@@ -1531,15 +1531,15 @@ main(int argc, char **argv)
                ") [ \"LINES\".\"ORDERID\" NOT NULL UNIQUE HASHCOL , 
\"LINES\".\"LINES\" NOT NULL UNIQUE, \"LINES\".\"PARTID\" NOT NULL UNIQUE, 
\"LINES\".\"QUANTITY\" NOT NULL UNIQUE ]\n");
 
        // test EXPLAIN SELECT query
-       ret = SQLExecDirect(stmt, (SQLCHAR *) "EXPLAIN SELECT * from 
odbctst.\"LINES\";", SQL_NTS);
-       compareResult(stmt, ret, "EXPLAIN SELECT * from odbctst.\"LINES\"",
+       ret = SQLExecDirect(stmt, (SQLCHAR *) "EXPLAIN PHYSICAL SELECT * from 
odbctst.\"LINES\";", SQL_NTS);
+       compareResult(stmt, ret, "EXPLAIN PHYSICAL SELECT * from 
odbctst.\"LINES\"",
            nrServerThreads > 1 ?
                "Resultset with 1 columns\n"
                "Resultset with 18 rows\n"
                "mal\n"
                "WLONGVARCHAR(190)\n"
                "function user.main():void;\n"
-               "    X_1:void := querylog.define(\"explain select * from 
odbctst.\\\"LINES\\\";\":str, \"default_pipe\":str, 27:int);\n"
+               "    X_1:void := querylog.define(\"explain physical select * 
from odbctst.\\\"LINES\\\";\":str, \"default_pipe\":str, 27:int);\n"
                "\n"
                "    X_33:bat[:int] := bat.new(nil:int);\n"
                "    X_34:bat[:int] := bat.new(nil:int);\n"
@@ -1561,7 +1561,7 @@ main(int argc, char **argv)
                "mal\n"
                "WLONGVARCHAR(190)\n"
                "function user.main():void;\n"
-               "    X_1:void := querylog.define(\"explain select * from 
odbctst.\\\"LINES\\\";\":str, \"default_pipe\":str, 27:int);\n"
+               "    X_1:void := querylog.define(\"explain physical select * 
from odbctst.\\\"LINES\\\";\":str, \"default_pipe\":str, 27:int);\n"
                "    X_33:bat[:int] := bat.new(nil:int);\n"
                "    X_34:bat[:int] := bat.new(nil:int);\n"
                "    X_35:bat[:int] := bat.new(nil:int);\n"
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -65,24 +65,26 @@
 
 #include <atomic>
 
-#if SIZEOF_LONG_LONG == 8
-#if ATOMIC_LLONG_LOCK_FREE != 2
-#if ATOMIC_LLONG_LOCK_FREE != 1
-#error "we need _Atomic(unsigned [long] long) to be lock free"
-#endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long ATOMIC_BASE_TYPE;
-#else
-typedef atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long long ATOMIC_BASE_TYPE;
-#endif
-#elif SIZEOF_LONG == 8
+#if SIZEOF_LONG == 8
 #if ATOMIC_LONG_LOCK_FREE != 2
 #error "we need _Atomic(unsigned long) to be lock free"
 #endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long ATOMIC_BASE_TYPE;
+#elif SIZEOF_LONG_LONG == 8
+#if ATOMIC_LLONG_LOCK_FREE != 2
+#if SIZEOF_SIZE_T == 4 && ATOMIC_LONG_LOCK_FREE == 2
+/* on 32 bit arch, fall back to 32 bit atomics if 64 bit is not lock free */
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(4)));
 typedef unsigned long ATOMIC_BASE_TYPE;
 #else
+#error "we need _Atomic(unsigned [long] long) to be lock free"
+#endif
+#else
+typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long long ATOMIC_BASE_TYPE;
+#endif
+#else
 #error "we need a 64 bit atomic type"
 #endif
 
@@ -90,23 +92,25 @@ typedef unsigned long ATOMIC_BASE_TYPE;
 
 #include <stdatomic.h>
 
-#if SIZEOF_LONG_LONG == 8
-#if ATOMIC_LLONG_LOCK_FREE != 2
-#if ATOMIC_LLONG_LOCK_FREE != 1
-#error "we need _Atomic(unsigned [long] long) to be lock free"
-#endif
-typedef atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long ATOMIC_BASE_TYPE;
-#else
-typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
-typedef unsigned long long ATOMIC_BASE_TYPE;
-#endif
-#elif SIZEOF_LONG == 8
+#if SIZEOF_LONG == 8
 #if ATOMIC_LONG_LOCK_FREE != 2
 #error "we need _Atomic(unsigned long) to be lock free"
 #endif
 typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(8)));
 typedef unsigned long ATOMIC_BASE_TYPE;
+#elif SIZEOF_LONG_LONG == 8
+#if ATOMIC_LLONG_LOCK_FREE != 2
+#if SIZEOF_SIZE_T == 4 && ATOMIC_LONG_LOCK_FREE == 2
+/* on 32 bit arch, fall back to 32 bit atomics */
+typedef volatile atomic_ulong ATOMIC_TYPE __attribute__((__aligned__(4)));
+typedef unsigned long ATOMIC_BASE_TYPE;
+#else
+#error "we need _Atomic(unsigned [long] long) to be lock free"
+#endif
+#else
+typedef volatile atomic_ullong ATOMIC_TYPE __attribute__((__aligned__(8)));
+typedef unsigned long long ATOMIC_BASE_TYPE;
+#endif
 #else
 #error "we need a 64 bit atomic type"
 #endif
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -946,12 +946,12 @@ BATsettrivprop(BAT *b)
                                        b->tmaxpos = 0;
                                }
                                b->tseqbase = sqbs;
-                       } else if ((b->tvheap
-                                   ? ATOMcmp(b->ttype,
-                                             b->tvheap->base + 
VarHeapVal(Tloc(b, 0), 0, b->twidth),
-                                             ATOMnilptr(b->ttype))
-                                   : ATOMcmp(b->ttype, Tloc(b, 0),
-                                             ATOMnilptr(b->ttype))) == 0) {
+                       } else if (b->tvheap
+                                  ? ATOMeq(b->ttype,
+                                           b->tvheap->base + 
VarHeapVal(Tloc(b, 0), 0, b->twidth),
+                                           ATOMnilptr(b->ttype))
+                                  : ATOMeq(b->ttype, Tloc(b, 0),
+                                           ATOMnilptr(b->ttype))) {
                                /* the only value is NIL */
                                b->tminpos = BUN_NONE;
                                b->tmaxpos = BUN_NONE;
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3076,7 +3076,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
        BAT *bn = NULL;
        int t;
        const void *nil;
-       int (*atomcmp)(const void *, const void *);
+       bool (*atomeq)(const void *, const void *);
        struct canditer ci;
        const char *err;
        lng t0 = 0;
@@ -3134,7 +3134,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
        } else {
                t = b->ttype;
                nil = ATOMnilptr(t);
-               atomcmp = ATOMcompare(t);
+               atomeq = ATOMequal(t);
                t = ATOMbasetype(t);
 
                bi = bat_iterator(b);
@@ -3172,7 +3172,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
                                                gid = gids[i] - min;
                                        else
                                                gid = (oid) i;
-                                       if ((*atomcmp)(BUNtail(bi, i), nil) != 
0) {
+                                       if (!(*atomeq)(BUNtail(bi, i), nil)) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to