Changeset: 10dc906a7fed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/10dc906a7fed
Modified Files:
gdk/gdk_logger.c
monetdb5/extras/rapi/rapi.c
sql/backends/monet5/sql_upgrades.c
tools/mserver/mserver5.c
Branch: Jun2023
Log Message:
Merge with Sep2022 branch.
diffs (truncated from 478 to 300 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -441,7 +441,7 @@ log_read_updates(logger *lg, trans *tr,
}
}
} else if (l->flag == LOG_UPDATE_BULK) {
- if (mnstr_readLng(lg->input_log, &offset) != 1) {
+ if (mnstr_readLng(lg->input_log, &offset) != 1) {
if (r)
BBPreclaim(r);
return LOG_ERR;
@@ -1046,12 +1046,6 @@ log_open_output(logger *lg)
TRC_CRITICAL(GDK, "allocation failure\n");
return GDK_FAIL;
}
- ATOMIC_INIT(&new_range->refcount, 1);
- ATOMIC_INIT(&new_range->last_ts, 0);
- ATOMIC_INIT(&new_range->end, 0);
- ATOMIC_INIT(&new_range->pend, 0);
- ATOMIC_INIT(&new_range->flushed_end, 0);
- ATOMIC_INIT(&new_range->drops, 0);
if (!LOG_DISABLED(lg)) {
char id[32];
char *filename;
@@ -1077,12 +1071,19 @@ log_open_output(logger *lg)
if (new_range->output_log == NULL ||
mnstr_errnr(new_range->output_log) != MNSTR_NO__ERROR) {
TRC_CRITICAL(GDK, "creating %s failed: %s\n", filename,
mnstr_peek_error(NULL));
+ close_stream(new_range->output_log);
GDKfree(new_range);
GDKfree(filename);
return GDK_FAIL;
}
GDKfree(filename);
}
+ ATOMIC_INIT(&new_range->refcount, 1);
+ ATOMIC_INIT(&new_range->last_ts, 0);
+ ATOMIC_INIT(&new_range->end, 0);
+ ATOMIC_INIT(&new_range->pend, 0);
+ ATOMIC_INIT(&new_range->flushed_end, 0);
+ ATOMIC_INIT(&new_range->drops, 0);
new_range->id = lg->id;
new_range->next = NULL;
logged_range* current = lg->current;
@@ -2252,6 +2253,12 @@ log_destroy(logger *lg)
log_close_output(lg);
for (logged_range *p = lg->pending; p; ){
logged_range *n = p->next;
+ ATOMIC_DESTROY(&p->refcount);
+ ATOMIC_DESTROY(&p->last_ts);
+ ATOMIC_DESTROY(&p->end);
+ ATOMIC_DESTROY(&p->pend);
+ ATOMIC_DESTROY(&p->flushed_end);
+ ATOMIC_DESTROY(&p->drops);
GDKfree(p);
p = n;
}
@@ -2324,8 +2331,8 @@ log_create(int debug, const char *fn, co
}
lg->current = lg->current->next;
assert(lg->pending == NULL && lg->flush_ranges == NULL);
- lg->pending = lg->current;
- lg->flush_ranges = lg->current;
+ lg->pending = lg->current;
+ lg->flush_ranges = lg->current;
return lg;
}
@@ -2358,7 +2365,7 @@ log_cleanup_range(logger *lg, ulng id)
static void
do_rotate(logger *lg) {
- logged_range* next = lg->current->next;
+ logged_range* next = lg->current->next;
if (next) {
assert(ATOMIC_GET(&next->refcount) == 1);
ulng end = ATOMIC_GET(&lg->current->end);
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -919,6 +919,7 @@ static str RAPIprelude(void) {
}
MT_lock_unset(&rapiLock);
printf("# MonetDB/R module loaded\n");
+ fflush(stdout);
}
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/sql_upgrades.c
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -140,6 +140,7 @@ sql_fix_system_tables(Client c, mvc *sql
assert(pos < bufsize);
printf("Running database upgrade commands to update system
tables.\n\n");
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -309,6 +310,7 @@ sql_update_hugeint(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -321,6 +323,7 @@ sql_update_shp(Client c)
{
const char *query = "create procedure SHPattach(fname string) external
name shp.attach;\ncreate procedure SHPload(fid integer) external name
shp.import;\ncreate procedure SHPload(fid integer, filter geometry) external
name shp.import;\nupdate sys.functions set system = true where schema_id = 2000
and name in ('shpattach', 'shpload');\n";
printf("Running database upgrade commands:\n%s\n", query);
+ fflush(stdout);
return SQLstatementIntern(c, query, "update", true, false, NULL);
}
#endif
@@ -365,6 +368,7 @@ sql_drop_functions_dependencies_Xs_on_Ys
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -709,25 +713,31 @@ sql_update_storagemodel(Client c, mvc *s
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
}
-#define FLUSH_INSERTS_IF_BUFFERFILLED /* Each new value should add about 20
bytes to the buffer, "flush" when is 200 bytes from being full */ \
- if (pos > 7900) { \
- pos += snprintf(buf + pos, bufsize - pos, \
- ") as t1(c1,c2,c3) where t1.c1
not in (select \"id\" from sys.dependencies where depend_id = t1.c2);\n"); \
- assert(pos < bufsize); \
- printf("Running database upgrade commands:\n%s\n", buf); \
- err = SQLstatementIntern(c, buf, "update", true, false, NULL); \
- if (err) \
- goto bailout; \
- pos = 0; \
- pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.dependencies select c1, c2, c3 from (values"); \
- ppos = pos; \
- first = true; \
- }
+#define FLUSH_INSERTS_IF_BUFFERFILLED
\
+ do {
\
+ /* Each new value should add about 20 bytes to the buffer, */
\
+ /* "flush" when is 200 bytes from being full */
\
+ if (pos > 7900) {
\
+ pos += snprintf(buf + pos, bufsize - pos,
\
+ ") as t1(c1,c2,c3)
where t1.c1 not in (select \"id\" from sys.dependencies where depend_id =
t1.c2);\n"); \
+ assert(pos < bufsize);
\
+ printf("Running database upgrade commands:\n%s\n",
buf); \
+ fflush(stdout);
\
+ err = SQLstatementIntern(c, buf, "update", true, false,
NULL); \
+ if (err)
\
+ goto bailout;
\
+ pos = 0;
\
+ pos += snprintf(buf + pos, bufsize - pos, "insert into
sys.dependencies select c1, c2, c3 from (values"); \
+ ppos = pos;
\
+ first = true;
\
+ }
\
+ } while (0)
static str
sql_update_nov2019_missing_dependencies(Client c, mvc *sql)
@@ -780,7 +790,7 @@ sql_update_nov2019_missing_dependencies(
pos += snprintf(buf +
pos, bufsize - pos, "%s(%d,%d,%d)", first ? "" : ",", next,
f->base.id, (int)(!IS_PROC(f) ? FUNC_DEPENDENCY : PROC_DEPENDENCY));
first = false;
-
FLUSH_INSERTS_IF_BUFFERFILLED
+
FLUSH_INSERTS_IF_BUFFERFILLED;
}
}
} else if (sql->session->status == -1) {
@@ -816,7 +826,7 @@ sql_update_nov2019_missing_dependencies(
pos +=
snprintf(buf + pos, bufsize - pos, "%s(%d,%d,%d)", first ? "" : ",",
next, t->base.id, (int) VIEW_DEPENDENCY);
first = false;
-
FLUSH_INSERTS_IF_BUFFERFILLED
+
FLUSH_INSERTS_IF_BUFFERFILLED;
}
}
}
@@ -844,7 +854,7 @@ sql_update_nov2019_missing_dependencies(
pos +=
snprintf(buf + pos, bufsize - pos, "%s(%d,%d,%d)", first ? "" : ",",
next, tr->base.id, (int) TRIGGER_DEPENDENCY);
first =
false;
-
FLUSH_INSERTS_IF_BUFFERFILLED
+
FLUSH_INSERTS_IF_BUFFERFILLED;
}
}
}
@@ -859,6 +869,7 @@ sql_update_nov2019_missing_dependencies(
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
}
@@ -1031,6 +1042,7 @@ sql_update_nov2019(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", 1, 0, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -1062,6 +1074,7 @@ sql_update_nov2019_sp1_hugeint(Client c,
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -1637,6 +1650,7 @@ sql_update_jun2020(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
if (err == MAL_SUCCEED) {
pos = snprintf(buf, bufsize,
@@ -1644,6 +1658,7 @@ sql_update_jun2020(Client c, mvc *sql)
"ALTER TABLE sys.function_languages SET READ
ONLY;\n");
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
}
GDKfree(buf);
@@ -1721,6 +1736,7 @@ sql_update_jun2020_bam(Client c, mvc *m)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
@@ -1775,6 +1791,7 @@ sql_update_jun2020_sp1_hugeint(Client c)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
GDKfree(buf);
return err; /* usually MAL_SUCCEED */
@@ -1789,6 +1806,7 @@ sql_update_oscar_lidar(Client c)
"drop procedure sys.lidarload(string) cascade;\n"
"drop procedure sys.lidarexport(string, string, string)
cascade;\n";
printf("Running database upgrade commands:\n%s\n", query);
+ fflush(stdout);
return SQLstatementIntern(c, query, "update", true, false, NULL);
}
@@ -1921,6 +1939,7 @@ sql_update_oscar(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false,
NULL);
}
BBPunfix(b->batCacheid);
@@ -2046,6 +2065,7 @@ sql_update_oct2020(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false,
NULL);
if (err != MAL_SUCCEED)
goto bailout;
@@ -2054,6 +2074,7 @@ sql_update_oct2020(Client c, mvc *sql)
"ALTER TABLE sys.keywords SET READ
ONLY;\n");
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false,
NULL);
if (err != MAL_SUCCEED)
goto bailout;
@@ -2091,6 +2112,7 @@ sql_update_oct2020_sp1(Client c, mvc *sq
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
err = SQLstatementIntern(c, buf, "update", true, false, NULL);
}
GDKfree(buf);
@@ -3113,6 +3135,7 @@ sql_update_jul2021(Client c, mvc *sql)
assert(pos < bufsize);
printf("Running database upgrade commands:\n%s\n", buf);
+ fflush(stdout);
if ((err = SQLstatementIntern(c, buf, "update", true,
false, NULL)) != MAL_SUCCEED)
goto bailout;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]