Changeset: 6188bd31e9f8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6188bd31e9f8
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/vaults/odbc/odbc_loader.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_select.c
        sql/server/rel_unnest.c
        sql/server/sql_parser.y
Branch: nested
Log Message:

merged with default


diffs (truncated from 1244 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3770,12 +3770,13 @@ main(int argc, char **argv)
        mapi_setfilecallback2(mid, getfile, putfile, &priv);
 
        mapi_trace(mid, trace);
+       if (!has_fileargs && command == NULL && isatty(fileno(stdin)))
+               catch_interrupts(mid);
+
        /* give the user a welcome message with some general info */
        if (!quiet && !has_fileargs && command == NULL && 
isatty(fileno(stdin))) {
                char *lang;
 
-               catch_interrupts(mid);
-
                if (mode == SQL) {
                        lang = "/SQL";
                } else {
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -834,7 +834,8 @@ COLcopy(BAT *b, int tt, bool writable, r
                bn->tnil = bi.nil;
                bn->tminpos = bi.minpos;
                bn->tmaxpos = bi.maxpos;
-               bn->tunique_est = bi.unique_est;
+               if (!bi.key)
+                       bn->tunique_est = bi.unique_est;
        } else if (ATOMstorage(tt) == ATOMstorage(b->ttype) &&
                   ATOMcompare(tt) == ATOMcompare(b->ttype)) {
                BUN h = bi.count;
@@ -861,7 +862,8 @@ COLcopy(BAT *b, int tt, bool writable, r
                }
                bn->tminpos = bi.minpos;
                bn->tmaxpos = bi.maxpos;
-               bn->tunique_est = bi.unique_est;
+               if (!bi.key)
+                       bn->tunique_est = bi.unique_est;
        } else {
                bn->tsorted = bn->trevsorted = false; /* set based on count 
later */
                bn->tnonil = bn->tnil = false;
@@ -873,6 +875,7 @@ COLcopy(BAT *b, int tt, bool writable, r
                bn->tsorted = ATOMlinear(b->ttype);
                bn->trevsorted = ATOMlinear(b->ttype);
                bn->tkey = true;
+               bn->tunique_est = (double) bn->batCount;
        }
        bat_iterator_end(&bi);
        if (!writable)
@@ -1665,8 +1668,12 @@ BUNinplacemulti(BAT *b, const oid *posit
        BUN nunique = b->thash ? b->thash->nunique : 0;
        MT_rwlock_wrunlock(&b->thashlock);
        MT_lock_set(&b->theaplock);
-       if (nunique != 0)
+       if (nunique != 0) {
                b->tunique_est = (double) nunique;
+               if (nunique == b->batCount && !b->tkey)
+                       BATkey(b, true);
+       } else if (b->tkey)
+               b->tunique_est = (double) b->batCount;
        b->tminpos = bi.minpos;
        b->tmaxpos = bi.maxpos;
        b->theap->dirty = true;
@@ -1954,8 +1961,10 @@ BATkey(BAT *b, bool flag)
        b->tkey = flag;
        if (!flag) {
                b->tseqbase = oid_nil;
-       } else
+       } else {
                b->tnokey[0] = b->tnokey[1] = 0;
+               b->tunique_est = (double) b->batCount;
+       }
        gdk_return rc = GDK_SUCCEED;
        if (flag && VIEWtparent(b)) {
                /* if a view is key, then so is the parent if the two
@@ -2021,6 +2030,7 @@ BATtseqbase(BAT *b, oid o)
                                b->trevsorted = b->batCount <= 1;
                                if (!b->trevsorted)
                                        b->tnorevsorted = 1;
+                               b->tunique_est = (double) b->batCount;
                        }
                }
        } else {
diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c
--- a/gdk/gdk_cand.c
+++ b/gdk/gdk_cand.c
@@ -1469,6 +1469,7 @@ BATmaskedcands(oid hseq, BUN nr, BAT *ma
                GDKfree(msks);
        }
        BATsetcount(bn, cnt);
+       bn->tunique_est = (double) cnt;
        TRC_DEBUG(ALGO, "hseq=" OIDFMT ", masked=" ALGOBATFMT ", selected=%s"
                  " -> " ALGOBATFMT "\n",
                  hseq, ALGOBATPAR(masked),
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3259,8 +3259,6 @@ hashjoin(BAT **r1p, BAT **r2p, BAT **r3p
                locked = false;
                MT_rwlock_rdunlock(&r->thashlock);
        }
-       bat_iterator_end(&li);
-       bat_iterator_end(&ri);
 
        if (hash_cand) {
                HEAPfree(&hsh->heaplink, true);
@@ -3269,7 +3267,7 @@ hashjoin(BAT **r1p, BAT **r2p, BAT **r3p
        }
        /* also set other bits of heap to correct value to indicate size */
        BATsetcount(r1, BATcount(r1));
-       r1->tunique_est = MIN(l->tunique_est, r->tunique_est);
+       r1->tunique_est = MIN(li.unique_est, ri.unique_est);
        if (BATcount(r1) <= 1) {
                r1->tsorted = true;
                r1->trevsorted = true;
@@ -3285,14 +3283,16 @@ hashjoin(BAT **r1p, BAT **r2p, BAT **r3p
                        r2->tkey = true;
                        r2->tseqbase = 0;
                }
-               r2->tunique_est = MIN(l->tunique_est, r->tunique_est);
+               r2->tunique_est = MIN(li.unique_est, ri.unique_est);
        }
        if (r3) {
                r3->tnonil = !r3->tnil;
                BATsetcount(r3, BATcount(r3));
                assert(BATcount(r1) == BATcount(r3));
-               r3->tunique_est = MIN(l->tunique_est, r->tunique_est);
+               r3->tunique_est = MIN(li.unique_est, ri.unique_est);
        }
+       bat_iterator_end(&li);
+       bat_iterator_end(&ri);
        if (BATcount(r1) > 0) {
                if (BATtdense(r1))
                        r1->tseqbase = ((oid *) r1->theap->base)[0];
diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -572,8 +572,8 @@ project_str(BATiter *restrict li, struct
        bn->tnonil = r1i->nonil & r2i->nonil;
        bn->tkey = false;
        bn->tunique_est =
-               MIN(li->b->tunique_est?li->b->tunique_est:BATcount(li->b),
-                  r1i->b->tunique_est?r1i->b->tunique_est:BATcount(r1i->b));
+               MIN(li->unique_est ? li->unique_est : BATcount(li->b),
+                   r1i->unique_est ? r1i->unique_est : BATcount(r1i->b));
        TRC_DEBUG(ALGO, "l=" ALGOBATFMT " r1=" ALGOBATFMT " r2=" ALGOBATFMT
                  " -> " ALGOBATFMT "%s " LLFMT "us\n",
                  ALGOBATPAR(li->b), ALGOBATPAR(r1i->b), ALGOBATPAR(r2i->b),
@@ -824,8 +824,8 @@ BATproject2(BAT *restrict l, BAT *restri
        }
 
        bn->tunique_est =
-               MIN(li.b->tunique_est?li.b->tunique_est:BATcount(li.b),
-                  r1i.b->tunique_est?r1i.b->tunique_est:BATcount(r1i.b));
+               MIN(li.unique_est ? li.unique_est : BATcount(li.b),
+                   r1i.unique_est ? r1i.unique_est : BATcount(r1i.b));
        if (!BATtdensebi(&r1i) || (r2 && !BATtdensebi(&r2i)))
                BATtseqbase(bn, oid_nil);
 
diff --git a/misc/selinux/monetdb.te b/misc/selinux/monetdb.te
--- a/misc/selinux/monetdb.te
+++ b/misc/selinux/monetdb.te
@@ -8,7 +8,7 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-policy_module(monetdb, 1.4)
+policy_module(monetdb, 1.5)
 # The above line declares that this file is a SELinux policy file. Its
 # name is monetdb, so the file should be saved as monetdb.te
 
@@ -28,7 +28,7 @@ require {
        class fifo_file { getattr read write };
        class file { entrypoint execute getattr manage_file_perms map open read 
};
        class netlink_selinux_socket create_socket_perms;
-       class process { rlimitinh siginh signal sigchld sigkill transition };
+       class process { rlimitinh siginh signal sigchld sigkill signull 
transition };
        class tcp_socket create_stream_socket_perms;
        class udp_socket create_stream_socket_perms;
        class unix_dgram_socket create_socket_perms;
@@ -58,7 +58,7 @@ type_transition monetdbd_t mserver5_exec
 allow monetdbd_t mserver5_t:process sigkill;
 # on EPEL 7 we need these as well
 allow mserver5_t monetdbd_t:process sigchld;
-allow monetdbd_t unconfined_service_t:process signal;
+allow monetdbd_t unconfined_service_t:process { signal signull };
 allow mserver5_t proc_t:file { open read getattr };      # read /proc/meminfo
 
 # declare a type for the systemd unit file (monetdbd.service)
diff --git a/sql/backends/monet5/UDF/udf/udf.c 
b/sql/backends/monet5/UDF/udf/udf.c
--- a/sql/backends/monet5/UDF/udf/udf.c
+++ b/sql/backends/monet5/UDF/udf/udf.c
@@ -366,7 +366,7 @@ UDFBATfuse_(BAT **ret, BAT *bone, BAT *b
                        bres->trevsorted = true;
                else
                        bres->trevsorted = (BATcount(bres) <= 1);
-               /* result tail is key (unique), iff both input tails are */
+               /* result tail is key (unique), if both input tails are */
                BATkey(bres, BATtkey(bone) || BATtkey(btwo));
 
                *ret = bres;
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2067,6 +2067,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                if (attr && attr->h) {
                        node *en;
                        list *l = sa_list(sql->sa);
+                       stmt *next = NULL;
 
                        for (en = attr->h; en; en = en->next) {
                                sql_exp *at = en->data;
@@ -2088,7 +2089,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                        if (need_distinct(e) && (grp || list_length(l) > 1)){
                                list *nl = sa_list(sql->sa);
                                stmt *ngrp = grp;
-                               stmt *next = ext;
+                               next = ext;
                                stmt *ncnt = cnt;
                                if (nl == NULL)
                                        return NULL;
@@ -2131,6 +2132,10 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                        for (node *n = obe->h; n; n = n->next) {
                                                sql_exp *oe = n->data;
                                                stmt *os = exp_bin(be, oe, 
left, right, NULL, NULL, NULL, sel, depth+1, 0, push);
+                                               if (!os)
+                                                       return NULL;
+                                               if (next)
+                                                       os = stmt_project(be, 
next, os);
                                                if (orderby)
                                                        orderby = 
stmt_reorder(be, os, is_ascending(oe), nulls_last(oe), orderby_ids, 
orderby_grp);
                                                else
@@ -2140,8 +2145,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                                orderby_grp = stmt_result(be, 
orderby, 2);
                                        }
                                        /* depending on type of aggr project 
input or ordered column */
-                                       stmt *h = l->h->data;
-                                       l->h->data = h = stmt_project(be, 
orderby_ids, h);
+                                       for (node *n = l->h; n; n = n->next)
+                                               n->data = stmt_project(be, 
orderby_ids, n->data);
                                        if (grp)
                                                grp = stmt_project(be, 
orderby_ids, grp);
                                        (void)orderby_vals;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2633,7 +2633,6 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt
                nr_parts = *getArgReference_int(stk, pci, 5);
        }
        BAT *b = store->storage_api.bind_cands(tr, t, nr_parts, part_nr);
-       b->tunique_est = (double)BATcount(b);
        if (b) {
                *res = b->batCacheid;
                BBPkeepref(b);
diff --git a/sql/backends/monet5/vaults/odbc/odbc_loader.c 
b/sql/backends/monet5/vaults/odbc/odbc_loader.c
--- a/sql/backends/monet5/vaults/odbc/odbc_loader.c
+++ b/sql/backends/monet5/vaults/odbc/odbc_loader.c
@@ -37,9 +37,13 @@
 #define ODBC_RELATION 1
 #define ODBC_LOADER   2
 
+/* some generic limitations on ODBC query result and buffer sizes for getting 
variable length data values */
 #define QUERY_MAX_COLUMNS 4096
 #define MAX_COL_NAME_LEN  1023
 #define MAX_TBL_NAME_LEN  1023
+/* limit data size for one field value to 16 MB */
+#define MAX_CHAR_STR_SIZE 16777215
+#define MAX_BIN_DATA_SIZE 16777216
 
 #ifdef HAVE_HGE
 #define MAX_PREC  38
@@ -76,37 +80,37 @@ map_rescol_type(SQLSMALLINT dataType, SQ
        case SQL_WVARCHAR:
        case SQL_WLONGVARCHAR:
        default:        /* all other ODBC types are also mapped to varchar for 
now */
+       {
                /* all ODBC char datatypes are mapped to varchar. char and clob 
are internally not used anymore */
                if (columnSize > (SQLULEN) INT_MAX)
                        columnSize = INT_MAX;
                return sql_bind_subtype(sql->sa, "varchar", (unsigned int) 
columnSize, 0);
+       }
 
        case SQL_BINARY:
        case SQL_VARBINARY:
        case SQL_LONGVARBINARY:
+       {
                if (columnSize > (SQLULEN) INT_MAX)
                        columnSize = INT_MAX;
                return sql_bind_subtype(sql->sa, "blob", (unsigned int) 
columnSize, 0);
+       }
 
        case SQL_DECIMAL:
        case SQL_NUMERIC:
        {
                /* columnSize contains the defined number of digits, so 
precision. */
                /* decimalDigits contains the scale (which can be negative). */
-               if (columnSize > MAX_PREC || abs(decimalDigits) > MAX_PREC) {
-                       /* too large precision/scale, not supported by MonetDB. 
Map this column to a string */
-                       if (columnSize > (SQLULEN) INT_MAX)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to