Changeset: 8ecbe4b8e821 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8ecbe4b8e821
Modified Files:
        sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

Defensive lines in sql_gencode. If the type of a SQL variable could not be not 
determined in a prepare statement, throw an error.


diffs (46 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -743,9 +743,14 @@ backend_dumpproc(backend *be, Client c, 
        if (m->argc) {
                for (argc = 0; argc < m->argc; argc++) {
                        atom *a = m->args[argc];
-                       int type = atom_type(a)->type->localtype;
-                       int varid = 0;
+                       sql_type *tpe = atom_type(a)->type;
+                       int type, varid = 0;
 
+                       if(!tpe) {
+                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument %d\n", argc+1);
+                               goto cleanup;
+                       }
+                       type = tpe->localtype;
                        snprintf(arg, IDLENGTH, "A%d", argc);
                        a->varid = varid = newVariable(mb, arg,strlen(arg), 
type);
                        curInstr = pushArgument(mb, curInstr, varid);
@@ -759,9 +764,14 @@ backend_dumpproc(backend *be, Client c, 
 
                for (n = m->params->h; n; n = n->next, argc++) {
                        sql_arg *a = n->data;
-                       int type = a->type.type->localtype;
-                       int varid = 0;
+                       sql_type *tpe = a->type.type;
+                       int type, varid = 0;
 
+                       if(!tpe) {
+                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument %d\n", argc+1);
+                               goto cleanup;
+                       }
+                       type = tpe->localtype;
                        snprintf(arg, IDLENGTH, "A%d", argc);
                        varid = newVariable(mb, arg,strlen(arg), type);
                        curInstr = pushArgument(mb, curInstr, varid);
@@ -824,7 +834,7 @@ backend_call(backend *be, Client c, cq *
                        sql_subtype *pt = cq->params + i;
 
                        if (!atom_cast(m->sa, a, pt)) {
-                               sql_error(m, 003, "wrong type for argument %d 
of " "function call: %s, expected %s\n", i + 1, atom_type(a)->type->sqlname, 
pt->type->sqlname);
+                               sql_error(m, 003, SQLSTATE(42000) "wrong type 
for argument %d of " "function call: %s, expected %s\n", i + 1, 
atom_type(a)->type->sqlname, pt->type->sqlname);
                                break;
                        }
                        if (atom_null(a)) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to