Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25244/src/server

Modified Files:
        rel_select.mx rel_semantic.mx sql_datetime.mx sql_parser.mx 
        sql_psm.mx sql_schema.mx sql_select.mx sql_semantic.mx 
        sql_sequence.mx sql_symbol.mx sql_trans.mx sql_updates.mx 
Log Message:

next step towards making sql compile with the Microsoft compiler without 
(down-cast) warnings:
replacing lng-type member ival of union symdata by
int-type member i_val and lng-type member l_val
and (hopefully) making the remaining code use the
proper one in all places;
adding assertions for consistency checks.

changes are wrapped in CVS tags
"symdata-ival" & "symdata-i_val-l_val"


U sql_schema.mx
Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- sql_schema.mx       2 Sep 2008 13:21:15 -0000       1.148
+++ sql_schema.mx       6 Sep 2008 20:02:47 -0000       1.149
@@ -537,7 +537,8 @@
                        /* list (new(1)/old(0)), char */
                        char *n = dl->data.lval->h->next->data.sval;
 
-                       if (!dl->data.lval->h->data.ival) 
+                       assert(dl->data.lval->h->type == type_int);
+                       if (!dl->data.lval->h->data.i_val) /*?l_val?*/
                                old_name = n;
                        else
                                new_name = n;
@@ -557,10 +558,11 @@
        if (!instantiate) {
                int event = (trigger_event->token == SQL_INSERT)?0:
                            (trigger_event->token == SQL_DELETE)?1:2;
-               int orientation = triggered_action->h->data.ival;
+               int orientation = triggered_action->h->data.i_val;
                char *condition = triggered_action->h->next->data.sval;
                char *q = QUERY(sql->scanner);
 
+               assert(triggered_action->h->type == type_int);
                trigger = mvc_create_trigger(sql, t, tname, time, orientation, 
                        event, old_name, new_name, condition, q);
        }
@@ -620,7 +622,8 @@
        int *id = GDKmalloc(sizeof(int)), *port = GDKmalloc(sizeof(int));
        symbol *user_symb = qname->h->next->next->next->next->data.sym;
        char *default_dbalias;
-       *port = (int) qname->h->next->data.ival;
+       assert(qname->h->next->type == type_int);
+       *port = qname->h->next->data.i_val;
        *id = -1;
        server = GDKstrdup(qname->h->data.sval);
        db = GDKstrdup(qname->h->next->next->data.sval);
@@ -1035,12 +1038,13 @@
                        {
                                dnode *n = s->data.lval->h;
                                char *rtname = qname_table(n->data.lval);
-                               int ref_actions = 
n->next->next->next->data.ival; 
+                               int ref_actions = 
n->next->next->next->data.i_val; 
                                sql_table *rt;
                                sql_fkey *fk;
                                list *cols;
                                sql_key *rk = NULL;
 
+                               assert(n->next->next->next->type == type_int);
                                if (isTempTable(t)) {
                                        (void) sql_error(sql, 02, "CONSTRAINT: 
constraints on temporary tables are not supported\n");
                                        return res;
@@ -1360,8 +1364,9 @@
                sql_fkey *fk;
                dnode *nms = n->next->data.lval->h;
                node *fnms;
-               int ref_actions = n->next->next->next->next->data.ival;
+               int ref_actions = n->next->next->next->next->data.i_val;
 
+               assert(n->next->next->next->next->type == type_int);
                if (name && mvc_bind_key(sql, ss, name)) {
                        return sql_error(sql, 02, "Create Key failed, key %s 
allready exists", name);
                }
@@ -1621,9 +1626,10 @@
        {
                dlist *l = s->data.lval;
                char *cname = l->h->data.sval;
-               int drop_action = l->h->next->data.ival;
+               int drop_action = l->h->next->data.i_val;
                sql_column *col = mvc_bind_column(sql, t, cname);
 
+               assert(l->h->next->type == type_int);
                if (col == NULL)
                        return sql_error(sql, 02, "cannot drop unknown column 
%s\n", cname);
                if (cs_size(&t->columns) <= 1)
@@ -1653,9 +1659,10 @@
        {
                dlist *l = s->data.lval;
                char *kname = l->h->data.sval;
-               int drop_action = l->h->next->data.ival;
+               int drop_action = l->h->next->data.i_val;
                sql_key * key = NULL;
 
+               assert(l->h->next->type == type_int);
                if ((key = mvc_bind_key(sql, ss, kname )) == NULL)
                        return sql_error(sql, 02, "cannot drop unknown 
constraint %s\n", kname);
                mvc_drop_key(sql, ss, key, drop_action);
@@ -1720,9 +1727,10 @@
                dlist *as_sq = table_elements_or_subquery->data.lval;
                dlist *column_spec = as_sq->h->data.lval;
                symbol *subquery = as_sq->h->next->data.sym;
-               int with_data = as_sq->h->next->next->data.ival;
+               int with_data = as_sq->h->next->next->data.i_val;
                sql_table *t = NULL; 
 
+               assert(as_sq->h->next->next->type == type_int);
                sq = flat_subquery(sql, subquery);
                if (!sq)
                        return NULL;
@@ -1879,11 +1887,15 @@
                        if (n->data.sym->token == SQL_CREATE_TABLE) {
                                dlist *l = n->data.sym->data.lval;
 
-                               res = sql_create_table(sql, ss, 
l->h->data.ival, l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.ival);
+                               assert(l->h->type == type_int);
+                               assert(l->h->next->next->next->type == 
type_int);
+                               res = sql_create_table(sql, ss, 
l->h->data.i_val, l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.i_val);
                        } else if (n->data.sym->token == SQL_CREATE_VIEW) {
                                dlist *l = n->data.sym->data.lval;
 
-                               res = create_view(sql, ss, l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.ival, l->h->next->next->next->next->data.ival);
+                               assert(l->h->next->next->next->type == 
type_int);
+                               assert(l->h->next->next->next->next->type == 
type_int);
+                               res = create_view(sql, ss, l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.i_val, l->h->next->next->next->next->data.i_val);
                        }
                        if (!res) {
                                list_destroy(table_elements);
@@ -1945,8 +1957,9 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->type == type_int);
                ret = drop_schema(sql, l->h->data.lval, /* qname */
-                                 l->h->next->data.ival);       /* drop_action 
*/
+                                 l->h->next->data.i_val);      /* drop_action 
*/
                sql->type = Q_SCHEMA;
        }
                break;
@@ -1954,7 +1967,8 @@
        {
                dlist *l = s->data.lval;
 
-               ret = drop_table(sql, l->h->data.lval, l->h->next->data.ival);
+               assert(l->h->next->type == type_int);
+               ret = drop_table(sql, l->h->data.lval, l->h->next->data.i_val);
                sql->type = Q_SCHEMA;
        }
                break;
@@ -1962,7 +1976,8 @@
        {
                dlist *l = s->data.lval;
 
-               ret = drop_view(sql, l->h->data.lval, l->h->next->data.ival);
+               assert(l->h->next->type == type_int);
+               ret = drop_view(sql, l->h->data.lval, l->h->next->data.i_val);
                sql->type = Q_SCHEMA;
        }
                break;
@@ -1971,7 +1986,9 @@
 
                dlist *l = s->data.lval;
 
-               ret = sql_create_table(sql, cur_schema(sql), l->h->data.ival, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.ival);
+               assert(l->h->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
+               ret = sql_create_table(sql, cur_schema(sql), l->h->data.i_val, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.i_val);
                sql->type = Q_SCHEMA;
        }
                break;
@@ -1979,7 +1996,9 @@
        {
                dlist *l = s->data.lval;
 
-               ret = create_view(sql, cur_schema(sql), l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.ival, l->h->next->next->next->next->data.ival);
+               assert(l->h->next->next->next->type == type_int);
+               assert(l->h->next->next->next->next->type == type_int);
+               ret = create_view(sql, cur_schema(sql), l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.i_val, l->h->next->next->next->next->data.i_val);
                sql->type = Q_SCHEMA;
        }
                break;
@@ -1987,7 +2006,8 @@
        {
                dlist *l = s->data.lval;
 
-               ret = create_index(sql, cur_schema(sql), l->h->data.sval, 
l->h->next->data.ival, l->h->next->next->data.lval, 
l->h->next->next->next->data.lval);
+               assert(l->h->next->type == type_int);
+               ret = create_index(sql, cur_schema(sql), l->h->data.sval, 
l->h->next->data.i_val, l->h->next->next->data.lval, 
l->h->next->next->next->data.lval);
                sql->type = Q_SCHEMA;
        }
                break;
@@ -2029,8 +2049,9 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->type == type_int);
                ret = create_role(sql, l->h->data.lval, /* role name */
-                                 l->h->next->data.ival);       /* role grantor 
*/
+                                 l->h->next->data.i_val);      /* role grantor 
*/
                sql->type = Q_SCHEMA;
        }
                break;
@@ -2055,10 +2076,12 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->next->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
                ret = grant_roles(sql, cur_schema(sql), l->h->data.lval,        
/* authids */
                                  l->h->next->data.lval,        /* grantees */
-                                 l->h->next->next->data.ival,  /* admin? */
-                                 l->h->next->next->next->data.ival ? 
sql->user_id : sql->role_id);
+                                 l->h->next->next->data.i_val, /* admin? */
+                                 l->h->next->next->next->data.i_val ? 
sql->user_id : sql->role_id);
                /* grantor ? */
                sql->type = Q_SCHEMA;
        } break;
@@ -2066,10 +2089,12 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->next->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
                ret = revoke_roles(sql, cur_schema(sql), l->h->data.lval,       
/* authids */
                                  l->h->next->data.lval,        /* grantees */
-                                 l->h->next->next->data.ival,  /* admin? */
-                                 l->h->next->next->next->data.ival ? 
sql->user_id : sql->role_id);
+                                 l->h->next->next->data.i_val, /* admin? */
+                                 l->h->next->next->next->data.i_val ? 
sql->user_id : sql->role_id);
                /* grantor ? */
                sql->type = Q_SCHEMA;
        } break;
@@ -2077,10 +2102,12 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->next->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
                ret = grant_privs(sql, cur_schema(sql), l->h->data.lval,        
/* privileges */
                                  l->h->next->data.lval,        /* grantees */
-                                 l->h->next->next->data.ival,  /* grant ? */
-                                 l->h->next->next->next->data.ival ? 
sql->user_id : sql->role_id);
+                                 l->h->next->next->data.i_val, /* grant ? */
+                                 l->h->next->next->next->data.i_val ? 
sql->user_id : sql->role_id);
                /* grantor ? */
                sql->type = Q_SCHEMA;
        } break;
@@ -2088,10 +2115,12 @@
        {
                dlist *l = s->data.lval;
 
+               assert(l->h->next->next->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
                ret = revoke_privs(sql, cur_schema(sql), l->h->data.lval,       
/* privileges */
                                   l->h->next->data.lval,       /* grantees */
-                                  l->h->next->next->data.ival, /* grant ? */
-                                  l->h->next->next->next->data.ival ? 
sql->user_id : sql->role_id);
+                                  l->h->next->next->data.i_val,        /* 
grant ? */
+                                  l->h->next->next->next->data.i_val ? 
sql->user_id : sql->role_id);
                /* grantor ? */
                sql->type = Q_SCHEMA;
        } break;
@@ -2109,7 +2138,8 @@
        {
                dlist *l = s->data.lval;
 
-               ret = create_trigger(sql, scp, l->h->data.lval, 
l->h->next->data.ival, l->h->next->next->data.sym, 
l->h->next->next->next->data.sval, l->h->next->next->next->next->data.lval, 
l->h->next->next->next->next->next->data.lval);
+               assert(l->h->next->type == type_int);
+               ret = create_trigger(sql, scp, l->h->data.lval, 
l->h->next->data.i_val, l->h->next->next->data.sym, 
l->h->next->next->next->data.sval, l->h->next->next->next->next->data.lval, 
l->h->next->next->next->next->next->data.lval);
                sql->type = Q_SCHEMA;
        }
                break;

U sql_semantic.mx
Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- sql_semantic.mx     2 Sep 2008 13:21:35 -0000       1.186
+++ sql_semantic.mx     6 Sep 2008 20:02:48 -0000       1.187
@@ -1056,8 +1056,9 @@
        case SQL_COLUMN: {
                /* can only be variables */ 
                dlist *l = se->data.lval;
+               assert(l->h->type != type_lng);
                if (dlist_length(l) == 1 && l->h->type == type_int) {
-                       atom *a = sql_bind_arg(sql, l->h->data.ival);
+                       atom *a = sql_bind_arg(sql, l->h->data.i_val);
                        return atom2sql(a);
                }
                return NULL;

U sql_select.mx
Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -d -r1.243 -r1.244
--- sql_select.mx       2 Sep 2008 13:21:24 -0000       1.243
+++ sql_select.mx       6 Sep 2008 20:02:48 -0000       1.244
@@ -334,8 +334,9 @@
 
        assert(column_r->token == SQL_COLUMN && column_r->type == type_list);
 
+       assert(l->h->type != type_lng);
        if (dlist_length(l) == 1 && l->h->type == type_int) {
-               return stmt_varnr(l->h->data.ival, atom_type(sql_bind_arg(sql, 
l->h->data.ival)));
+               return stmt_varnr(l->h->data.i_val, atom_type(sql_bind_arg(sql, 
l->h->data.i_val)));
        } else if (dlist_length(l) == 1) {
                char *name = l->h->data.sval;
 
@@ -1156,12 +1157,13 @@
 {
        dlist *l = se->data.lval;
        sql_subaggr *a = NULL;
-       int distinct = l->h->next->data.ival;
+       int distinct = l->h->next->data.i_val;
        stmt *s = NULL;
        char *aggrstr = l->h->data.sval; 
        int remove_nils = 0; 
        sql_schema *schema = sql->session->schema;
 
+       assert(l->h->next->type == type_int);
        if (f == sql_where) 
                return sql_error(sql, 02, "%s: not allowed in WHERE clause", 
toUpper(alloca(strlen(aggrstr) + 1), aggrstr));
        
@@ -1460,9 +1462,10 @@
 
                if (order->token == SQL_COLUMN) {
                        symbol *col = order->data.lval->h->data.sym;
-                       int direction = order->data.lval->h->next->data.ival;
+                       int direction = order->data.lval->h->next->data.i_val;
                        stmt *sc = NULL;
 
+                       assert(order->data.lval->h->next->type == type_int);
                        if (sel)
                                sc = orderby_column_ref(sql, col, sel);
                        if (sel && !sc) {
@@ -1720,7 +1723,8 @@
        case SQL_PARAMETER:{
                if (sql->emode != m_prepare) 
                        return sql_error(sql, 02, "SELECT: parameters ('?') not 
allowed in normal queries, use PREPARE");
-               return stmt_varnr(se->data.ival, NULL);
+               assert(se->type == type_int);
+               return stmt_varnr(se->data.i_val, NULL);
        }
        case SQL_NULL:
                return stmt_atom(atom_general(sql_bind_localtype("str"), NULL, 
0));
@@ -2149,11 +2153,13 @@
 {
        dnode *n = q->data.lval->h;
        symbol *tab_ref1 = n->data.sym;
-       int natural = n->next->data.ival;
-       jt jointype = (jt) n->next->next->data.ival;
+       int natural = n->next->data.i_val;
+       jt jointype = (jt) n->next->next->data.i_val;
        symbol *tab_ref2 = n->next->next->next->data.sym;
        symbol *joinspec = n->next->next->next->next->data.sym;
 
+       assert(n->next->type == type_int);
+       assert(n->next->next->type == type_int);
        return sql_join_(sql, scp, tab_ref1, natural, jointype, tab_ref2, 
joinspec);
 }
 
@@ -2445,13 +2451,14 @@
        stmt *res = NULL;
        dnode *n = q->data.lval->h;
        symbol *tab_ref1 = n->data.sym;
-       int dist = n->next->data.ival;
+       int dist = n->next->data.i_val;
        dlist *corresponding = n->next->next->data.lval;
        symbol *tab_ref2 = n->next->next->next->data.sym;
 
        tvar *tv1 = table_ref(sql, scp, tab_ref1);
        tvar *tv2 = table_ref(sql, scp, tab_ref2);
 
+       assert(n->next->type == type_int);
        if (!tv1 || !tv2) {
                return NULL;
        }
@@ -2595,11 +2602,12 @@
                node *m;
                dnode *n = q->data.lval->h;
 
-               /*int all = n->next->data.ival; */
+               /*int all = n->next->data.i_val; */
                tvar *lv = table_ref(sql, nscp, n->data.sym);
                tvar *rv = table_ref(sql, nscp, n->next->next->data.sym);
                list *unions, *matching_columns;
 
+               /*assert(n->next->type == type_int);*/
                if (!lv || !rv)
                        return NULL;
 
@@ -3210,7 +3218,7 @@
        {
                stmt *res = NULL;
                symbol *lo = sc->data.lval->h->data.sym;
-               int symmetric = sc->data.lval->h->next->data.ival;
+               int symmetric = sc->data.lval->h->next->data.i_val;
                symbol *ro1 = sc->data.lval->h->next->next->data.sym;
                symbol *ro2 = sc->data.lval->h->next->next->next->data.sym;
                stmt *ls = sql_value_exp(sql, scp, lo, grp, subset, f, iek);
@@ -3218,6 +3226,7 @@
                stmt *rs2 = sql_value_exp(sql, scp, ro2, grp, subset, f, iek);
                sql_subtype *ct = NULL;
 
+               assert(sc->data.lval->h->next->type == type_int);
                if (!ls || !rs1 || !rs2)
                        return NULL;
                ct = tail_type(ls);

U sql_updates.mx
Index: sql_updates.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_updates.mx,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- sql_updates.mx      25 Aug 2008 13:36:18 -0000      1.143
+++ sql_updates.mx      6 Sep 2008 20:02:50 -0000       1.144
@@ -1411,9 +1411,11 @@
        char *ssep = (seps->h->next->next)?seps->h->next->next->data.sval:"\"";
        char *ns = (null_string)?null_string:"null";
        list *slist;
-       int nr = (nr_offset)?nr_offset->h->data.ival:-1;
-       int offset = (nr_offset)?nr_offset->h->next->data.ival:0;
+       int nr = (nr_offset)?nr_offset->h->data.i_val:-1;
+       int offset = (nr_offset)?nr_offset->h->next->data.i_val:0;
 
+       assert(!nr_offset || nr_offset->h->type == type_int);
+       assert(!nr_offset || nr_offset->h->next->type == type_int);
        if (sname && !(s=mvc_bind_schema(sql, sname))) {
                (void) sql_error(sql, 02, "COPY INTO: no such schema '%s'", 
sname);
                return NULL;

U sql_trans.mx
Index: sql_trans.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_trans.mx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- sql_trans.mx        25 Aug 2008 13:36:18 -0000      1.26
+++ sql_trans.mx        6 Sep 2008 20:02:50 -0000       1.27
@@ -60,7 +60,8 @@
        case TR_COMMIT:
                if (sql->session->auto_commit == 1) 
                        return sql_error(sql, 01, "COMMIT: not allowed in auto 
commit mode");
-               ret = mvc_commit(sql, s->data.ival, NULL);
+               assert(s->type == type_int);
+               ret = mvc_commit(sql, s->data.i_val, NULL);
                if (ret < 0)
                        return sql_error(sql, 01, "COMMIT: failed");
                break;
@@ -76,7 +77,8 @@
 
                if (sql->session->auto_commit == 1) 
                        return sql_error(sql, 01, "ROLLBACK: not allowed in 
auto commit mode");
-               ret = mvc_rollback(sql, l->h->data.ival, l->h->next->data.sval);
+               assert(l->h->type == type_int);
+               ret = mvc_rollback(sql, l->h->data.i_val, 
l->h->next->data.sval);
                if (ret < 0 && l->h->next->data.sval)
                        return sql_error(sql, 01, "ROLLBACK TO SAVEPOINT: (%s) 
failed", l->h->next->data.sval);
        }
@@ -89,7 +91,8 @@
                        mvc_rollback(sql, 0, NULL);
                sql->session->auto_commit = 0;
                sql->session->ac_on_commit = 1;
-               sql->session->level = s->data.ival;
+               assert(s->type == type_int);
+               sql->session->level = s->data.i_val;
                (void) mvc_trans(sql);
        } break;
        default:

U sql_datetime.mx
Index: sql_datetime.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_datetime.mx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- sql_datetime.mx     11 Jan 2008 10:52:11 -0000      1.23
+++ sql_datetime.mx     6 Sep 2008 20:02:44 -0000       1.24
@@ -70,12 +70,14 @@
        if (pers) {
                dlist *s = pers->h->data.lval;
 
-               *ek = *sk = s->h->data.ival;
+               assert(s->h->type == type_int);
+               *ek = *sk = s->h->data.i_val;
 
                if (dlist_length(pers) == 2) {
                        dlist *e = pers->h->next->data.lval;
 
-                       *ek = e->h->data.ival;
+                       assert(e->h->type == type_int);
+                       *ek = e->h->data.i_val;
                }
        }
        if (*sk > *ek) {

U rel_select.mx
Index: rel_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_select.mx,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- rel_select.mx       5 Sep 2008 14:49:50 -0000       1.86
+++ rel_select.mx       6 Sep 2008 20:02:44 -0000       1.87
@@ -1349,8 +1349,9 @@
 
        assert(column_r->token == SQL_COLUMN && column_r->type == type_list);
        if (dlist_length(l) == 1 && l->h->type == type_int) {
-               int nr = l->h->data.ival;
+               int nr = l->h->data.i_val;
                atom *a;
+               assert(l->h->type == type_int);
                if ((a = sql_bind_arg(sql, nr)) != NULL)
                        return exp_atom_ref(nr, atom_type(a));
                return NULL;
@@ -2095,7 +2096,7 @@
        case SQL_NOT_BETWEEN:
        {
                symbol *lo = sc->data.lval->h->data.sym;
-               int symmetric = sc->data.lval->h->next->data.ival;
+               int symmetric = sc->data.lval->h->next->data.i_val;
                symbol *ro1 = sc->data.lval->h->next->next->data.sym;
                symbol *ro2 = sc->data.lval->h->next->next->next->data.sym;
                sql_exp *le = rel_value_exp(sql, rel, lo, f, ek);
@@ -2104,6 +2105,7 @@
                sql_exp *e1 = NULL, *e2 = NULL;
                sql_subtype *ct = NULL;
 
+               assert(sc->data.lval->h->next->type == type_int);
                if (!le || !re1 || !re2) {
                        exp_destroy(le);
                        exp_destroy(re1);
@@ -2434,7 +2436,7 @@
        case SQL_NOT_BETWEEN:
        {
                symbol *lo = sc->data.lval->h->data.sym;
-               int symmetric = sc->data.lval->h->next->data.ival;
+               int symmetric = sc->data.lval->h->next->data.i_val;
                symbol *ro1 = sc->data.lval->h->next->next->data.sym;
                symbol *ro2 = sc->data.lval->h->next->next->next->data.sym;
                sql_exp *le = rel_value_exp(sql, &rel, lo, f, ek);
@@ -2442,6 +2444,7 @@
                sql_exp *re2 = rel_value_exp(sql, &rel, ro2, f, ek);
                sql_subtype *ct = NULL;
 
+               assert(sc->data.lval->h->next->type == type_int);
                if (!le || !re1 || !re2) {
                        exp_destroy(le);
                        exp_destroy(re1);
@@ -2847,12 +2850,13 @@
 {
        dlist *l = se->data.lval;
        sql_subaggr *a = NULL;
-       int distinct = l->h->next->data.ival;
+       int distinct = l->h->next->data.i_val;
        char *aggrstr = l->h->data.sval;
        sql_exp *e = NULL, *exp = NULL;
        sql_rel *groupby, *old;
        int no_nil = 0;
 
+       assert(l->h->next->type == type_int);
        groupby = *rel;
 
        if (groupby->l && groupby->op == op_project) {
@@ -3304,9 +3308,10 @@
 
                if (order->token == SQL_COLUMN) {
                        symbol *col = order->data.lval->h->data.sym;
-                       int direction = order->data.lval->h->next->data.ival;
+                       int direction = order->data.lval->h->next->data.i_val;
                        sql_exp *e = rel_column_ref(sql, rel, col);
 
+                       assert(order->data.lval->h->next->type == type_int);
                        if (!e) {
                                /* reset error */
                                sql->session->status = 0;
@@ -3453,7 +3458,8 @@
        case SQL_PARAMETER:{
                if (sql->emode != m_prepare) 
                        return sql_error(sql, 02, "SELECT: parameters ('?') not 
allowed in normal queries, use PREPARE");
-               return exp_atom_ref(se->data.ival, NULL);
+               assert(se->type == type_int);
+               return exp_atom_ref(se->data.i_val, NULL);
        }
        case SQL_NULL:
                return exp_atom(atom_general(sql_bind_localtype("str"), NULL, 
0));
@@ -4037,13 +4043,14 @@
        sql_rel *res = NULL;
        dnode *n = q->data.lval->h;
        symbol *tab_ref1 = n->data.sym;
-       int dist = n->next->data.ival;
+       int dist = n->next->data.i_val;
        dlist *corresponding = n->next->next->data.lval;
        symbol *tab_ref2 = n->next->next->next->data.sym;
 
        sql_rel *t1 = table_ref(sql, NULL, tab_ref1);
        sql_rel *t2 = table_ref(sql, NULL, tab_ref2);
 
+       assert(n->next->type == type_int);
        (void)rel; /* TODO coorelated unions */
        if (!t1 || !t2) 
                return NULL;
@@ -4198,11 +4205,13 @@
 
        dnode *n = q->data.lval->h;
        symbol *tab_ref1 = n->data.sym;
-       int natural = n->next->data.ival;
-       jt jointype = (jt) n->next->next->data.ival;
+       int natural = n->next->data.i_val;
+       jt jointype = (jt) n->next->next->data.i_val;
        symbol *tab_ref2 = n->next->next->next->data.sym;
        symbol *joinspec = n->next->next->next->next->data.sym;
 
+       assert(n->next->type == type_int);
+       assert(n->next->next->type == type_int);
        return rel_joinquery_(sql, rel, tab_ref1, natural, jointype, tab_ref2, 
joinspec);
 }
 
@@ -4228,11 +4237,12 @@
        dnode *n = q->data.lval->h;
        sql_rel *lv = table_ref(sql, rel, n->data.sym);
        sql_rel *rv = table_ref(sql, rel, n->next->next->data.sym);
-       int all = n->next->data.ival; 
+       int all = n->next->data.i_val; 
        list *lexps, *rexps;
        node *m;
        int found = 0;
 
+       assert(n->next->type == type_int);
        if (!lv || !rv)
                return NULL;
 

U rel_semantic.mx
Index: rel_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_semantic.mx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- rel_semantic.mx     11 Aug 2008 19:08:45 -0000      1.29
+++ rel_semantic.mx     6 Sep 2008 20:02:44 -0000       1.30
@@ -231,8 +231,10 @@
        case SQL_CREATE_VIEW:
        {
                dlist *l = s->data.lval;
-               sql_rel *ret = rel_view(sql, l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.ival, l->h->next->next->next->next->data.ival);
+               sql_rel *ret = rel_view(sql, l->h->data.lval, 
l->h->next->data.lval, l->h->next->next->data.sym, 
l->h->next->next->next->data.i_val, l->h->next->next->next->next->data.i_val);
 
+               assert(l->h->next->next->next->type == type_int);
+               assert(l->h->next->next->next->next->type == type_int);
                sql->type = Q_SCHEMA;
                return ret;
        } break;

U sql_psm.mx
Index: sql_psm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_psm.mx,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- sql_psm.mx  25 Aug 2008 13:36:16 -0000      1.57
+++ sql_psm.mx  6 Sep 2008 20:02:46 -0000       1.58
@@ -156,7 +156,8 @@
                return sql_error(sql, 01, "Variable '%s' allready declared", 
                        name);
        
-       ret = sql_create_table(sql, cur_schema(sql), SQL_DECLARED_TABLE, qname, 
n->next->next->data.sym, n->next->next->next->data.ival);
+       assert(n->next->next->next->type == type_int);
+       ret = sql_create_table(sql, cur_schema(sql), SQL_DECLARED_TABLE, qname, 
n->next->next->data.sym, n->next->next->next->data.i_val);
 
        if (!ret)
                return NULL;
@@ -796,10 +797,12 @@
                dlist *l = s->data.lval;
                int is_func = (s->token == SQL_DROP_FUNC);
 
-               if (l->h->next->data.ival)
-                       ret = drop_all_func(sql, l->h->data.lval, 
l->h->next->next->next->data.ival, is_func);
+               assert(l->h->next->type == type_int);
+               assert(l->h->next->next->next->type == type_int);
+               if (l->h->next->data.i_val) /*?l_val?*/
+                       ret = drop_all_func(sql, l->h->data.lval, 
l->h->next->next->next->data.i_val, is_func);
                else
-                       ret = drop_func(sql, l->h->data.lval, 
l->h->next->next->data.lval, l->h->next->next->next->data.ival, is_func);
+                       ret = drop_func(sql, l->h->data.lval, 
l->h->next->next->data.lval, l->h->next->next->next->data.i_val, is_func);
 
                sql->type = Q_SCHEMA;
        }       break;

U sql_symbol.mx
Index: sql_symbol.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_symbol.mx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- sql_symbol.mx       25 Aug 2008 13:36:17 -0000      1.33
+++ sql_symbol.mx       6 Sep 2008 20:02:49 -0000       1.34
@@ -27,6 +27,7 @@
 
 typedef enum symtype {
        type_int,
+       type_lng,
        type_string,
        type_list,
        type_symbol,
@@ -34,7 +35,8 @@
 } symtype;
 
 typedef union symbdata {
-       lng ival;
+       int i_val;
+       lng l_val;
        char *sval;
        struct dlist *lval;
        struct symbol *sym;
@@ -59,6 +61,7 @@
 extern dlist *dlist_append_string(sql_allocator *sa, dlist *l, char *data);
 extern dlist *dlist_append_list(sql_allocator *sa, dlist *l, dlist *data);
 extern dlist *dlist_append_int(sql_allocator *sa, dlist *l, lng data);
+extern dlist *dlist_append_lng(sql_allocator *sa, dlist *l, lng data);
 extern dlist *dlist_append_symbol(sql_allocator *sa, dlist *l, struct symbol 
*data);
 extern dlist *dlist_append_type(sql_allocator *sa, dlist *l, struct 
sql_subtype *data);
 
@@ -92,6 +95,7 @@
 extern symbol *symbol_create(sql_allocator *sa, int token, char *data);
 extern symbol *symbol_create_list(sql_allocator *sa, int token, dlist *data);
 extern symbol *symbol_create_int(sql_allocator *sa, int token, lng data);
+extern symbol *symbol_create_lng(sql_allocator *sa, int token, lng data);
 extern symbol *symbol_create_symbol(sql_allocator *sa, int token, symbol 
*data);
 
 extern int symbol_cmp(symbol *s1, symbol *s2);
@@ -147,15 +151,31 @@
 }
 
 symbol *
-symbol_create_int(sql_allocator *sa, int token, lng data)
+symbol_create_int(sql_allocator *sa, int token, lng ldata)
 {
        symbol *s = SA_NEW(sa, symbol);
+       int data = (int) ldata;
 
+       assert((lng) GDK_int_min <= ldata && ldata <= (lng) GDK_int_max);
        if (s) {
                symbol_init(s, token, type_int);
-               s->data.ival = data;
+               s->data.i_val = data;
                if (symbol_debug)
-                       fprintf(stderr, "" PTRFMT " = 
symbol_create_int(%s,"LLFMT")\n", PTRFMTCAST s, token2string(s->token), data);
+                       fprintf(stderr, "" PTRFMT " = 
symbol_create_int(%s,%d)\n", PTRFMTCAST s, token2string(s->token), data);
+       }
+       return s;
+}
+
+symbol *
+symbol_create_lng(sql_allocator *sa, int token, lng data)
+{
+       symbol *s = SA_NEW(sa, symbol);
+
+       if (s) {
+               symbol_init(s, token, type_lng);
+               s->data.l_val = data;
+               if (symbol_debug)
+                       fprintf(stderr, "" PTRFMT " = 
symbol_create_lng(%s,"LLFMT")\n", PTRFMTCAST s, token2string(s->token), data);
        }
        return s;
 }
@@ -207,17 +227,28 @@
        return n;
 }
 static dnode *
-dnode_create_int(sql_allocator *sa, lng data)
+dnode_create_int(sql_allocator *sa, int data)
 {
        dnode *n = dnode_create(sa);
 
        if (n) {
-               n->data.ival = data;
+               n->data.i_val = data;
                n->type = type_int;
        }
        return n;
 }
 static dnode *
+dnode_create_lng(sql_allocator *sa, lng data)
+{
+       dnode *n = dnode_create(sa);
+
+       if (n) {
+               n->data.l_val = data;
+               n->type = type_lng;
+       }
+       return n;
+}
+static dnode *
 dnode_create_symbol(sql_allocator *sa, symbol *data)
 {
        dnode *n = dnode_create(sa);
@@ -296,9 +327,22 @@
 }
 
 dlist *
-dlist_append_int(sql_allocator *sa, dlist *l, lng data)
+dlist_append_int(sql_allocator *sa, dlist *l, lng ldata)
 {
-       dnode *n = dnode_create_int(sa, data);
+       dnode *n;
+       int data = (int) ldata;
+
+       assert((lng) GDK_int_min <= ldata && ldata <= (lng) GDK_int_max);
+       n = dnode_create_int(sa, data);
+       if (!n)
+               return NULL;
+       return dlist_append_default(l, n);
+}
+
+dlist *
+dlist_append_lng(sql_allocator *sa, dlist *l, lng data)
+{
+       dnode *n = dnode_create_lng(sa, data);
 
        if (!n)
                return NULL;
@@ -375,7 +419,12 @@
        if (d1->type == d2->type) {
                switch (d1->type) {
                case type_int:
-                       return (d1->data.ival - d2->data.ival);
+                       return (d1->data.i_val - d2->data.i_val);
+               case type_lng: {
+                       lng c = d1->data.l_val - d2->data.l_val;
+                       assert((lng) GDK_int_min <= c && c <= (lng) 
GDK_int_max);
+                       return (int) c;
+               }
                case type_string:
                        if (d1->data.sval == d2->data.sval)
                                return 0;
@@ -452,7 +501,12 @@
        }
        switch (s1->type) {
        case type_int:
-               return (s1->data.ival - s2->data.ival);
+               return (s1->data.i_val - s2->data.i_val);
+       case type_lng: {
+               lng c = s1->data.l_val - s2->data.l_val;
+               assert((lng) GDK_int_min <= c && c <= (lng) GDK_int_max);
+               return (int) c;
+       }
        case type_string:
                if (s1->data.sval == s2->data.sval)
                        return 0;

U sql_parser.mx
Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -d -r1.287 -r1.288
--- sql_parser.mx       11 Aug 2008 19:08:46 -0000      1.287
+++ sql_parser.mx       6 Sep 2008 20:02:45 -0000       1.288
@@ -210,6 +210,7 @@
 #define _symbol_create(t,d)         symbol_create( SA, t, d)
 #define _symbol_create_list(t,d)    symbol_create_list( SA, t, d)
 #define _symbol_create_int(t,d)     symbol_create_int( SA, t, d)
+#define _symbol_create_lng(t,d)     symbol_create_lng( SA, t, d)
 #define _symbol_create_symbol(t,d)  symbol_create_symbol( SA, t, d)
 #define _symbol_create_hexa(t,d)    symbol_create_hexa( SA, t, d)
 #define _newAtomNode(d)                    newAtomNode( SA, d)
@@ -218,6 +219,7 @@
 
 #define append_list(l,d)     dlist_append_list( SA, l, d)
 #define append_int(l,d)      dlist_append_int( SA, l, d)
+#define append_lng(l,d)      dlist_append_lng( SA, l, d)
 #define append_symbol(l,d)   dlist_append_symbol( SA, l, d)
 #define append_string(l,d)   dlist_append_string( SA, l, d)
 #define append_type(l,d)     dlist_append_type( SA, l, d)
@@ -1219,11 +1221,11 @@
        opt_cache
        opt_cycle
        { dlist *l = L();
-         append_int(l, $1);
-         append_int(l, $2);
-         append_int(l, $3);
-         append_int(l, $4);
-         append_int(l, $5);
+         append_lng(l, $1);
+         append_lng(l, $2);
+         append_lng(l, $3);
+         append_lng(l, $4);
+         append_lng(l, $5);
          append_int(l, $6);
          $$ = l;
        }
@@ -1238,10 +1240,10 @@
        opt_cycle
        { dlist *l = L();
          append_list(l, $1);
-         append_int(l, $2);
-         append_int(l, $3);
-         append_int(l, $4);
-         append_int(l, $5);
+         append_lng(l, $2);
+         append_lng(l, $3);
+         append_lng(l, $4);
+         append_lng(l, $5);
          append_int(l, $6);
          $$ = l;
        }
@@ -1472,11 +1474,11 @@
                        sql_find_subtype(&it, "int", 32, 0);
                        append_type(l, &it);
                        /* finally all the options (no defaults here) */
-                       append_int(o, 1); /* start */
-                       append_int(o, 1); /* increment */
-                       append_int(o, 1); /* min */
-                       append_int(o, 0); /* max */
-                       append_int(o, 1); /* cache */
+                       append_lng(o, 1); /* start */
+                       append_lng(o, 1); /* increment */
+                       append_lng(o, 1); /* min */
+                       append_lng(o, 0); /* max */
+                       append_lng(o, 1); /* cache */
                        append_int(o, 0); /* cycle */
                        append_list(l, o);
 
@@ -1605,11 +1607,11 @@
                sql_find_subtype(&it, "int", 32, 0);
                append_type(l, &it);
                /* finally all the options (no defaults here) */
-               append_int(o, 1); /* start */
-               append_int(o, 1); /* increment */
-               append_int(o, 1); /* min */
-               append_int(o, 0); /* max */
-               append_int(o, 1); /* cache */
+               append_lng(o, 1); /* start */
+               append_lng(o, 1); /* increment */
+               append_lng(o, 1); /* min */
+               append_lng(o, 0); /* max */
+               append_lng(o, 1); /* cache */
                append_int(o, 0); /* cycle */
                append_list(l, o);
                if (m->scanner.schema)
@@ -1631,11 +1633,11 @@
        /* empty: return the defaults */
        { $$ = L();
          /* finally all the options (no defaults here) */
-         append_int($$, 1); /* start */
-         append_int($$, -1); /* increment */
-         append_int($$, -1); /* min */
-         append_int($$, -1); /* max */
-         append_int($$, -1); /* cache */
+         append_lng($$, 1); /* start */
+         append_lng($$, -1); /* increment */
+         append_lng($$, -1); /* min */
+         append_lng($$, -1); /* max */
+         append_lng($$, -1); /* cache */
          append_int($$, 0);  /* cycle */
        }
   |    '(' opt_seq_params ')'  { $$ = $2; }
@@ -3231,8 +3233,9 @@
  |  '-' scalar_exp %prec UMINUS 
                        { 
                          $$ = NULL;
+                         assert($2->token != SQL_COLUMN || 
$2->data.lval->h->type != type_lng);
                          if ($2->token == SQL_COLUMN && $2->data.lval->h->type 
== type_int) {
-                               atom *a = sql_bind_arg(parm, 
$2->data.lval->h->data.ival);
+                               atom *a = sql_bind_arg(parm, 
$2->data.lval->h->data.i_val);
                                if (!atom_neg(a))
                                        $$ = $2;
                          } 

U sql_sequence.mx
Index: sql_sequence.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_sequence.mx,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- sql_sequence.mx     25 Aug 2008 13:36:17 -0000      1.47
+++ sql_sequence.mx     6 Sep 2008 20:02:49 -0000       1.48
@@ -96,12 +96,13 @@
 {
        char* name = qname_table(qname);
        char *sname = qname_schema(qname);
-       int start_type = start_list->h->data.ival;
+       int start_type = start_list->h->data.i_val;
        sql_sequence *seq;
        stmt *val = NULL, *ssname = NULL, *seqname = NULL;
        sql_subtype *lng_t = sql_bind_localtype("lng");
        sql_schema *s = NULL;
 
+       assert(start_list->h->type == type_int);
        if (sname && !(s = mvc_bind_schema(sql, sname)))
                return sql_error(sql, 02, "CREATE SEQUENCE: no such schema 
'%s'", sname);
        if (!s)
@@ -133,7 +134,16 @@
                if (!val || !(val = check_types(sql, lng_t, val, type_equal)))
                        return NULL;
        } else if (start_type == 2) {
-               val = stmt_atom_lng(start_list->h->next->data.ival);
+               switch (start_list->h->next->type) {
+                       case type_int:
+                               val = 
stmt_atom_lng((lng)start_list->h->next->data.i_val);
+                               break;
+                       case type_lng:
+                               val = 
stmt_atom_lng(start_list->h->next->data.l_val);
+                               break;
+                       default:
+                               assert(0);
+               }
        }
        ssname = stmt_atom_string(_strdup(seq->s->base.name));
        seqname = stmt_atom_string(_strdup(name));
@@ -183,17 +193,23 @@
                        dlist *l = s->data.lval;
                        dlist *h = l->h->next->next->data.lval;
 
+                       assert(h->h->type == type_lng);
+                       assert(h->h->next->type == type_lng);
+                       assert(h->h->next->next->type == type_lng);
+                       assert(h->h->next->next->next->type == type_lng);
+                       assert(h->h->next->next->next->next->type == type_lng);
+                       assert(h->h->next->next->next->next->next->type == 
type_int);
                        res = sql_create_seq(
 /* mvc* sql */         sql,
 /* sql_schema* s */    cur_schema(sql), 
 /* dlist* qname */     l->h->data.lval, 
 /* sql_subtype* t*/    &l->h->next->data.typeval, 
-/* lng start */                h->h->data.ival, 
-/* lng inc */          h->h->next->data.ival, 
-/* lng min */          h->h->next->next->data.ival, 
-/* lng max */          h->h->next->next->next->data.ival,
-/* lng cache */                h->h->next->next->next->next->data.ival,
-/* int cycle */                h->h->next->next->next->next->next->data.ival);
+/* lng start */                h->h->data.l_val, 
+/* lng inc */          h->h->next->data.l_val, 
+/* lng min */          h->h->next->next->data.l_val, 
+/* lng max */          h->h->next->next->next->data.l_val,
+/* lng cache */                h->h->next->next->next->next->data.l_val,
+/* int cycle */                h->h->next->next->next->next->next->data.i_val);
                }
                break;
                case SQL_ALTER_SEQ:
@@ -201,17 +217,22 @@
                        dlist* l = s->data.lval;
                        dlist *h = l->h->next->next->data.lval;
                        
+                       assert(h->h->next->type == type_lng);
+                       assert(h->h->next->next->type == type_lng);
+                       assert(h->h->next->next->next->type == type_lng);
+                       assert(h->h->next->next->next->next->type == type_lng);
+                       assert(h->h->next->next->next->next->next->type == 
type_int);
                        res = sql_alter_seq(
 /* mvc* sql */         sql,
 /* sql_schema* s */    cur_schema(sql), 
 /* dlist* qname */     l->h->data.lval, 
 /* sql_subtype* t*/    &l->h->next->data.typeval, 
 /* dlist start */      h->h->data.lval, 
-/* lng inc */          h->h->next->data.ival, 
-/* lng min */          h->h->next->next->data.ival, 
-/* lng max */          h->h->next->next->next->data.ival,
-/* lng cache */                h->h->next->next->next->next->data.ival,
-/* int cycle */                h->h->next->next->next->next->next->data.ival);
+/* lng inc */          h->h->next->data.l_val, 
+/* lng min */          h->h->next->next->data.l_val, 
+/* lng max */          h->h->next->next->next->data.l_val,
+/* lng cache */                h->h->next->next->next->next->data.l_val,
+/* int cycle */                h->h->next->next->next->next->next->data.i_val);
                }
                break;
                case SQL_DROP_SEQ:


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to