Changeset: e00d391be073 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e00d391be073
Modified Files:
gdk/gdk.h
gdk/gdk_batop.c
gdk/gdk_hash.c
gdk/gdk_heap.c
gdk/gdk_private.h
gdk/gdk_utils.c
sql/test/BugTracker-2024/Tests/All
sql/test/information-schema/Tests/columns.test
testing/sqllogictest.py
Branch: default
Log Message:
Merge with Dec2023 branch.
diffs (truncated from 481 to 300 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -887,9 +887,6 @@ mskGetVal(BAT *b, BUN p)
* @item int
* @tab
* HEAPcopy (Heap *dst,*src);
- * @item int
- * @tab
- * HEAPwarm (Heap *h);
* @end multitable
*
*
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -665,7 +665,7 @@ append_msk_bat(BAT *b, BATiter *ni, stru
/* Append the contents of BAT n (subject to the optional candidate
* list s) to BAT b. If b is empty, b will get the seqbase of s if it
* was passed in, and else the seqbase of n. */
-gdk_return
+static gdk_return
BATappend2(BAT *b, BAT *n, BAT *s, bool force, bool mayshare)
{
struct canditer ci;
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -1381,32 +1381,3 @@ HASHfree(BAT *b)
MT_rwlock_wrunlock(&b->thashlock);
}
}
-
-bool
-HASHgonebad(BAT *b, const void *v)
-{
- Hash *h = b->thash;
- BUN cnt, hit;
-
- if (h == NULL)
- return true; /* no hash is bad hash? */
-
- BATiter bi = bat_iterator(b);
- if (h->nbucket * 2 < BATcount(b)) {
- int (*cmp) (const void *, const void *) = ATOMcompare(bi.type);
- BUN i = HASHget(h, (BUN) HASHprobe(h, v));
- for (cnt = hit = 1; i != BUN_NONE; i = HASHgetlink(h, i), cnt++)
- hit += ((*cmp) (v, BUNtail(bi, (BUN) i)) == 0);
-
- if (cnt / hit > 4) {
- bat_iterator_end(&bi);
- return true; /* linked list too long */
- }
-
- /* in this case, linked lists are long but contain the
- * desired values such hash tables may be useful for
- * locating all duplicates */
- }
- bat_iterator_end(&bi);
- return false; /* a-ok */
-}
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -439,57 +439,6 @@ HEAPextend(Heap *h, size_t size, bool ma
return GDK_FAIL;
}
-gdk_return
-HEAPshrink(Heap *h, size_t size)
-{
- char *p = NULL;
-
- assert(size >= h->free);
- assert(size <= h->size);
- if (h->storage == STORE_MEM) {
- p = GDKrealloc(h->base, size);
- TRC_DEBUG(HEAP, "Shrinking malloced heap %s %zu %zu %p %p\n",
- h->filename, h->size, size, h->base, p);
- } else {
- char *path;
-
- assert(h->hasfile);
- /* shrink memory mapped file */
- /* round up to multiple of GDK_mmap_pagesize with
- * minimum of one */
- size = (size + GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize -
1);
- if (size == 0)
- size = GDK_mmap_pagesize;
- if (size >= h->size) {
- /* don't grow */
- return GDK_SUCCEED;
- }
- if ((path = GDKfilepath(h->farmid, BATDIR, h->filename, NULL))
== NULL)
- return GDK_FAIL;
- p = GDKmremap(path,
- h->storage == STORE_PRIV ?
- MMAP_COPY | MMAP_READ | MMAP_WRITE :
- MMAP_READ | MMAP_WRITE,
- h->base, h->size, &size);
- GDKfree(path);
- TRC_DEBUG(HEAP, "Shrinking %s mmapped "
- "heap (%s) %zu %zu %p %p\n",
- h->storage == STORE_MMAP ? "shared" : "privately",
- h->filename, h->size, size, h->base, p);
- }
- if (p) {
- if (h->farmid == 1) {
- QryCtx *qc = MT_thread_get_qry_ctx();
- if (qc)
- ATOMIC_SUB(&qc->datasize, h->size - size);
- }
- h->size = size;
- h->base = p;
- return GDK_SUCCEED;
- }
- return GDK_FAIL;
-}
-
/* grow the string offset heap so that the value v fits (i.e. wide
* enough to fit the value), and it has space for at least cap elements;
* copy ncopy BUNs, or up to the heap size, whichever is smaller */
@@ -962,22 +911,6 @@ HEAPsave(Heap *h, const char *nme, const
return rc;
}
-int
-HEAPwarm(Heap *h)
-{
- int bogus_result = 0;
-
- if (h->storage != STORE_MEM) {
- /* touch the heap sequentially */
- int *cur = (int *) h->base;
- int *lim = (int *) (h->base + h->free) - 4096;
-
- for (; cur < lim; cur += 4096) /* try to schedule 4 parallel
memory accesses */
- bogus_result |= cur[0] | cur[1024] | cur[2048] |
cur[3072];
- }
- return bogus_result;
-}
-
/* Return the (virtual) size of the heap. */
size_t
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -58,8 +58,6 @@ const char *ATOMunknown_name(int a)
__attribute__((__visibility__("hidden")));
void ATOMunknown_clean(void)
__attribute__((__visibility__("hidden")));
-gdk_return BATappend2(BAT *b, BAT *n, BAT *s, bool force, bool mayshare)
- __attribute__((__visibility__("hidden")));
bool BATcheckhash(BAT *b)
__attribute__((__visibility__("hidden")));
bool BATcheckimprints(BAT *b)
@@ -154,9 +152,6 @@ FILE *GDKfileopen(int farmid, const char
__attribute__((__visibility__("hidden")));
char *GDKload(int farmid, const char *nme, const char *ext, size_t size,
size_t *maxsize, storage_t mode)
__attribute__((__visibility__("hidden")));
-void GDKlog(_In_z_ _Printf_format_string_ FILE * fl, const char *format, ...)
- __attribute__((__format__(__printf__, 2, 3)))
- __attribute__((__visibility__("hidden")));
gdk_return GDKmove(int farmid, const char *dir1, const char *nme1, const char
*ext1, const char *dir2, const char *nme2, const char *ext2, bool report)
__attribute__((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
@@ -189,8 +184,6 @@ void HASHappend_locked(BAT *b, BUN i, co
__attribute__((__visibility__("hidden")));
void HASHfree(BAT *b)
__attribute__((__visibility__("hidden")));
-bool HASHgonebad(BAT *b, const void *v)
- __attribute__((__visibility__("hidden")));
BUN HASHdelete(BATiter *bi, BUN p, const void *v)
__attribute__((__visibility__("hidden")));
void HASHdelete_locked(BATiter *bi, BUN p, const void *v)
@@ -227,11 +220,6 @@ void HEAP_recover(Heap *, const var_t *,
gdk_return HEAPsave(Heap *h, const char *nme, const char *ext, bool dosync,
BUN free, MT_Lock *lock)
__attribute__((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
-gdk_return HEAPshrink(Heap *h, size_t size)
- __attribute__((__warn_unused_result__))
- __attribute__((__visibility__("hidden")));
-int HEAPwarm(Heap *h)
- __attribute__((__visibility__("hidden")));
void IMPSdecref(Imprints *imprints, bool remove)
__attribute__((__visibility__("hidden")));
void IMPSfree(BAT *b)
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -339,7 +339,7 @@ GDKcopyenv(BAT **key, BAT **val, bool wr
* Single-lined comments can now be logged safely, together with
* process, thread and user ID, and the current time.
*/
-void
+static void __attribute__((__format__(__printf__, 2, 3)))
GDKlog(FILE *lockFile, const char *format, ...)
{
va_list ap;
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
@@ -51,3 +51,4 @@ rel_groupby_cse-Bug-7485
CMDgen_group-Bug-7486
sql_init_subtype-Bug-7487
orderby-max-over-rows-Bug-7488
+rel2bin_select-Bug-7496
diff --git a/sql/test/BugTracker-2024/Tests/rel2bin_select-Bug-7496.test
b/sql/test/BugTracker-2024/Tests/rel2bin_select-Bug-7496.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/rel2bin_select-Bug-7496.test
@@ -0,0 +1,38 @@
+statement ok
+create view columns_7496 as select
+ s."name" as table_schema,
+ t."name" as table_name,
+ c."name" as column_name,
+ cast(1 + c."number" as int) as ordinal_position,
+ c."default" as column_default,
+ cast(sys.ifthenelse(c."null", 'YES', 'NO') as varchar(3)) as is_nullable,
+ cast(sys."describe_type"(c."type", c."type_digits", c."type_scale") as
varchar(1024)) as data_type,
+ cast(sys.ifthenelse(seq."name" is null, 'NO', 'YES') as varchar(3)) as
is_identity,
+ seq."name" as identity_generation,
+ seq."start" as identity_start,
+ seq."increment" as identity_increment,
+ seq."maxvalue" as identity_maximum,
+ seq."minvalue" as identity_minimum,
+ cast(sys.ifthenelse(seq."cycle", 'YES', 'NO') as varchar(3)) as
identity_cycle,
+ cast(sys.ifthenelse(seq."name" is null, 'NO', 'YES') as varchar(3)) as
is_generated,
+ cast(sys.ifthenelse(seq."name" is null, null, c."default") as varchar(1024))
as generation_expression,
+ cm."remark" as comments
+ from sys."columns" c
+ inner join sys."tables" t on c."table_id" = t."id"
+ inner join sys."schemas" s on t."schema_id" = s."id"
+ left outer join sys."comments" cm on c."id" = cm."id"
+ left outer join sys."sequences" seq on ((seq."name"||'"') =
substring(c."default", 3 + sys."locate"('"."seq_',c."default",14)))
+ order by s."name", t."name", c."number"
+
+query TI nosort
+SELECT "is_generated", length("is_generated") as data_length FROM columns_7496
WHERE "identity_generation" IS NOT NULL AND length("is_generated") > 2
+----
+
+-- next query causes: sql/backends/monet5/rel_bin.c:4355: rel2bin_select:
Assertion `sql->session->status == -10' failed
+skipif knownfail
+query TI nosort
+SELECT "is_generated", length("is_generated") as data_length FROM columns_7496
WHERE "is_generated" IS NOT NULL AND length("is_generated") > 2
+----
+
+statement ok
+drop view columns_7496
diff --git a/sql/test/information-schema/Tests/columns.test
b/sql/test/information-schema/Tests/columns.test
--- a/sql/test/information-schema/Tests/columns.test
+++ b/sql/test/information-schema/Tests/columns.test
@@ -230,3 +230,175 @@ URL
2147483643
8589934572
+-- entity integrity checks
+query ITTTT rowsort
+SELECT COUNT(*) AS duplicates, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,
COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ GROUP BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
+ HAVING COUNT(*) > 1
+----
+
+-- as TABLE_CATALOG is always NULL the TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
combo should be unique also
+query ITTT rowsort
+SELECT COUNT(*) AS duplicates, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ GROUP BY TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
+ HAVING COUNT(*) > 1
+----
+
+-- it should also be unique when using schema_id instead of TABLE_SCHEMA
+query IITT rowsort
+SELECT COUNT(*) AS duplicates, schema_id, TABLE_NAME, COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ GROUP BY schema_id, TABLE_NAME, COLUMN_NAME
+ HAVING COUNT(*) > 1
+----
+
+-- it should also be unique when using table_id instead of TABLE_SCHEMA,
TABLE_NAME
+query IIT rowsort
+SELECT COUNT(*) AS duplicates, table_id, COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ GROUP BY table_id, COLUMN_NAME
+ HAVING COUNT(*) > 1
+----
+
+-- column_id alone should be unique also
+query II rowsort
+SELECT COUNT(*) AS duplicates, column_id
+ FROM INFORMATION_SCHEMA.COLUMNS
+ GROUP BY column_id
+ HAVING COUNT(*) > 1
+----
+
+-- referential integrity checks
+query TTTT rowsort
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]