Changeset: 8c352f5d30ef for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8c352f5d30ef
Modified Files:
monetdb5/mal/mal_client.c
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_profiler.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
sql/server/sql_mvc.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: sql_profiler
Log Message:
Fix return code from generated events.
Needs improvement of rc with SQL_ERROR.
diffs (truncated from 302 to 300 lines):
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -207,17 +207,10 @@ MCexitClient(Client c)
c->fdout = NULL;
c->fdin = NULL;
}
-
if(malProfileMode > 0)
generic_event("client_connection",
- (struct GenericEvent)
- { &c->idx,
- NULL,
- NULL,
- NULL,
- 0 },
- 1);
-
+ (struct GenericEvent) { &c->idx, NULL,
NULL, NULL, 0 },
+ 1);
setClientContext(NULL);
}
@@ -317,11 +310,7 @@ MCinitClient(oid user, bstream *fin, str
if(malProfileMode > 0)
generic_event("client_connection",
(struct GenericEvent)
- { &c->idx,
- NULL,
- NULL,
- NULL,
- 0 },
+ { &c->idx, NULL, NULL, NULL, 0
},
0);
}
MT_lock_unset(&mal_contextLock);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -193,7 +193,6 @@ prepare_generic_event(str face, struct G
if (logadd(&logbuf,
"{"
"\"version\":\""MONETDB_VERSION" (hg id: %s)\""
- /* ",\"user\":"OIDFMT */
",\"clk\":"LLFMT
",\"mclk\":%"PRIu64""
",\"thread\":%d"
@@ -203,19 +202,19 @@ prepare_generic_event(str face, struct G
",\"transaction_id\":"ULLFMT
",\"tag\":"OIDFMT
",\"query\":\"%s\""
- ",\"error\":\"%s\""
+ ",\"rc\":\"%s\""
"}\n",
mercurial_revision(),
clk,
mclk,
THRgettid(),
face,
- state ? "done" : "start",
- e.client_id ? *(e.client_id) : 0,
- e.transaction_id ? *(e.transaction_id) : 0,
- e.tag ? *(e.tag) : 0,
- e.query ? e.query : "none",
- e.error ? "true" : "false"))
+ state? "done" : "start",
+ (e.client_id)? *(e.client_id) : 0,
+ (e.transaction_id)? *(e.transaction_id) : 0,
+ (e.tag)? *(e.tag) : 0,
+ (e.query)? e.query : "none",
+ (e.rc)? "false" : "true"))
return logbuf.logbuffer;
else {
logdel(&logbuf);
diff --git a/monetdb5/mal/mal_profiler.h b/monetdb5/mal/mal_profiler.h
--- a/monetdb5/mal/mal_profiler.h
+++ b/monetdb5/mal/mal_profiler.h
@@ -25,7 +25,7 @@ struct GenericEvent {
oid* tag;
ulng* transaction_id;
str query;
- int error;
+ int rc; /* return code */
};
mal_export int malProfileMode;
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
@@ -132,11 +132,7 @@ sql_symbol2relation(backend *be, symbol
if(malProfileMode > 0 )
generic_event("sql_to_rel",
(struct GenericEvent)
- { &(c->idx),
- &(c->curprg->def->tag),
- NULL,
- NULL,
- 0 },
+ { &(c->idx), &(c->curprg->def->tag),
NULL, NULL, 0 },
0);
rel = rel_semantic(query, sym);
@@ -144,19 +140,11 @@ sql_symbol2relation(backend *be, symbol
if(malProfileMode > 0 ) {
generic_event("sql_to_rel",
(struct GenericEvent)
- { &(c->idx),
- &(c->curprg->def->tag),
- NULL,
- NULL,
- rel ? 1 : 0 },
+ { &(c->idx), &(c->curprg->def->tag),
NULL, NULL, rel ? 0 : 1 },
1);
generic_event("rel_opt",
(struct GenericEvent)
- { &(c->idx),
- &(c->curprg->def->tag),
- NULL,
- NULL,
- 0 },
+ { &(c->idx), &(c->curprg->def->tag),
NULL, NULL, 0 },
0);
}
@@ -173,11 +161,7 @@ sql_symbol2relation(backend *be, symbol
if(malProfileMode > 0)
generic_event("rel_opt",
(struct GenericEvent)
- { &c->idx,
- &(c->curprg->def->tag),
- NULL,
- NULL,
- rel ? 1 : 0},
+ { &c->idx, &(c->curprg->def->tag),
NULL, NULL, rel ? 0 : 1},
1);
return rel;
}
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
@@ -1114,11 +1114,7 @@ SQLparser(Client c)
if(malProfileMode > 0)
generic_event("sql_parse",
(struct GenericEvent)
- { &c->idx,
- &(c->curprg->def->tag),
- NULL,
- NULL,
- 0 },
+ { &c->idx, &(c->curprg->def->tag),
NULL, NULL, 0 },
0);
if ((err = sqlparse(m)) ||
@@ -1148,16 +1144,11 @@ SQLparser(Client c)
c->query = query_cleaned(m->sa, QUERY(m->scanner));
if(malProfileMode > 0) {
- str escaped_query = c->query ? mal_quote(c->query,
sizeof(c->query)) : NULL;
+ str escaped_query = c->query? mal_quote(c->query,
sizeof(c->query)) : NULL;
generic_event("sql_parse",
(struct GenericEvent)
- { &c->idx,
- &(c->curprg->def->tag),
- NULL,
- escaped_query,
- c->query ? 0 : 1, },
+ { &c->idx, &(c->curprg->def->tag),
NULL, escaped_query, c->query? 0 : 1, },
1);
-
GDKfree(escaped_query);
}
@@ -1219,11 +1210,7 @@ SQLparser(Client c)
if(malProfileMode > 0)
generic_event("rel_to_mal",
(struct GenericEvent)
- { &c->idx,
-
&(c->curprg->def->tag),
- NULL,
- NULL,
- c->query ? 0 : 1 },
+ { &c->idx,
&(c->curprg->def->tag), NULL, NULL, c->query? 0 : 1 },
0);
if (backend_dumpstmt(be, c->curprg->def, r, !(m->emod &
mod_exec), 0, c->query) < 0)
@@ -1234,11 +1221,7 @@ SQLparser(Client c)
if(malProfileMode > 0)
generic_event("rel_to_mal",
(struct GenericEvent)
- { &c->idx,
-
&(c->curprg->def->tag),
- NULL,
- NULL,
- c->query ? 0 : 1 },
+ { &c->idx,
&(c->curprg->def->tag), NULL, NULL, c->query? 0 : 1 },
1);
} else {
char *q_copy = sa_strdup(m->sa, c->query);
@@ -1321,11 +1304,7 @@ SQLparser(Client c)
if(malProfileMode > 0)
generic_event("mal_opt",
(struct GenericEvent)
- { &c->idx,
-
&(c->curprg->def->tag),
- NULL,
- NULL,
- 0 },
+ { &c->idx,
&(c->curprg->def->tag), NULL, NULL, 0 },
0);
msg = SQLoptimizeQuery(c, c->curprg->def);
@@ -1333,11 +1312,7 @@ SQLparser(Client c)
if(malProfileMode > 0)
generic_event("mal_opt",
(struct GenericEvent)
- { &c->idx,
-
&(c->curprg->def->tag),
- NULL,
- NULL,
- msg == MAL_SUCCEED ?
0 : 1 },
+ { &c->idx,
&(c->curprg->def->tag), NULL, NULL, msg == MAL_SUCCEED? 0 : 1 },
1);
if (msg != MAL_SUCCEED) {
diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -125,18 +125,14 @@ mvc_fix_depend(mvc *m, sql_column *depid
}
static void
-generic_event_wrapper(str face, ulng transaction_id, int error, int state)
+generic_event_wrapper(str face, ulng transaction_id, int rc, int state)
{
int client_id = 0;
if(malProfileMode > 0)
generic_event(face,
(struct GenericEvent)
- { &client_id,
- NULL,
- &transaction_id,
- NULL,
- error },
+ { &client_id, NULL, &transaction_id,
NULL, rc },
state);
}
@@ -495,11 +491,7 @@ mvc_trans(mvc *m)
if(malProfileMode > 0)
generic_event("transaction",
(struct GenericEvent)
- { &(m->clientid),
- NULL,
- &(m->session->tr->tid),
- NULL,
- 0 },
+ { &(m->clientid), NULL,
&(m->session->tr->tid), NULL, (res || err)? 1 : 0 },
0);
if (m->qc && (res || err)) {
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -332,7 +332,7 @@ sql_export void res_tables_destroy(res_t
extern res_table *res_tables_find(res_table *results, int res_id);
/* callback to access generic_event in store.c */
-typedef void (*generic_event_wrapper_fptr) (str face, ulng transaction_id, int
error, int state);
+typedef void (*generic_event_wrapper_fptr) (str face, ulng transaction_id, int
rc, int state);
extern struct sqlstore *store_init(int debug, store_type store, int readonly,
int singleuser, generic_event_wrapper_fptr event_wrapper);
extern void store_exit(struct sqlstore *store);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3910,7 +3910,6 @@ sql_trans_commit(sql_trans *tr)
}
}
-
store->generic_event_wrapper("commit", tr->tid, 0, 0);
/* log changes should only be done if there is something to log
*/
@@ -4043,7 +4042,7 @@ sql_trans_commit(sql_trans *tr)
if (ok == LOG_OK)
ok = clean_predicates_and_propagate_to_parent(tr);
- store->generic_event_wrapper("commit", tr->tid, ok, 1);
+ store->generic_event_wrapper("commit", tr->tid, (ok == LOG_OK)? SQL_OK
: SQL_ERR, 1);
return (ok==LOG_OK)?SQL_OK:SQL_ERR;
}
@@ -7044,7 +7043,7 @@ sql_trans_end(sql_session *s, int ok)
}
store->oldest = oldest;
assert(list_length(store->active) == (int)
ATOMIC_GET(&store->nr_active));
- store->generic_event_wrapper("transaction", s->tr->tid, ok, 1);
+ store->generic_event_wrapper("transaction", s->tr->tid, (ok == LOG_OK)?
SQL_OK : SQL_ERR, 1);
store_unlock(store);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]