Changeset: 191743cf6f37 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/191743cf6f37
Branch: newjson
Log Message:
merge nested
diffs (truncated from 302 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1403,7 +1403,6 @@ str RAstatementEnd(Client cntxt, MalBlkP
str SQLautocommit(mvc *m);
void SQLdestroyResult(res_table *destroy);
void SQLengine(Client c);
-str SQLengineIntern(Client c, backend *be);
str SQLengine_(Client c);
str SQLescapeString(str s);
str SQLexitClient(Client c);
@@ -1767,7 +1766,6 @@ stream *socket_wstream(SOCKET socket, co
stream *stderr_wastream(void);
stream *stdin_rastream(void);
stream *stdout_wastream(void);
-stream *stream_blackhole_create(void);
stream *stream_fwf_create(stream *restrict s, size_t num_fields, size_t
*restrict widths, char filler);
stream *xz_stream(stream *inner, int preset);
diff --git a/common/stream/CMakeLists.txt b/common/stream/CMakeLists.txt
--- a/common/stream/CMakeLists.txt
+++ b/common/stream/CMakeLists.txt
@@ -39,7 +39,6 @@ target_sources(stream
mapi_stream.c
memio.c
callback.c
- blackhole.c
fwf.c
text_stream.c
$<$<BOOL:${OPENSSL_FOUND}>:openssl_stream.c>
diff --git a/common/stream/blackhole.c b/common/stream/blackhole.c
deleted file mode 100644
--- a/common/stream/blackhole.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SPDX-License-Identifier: MPL-2.0
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * Copyright 2024, 2025 MonetDB Foundation;
- * Copyright August 2008 - 2023 MonetDB B.V.;
- * Copyright 1997 - July 2008 CWI.
- */
-
-#include "monetdb_config.h"
-#include "stream.h"
-#include "stream_internal.h"
-
-
-
-static ssize_t
-stream_blackhole_write(stream *restrict s, const void *restrict buf, size_t
elmsize, size_t cnt)
-{
- (void) s;
- (void) buf;
- (void) elmsize;
- return (ssize_t) cnt;
-}
-
-static void
-stream_blackhole_close(stream *s)
-{
- (void) s;
- /* no resources to close */
-}
-
-stream *
-stream_blackhole_create(void)
-{
- stream *s;
- if ((s = create_stream("blackhole")) == NULL) {
- return NULL;
- }
-
- s->read = NULL;
- s->write = stream_blackhole_write;
- s->close = stream_blackhole_close;
- s->flush = NULL;
- s->readonly = false;
- return s;
-}
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -269,8 +269,6 @@ stream_export stream *callback_stream(
void (*destroy)(void *priv),
const char *restrict name); // used in mclient.c, for readline
-stream_export stream *stream_blackhole_create(void); // never used
-
stream_export stream *stream_fwf_create(stream *restrict s, size_t num_fields,
size_t *restrict widths, char filler); // sql.c
stream_export stream *create_text_stream(stream *s);
diff --git a/monetdb5/modules/atoms/json.h b/monetdb5/modules/atoms/json.h
--- a/monetdb5/modules/atoms/json.h
+++ b/monetdb5/modules/atoms/json.h
@@ -46,7 +46,7 @@ typedef struct JSON {
int free;
} JSON;
-extern JSON *JSONparse(const char *j);
-extern void JSONfree(JSON *jt);
+mal_export JSON *JSONparse(const char *j);
+mal_export void JSONfree(JSON *jt);
#endif /* __JSON_H__ */
diff --git a/sql/backends/monet5/mal_backend.h
b/sql/backends/monet5/mal_backend.h
--- a/sql/backends/monet5/mal_backend.h
+++ b/sql/backends/monet5/mal_backend.h
@@ -51,7 +51,6 @@ typedef struct backend {
int mvc_var; /* current variable holding the latest query
context (used to create dependencies in mal statements) */
int rowcount; /* when multiple insert/update/delete/truncate
statements are present, use an accumulator to hold the total number of rows
affected */
- int vtop; /* top of the variable stack
before the current function */
int join_idx; /* number of index joins (used in rel_bin) */
lng reloptimizer; /* timer for optimizer phase */
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2478,6 +2478,8 @@ rel2bin_basetable(backend *be, sql_rel *
} else {
sql_column *c = find_sql_column(t, oname);
+ if (c->type.multiset || c->type.type->composite)
+ continue;
fcol = c;
col = stmt_col(be, c, multiset?dels:NULL,
dels->partition);
}
@@ -2512,6 +2514,8 @@ rel2bin_basetable(backend *be, sql_rel *
dels = odels;
c = find_sql_column(t, oname);
}
+ if (!c->type.multiset && c->type.type->composite)
+ continue;
s = (c == fcol) ? col : stmt_col(be, c,
multiset?dels:NULL, dels->partition);
if (c->type.multiset) {
@@ -4872,6 +4876,9 @@ rel2bin_project(backend *be, sql_rel *re
return NULL;
for (en = rel->exps->h; en; en = en->next) {
sql_exp *exp = en->data;
+ sql_subtype *st = exp_subtype(exp);
+ if (st && st->type->composite)
+ continue;
int oldvtop = be->mb->vtop, oldstop = be->mb->stop;
stmt *s = exp_bin(be, exp, sub, NULL /*psub*/, NULL, NULL,
NULL, NULL, 0, 0, 0);
diff --git a/sql/backends/monet5/sql_execute.c
b/sql/backends/monet5/sql_execute.c
--- a/sql/backends/monet5/sql_execute.c
+++ b/sql/backends/monet5/sql_execute.c
@@ -539,13 +539,9 @@ SQLstatementIntern(Client c, const char
if (!output)
sql->out = NULL; /* no output stream */
be->depth++;
- msg = SQLrun(c,m);
+ msg = SQLrun(c, m);
be->depth--;
- if (c->curprg->def->stop > 1) {
- assert(0);
- MSresetInstructions(c->curprg->def, oldstop);
- freeVariables(c, c->curprg->def, NULL, oldvtop);
- }
+ assert (c->curprg->def->stop <= 1);
sqlcleanup(sql, 0);
if (!execute)
goto endofcompile;
@@ -603,38 +599,6 @@ endofcompile:
return msg;
}
-str
-SQLengineIntern(Client c, backend *be)
-{
- str msg = MAL_SUCCEED;
- //char oldlang = be->language;
- mvc *m = be->mvc;
-
- assert (m->emode != m_deallocate && m->emode != m_prepare);
- assert (c->curprg->def->stop > 2);
-
- //be->language = 'D';
- if (MALcommentsOnly(c->curprg->def))
- msg = MAL_SUCCEED;
- else
- msg = SQLrun(c,m);
-
- if (m->type == Q_SCHEMA && m->qc != NULL)
- qc_clean(m->qc);
- be->q = NULL;
- if (msg)
- m->session->status = -10;
- sqlcleanup(be, (!msg) ? 0 : -1);
- MSresetInstructions(c->curprg->def, 1);
- freeVariables(c, c->curprg->def, NULL, be->vtop);
- //be->language = oldlang;
- /*
- * Any error encountered during execution should block further
processing
- * unless auto_commit has been set.
- */
- return msg;
-}
-
void
SQLdestroyResult(res_table *destroy)
{
@@ -692,12 +656,10 @@ RAstatement(Client c, MalBlkPtr mb, MalS
if (backend_dumpstmt(be, c->curprg->def, rel, 0, 1, NULL) < 0) {
msg = createException(SQL,"RAstatement","Program
contains errors"); // TODO: use macro definition.
} else {
- //SQLaddQueryToCache(c);
msg = SQLoptimizeFunction(c, c->curprg->def);
if (msg == MAL_SUCCEED)
msg = SQLrun(c,m);
resetMalBlk(c->curprg->def);
- //SQLremoveQueryFromCache(c);
}
rel_destroy(rel);
}
diff --git a/sql/backends/monet5/sql_execute.h
b/sql/backends/monet5/sql_execute.h
--- a/sql/backends/monet5/sql_execute.h
+++ b/sql/backends/monet5/sql_execute.h
@@ -15,7 +15,6 @@
#include "sql.h"
sql5_export str SQLstatementIntern(Client c, const char *expr, const char
*nme, bit execute, bit output, res_table **result);
-sql5_export str SQLengineIntern(Client c, backend *be);
sql5_export str RAstatement(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str RAstatement2(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str RAstatementEnd(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -366,7 +366,7 @@ SQLexecPostLoginTriggers(Client c)
stream *out = be->out;
be->out = NULL; /* no output stream */
if (!msg)
- msg = SQLrun(c,m);
+ msg = SQLrun(c, m);
// restore previous state
be->out = out;
@@ -1436,7 +1436,6 @@ SQLparser_body(Client c, backend *be)
int oldvtop = c->curprg->def->vtop;
int oldstop = c->curprg->def->stop;
- be->vtop = oldvtop;
(void)runtimeProfileSetTag(c); /* generate and set the tag in
the mal block of the clients current program. */
if (m->emode != m_prepare || (m->emode == m_prepare && (m->emod
& mod_exec) && is_ddl(r->op)) /* direct execution prepare */) {
mvc_query_processed(m);
@@ -1651,6 +1650,7 @@ SQLengine_(Client c)
if (msg || c->mode <= FINISHCLIENT)
return msg;
+ int oldvtop = c->curprg?c->curprg->def->vtop:0;
if (be->language == 'X') {
return SQLchannelcmd(c, be);
} else if (be->language !='S') {
@@ -1670,7 +1670,27 @@ SQLengine_(Client c)
sqlcleanup(be, 0);
return NULL;
}
- return SQLengineIntern(c, be);
+
+ mvc *m = be->mvc;
+
+ assert (m->emode != m_deallocate && m->emode != m_prepare);
+ assert (c->curprg->def->stop > 2);
+
+ msg = SQLrun(c, m);
+
+ if (m->type == Q_SCHEMA && m->qc != NULL)
+ qc_clean(m->qc);
+ be->q = NULL;
+ if (msg)
+ m->session->status = -10;
+ sqlcleanup(be, (!msg) ? 0 : -1);
+ MSresetInstructions(c->curprg->def, 1);
+ freeVariables(c, c->curprg->def, NULL, oldvtop);
+ /*
+ * Any error encountered during execution should block further
processing
+ * unless auto_commit has been set.
+ */
+ return msg;
}
void
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -4040,7 +4040,7 @@ stmt_convert(backend *be, stmt *v, stmt
if (v->nr < 0)
goto bailout;
- if (f->type->eclass == EC_EXTERNAL && strcmp(f->type->base.name,
"json") == 0)
+ if (f->type->eclass == EC_EXTERNAL && t->type->composite &&
strcmp(f->type->base.name, "json") == 0)
return stmt_from_json(be, v, sel, t);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]