Changeset: 1945f05676ae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1945f05676ae
Branch: default
Log Message:
Merged with Jul2021
diffs (294 lines):
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -860,10 +860,17 @@ BATsave_locked(BAT *bd)
bd->tvheap->wasempty = vhs.wasempty;
bd->batCopiedtodisk = true;
DESCclean(bd);
- MT_rwlock_rdlock(&bd->thashlock);
- if (bd->thash && bd->thash != (Hash *) 1)
- BAThashsave(bd, dosync);
- MT_rwlock_rdunlock(&bd->thashlock);
+ if (MT_rwlock_rdtry(&bd->thashlock)) {
+ /* if we can't get the lock, don't bother saving
+ * the hash (normally, the hash lock should not
+ * be acquired when the heap lock has already
+ * been acquired, and here we have the heap
+ * lock, so we must be careful with the hash
+ * lock) */
+ if (bd->thash && bd->thash != (Hash *) 1)
+ BAThashsave(bd, dosync);
+ MT_rwlock_rdunlock(&bd->thashlock);
+ }
}
return err;
}
diff --git a/misc/python/create_include_object.py.in
b/misc/python/create_include_object.py.in
--- a/misc/python/create_include_object.py.in
+++ b/misc/python/create_include_object.py.in
@@ -81,15 +81,13 @@ def mal2c(content):
def sql2c(content):
comment_or_empty = re.compile('^[ \t]*(--|#|$)')
comment = re.compile(r'/\*.*?\*/|--.*')
- space = re.compile('[ \t]+')
c_array = []
length = 0
for line in content.split('\n'):
if comment_or_empty.match(line):
continue
line = comment.sub('', line)
- line = space.sub(' ', line)
- line = line.strip()
+ line = line.rstrip()
if line.startswith('include '):
continue
if not line:
@@ -112,7 +110,6 @@ def create_c_sourcefile(srcfile, lang, m
def copy2c(content):
return ",".join(str(ord(c)) for c in content) + ","
-
def txt2c(content, sql):
buffer = bytearray()
@@ -183,7 +180,6 @@ def txt2c(content, sql):
#return buffer
return buffer_as_string
-
def main():
parser = argparse.ArgumentParser()
parser.add_argument("name", help="The name of the module to convert")
diff --git a/sql/scripts/23_skyserver.sql b/sql/scripts/23_skyserver.sql
--- a/sql/scripts/23_skyserver.sql
+++ b/sql/scripts/23_skyserver.sql
@@ -10,15 +10,15 @@ BEGIN
DECLARE res varchar(32), aux varchar(32);
DECLARE ofset int;
- IF ( st < 0 or st > LENGTH(s1))
- THEN RETURN '';
- END IF;
+ IF ( st < 0 or st > LENGTH(s1))
+ THEN RETURN '';
+ END IF;
- SET ofset = 1;
- SET res = SUBSTRING(s1,ofset,st-1);
- SET res = res || s3;
- SET ofset = st + len;
- SET aux = SUBSTRING(s1,ofset,LENGTH(s1)-ofset+1);
+ SET ofset = 1;
+ SET res = SUBSTRING(s1,ofset,st-1);
+ SET res = res || s3;
+ SET ofset = st + len;
+ SET aux = SUBSTRING(s1,ofset,LENGTH(s1)-ofset+1);
SET res = res || aux;
RETURN res;
END;
@@ -45,7 +45,7 @@ grant execute on function MS_ROUND to pu
CREATE FUNCTION MS_STR(num float, prc int, truncat int)
RETURNS string
BEGIN
- RETURN CAST(num as string);
+ RETURN CAST(num as string);
END;
grant execute on function MS_STR to public;
diff --git a/sql/scripts/52_describe.sql b/sql/scripts/52_describe.sql
--- a/sql/scripts/52_describe.sql
+++ b/sql/scripts/52_describe.sql
@@ -537,11 +537,11 @@ END;
CREATE FUNCTION sys.describe_function(schemaName string, functionName string)
RETURNS TABLE(id integer, name string, type string, language string,
remark string)
BEGIN
- RETURN SELECT f.id, f.name, ft.function_type_keyword, fl.language_keyword,
c.remark
- FROM sys.functions f
- JOIN sys.schemas s ON f.schema_id = s.id
- JOIN sys.function_types ft ON f.type = ft.function_type_id
- LEFT OUTER JOIN sys.function_languages fl ON f.language =
fl.language_id
- LEFT OUTER JOIN sys.comments c ON f.id = c.id
- WHERE f.name=functionName AND s.name = schemaName;
+ RETURN SELECT f.id, f.name, ft.function_type_keyword,
fl.language_keyword, c.remark
+ FROM sys.functions f
+ JOIN sys.schemas s ON f.schema_id = s.id
+ JOIN sys.function_types ft ON f.type = ft.function_type_id
+ LEFT OUTER JOIN sys.function_languages fl ON f.language =
fl.language_id
+ LEFT OUTER JOIN sys.comments c ON f.id = c.id
+ WHERE f.name=functionName AND s.name = schemaName;
END;
diff --git a/sql/scripts/76_dump.sql b/sql/scripts/76_dump.sql
--- a/sql/scripts/76_dump.sql
+++ b/sql/scripts/76_dump.sql
@@ -145,13 +145,13 @@ CREATE FUNCTION sys.esc(s STRING) RETURN
CREATE FUNCTION sys.prepare_esc(s STRING, t STRING) RETURNS STRING
BEGIN
- RETURN
- CASE
- WHEN (t = 'varchar' OR t ='char' OR t = 'clob' OR t = 'json' OR t
= 'geometry' OR t = 'url') THEN
- 'CASE WHEN ' || sys.DQ(s) || ' IS NULL THEN ''null'' ELSE ' ||
'sys.esc(' || sys.DQ(s) || ')' || ' END'
- ELSE
- 'CASE WHEN ' || sys.DQ(s) || ' IS NULL THEN ''null'' ELSE
CAST(' || sys.DQ(s) || ' AS STRING) END'
- END;
+RETURN
+ CASE
+ WHEN (t = 'varchar' OR t ='char' OR t = 'clob' OR t = 'json' OR
t = 'geometry' OR t = 'url') THEN
+ 'CASE WHEN ' || sys.DQ(s) || ' IS NULL THEN ''null''
ELSE ' || 'sys.esc(' || sys.DQ(s) || ')' || ' END'
+ ELSE
+ 'CASE WHEN ' || sys.DQ(s) || ' IS NULL THEN ''null''
ELSE CAST(' || sys.DQ(s) || ' AS STRING) END'
+ END;
END;
--The dump statement should normally have an auto-incremented column
representing the creation order.
@@ -163,8 +163,8 @@ CREATE TABLE sys.dump_statements(o INT,
CREATE PROCEDURE sys._dump_table_data(sch STRING, tbl STRING) BEGIN
- DECLARE k INT;
- SET k = (SELECT MIN(c.id) FROM sys.columns c, sys.tables t WHERE
c.table_id = t.id AND t.name = tbl);
+ DECLARE k INT;
+ SET k = (SELECT MIN(c.id) FROM sys.columns c, sys.tables t WHERE
c.table_id = t.id AND t.name = tbl);
IF k IS NOT NULL THEN
DECLARE cname STRING;
@@ -206,7 +206,7 @@ END;
CREATE PROCEDURE sys.dump_table_data() BEGIN
DECLARE i INT;
- SET i = (SELECT MIN(t.id) FROM sys.tables t, sys.table_types ts WHERE
t.type = ts.table_type_id AND ts.table_type_name = 'TABLE' AND NOT t.system);
+ SET i = (SELECT MIN(t.id) FROM sys.tables t, sys.table_types ts WHERE
t.type = ts.table_type_id AND ts.table_type_name = 'TABLE' AND NOT t.system);
IF i IS NOT NULL THEN
DECLARE M INT;
diff --git a/sql/scripts/81_tracer.sql b/sql/scripts/81_tracer.sql
--- a/sql/scripts/81_tracer.sql
+++ b/sql/scripts/81_tracer.sql
@@ -8,39 +8,39 @@ CREATE SCHEMA logging;
-- Flush the buffer
CREATE PROCEDURE logging.flush()
- EXTERNAL NAME logging.flush;
+ EXTERNAL NAME logging.flush;
-- Sets the log level for a specific component
CREATE PROCEDURE logging.setcomplevel(comp_id STRING, lvl_id STRING)
- EXTERNAL NAME logging.setcomplevel;
+ EXTERNAL NAME logging.setcomplevel;
-- Resets the log level for a specific component back to the default
CREATE PROCEDURE logging.resetcomplevel(comp_id STRING)
- EXTERNAL NAME logging.resetcomplevel;
+ EXTERNAL NAME logging.resetcomplevel;
-- Sets the log level for a specific layer
CREATE PROCEDURE logging.setlayerlevel(layer_id STRING, lvl_id STRING)
- EXTERNAL NAME logging.setlayerlevel;
+ EXTERNAL NAME logging.setlayerlevel;
-- Resets the log level for a specific layer back to the default
CREATE PROCEDURE logging.resetlayerlevel(layer_id STRING)
- EXTERNAL NAME logging.resetlayerlevel;
+ EXTERNAL NAME logging.resetlayerlevel;
-- Sets the flush level
CREATE PROCEDURE logging.setflushlevel(lvl_id STRING)
- EXTERNAL NAME logging.setflushlevel;
+ EXTERNAL NAME logging.setflushlevel;
-- Resets the flush level back to the default
CREATE PROCEDURE logging.resetflushlevel()
- EXTERNAL NAME logging.resetflushlevel;
+ EXTERNAL NAME logging.resetflushlevel;
-- Sets the adapter
CREATE PROCEDURE logging.setadapter(adapter_id STRING)
- EXTERNAL NAME logging.setadapter;
+ EXTERNAL NAME logging.setadapter;
-- Resets the adapter back to the default
CREATE PROCEDURE logging.resetadapter()
- EXTERNAL NAME logging.resetadapter;
+ EXTERNAL NAME logging.resetadapter;
-- Returns in the form of a SQL result-set all the
-- components along with their ID and their current
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1121,9 +1121,8 @@ cs_update_bat( sql_trans *tr, column_sto
else {
BATsetcount(ins, ucnt); /* all full updates */
msk =
(int*)Tloc(ins, 0);
- int end =
(ucnt+31)/32;
- for (int i=0;
i<end; i++)
- msk[i]
= 0;
+ BUN end =
(ucnt+31)/32;
+ memset(msk, 0,
end * sizeof(int));
}
}
for (oid i = 0, rid = start;
rid < lend && res == LOG_OK; rid++, i++) {
@@ -1165,9 +1164,8 @@ cs_update_bat( sql_trans *tr, column_sto
} else {
BATsetcount(ins, ucnt); /* all full updates */
msk =
(int*)Tloc(ins, 0);
- int end =
(ucnt+31)/32;
- for (int i=0;
i<end; i++)
- msk[i]
= 0;
+ BUN end =
(ucnt+31)/32;
+ memset(msk, 0,
end * sizeof(int));
}
}
ptr upd = BUNtail(upi, i);
@@ -1510,6 +1508,12 @@ update_col(sql_trans *tr, sql_column *c,
bool update_conflict = false;
sql_delta *delta, *odelta = ATOMIC_PTR_GET(&c->data);
+ if (tpe == TYPE_bat) {
+ BAT *t = tids;
+ if (!BATcount(t))
+ return LOG_OK;
+ }
+
if ((delta = bind_col_data(tr, c, &update_conflict)) == NULL)
return update_conflict ? LOG_CONFLICT : LOG_ERR;
@@ -1561,6 +1565,12 @@ update_idx(sql_trans *tr, sql_idx * i, v
bool update_conflict = false;
sql_delta *delta, *odelta = ATOMIC_PTR_GET(&i->data);
+ if (tpe == TYPE_bat) {
+ BAT *t = tids;
+ if (!BATcount(t))
+ return LOG_OK;
+ }
+
if ((delta = bind_idx_data(tr, i, &update_conflict)) == NULL)
return update_conflict ? LOG_CONFLICT : LOG_ERR;
diff --git a/sql/storage/objectset.c b/sql/storage/objectset.c
--- a/sql/storage/objectset.c
+++ b/sql/storage/objectset.c
@@ -343,7 +343,7 @@ static objectset *
os_append_node_id(objectset *os, versionhead *n)
{
lock_writer(os);
- if (!os->id_map || (os->id_map->size*16 < os->id_based_cnt &&
os->id_based_cnt > HASH_MIN_SIZE))
+ if ((!os->id_map || os->id_map->size*16 < os->id_based_cnt) &&
os->id_based_cnt > HASH_MIN_SIZE)
os_append_id_map(os); /* on failure just fall back too slow
method */
if (os->id_map) {
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1757,8 +1757,8 @@ store_load(sqlstore *store, sql_allocato
/* for now use malloc and free */
store->active = list_create(NULL);
- store->dependencies = hash_new(NULL, 1024, (fkeyvalue)&dep_hash);
- store->depchanges = hash_new(NULL, 1024, (fkeyvalue)&dep_hash);
+ store->dependencies = hash_new(NULL, 32, (fkeyvalue)&dep_hash);
+ store->depchanges = hash_new(NULL, 32, (fkeyvalue)&dep_hash);
if (store->first) {
/* cannot initialize database in readonly mode */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list