MonetDB: default - Removed columns for status and filename from ...

2023-12-22 Thread Sjoerd Mullender via checkin-list
Changeset: 5f814882394e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5f814882394e
Modified Files:
gdk/gdk.h
gdk/gdk_bbp.c
Branch: default
Log Message:

Removed columns for status and filename from BBP.dir.
The status column was ignored already when reading, and the filename can
simply be calculated.


diffs (235 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -756,7 +756,8 @@ typedef struct {
 #define GDKLIBRARY_HASHASH 061044U /* first in Jul2021: hashash bit in 
string heaps */
 #define GDKLIBRARY_HSIZE   061045U /* first in Jan2022: heap "size" values 
*/
 #define GDKLIBRARY_JSON061046U /* first in Sep2022: json storage 
changes*/
-#define GDKLIBRARY 061047U /* first in Dec2023 */
+#define GDKLIBRARY_STATUS  061047U /* first in Dec2023: no status/filename 
columns */
+#define GDKLIBRARY 061050U /* first after Dec2023 */
 
 /* The batRestricted field indicates whether a BAT is readonly.
  * we have modes: BAT_WRITE  = all permitted
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -370,6 +370,42 @@ recover_dir(int farmid, bool direxists)
return GDKmove(farmid, BAKDIR, "BBP", "dir", BATDIR, "BBP", "dir", 
true);
 }
 
+static inline str
+BBPsubdir_recursive(char *s, bat i)
+{
+   i >>= 6;
+   if (i >= 0100) {
+   s = BBPsubdir_recursive(s, i);
+   *s++ = DIR_SEP;
+   }
+   i &= 077;
+   *s++ = '0' + (i >> 3);
+   *s++ = '0' + (i & 7);
+   return s;
+}
+
+static inline void
+BBPgetsubdir(char *s, bat i)
+{
+   if (i >= 0100) {
+   s = BBPsubdir_recursive(s, i);
+   }
+   *s = 0;
+}
+
+static inline void
+BBPgetfilename(char *s, size_t len, bat i)
+{
+   if (i >= 0100) {
+   char *p = BBPsubdir_recursive(s, i);
+   *p++ = DIR_SEP;
+   len -= (p - s);
+   s = p;
+   }
+   if (snprintf(s, len, "%o", i) >= (int) len)
+   TRC_CRITICAL(BAT_, "impossible error\n");
+}
+
 static gdk_return BBPrecover(int farmid);
 static gdk_return BBPrecover_subdir(void);
 static bool BBPdiskscan(const char *, size_t);
@@ -585,11 +621,10 @@ BBPreadBBPline(FILE *fp, unsigned bbpver
 {
char buf[4096];
uint64_t batid;
-   unsigned int status;
unsigned int properties;
int nread, n;
char *s;
-   uint64_t count, capacity = 0, base = 0;
+   uint64_t count, base = 0;
 
if (fgets(buf, sizeof(buf), fp) == NULL) {
if (ferror(fp)) {
@@ -613,19 +648,24 @@ BBPreadBBPline(FILE *fp, unsigned bbpver
 
if (bbpversion <= GDKLIBRARY_HSIZE ?
sscanf(buf,
-  "%" SCNu64 " %u %128s %23s %u %" SCNu64
-  " %" SCNu64 " %" SCNu64
+  "%" SCNu64 " %*u %128s %*s %u %" SCNu64 " %*u %" SCNu64
   "%n",
-  &batid, &status, batname, filename,
-  &properties, &count, &capacity, &base,
-  &nread) < 8 :
+  &batid, batname,
+  &properties, &count, &base,
+  &nread) < 5 :
+   bbpversion <= GDKLIBRARY_STATUS ?
sscanf(buf,
-  "%" SCNu64 " %u %128s %23s %u %" SCNu64
-  " %" SCNu64
+  "%" SCNu64 " %*u %128s %*s %u %" SCNu64 " %" SCNu64
   "%n",
-  &batid, &status, batname, filename,
+  &batid, batname,
   &properties, &count, &base,
-  &nread) < 7) {
+  &nread) < 5 :
+   sscanf(buf,
+  "%" SCNu64 " %128s %u %" SCNu64 " %" SCNu64
+  "%n",
+  &batid, batname,
+  &properties, &count, &base,
+  &nread) < 5) {
TRC_CRITICAL(GDK, "invalid format for BBP.dir on line %d", 
*lineno);
return -1;
}
@@ -635,17 +675,7 @@ BBPreadBBPline(FILE *fp, unsigned bbpver
return -1;
}
 
-   /* convert both / and \ path separators to our own DIR_SEP */
-#if DIR_SEP != '/'
-   s = filename;
-   while ((s = strchr(s, '/')) != NULL)
-   *s++ = DIR_SEP;
-#endif
-#if DIR_SEP != '\\'
-   s = filename;
-   while ((s = strchr(s, '\\')) != NULL)
-   *s++ = DIR_SEP;
-#endif
+   BBPgetfilename(filename, sizeof(BBP_physical(0)), (bat) batid);
 
bn->batCacheid = (bat) batid;
bn->batTransient = false;
@@ -864,7 +894,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver
BBP_lrefs(b.batCacheid) = 1;/* any BAT we encounter here is 
persistent, so has a logical reference */
BBP_desc(b.batCacheid) = bn;
BBP_pid(b.batCacheid) = 0;
-   BBP_status_set(b.batCacheid, BBPEXISTING);  /* do we need 
other status bits? */
+   BBP_status_set(b.bat

MonetDB: Dec2023 - Use batRole instead of BBP_status to decide w...

2023-12-22 Thread Sjoerd Mullender via checkin-list
Changeset: e37de2be0fae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e37de2be0fae
Modified Files:
gdk/gdk_join.c
gdk/gdk_select.c
Branch: Dec2023
Log Message:

Use batRole instead of BBP_status to decide whether to create a hash.


diffs (24 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3669,7 +3669,7 @@ joincost(BAT *r, BUN lcount, struct cand
/* only count the cost of creating the hash for
 * non-persistent bats */
MT_lock_set(&r->theaplock);
-   if (!(BBP_status(r->batCacheid) & BBPEXISTING) /* || 
r->theap->dirty */ || GDKinmemory(r->theap->farmid))
+   if (r->batRole != PERSISTENT /* || r->theap->dirty */ 
|| GDKinmemory(r->theap->farmid))
rcost += cnt * 2.0;
MT_lock_unset(&r->theaplock);
 #else
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1758,7 +1758,7 @@ BATselect(BAT *b, BAT *s, const void *tl
}
}
}
-   if (wanthash && !havehash) {
+   if (wanthash && !havehash && b->batRole != PERSISTENT) {
MT_lock_set(&b->theaplock);
if (++b->selcnt > 1000)
b->selcnt = 1000; /* limit value */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Dec2023 branch.

2023-12-22 Thread Sjoerd Mullender via checkin-list
Changeset: d20c215100f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d20c215100f4
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (267 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3669,7 +3669,7 @@ joincost(BAT *r, BUN lcount, struct cand
/* only count the cost of creating the hash for
 * non-persistent bats */
MT_lock_set(&r->theaplock);
-   if (!(BBP_status(r->batCacheid) & BBPEXISTING) /* || 
r->theap->dirty */ || GDKinmemory(r->theap->farmid))
+   if (r->batRole != PERSISTENT /* || r->theap->dirty */ 
|| GDKinmemory(r->theap->farmid))
rcost += cnt * 2.0;
MT_lock_unset(&r->theaplock);
 #else
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1758,7 +1758,7 @@ BATselect(BAT *b, BAT *s, const void *tl
}
}
}
-   if (wanthash && !havehash) {
+   if (wanthash && !havehash && b->batRole != PERSISTENT) {
MT_lock_set(&b->theaplock);
if (++b->selcnt > 1000)
b->selcnt = 1000; /* limit value */
diff --git a/geom/ChangeLog-Archive b/geom/ChangeLog-Archive
--- a/geom/ChangeLog-Archive
+++ b/geom/ChangeLog-Archive
@@ -15,7 +15,7 @@
   used in the implementation of the filter functions ST_Intersects and
   ST_Dwithin for geometric points.
 - Improves shapefile support by replacing functions SHPattach,
-  SHPpartialimport, ahd SHPimport with SHPload.
+  SHPpartialimport, and SHPimport with SHPload.
 - Introduces functions ST_DistanceGeographic, ST_DwithinGeographic,
   ST_IntersectsGeographic, ST_CoversGeographic, ST_Collects with geodesic
   semantics. ST_Transform can be used to convert geodetic into geographic
diff --git a/sql/ChangeLog-Archive b/sql/ChangeLog-Archive
--- a/sql/ChangeLog-Archive
+++ b/sql/ChangeLog-Archive
@@ -3,9 +3,9 @@
 
 * Tue Dec  5 2023 Lucas Pereira  - 
11.49.1-20231221
 - Introduction of table returning function `persist_unlogged(schema
-  string, table string)` that attempts to persist data in disk if
-  "schema"."table" is unlogged table in insert only mode.  If persist
-  attempt is successful, the count of the persisted rows is returned,
+  string, table string)` that attempts to persist data to disk if the
+  "schema"."table" is an unlogged table and set to insert only mode.  If
+  persist attempt is successful, the count of persisted rows is returned,
   otherwise the count is 0.
 
 * Thu Aug 24 2023 Martin van Dinther  
- 11.49.1-20231221
diff --git a/sql/test/BugTracker-2023/Tests/All 
b/sql/test/BugTracker-2023/Tests/All
--- a/sql/test/BugTracker-2023/Tests/All
+++ b/sql/test/BugTracker-2023/Tests/All
@@ -1,3 +1,5 @@
+ifnull-6933
+HAVE_GEOM?empty-result-aggr-crash-7274
 ambiguous-identifiers-7372
 temp-table-foreign-key-crash-7378
 update-mask-id-crash-7379
@@ -10,6 +12,7 @@ rollback-alter-drop-col-crash-7385
 view-on-alias-crash-7386
 alter-inc-seq-crash-7387
 misc-crashes-7390
+greatest-least-multi-arg-7391
 union-query-7401
 join-on-row_number-over-7403
 between-crash-7413
diff --git a/sql/test/BugTracker-2023/Tests/between-crash-7413.test 
b/sql/test/BugTracker-2023/Tests/between-crash-7413.test
--- a/sql/test/BugTracker-2023/Tests/between-crash-7413.test
+++ b/sql/test/BugTracker-2023/Tests/between-crash-7413.test
@@ -7,3 +7,6 @@ INSERT INTO v0 (v1) VALUES (NULL) , (3) 
 statement ok
 DELETE FROM v0 WHERE v1 <= (SELECT 2 AS zero WHERE (v1 BETWEEN 1 AND (SELECT 
MAX (v1) FROM v0 name)) >= v1)
 
+statement ok
+DROP TABLE v0
+
diff --git a/sql/test/BugTracker-2023/Tests/empty-result-aggr-crash-7274.test 
b/sql/test/BugTracker-2023/Tests/empty-result-aggr-crash-7274.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2023/Tests/empty-result-aggr-crash-7274.test
@@ -0,0 +1,16 @@
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE TABLE t7274 ( "id" INTEGER, "g"  GEOMETRY )
+
+query IT
+select id, st_collect(g) as g from t7274  where false  group by id
+
+
+statement ok
+create table t7274b as  select id, st_collect(g) as g from t7274  where false  
group by id
+
+statement ok
+ROLLBACK
+
diff --git a/sql/test/BugTracker-2023/Tests/greatest-least-multi-arg-7391.test 
b/sql/test/BugTracker-2023/Tests/greatest-least-multi-arg-7391.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2023/Tests/greatest-least-multi-arg-7391.test
@@ -0,0 +1,56 @@
+query I
+SELECT greatest(3, 4, 2, 1)
+
+4
+
+query I
+SELECT least(3, 4, 2, 1)
+
+1
+
+query I
+SELECT greatest(3, 4, '0', '5')
+
+5
+
+query I
+SELECT least(3, 4, 1, 2, '0', '5')
+
+0
+
+query R
+SELECT greatest(3.321, 4.4321, '0.210', '5.54321', -6.54321)
+
+