Changeset: f200f43f11f5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f200f43f11f5
Modified Files:
sql/backends/monet5/sql_execute.c
Branch: Jun2020
Log Message:
Go to bailout on error and clean everything
diffs (107 lines):
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
@@ -450,14 +450,14 @@ SQLstatementIntern(Client c, str *expr,
{
int status = 0, err = 0, oldvtop, oldstop = 1, inited = 0, ac,
sizevars, topvars;
unsigned int label;
- mvc *o, *m;
+ mvc *o = NULL, *m = NULL;
sql_var *vars;
- buffer *b;
- char *n, *mquery;
- bstream *bs;
- stream *buf;
+ buffer *b = NULL;
+ char *n = NULL, *mquery;
+ bstream *bs = NULL;
+ stream *buf = NULL;
str msg = MAL_SUCCEED;
- backend *be, *sql = (backend *) c->sqlcontext;
+ backend *be = NULL, *sql = (backend *) c->sqlcontext;
size_t len = strlen(*expr);
#ifdef _SQL_COMPILE
@@ -488,17 +488,19 @@ SQLstatementIntern(Client c, str *expr,
/* create private allocator */
m->sa = NULL;
if ((msg = SQLtrans(m)) != MAL_SUCCEED) {
- if (inited)
- SQLresetClient(c);
- return msg;
+ be = sql;
+ sql = NULL;
+ goto endofcompile;
}
status = m->session->status;
m->type = Q_PARSE;
be = sql;
sql = backend_create(m, c);
- if( sql == NULL)
- throw(SQL,"sql.statement",SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ if (sql == NULL) {
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
+ }
sql->output_format = be->output_format;
if (!output) {
sql->output_format = OFMT_NONE;
@@ -513,12 +515,14 @@ SQLstatementIntern(Client c, str *expr,
/* mimic a client channel on which the query text is received */
b = (buffer *) GDKmalloc(sizeof(buffer));
- if( b == NULL)
- throw(SQL,"sql.statement", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ if (b == NULL) {
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
+ }
n = GDKmalloc(len + 1 + 1);
- if( n == NULL) {
- GDKfree(b);
- throw(SQL,"sql.statement", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ if (n == NULL) {
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
}
strncpy(n, *expr, len);
n[len] = '\n';
@@ -526,14 +530,18 @@ SQLstatementIntern(Client c, str *expr,
len++;
buffer_init(b, n, len);
buf = buffer_rastream(b, "sqlstatement");
- if(buf == NULL) {
- buffer_destroy(b);//n and b will be freed by the buffer
- throw(SQL,"sql.statement",SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ if (buf == NULL) {
+ buffer_destroy(b); /* n and b will be freed by the buffer */
+ b = NULL;
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
}
bs = bstream_create(buf, b->len);
- if(bs == NULL) {
- buffer_destroy(b);//n and b will be freed by the buffer
- throw(SQL,"sql.statement",SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ if (bs == NULL) {
+ mnstr_destroy(buf);
+ b = NULL;
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
}
scanner_init(&m->scanner, bs, NULL);
m->scanner.mode = LINE_N;
@@ -545,10 +553,8 @@ SQLstatementIntern(Client c, str *expr,
if (!m->sa)
m->sa = sa_create();
if (!m->sa) {
- *m = *o;
- _DELETE(o);
- bstream_destroy(m->scanner.rs);
- throw(SQL,"sql.statement",SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ msg = createException(SQL,"sql.statement",SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ goto endofcompile;
}
/*
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list