Changeset: 1a08837e8931 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1a08837e8931 Branch: default Log Message:
Merge with Dec2023 branch. diffs (truncated from 975 to 300 lines): diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c --- a/clients/mapilib/connect.c +++ b/clients/mapilib/connect.c @@ -111,7 +111,9 @@ scan_sockets(Mapi mid) errmsg = allocated_errmsg; } if (errmsg) { - return mapi_setError(mid, errmsg, __func__, MERROR); + MapiMsg err = mapi_setError(mid, errmsg, __func__, MERROR); + free(allocated_errmsg); + return err; } return establish_connection(mid); } @@ -697,11 +699,13 @@ mapi_handshake(Mapi mid) ) { mapi_close_handle(hdl); close_connection(mid); - return mapi_printError( + MapiMsg err = mapi_printError( mid, __func__, MERROR, "%s: %s", error_message ? error_message : "invalid redirect", red); + free(error_message); + return err; } if (strncmp("mapi:merovingian", red, 16) == 0) { diff --git a/clients/mapilib/connect_openssl.c b/clients/mapilib/connect_openssl.c --- a/clients/mapilib/connect_openssl.c +++ b/clients/mapilib/connect_openssl.c @@ -342,21 +342,25 @@ wrap_tls(Mapi mid, SOCKET sock) BIO_free_all(bio); // drops first ref BIO_free_all(bio); // drops second ref free(hostcolonport); - return croak_openssl(mid, __func__, "openssl_rstream: %s", mnstr_peek_error(rstream)); + msg = croak_openssl(mid, __func__, "openssl_rstream: %s", mnstr_peek_error(rstream)); + close_stream(rstream); + return msg; } // On error: free 'bio' and close 'rstream'. stream *wstream = openssl_wstream(hostcolonport ? hostcolonport : "ssl wstream", bio); free(hostcolonport); if (wstream == NULL || mnstr_errnr(wstream) != MNSTR_NO__ERROR) { BIO_free_all(bio); - mnstr_close(rstream); - return croak_openssl(mid, __func__, "openssl_wstream: %s", mnstr_peek_error(wstream)); + close_stream(rstream); + msg = croak_openssl(mid, __func__, "openssl_wstream: %s", mnstr_peek_error(wstream)); + close_stream(wstream); + return msg; } // On error: free 'rstream' and 'wstream'. msg = mapi_wrap_streams(mid, rstream, wstream); if (msg != MOK) { - mnstr_close(rstream); - mnstr_close(wstream); + close_stream(rstream); + close_stream(wstream); return msg; } // 'rstream' and 'wstream' are part of 'mid' now. diff --git a/clients/mapilib/connect_unix.c b/clients/mapilib/connect_unix.c --- a/clients/mapilib/connect_unix.c +++ b/clients/mapilib/connect_unix.c @@ -70,6 +70,7 @@ scan_unix_sockets(Mapi mid) candidates[ncandidates].port = port; candidates[ncandidates++].priority = st.st_uid == me ? 0 : 1; } + closedir(dir); } mapi_log_record(mid, "CONN", "Found %d Unix domain sockets", ncandidates); @@ -180,5 +181,3 @@ connect_socket_unix(Mapi mid) return wrap_socket(mid, s); } - - diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1847,7 +1847,7 @@ set_uri(Mapi mid) const char *host = msetting_string(mid->settings, MP_HOST); const char *database = msetting_string(mid->settings, MP_DATABASE); int port = msetting_long(mid->settings, MP_PORT); - size_t urilen = strlen(host) + strlen(database) + 32; + size_t urilen = strlen(host) + (database ? strlen(database) : 0) + 32; char *uri = malloc(urilen); /* uri looks as follows: diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -572,7 +572,7 @@ validate_certhash(msettings *mp) if (i < sizeof(mp->certhash_digits_buffer) - 1) mp->certhash_digits_buffer[i++] = tolower(*r); } - mp->certhash_digits_buffer[i++] = '\0'; + mp->certhash_digits_buffer[i] = '\0'; if (i == 0) return "certhash: need at least one digit"; @@ -844,4 +844,3 @@ msettings_lang_is_sql(const msettings *m { return mp->lang_is_sql; } - diff --git a/documentation/source/manual_pages/monetdb.rst b/documentation/source/manual_pages/monetdb.rst --- a/documentation/source/manual_pages/monetdb.rst +++ b/documentation/source/manual_pages/monetdb.rst @@ -71,7 +71,7 @@ allows to do wildcard matches. For detai maintenance mode. This allows the database administrator to perform initialization steps before releasing it to users, unless the **-p** argument is supplied. See also **monetdb lock**. The name of the - database must match the expression [A-Za-z0-9_-]+. + database must match the expression [A-Za-z0-9\_-]+. **-m**\ *pattern* With the **-m** flag, instead of creating a database, a diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -523,7 +523,7 @@ BATimprints(BAT *b) imprints->imprints.parentid = b->batCacheid; #define SMP_SIZE 2048 - s1 = BATsample_with_seed(b, SMP_SIZE, (uint64_t) GDKusec() * (uint64_t) b->batCacheid); + s1 = BATsample(b, SMP_SIZE); if (s1 == NULL) { GDKfree(imprints); bat_iterator_end(&bi); diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -3559,11 +3559,9 @@ guess_uniques(BAT *b, struct canditer *c ALGOBATPAR(b)); return unique_est; } - s1 = BATcreatesample(b->hseqbase, batcount, 1000, - (uint64_t) GDKusec() * (uint64_t) b->batCacheid); + s1 = BATsample(b, 1000); } else { - BAT *s2 = BATcreatesample(ci->s->hseqbase, ci->ncand, 1000, - (uint64_t) GDKusec() * (uint64_t) b->batCacheid); + BAT *s2 = BATsample(ci->s, 1000); if (s2 == NULL) return -1; s1 = BATproject(s2, ci->s); diff --git a/gdk/gdk_logger_internals.h b/gdk/gdk_logger_internals.h --- a/gdk/gdk_logger_internals.h +++ b/gdk/gdk_logger_internals.h @@ -40,8 +40,6 @@ struct logger { int8_t type_id[128]; /* mapping from GDK type nr to logger type id */ // CHECK writer only - lng end; - ulng* writer_end; lng total_cnt; /* When logging the content of a bats in multiple runs, total_cnt is used the very first to signal this and keep track in the logging*/ void *rbuf; size_t rbufsize; diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -67,8 +67,6 @@ gdk_return BATcheckmodes(BAT *b, bool pe __attribute__((__visibility__("hidden"))); BAT *BATcreatedesc(oid hseq, int tt, bool heapnames, role_t role, uint16_t width) __attribute__((__visibility__("hidden"))); -BAT *BATcreatesample(oid hseq, BUN cnt, BUN n, uint64_t seed) - __attribute__((__visibility__("hidden"))); void BATdelete(BAT *b) __attribute__((__visibility__("hidden"))); void BATdestroy(BAT *b) diff --git a/gdk/gdk_sample.c b/gdk/gdk_sample.c --- a/gdk/gdk_sample.c +++ b/gdk/gdk_sample.c @@ -42,7 +42,7 @@ struct oidtreenode { }; }; -static int +static bool OIDTreeMaybeInsert(struct oidtreenode *tree, oid o, BUN allocated) { struct oidtreenode **nodep; @@ -50,12 +50,12 @@ OIDTreeMaybeInsert(struct oidtreenode *t if (allocated == 0) { tree->left = tree->right = NULL; tree->o = o; - return 1; + return true; } nodep = &tree; while (*nodep) { if (o == (*nodep)->o) - return 0; + return false; if (o < (*nodep)->o) nodep = &(*nodep)->left; else @@ -64,7 +64,7 @@ OIDTreeMaybeInsert(struct oidtreenode *t *nodep = &tree[allocated]; tree[allocated].left = tree[allocated].right = NULL; tree[allocated].o = o; - return 1; + return true; } /* inorder traversal, gives us a sorted BAT */ @@ -134,19 +134,14 @@ do_batsample(oid hseq, BUN cnt, BUN n, r return NULL; } + if (lock) + MT_lock_set(lock); /* generate a list of random numbers; note we use the * "tree" array, but we use the value from each location * before it is overwritten by the use as part of the * binary tree */ - if (lock) { - MT_lock_set(lock); - for (rescnt = 0; rescnt < n; rescnt++) - tree[rescnt].r = next(rse); - MT_lock_unset(lock); - } else { - for (rescnt = 0; rescnt < n; rescnt++) - tree[rescnt].r = next(rse); - } + for (rescnt = 0; rescnt < n; rescnt++) + tree[rescnt].r = next(rse); /* while we do not have enough sample OIDs yet */ BUN rnd = 0; @@ -156,12 +151,8 @@ do_batsample(oid hseq, BUN cnt, BUN n, r if (rnd == n) { /* we ran out of random numbers, * so generate more */ - if (lock) - MT_lock_set(lock); for (rnd = rescnt; rnd < n; rnd++) tree[rnd].r = next(rse); - if (lock) - MT_lock_unset(lock); rnd = rescnt; } candoid = minoid + tree[rnd++].r % cnt; @@ -169,6 +160,8 @@ do_batsample(oid hseq, BUN cnt, BUN n, r * generated, try again */ } while (!OIDTreeMaybeInsert(tree, candoid, rescnt)); } + if (lock) + MT_lock_unset(lock); if (!antiset) { OIDTreeToBAT(tree, bn); } else { @@ -185,26 +178,20 @@ do_batsample(oid hseq, BUN cnt, BUN n, r return bn; } +/* BATsample implements sampling for BATs */ BAT * -BATcreatesample(oid hseq, BUN cnt, BUN n, uint64_t seed) +BATsample_with_seed(BAT *b, BUN n, uint64_t seed) { random_state_engine rse; init_random_state_engine(rse, seed); - BAT *bn = do_batsample(hseq, cnt, n, rse, NULL); - TRC_DEBUG(ALGO, OIDFMT "," BUNFMT "," BUNFMT " -> " ALGOOPTBATFMT "\n", - hseq, cnt, n, ALGOOPTBATPAR(bn)); + BAT *bn = do_batsample(b->hseqbase, BATcount(b), n, rse, NULL); + TRC_DEBUG(ALGO, ALGOBATFMT "," BUNFMT " -> " ALGOOPTBATFMT "\n", + ALGOBATPAR(b), n, ALGOOPTBATPAR(bn)); return bn; } -/* BATsample implements sampling for BATs */ -BAT * -BATsample_with_seed(BAT *b, BUN n, uint64_t seed) -{ - return BATcreatesample(b->hseqbase, b->batCount, n, seed); -} - static MT_Lock rse_lock = MT_LOCK_INITIALIZER(rse_lock); BAT * BATsample(BAT *b, BUN n) diff --git a/gdk/xoshiro256starstar.h b/gdk/xoshiro256starstar.h --- a/gdk/xoshiro256starstar.h +++ b/gdk/xoshiro256starstar.h @@ -17,12 +17,14 @@ worldwide. This software is distributed See <http://creativecommons.org/publicdomain/zero/1.0/>. */ -static inline uint64_t rotl(const uint64_t x, int k) { +typedef uint64_t random_state_engine[4]; + +static inline uint64_t +rotl(const uint64_t x, int k) _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org