Changeset: f6079c49f773 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f6079c49f773
Modified Files:
monetdb5/mal/mal_instruction.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_scenario.c
Branch: malerrors
Log Message:
Small SQLSTATE fixes
diffs (206 lines):
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -933,7 +933,7 @@ trimMalVariables(MalBlkPtr mb, MalStkPtr
clrVarUsed(mb,i);
/* the return variable is also 'used' */
i = findVariable(mb, getFunctionId(mb->stmt[0]));
- assert(i >=0);
+ /* assert(i >=0); Not necessary the cases for WLC */
setVarUsed(mb,i);
/* build the use table */
for (i = 0; i < mb->stop; i++) {
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
@@ -203,7 +203,7 @@ SQLexecutePrepared(Client c, backend *be
if (pci->argc >= MAXARG){
argv = (ValPtr *) GDKmalloc(sizeof(ValPtr) * pci->argc);
if( argv == NULL)
- throw(SQL,"sql.prepare",MAL_MALLOC_FAIL);
+ throw(SQL,"sql.prepare","SQLSTATE HY001
!"MAL_MALLOC_FAIL);
} else
argv = argvbuffer;
@@ -212,7 +212,7 @@ SQLexecutePrepared(Client c, backend *be
if( argrec == NULL){
if( argv != argvbuffer)
GDKfree(argv);
- throw(SQL,"sql.prepare",MAL_MALLOC_FAIL);
+ throw(SQL,"sql.prepare","SQLSTATE HY001
!"MAL_MALLOC_FAIL);
}
} else
argrec = argrecbuffer;
@@ -231,7 +231,7 @@ SQLexecutePrepared(Client c, backend *be
GDKfree(argv);
if (pci->retc >= MAXARG && argrec != argrecbuffer)
GDKfree(argrec);
- throw(SQL, "sql.prepare", "07001!EXEC: wrong number of
arguments for prepared statement: %d, expected %d", argc, parc);
+ throw(SQL, "sql.prepare", "SQLSTATE 07001!EXEC: wrong number of
arguments for prepared statement: %d, expected %d", argc, parc);
} else {
for (i = 0; i < m->argc; i++) {
atom *arg = m->args[i];
@@ -243,7 +243,7 @@ SQLexecutePrepared(Client c, backend *be
GDKfree(argv);
if (pci->retc >= MAXARG && argrec !=
argrecbuffer)
GDKfree(argrec);
- throw(SQL, "sql.prepare", "07001!EXEC: wrong
type for argument %d of " "prepared statement: %s, expected %s", i + 1,
atom_type(arg)->type->sqlname, pt->type->sqlname);
+ throw(SQL, "sql.prepare", "SQLSTATE 07001!EXEC:
wrong type for argument %d of " "prepared statement: %s, expected %s", i + 1,
atom_type(arg)->type->sqlname, pt->type->sqlname);
}
argv[pci->retc + i] = &arg->data;
}
@@ -282,7 +282,7 @@ SQLrun(Client c, backend *be, mvc *m){
// locate and inline the query template instruction
mb = copyMalBlk(c->curprg->def);
if (!mb) {
- throw(SQL, "sql.prepare", "Out of memory");
+ throw(SQL, "sql.prepare", "SQLSTATE HY001 !" MAL_MALLOC_FAIL);
}
mb->history = c->curprg->def->history;
c->curprg->def->history = 0;
@@ -298,7 +298,7 @@ SQLrun(Client c, backend *be, mvc *m){
if( getFunctionId(p) && p->blk &&
qc_isaquerytemplate(getFunctionId(p)) ) {
mc = copyMalBlk(p->blk);
if (!mc) {
- throw(SQL, "sql.prepare", "Out of memory");
+ throw(SQL, "sql.prepare", "SQLSTATE HY001 !"
MAL_MALLOC_FAIL);
}
retc = p->retc;
freeMalBlk(mb);
@@ -310,11 +310,11 @@ SQLrun(Client c, backend *be, mvc *m){
atom *arg = m->args[j];
if (!atom_cast(m->sa, arg, pt)) {
- throw(SQL, "sql.prepare", "07001!EXEC:
wrong type for argument %d of " "query template : %s, expected %s", i + 1,
atom_type(arg)->type->sqlname, pt->type->sqlname);
+ throw(SQL, "sql.prepare", "SQLSTATE
07001!EXEC: wrong type for argument %d of " "query template : %s, expected %s",
i + 1, atom_type(arg)->type->sqlname, pt->type->sqlname);
}
val= (ValPtr) &arg->data;
if (VALcopy(&mb->var[j+retc].value, val) ==
NULL)
- throw(MAL, "sql.prepare",
MAL_MALLOC_FAIL);
+ throw(MAL, "sql.prepare", "SQLSTATE
HY100 !"MAL_MALLOC_FAIL);
setVarConstant(mb, j+retc);
setVarFixed(mb, j+retc);
}
@@ -425,7 +425,7 @@ SQLstatementIntern(Client c, str *expr,
}
if (msg){
freeException(msg);
- throw(SQL, "SQLstatement", "Catalogue not available");
+ throw(SQL, "SQLstatement", "SQLSTATE HY002 !""Catalogue not
available");
}
initSQLreferences();
@@ -435,7 +435,7 @@ SQLstatementIntern(Client c, str *expr,
if (!o) {
if (inited)
SQLresetClient(c);
- throw(SQL, "SQLstatement", MAL_MALLOC_FAIL);
+ throw(SQL, "SQLstatement", "SQLSTATE HY001"MAL_MALLOC_FAIL);
}
*o = *m;
/* hide query cache, this causes crashes in SQLtrans() due to
uninitialized memory otherwise */
@@ -450,7 +450,7 @@ SQLstatementIntern(Client c, str *expr,
be = sql;
sql = backend_create(m, c);
if( sql == NULL)
- throw(SQL,"SQLstatement",MAL_MALLOC_FAIL);
+ throw(SQL,"SQLstatement","SQLSTATE HY001"MAL_MALLOC_FAIL);
sql->output_format = be->output_format;
if (!output) {
sql->output_format = OFMT_NONE;
@@ -465,10 +465,10 @@ 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",MAL_MALLOC_FAIL);
+ throw(SQL,"sql.statement", "SQLSTATE HY001 !"MAL_MALLOC_FAIL);
n = GDKmalloc(len + 1 + 1);
if( n == NULL)
- throw(SQL,"sql.statement",MAL_MALLOC_FAIL);
+ throw(SQL,"sql.statement", "SQLSTATE HY001 !"MAL_MALLOC_FAIL);
strncpy(n, *expr, len);
n[len] = '\n';
n[len + 1] = 0;
@@ -874,7 +874,7 @@ RAstatement2(Client cntxt, MalBlkPtr mb,
refs = sa_list(m->sa);
rel = rel_read(m, *expr, &pos, refs);
if (!rel)
- throw(SQL, "sql.register", "Cannot register %s", buf);
+ throw(SQL, "sql.register", "SQLSTATE 42000 !""Cannot register
%s", buf);
if (rel) {
monet5_create_relational_function(m, *mod, *nme, rel, NULL,
ops, 0);
rel_destroy(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
@@ -505,7 +505,7 @@ SQLinitClient(Client c)
if (bstream_next(createdb_bstream) >= 0)
msg = SQLstatementIntern(c,
&createdb_bstream->buf, "sql.init", TRUE, FALSE, NULL);
else
- msg = createException(MAL, "createdb", "could
not load inlined createdb script");
+ msg = createException(MAL, "createdb",
"SQLSTATE 42000 ! Could not load inlined createdb script");
free(createdb_buf);
free(createdb_stream);
@@ -547,7 +547,7 @@ SQLinitClient(Client c)
sz = getFileSize(fd);
if (sz > (size_t) 1 << 29) {
mnstr_destroy(fd);
- newmsg = createException(MAL,
"createdb", "file %s too large to process", filename);
+ newmsg = createException(MAL,
"createdb", "SQLSTATE 42000 !""File %s too large to process", filename);
} else {
bfd = bstream_create(fd, sz ==
0 ? (size_t) (128 * BLOCK) : sz);
if (bfd && bstream_next(bfd) >=
0)
@@ -1016,10 +1016,10 @@ SQLparser(Client c)
m->session->ac_on_commit = m->session->auto_commit;
if (m->session->active) {
if (commit && mvc_commit(m, 0, NULL) < 0) {
- msg = createException(SQL, "COMMIT",
"commit failed while enabling auto_commit");
+ msg = createException(SQL, "COMMIT",
"SQLSTATE 42000 !""Commit failed while enabling auto_commit");
} else if (!commit && mvc_rollback(m, 0, NULL)
< 0) {
mnstr_printf(out, "!COMMIT: rollback
failed while " "disabling auto_commit\n");
- msg = createException(SQL, "COMMIT",
"rollback failed while " "disabling auto_commit");
+ msg = createException(SQL, "COMMIT",
"SQLSTATE 42000 !""rollback failed while " "disabling auto_commit");
}
}
in->pos = in->len; /* HACK: should use parsed
length */
@@ -1030,7 +1030,7 @@ SQLparser(Client c)
if (strncmp(in->buf + in->pos, "reply_size ", 11) == 0) {
v = (int) strtol(in->buf + in->pos + 11, NULL, 10);
if (v < -1) {
- msg = createException(SQL, "SQLparser",
"SQLSTATE 42000 !""reply_size cannot be negative");
+ msg = createException(SQL, "SQLparser",
"SQLSTATE 42000 !""Reply_size cannot be negative");
goto finalize;
}
m->reply_size = v;
@@ -1047,11 +1047,11 @@ SQLparser(Client c)
c->mode = FINISHCLIENT;
return MAL_SUCCEED;
}
- msg = createException(SQL, "SQLparser", "SQLSTATE 42000
!""unrecognized X command: %s\n", in->buf + in->pos);
+ msg = createException(SQL, "SQLparser", "SQLSTATE 42000
!""Unrecognized X command: %s\n", in->buf + in->pos);
goto finalize;
}
if (be->language !='S') {
- msg = createException(SQL, "SQLparser", "SQLSTATE 42000
!""unrecognized language prefix: %ci\n", be->language);
+ msg = createException(SQL, "SQLparser", "SQLSTATE 42000
!""Unrecognized language prefix: %ci\n", be->language);
goto finalize;
}
@@ -1084,14 +1084,14 @@ SQLparser(Client c)
be->q = qc_find(m->qc, m->sym->data.lval->h->data.i_val);
if (!be->q) {
err = -1;
- msg = createException(SQL, "EXEC", "07003!no prepared
statement with id: %d\n", m->sym->data.lval->h->data.i_val);
+ msg = createException(SQL, "EXEC", "SQLSTATE 07003!
""No prepared statement with id: %d\n", m->sym->data.lval->h->data.i_val);
*m->errstr = 0;
msg = handle_error(m, pstatus, msg);
sqlcleanup(m, err);
goto finalize;
} else if (be->q->type != Q_PREPARE) {
err = -1;
- msg = createException(SQL, "EXEC", "07005!: given
handle id is not for a " "prepared statement: %d\n",
m->sym->data.lval->h->data.i_val);
+ msg = createException(SQL, "EXEC", "SQLSTATE 07005
!""Given handle id is not for a " "prepared statement: %d\n",
m->sym->data.lval->h->data.i_val);
*m->errstr = 0;
msg = handle_error(m, pstatus, msg);
sqlcleanup(m, err);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list