Changeset: 719b030043e7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=719b030043e7
Modified Files:
        sql/backends/monet5/sql_gencode.c
Branch: resultset
Log Message:

Cleanup the code.


diffs (truncated from 335 to 300 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
@@ -164,8 +164,6 @@ dump_header(mvc *sql, MalBlkPtr mb, stmt
        node *n;
        InstrPtr q;
        int ret = -1;
-
-#ifdef NEWRESULTSET
        // gather the meta information
        int tblId, nmeId, tpeId, lenId, scaleId;
        InstrPtr p, list;
@@ -185,7 +183,7 @@ dump_header(mvc *sql, MalBlkPtr mb, stmt
        getArg(list,3) = tpeId;
        getArg(list,4) = lenId;
        getArg(list,5) = scaleId;
-#endif
+
        (void) s;
 
        for (n = l->h; n; n = n->next) {
@@ -206,24 +204,12 @@ dump_header(mvc *sql, MalBlkPtr mb, stmt
                        fqtn = NEW_ARRAY(char, fqtnl);
                        snprintf(fqtn, fqtnl, "%s.%s", nsn, ntn);
 
-#ifdef NEWRESULTSET
                        metaInfo(tblId,Str,fqtn);
                        metaInfo(nmeId,Str,cn);
                        metaInfo(tpeId,Str,(t->type->localtype == TYPE_void ? 
"char" : t->type->sqlname));
                        metaInfo(lenId,Int,t->digits);
                        metaInfo(scaleId,Int,t->scale);
                        list = pushArgument(mb,list,c->nr);
-#else
-                       (void) s;
-                       q = newStmt1(mb, sqlRef, "rsColumn");
-                       q = pushArgument(mb, q, s->nr);
-                       q = pushStr(mb, q, fqtn);
-                       q = pushStr(mb, q, cn);
-                       q = pushStr(mb, q, t->type->localtype == TYPE_void ? 
"char" : t->type->sqlname);
-                       q = pushInt(mb, q, t->digits);
-                       q = pushInt(mb, q, t->scale);
-                       q = pushArgument(mb, q, c->nr);
-#endif
                        _DELETE(fqtn);
                } else
                        q = NULL;
@@ -232,7 +218,6 @@ dump_header(mvc *sql, MalBlkPtr mb, stmt
                if (q == NULL)
                        return -1;
        }
-#ifdef NEWRESULTSET
        getArg(list,1) = tblId;
        getArg(list,2) = nmeId;
        getArg(list,3) = tpeId;
@@ -240,7 +225,6 @@ dump_header(mvc *sql, MalBlkPtr mb, stmt
        getArg(list,5) = scaleId;
        ret = getArg(list,0);
        pushInstruction(mb,list);
-#endif
        return ret;
 }
 
@@ -2282,17 +2266,14 @@ static int
 
                        if (lst->type == st_list) {
                                list *l = lst->op4.lval;
-                               int file, cnt = list_length(l);
+                               int cnt = list_length(l);
                                stmt *first;
-#ifndef NEWRESULTSET
-                               InstrPtr k;
-#endif
 
                                n = l->h;
                                first = n->data;
 
                                /* single value result, has a fast exit */
-                               if (cnt == 1 && first->nrcols <= 0 && s->type 
!= st_export) {
+                               if (cnt == 1 && first->nrcols <= 0 ){
                                        stmt *c = n->data;
                                        sql_subtype *t = tail_type(c);
                                        char *tname = table_name(sql->mvc->sa, 
c);
@@ -2308,20 +2289,6 @@ static int
 
                                        snprintf(fqtn, fqtnl, "%s.%s", nsn, 
ntn);
 
-#ifndef NEWRESULTSET
-                                       q = newStmt2(mb, sqlRef, 
exportValueRef);
-                                       if (q) {
-                                               s->nr = getDestVar(q);
-                                               q = pushInt(mb, q, 
sql->mvc->type);
-                                               q = pushStr(mb, q, fqtn);
-                                               q = pushStr(mb, q, cn);
-                                               q = pushStr(mb, q, 
t->type->localtype == TYPE_void ? "char" : t->type->sqlname);
-                                               q = pushInt(mb, q, t->digits);
-                                               q = pushInt(mb, q, t->scale);
-                                               q = pushArgument(mb, q, c->nr);
-                                               q = pushStr(mb, q, ""); /* 
warning */
-                                       }
-#else
                                        q = newStmt2(mb, sqlRef, resultSetRef);
                                        if (q) {
                                                s->nr = getDestVar(q);
@@ -2332,7 +2299,7 @@ static int
                                                q = pushInt(mb, q, t->scale);
                                                q = pushArgument(mb, q, c->nr);
                                        }
-#endif
+
                                        _DELETE(ntn);
                                        _DELETE(nsn);
                                        _DELETE(fqtn);
@@ -2340,26 +2307,31 @@ static int
                                                return -1;
                                        break;
                                }
-#ifndef NEWRESULTSET
-                               k = newStmt2(mb, sqlRef, resultSetRef);
-                               s->nr = getDestVar(k);
-                               k = pushInt(mb, k, cnt);
-                               if (s->type == st_export) {
-                                       node *n = s->op4.lval->h;
-                                       char *sep = n->data;
-                                       char *rsep = n->next->data;
-                                       char *ssep = n->next->next->data;
-                                       char *ns = n->next->next->next->data;
+                               if ( (s->nr =dump_header(sql->mvc, mb, s, l)) < 
0)
+                                       return -1;
 
-                                       k = pushStr(mb, k, sep);
-                                       k = pushStr(mb, k, rsep);
-                                       k = pushStr(mb, k, ssep);
-                                       k = pushStr(mb, k, ns);
-                               } else {
-                                       k = pushInt(mb, k, sql->mvc->type);
-                               }
-                               (void) pushArgument(mb, k, first->nr);
-#endif
+                       } else {
+                               q = newStmt1(mb, sqlRef, "raise");
+                               q = pushStr(mb, q, "not a valid output list\n");
+                               if (q == NULL)
+                                       return -1;
+                               s->nr = 1;
+                       }
+               }
+               break;
+               case st_export:{
+                       stmt *lst = s->op1;
+
+                       if (_dumpstmt(sql, mb, lst) < 0)
+                               return -1;
+
+                       if (lst->type == st_list) {
+                               list *l = lst->op4.lval;
+                               int file;
+
+                               n = l->h;
+
+                               /* single value result, has a fast exit */
                                if ( (s->nr =dump_header(sql->mvc, mb, s, l)) < 
0)
                                        return -1;
 
@@ -2387,170 +2359,8 @@ static int
                                                return -1;
                                        file = getDestVar(q);
                                }
-#ifndef NEWRESULTSET
-                               else {
-                                       q = newStmt(mb, "io", "stdout");
-                                       if (q == NULL)
-                                               return -1;
-                                       file = getDestVar(q);
-                               }
-                               q = newStmt2(mb, sqlRef, exportResultRef);
-                               q = pushArgument(mb, q, file);
-                               q = pushArgument(mb, q, s->nr);
-                               if (q == NULL)
-                                       return -1;
-                               if (s->type == st_export && s->op2) {
-                                       q = newStmt(mb, "streams", "close");
-                                       q = pushArgument(mb, q, file);
-                                       if (q == NULL)
-                                               return -1;
-                               }
-#else
-#endif
                        } else {
-                               q = newStmt1(mb, sqlRef, "print");
-                               q = pushStr(mb, q, "not a valid output list\n");
-                               if (q == NULL)
-                                       return -1;
-                               s->nr = 1;
-                       }
-               }
-               break;
-               case st_export:{
-                       stmt *lst = s->op1;
-
-                       if (_dumpstmt(sql, mb, lst) < 0)
-                               return -1;
-
-                       if (lst->type == st_list) {
-                               list *l = lst->op4.lval;
-                               int file, cnt = list_length(l);
-                               stmt *first;
-#ifndef NEWRESULTSET
-                               InstrPtr k;
-#endif
-
-                               n = l->h;
-                               first = n->data;
-
-                               /* single value result, has a fast exit */
-                               if (cnt == 1 && first->nrcols <= 0 && s->type 
!= st_export) {
-                                       stmt *c = n->data;
-                                       sql_subtype *t = tail_type(c);
-                                       char *tname = table_name(sql->mvc->sa, 
c);
-                                       char *sname = schema_name(sql->mvc->sa, 
c);
-                                       char *_empty = "";
-                                       char *tn = (tname) ? tname : _empty;
-                                       char *sn = (sname) ? sname : _empty;
-                                       char *cn = column_name(sql->mvc->sa, c);
-                                       char *ntn = sql_escape_ident(tn);
-                                       char *nsn = sql_escape_ident(sn);
-                                       size_t fqtnl = strlen(ntn) + 1 + 
strlen(nsn) + 1;
-                                       char *fqtn = NEW_ARRAY(char, fqtnl);
-
-                                       snprintf(fqtn, fqtnl, "%s.%s", nsn, 
ntn);
-
-#ifndef NEWRESULTSET
-                                       q = newStmt2(mb, sqlRef, 
exportValueRef);
-                                       if (q) {
-                                               s->nr = getDestVar(q);
-                                               q = pushInt(mb, q, 
sql->mvc->type);
-                                               q = pushStr(mb, q, fqtn);
-                                               q = pushStr(mb, q, cn);
-                                               q = pushStr(mb, q, 
t->type->localtype == TYPE_void ? "char" : t->type->sqlname);
-                                               q = pushInt(mb, q, t->digits);
-                                               q = pushInt(mb, q, t->scale);
-                                               q = pushArgument(mb, q, c->nr);
-                                               q = pushStr(mb, q, ""); /* 
warning */
-                                       }
-#else
-                                       q = newStmt2(mb, sqlRef, resultSetRef);
-                                       if (q) {
-                                               s->nr = getDestVar(q);
-                                               q = pushStr(mb, q, fqtn);
-                                               q = pushStr(mb, q, cn);
-                                               q = pushStr(mb, q, 
t->type->localtype == TYPE_void ? "char" : t->type->sqlname);
-                                               q = pushInt(mb, q, t->digits);
-                                               q = pushInt(mb, q, t->scale);
-                                               q = pushArgument(mb, q, c->nr);
-                                       }
-#endif
-                                       _DELETE(ntn);
-                                       _DELETE(nsn);
-                                       _DELETE(fqtn);
-                                       if (q == NULL)
-                                               return -1;
-                                       break;
-                               }
-#ifndef NEWRESULTSET
-                               k = newStmt2(mb, sqlRef, resultSetRef);
-                               s->nr = getDestVar(k);
-                               k = pushInt(mb, k, cnt);
-                               if (s->type == st_export) {
-                                       node *n = s->op4.lval->h;
-                                       char *sep = n->data;
-                                       char *rsep = n->next->data;
-                                       char *ssep = n->next->next->data;
-                                       char *ns = n->next->next->next->data;
-
-                                       k = pushStr(mb, k, sep);
-                                       k = pushStr(mb, k, rsep);
-                                       k = pushStr(mb, k, ssep);
-                                       k = pushStr(mb, k, ns);
-                               } else {
-                                       k = pushInt(mb, k, sql->mvc->type);
-                               }
-                               (void) pushArgument(mb, k, first->nr);
-#endif
-                               if ( (s->nr =dump_header(sql->mvc, mb, s, l)) < 
0)
-                                       return -1;
-
-                               if (s->type == st_export && s->op2) {
-                                       int codeset;
-
-                                       q = newStmt(mb, "str", "codeset");
-                                       if (q == NULL)
-                                               return -1;
-                                       codeset = getDestVar(q);
-                                       if ((file = _dumpstmt(sql, mb, s->op2)) 
< 0)
-                                               return -1;
-
-                                       q = newStmt(mb, "str", "iconv");
-                                       q = pushArgument(mb, q, file);
-                                       q = pushStr(mb, q, "UTF-8");
-                                       q = pushArgument(mb, q, codeset);
-                                       if (q == NULL)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to