Changeset: 0c4024427f78 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0c4024427f78
Modified Files:
sql/backends/monet5/mal_backend.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
Branch: queryid
Log Message:
added query id export to monet
diffs (75 lines):
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
@@ -38,7 +38,7 @@ typedef struct backend {
stream *out;
ofmt output_format; /* csv, json */
Client client;
- MalBlkPtr mb; /* needed during mal generation */
+ MalBlkPtr mb; /* needed during mal generation and result set
export */
int mvc_var;
int vtop; /* top of the variable stack before the current
function */
cq *q; /* pointer to the cached query */
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2825,6 +2825,9 @@ mvc_result_set_wrap( Client cntxt, MalBl
BBPunfix(bid);
}
/* now sent it to the channel cntxt->fdout */
+
+ ((backend*)(cntxt->sqlcontext))->mb = mb;
+
if (mvc_export_result(cntxt->sqlcontext, cntxt->fdout, res))
msg = createException(SQL, "sql.resultset", "failed");
wrapup_result_set:
@@ -3290,6 +3293,9 @@ mvc_affected_rows_wrap(Client cntxt, Mal
assert(mtype == TYPE_lng);
nr = *getArgReference_lng(stk, pci, 2);
b = cntxt->sqlcontext;
+
+ b->mb = mb; // to allow query id export in result set
+
error = mvc_export_affrows(b, b->out, nr, "");
if (error)
throw(SQL, "sql.affectedRows", "failed");
@@ -3401,6 +3407,8 @@ mvc_scalar_value_wrap(Client cntxt, MalB
if (ATOMextern(mtype))
p = *(ptr *) p;
+ b->mb = mb; // for query id export
+
// scalar values are single-column result sets
mvc_result_table(b->mvc, 1, 1, NULL);
mvc_result_value(b->mvc, *tn, *cn, *type, *digits, *scale, p, mtype);
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1610,7 +1610,7 @@ mvc_export_value(backend *b, stream *s,
assert(qtype == Q_TABLE);
if (csv &&
- (mnstr_write(s, "&1 0 1 1 1\n", 11, 1) != 1 ||
+ (mnstr_printf(s, "&1 0 1 1 1 "OIDFMT"\n", b->mb->tag) != 1 ||
/* fallback to default tuplecount (1) and id (0) */
/* TODO first header name then values */
mnstr_write(s, "% ", 2, 1) != 1 ||
@@ -1681,7 +1681,7 @@ mvc_export_affrows(backend *b, stream *s
m->rowcnt = val;
stack_set_number(m, "rowcnt", m->rowcnt);
- if (mnstr_write(s, "&2 ", 3, 1) != 1 || !mvc_send_lng(s, val) ||
mnstr_write(s, " ", 1, 1) != 1 || !mvc_send_lng(s, m->last_id) ||
mnstr_write(s, "\n", 1, 1) != 1)
+ if (mnstr_write(s, "&2 ", 3, 1) != 1 || !mvc_send_lng(s, val) ||
mnstr_write(s, " ", 1, 1) != 1 || !mvc_send_lng(s, m->last_id) ||
mnstr_write(s, " ", 1, 1) != 1 || !mvc_send_lng(s, (lng) b->mb->tag) ||
mnstr_write(s, "\n", 1, 1) != 1)
return -1;
if (mvc_export_warning(s, w) != 1)
return -1;
@@ -1741,6 +1741,9 @@ mvc_export_head(backend *b, stream *s, i
if (!mvc_send_int(s, (m->reply_size >= 0 && (BUN) m->reply_size <
count) ? m->reply_size : (int) count))
return -1;
+ if (mnstr_write(s, " ", 1, 1) != 1 || !mvc_send_lng(s, (lng)
b->mb->tag))
+ return -1;
+
if (mnstr_write(s, "\n% ", 3, 1) != 1)
return -1;
for (i = 0; i < t->nr_cols; i++) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list